【发布时间】:2017-01-24 17:02:34
【问题描述】:
这是我的原始查询 dsl,总点击量为 8,981。
GET /{index}/{document}/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "blue shoes",
"boost": 2
}
}
},
{
"match": {
"description": {
"query": "blue shoes",
"operator": "and",
"boost": 1
}
}
}
]
}
}
}
我想为此查询添加过滤器。
GET /{index}/{document}/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "blue shoes",
"boost": 2
}
}
},
{
"match": {
"description": {
"query": "blue shoes",
"operator": "and",
"boost": 1
}
}
}
],
"filter": {
"terms": {
"store.id": [ "store_a.com", "store_b.com" ]
}
}
}
}
}
现在它的点击总数为 15,989(increased)。
我在 asc 中按分数对结果进行排序(我不知道为什么它是 asc 而不是 desc),有些文档得分为 0。
我认为没有更多的查询过滤,因为它已经被过滤了。
我可以从结果中删除 0 个评分的文档吗?
【问题讨论】:
-
出于好奇,我的回答有帮助还是我错过了什么?
-
@nikoshr 对我迟到的回复感到抱歉。我通过将匹配项之一(在本例中为“标题”)从“应该”移动到“必须”来解决了这个问题。
标签: elasticsearch