2

Let's consider following case - I have list of some video titles and video categories which are indexed in elastic.

And task is to match video with categories.

I have three categories in the index:

{
  "category" : "rock climbing"
  ...
},

{
  "category" : "rock and roll"
  ...
}

And

{
  "category" : "outdoor"
  ...
}

"category" field is mapped to analyzed string and uses multiple analyzers. So inverted index for first document is "rock, climb", second - "outdoor" and for the last one is "rock, roll".

Now I want to find all available categories to video with title "outdoor rock climbing in national park"

So I need to receive "rock climbing" and "outdoor"

I am trying to run following query

{
 "query": {
   "match": {
     "category": "outdoor rock climbing in national park"
   }
 }
}

And it returns all documents, because it founds documents by occurrences of "outdoor, rock and climb".

But I want query to return only those documents where query contains all inverted index words.

Analyzed query: outdoor,rock,climb,nation,park

Expected result: outdoor, rock+climb

I am beginner in the elastic search, please help.

Thanks in advance!

Vitaly
  • 63
  • 8

0 Answers0