Elasticsearch: Get report of unmatched should elements in a bool query -


i'm looking way report of unmatched should querys , display it. instance have 2 user objects

user 1:

{ "username": "user1" "doctype": "user" "level": "professor" "discipline": "sciences" "sub-discipline": "mathematical" } 

user 2:

{ "username": "user1" "doctype": "user" "level": "professor" "discipline": "sciences" "subdiscipline": "physics" } 

when bool query matching discipline in must query , sub-discipline in should query

bool:   must: [{     term: { "doc.doctype": "user" }   },{     term: { "doc.level": "professor" }   },{     term: { "doc.discipline": "sciences" }   }],   should: [{     term: { "subdiscipline": "physics" }   }] 

how can unmatched elements in result that:

result 1: user1 match 100% result 2: user2 match 70% (unmatch subdiscipine "physics") 

i had explainapi result doesn't seems provided use case , seems complicated parse.

you need use named queries this. using same , create bool query below -

{   "query": {     "bool": {       "must": [         {           "match": {             "sourcename": {               "query": "cnn",               "_name": "sourcematch"             }           }         },         {           "match": {             "author": {               "query": "qbox.io",               "_name": "author"             }           }         }       ]     }   } } 

in result section , tell named queries matched. can use information fabricate stats looking for.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -