我有这种情况,其中在同一个查询中有两个 multi_match 搜索。问题是,当我在 ruby 中为其创建 JSON 时,似乎不可能使用具有非唯一键的 json,因此只出现其中一个键。
这是我的查询:
{
"fields": ["id", "title",
"address.city", "address.state", "address.country", "address.state_code", "address.country_code", "proxy_titles", "location"],
"size":2,
"query":{
"filtered":{
"filter": {
"range": {
"custom_score": {
"gte": 100
}
}
},
"query":{
"bool": {
"must": {
"multi_match":{
"query": "term 1",
"type": "cross_fields",
"fields": ["title^2", "proxy_titles^2","description"]
}
},
"must": {
"multi_match": {
"query": "us",
"fields": ["address.city", "address.country", "address.state",
"address.zone", "address.country_code", "address.state_code", "address.zone_code"]
}
}
}
}
}
},
"sort": {
"_score": { "order": "desc" },
"variation": {"order": "asc"},
"updated_at": { "order": "desc" }
}
}
我也是最近才开始使用弹性搜索,所以如果你能建议我一个更好的查询来完成同样的事情,那将非常有帮助。