OR query with elasticsearch -


i have index "name" , "description" filed. running boolean query against index. term present in both name , description fields, in case documents in both name , description contains search term scored higher compared ones having either name or description having search term.

what want score them equal. the documents either name or description having term has same score document having search term present in both name , description.

is possible?

here example:

{     "name":     "xyz",     "description":  "abc xyz" }, {     "name":     "abc",     "description":  "xyz pqr" }, {     "name":     "xyz",     "description":  "abc pqr" } 

if user search term "xyz" want 3 documents above have same score. documents contains term "xyz" either in name or in description or in both fields.

you can use filtered query this. filters not scored. see query below searching term "xyz":

post <index name>/<type>/_search {     "filtered": {         "query": {             "match_all": {}         },         "filter": {             "bool": {                 "should": [                     {                         "term": {                             "name": "xyz"                         }                     },                     {                         "term": {                             "description": "xyz"                         }                     }                 ]             }         }     } } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -