i have multi-valued field favsports
(not analyzed) in elasticsearch index:
{"name":"mike","favsports":["soccer","tennis"],...} {"name":"joe","favsports":["soccer","tennis","basketball"],...}
i want write query find persons both soccer , tennis, query:
"query": { "bool": { "must": [ { "term": { "favsports": "soccer" } }, { "term": { "favsports": "tennis" } } ], "must": { "query_string": { .....(other query criteria) } } } }
in query above, score of "favsports":"soccer/tennis"
same mike , joe.
i want write query mike has higher score joe because mike exact match soccer/tennis
while joe have additional basketball
, how can write such query?
another question: if want "soccer" , "tennis" (if sport other soccer , tennis, won't included in query result) how write query?
writing function query this.
"script_score": { "script": { "file": "countreciprocal",// 1/doc[field].values.size() "params": { "field": "favsports" } } }
Comments
Post a Comment