【发布时间】:2016-11-02 12:36:13
【问题描述】:
在 elasticsearch 中搜索 galaxy mobiles 时。
它会创建一个如下所示的查询,因为应在 mobiles 类别中搜索 galaxy。
{
"query": {
"bool": {
"should": [{
"multi_match": {
"query": "galaxy",
"fields": ["title", "product_specs", "category", "brand", "os"],
"operator": "and"
}
}, {
"multi_match": {
"query": "galaxy",
"fields": ["title", "product_specs", "category", "brand", "os"],
"type": "phrase_prefix"
}
}, {
"multi_match": {
"query": "galaxy",
"fields": ["title", "product_specs", "category", "brand", "os"],
"type": "phrase"
}
}],
"must": [{
"term": {
"category": "mobiles"
}
}]
}
}
}
只有must 条件有效,should 条件无效。
上面的查询有什么问题吗?
【问题讨论】:
-
不工作是什么意思?你在期待什么?
-
我想要移动类别的产品,标题或其他字段中包含银河。但它只给了我手机类别
标签: php search elasticsearch lucene