Semantic search - how to get correct results

Hi! I am using the michelin dataset from Getting Started with Elasticsearch | Elastic Videos and using semantic search following Semantic search | Elasticsearch Guide [8.12] | Elastic.

For the cuisine field, I created a cuisine_embedding using ELSER. However, when I try a query like

GET michelin2/_search
{
   "query":{
      "text_expansion":{
         "cuisine_embedding":{
            "model_id":".elser_model_2_linux-x86_64",
            "model_text":"not asian"
         }
      }
   }
}

instead of getting non-asian restaurants, I get only asian ones.

What would be a good way to fix it? I am new to NLP models.

Hey there, text expansion queries essentially take the semantic meaning of the words and join them together into a massive OR query. So that makes terms like “not ___” not really work the way you want it to. If you need to exclude results I’d probably suggest looking into creating Boolean queries and filtering out things you don’t want. However you’re not going to get that right out of the box with text expansion alone and depending on your use case you may need to do some front end work to formulate the query in the way you want.

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