GET /thing/_search/? { "query": { "multi_match" : { "query": "castle pontivy", "type": "most_fields", "fields": [ "title", "loc" ] } } }
thing 哪里 title loc 包含 castle pontivy 以相关的顺序。不错。
thing
title
loc
castle
pontivy
标题 . 也就是说如果一个项目完全匹配 castle pontivy
标题
castle pontivy
有办法吗?
你可以做一个 phrase 匹配并给它一个 boost function score query (我建议你应该)
phrase
boost
第二个multi\u匹配将使用 most_fields .
most_fields
{ "query":{ "bool":{ "should":[ { "multi_match":{ "query":"castle pontivy", "type":"phrase", "fields":[ "title", "loc" ], "boost":5 } }, { "multi_match":{ "query":"castle pontivy", "type":"most_fields", "fields":[ "title", "loc" ] } } ] } } }