【发布时间】:2016-10-09 13:27:00
【问题描述】:
鉴于这份文件:
{"name": "Perfect Sunny-Side Up Eggs","ingredientList": ["canola oil","eggs"]}
如何在弹性搜索中构建查询以返回给定查询词“油蛋”的字符串数组的完全匹配,到目前为止,这就是我所拥有的,但它返回其他不相关的文档:
POST /recipes/recipe/_search
{
"query": {
"match": {
"ingredientList": {
"query": [
"oil",
"eggs"
],
"operator": "and"
}
}
}
}
例如,返回此文档但它不包含“油”。结果应该只包含“油”和“鸡蛋”:
{"name": "Quick Baked French Toast","ingredientList": ["butter","cinnamon raisin bread","eggs"]}
【问题讨论】:
-
您需要一个带有多个
Must子句的bool查询:elastic.co/guide/en/elasticsearch/reference/current/…
标签: elasticsearch