I am new in Elastic Search. I would like to get category wise most matched(Score wise) single record. Lets take a example.
My Index detail
PUT commentdetail { "mappings": { "properties": { "category" : { "type": "text" }, "comment" : { "type": "text" }
}} }
Sample Data
category Comment
fruit I like apple
fruit I like apple and banana
fruit I like banana and apple
fruit I like banana but not apple
fruit I like apple but not banana
fruit I like banana
vegetable I like potato
vegetable I like potato and tomato
vegetable I like tomato and potato
vegetable I like tomato but not potato
vegetable I like potato but not tomato
vegetable I like tomato
Expected Result If I search "i like" on comment field then expected output is
GET commentdetail/_search { "query": { "match_phrase": { "comment": "I like" } } }
Result:
category Comment
-----------------------
Fruit I like apple
Vegetable I like potato