而在elasticsearch搜索galaxy mobiles
。 它會創建一個類似於下面的查詢,因爲galaxy
應該在mobiles
類別中進行搜索。'必須'和'應該'結合在布爾查詢不起作用
{
"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
條件不工作。 上述查詢中是否有問題?
你說的不工作呢?你在期待什麼? – femtoRgon
我想要在標題或其他字段中使用銀河移動類別的產品。但它只給我手機類別 –