弹性搜索:multi_match没有效果与过滤器 [英] Elasticsearch: multi_match no effect with filters
本文介绍了弹性搜索:multi_match没有效果与过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
multi_match
中存在的搜索关键字。我插入的任何搜索文本我总是得到相同的结果。 如果我删除 filters / filter c $ c>,它给我一个正确的搜索。为什么?
GET / catalog / products / _search
{
from:0,
size:150
查询:{
过滤:{
查询:{
multi_match:{
查询:要搜索的文本,
fields:[
title ^ 5,
description
]
},
过滤器:{
和:[
{
term:{
category:2
}
},
{
not:{
term:{
subCategory:3
}
}
}
]
}
}
}
}
}
解决方案
e在同一级别筛选查询,如下所示:
GET / catalog / products / _search
{
from:0,
size:150,
查询:{
过滤:{
查询:{
查询:要搜索的文本,
fields:[
title ^ 5,
description
]
},
过滤器:{
和:[
{
term:{
category 2
}
},
{
not:{
term:{
subCategory:3
}
}
}
]
}
}
}
}
I try to be brief. This search does not apply the search keywords present in multi_match
. Any search text I insert, I always get the same result.
If I delete filtered / filter
, it gives me a proper search. Why?
GET /catalog/products/_search
{
"from":0,
"size":150,
"query":{
"filtered":{
"query":{
"multi_match":{
"query":"text to search",
"fields":[
"title^5",
"description"
]
},
"filter":{
"and":[
{
"term":{
"category": 2
}
},
{
"not":{
"term":{
"subCategory": 3
}
}
}
]
}
}
}
}
}
解决方案
Put the filter on the same level at query, like this:
GET /catalog/products/_search
{
"from":0,
"size":150,
"query":{
"filtered":{
"query":{
"multi_match":{
"query":"text to search",
"fields":[
"title^5",
"description"
]
}
},
"filter":{
"and":[
{
"term":{
"category": 2
}
},
{
"not":{
"term":{
"subCategory": 3
}
}
}
]
}
}
}
}
这篇关于弹性搜索:multi_match没有效果与过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文