【发布时间】:2016-08-11 22:33:38
【问题描述】:
我的目的是组合 2 个多重匹配查询,如下所示。我希望 MPN 或 SKU 字段必须与每个关键字匹配。因此关键字“hp”和“301”都必须存在于 MPN 或 SKU 中。 或者 Name 或 Name.raw 应该具有关键字“hp”或“301”之一。 MPN/SKU 的完全匹配应该有更高的分数。 我编写了如下查询,但尽管有文档具有这些条件,但它没有返回任何结果。 我的问题是,
1) Does must query require keyword to be found in both SKU and MPN
for the multi_match query?
2) Combination of must and should is AND or OR? it looks like AND
for me as it doesn't return any result. if it is AND, how to make it
as OR? I cant find any operator on bool. I tried to wrap in another
should query but it didnt help.
我也感谢任何针对我的目的的查询建议。
"from": 0,
"size": 10,
"explain": true,
"query": {
"bool": {
"must": [
{
"multi_match": {
"type": "best_fields",
"query": "hp 301",
"fields": [
"MPN^9",
"SKU^8"
],
"operator": "and"
}
}
],
"should": [
{"multi_match": {
"type": "best_fields",
"query": "hp 301",
"fields": [
"Name.raw2^7.5",
"Name^7"
]
}}
]
}
}
【问题讨论】:
标签: elasticsearch