This is such a basic thing nowadays, and ElasticSearch is massive overkill for it. Something like SQLite or LanceDB or basically any vector database is much more appropriate. This seems to be coming from the “we must make ElasticSearch AI-compatible” department more than anything.
Nah, "Any other vector DB" starts to fall apart once you need stuff like scripted scoring like OP uses. Then it starts to be a question of, "do you need ANN for performance?" since SQLite only does brute-force vector scoring. And granted, brute-force is performant for far more vectors than most people give it credit for, but it definitely hits a wall well below 1 million if you want it to have webpage-type latency. M…
Postgres and PGVector works for me.
Elastic search always wants a lot of resources and takes a long time to populate, requiring the JVM is yet another thing to add and configure too.