Semantic search with search correlation between fields

Can semantic search with correlation between fields can be implemented with Elasticsearch ?
I have ecommerce data indexed to Elasticsearch with below fields and description is vector text embedded.

Name : product name(text)
Price : product price (Float)
Description : product description (text)

I would like to have to have semantic search functionality implemented for search if I search something like "products below 100$". expectation is Elasticsearch to return corresponding products less than 100$. Can this functionality achieved with Elasticsearch ? if yes, pls guide with relevant details and documentation for such implementation

Index Mapping

PUT collection-with-embeddings
  "mappings": {
    "properties": {
    "text_embedding.predicted_value": {
        "type": "dense_vector",
        "dims": 768,
        "index": true,
        "similarity": "dot_product"
      "price": {
        "type": "float" 
      "name": {
        "type": "text" 
      "description": {
        "type": "text" 

KNN Search

GET collection-with-embeddings/_search
  "knn": {
    "field": "text_embedding.predicted_value",
    "query_vector_builder": {
	"text_embedding": {
          "model_id": "sentence-transformers__msmarco-minilm-l-12-v3",
          "model_text": "products below 100$"
    "k": 5,
    "num_candidates": 10

@Francois_Protopapa /@Peter_Steenbergen , could you please guide us with the relevant details or documentation for this use case.


Sounds like you are looking for the filter within the knn search found here:

Instead of term in the example you could make use of range here.

Hi @Peter_Steenbergen , Thank you for your response.
We are not looking to add filters inside KNN. As we are trying to achieve this with semantic search, we are expecting Elasticsearch to understand intent of user search query.
Is there anyway to achieve this this either with ELSER or with some other Model can be deployed on Elasticsearch ?

Hey @sivagurlinka . At the moment the best way to do this in a general purpose way is to use an LLM first to "self query" the index metadata and decide which parts of the query are filters versus keywords. This can be accomplished using the LangChain module of the same name: Self-querying | 🦜️🔗 Langchain

You would need to be cautious with the latency and cost ($) of using an LLM to reflect in this way though.

For a more scalable and cost effective approach, there are several methods to choose from but it's typically best to start with some hand-crafted rules as there is nothing out-of-the-box in Elasticsearch (yet) to do this automatically.

If you go down that road, have a look at libraries like Duckling which can help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.