我有以下查询:
{
"from": 0,
"query": {
"custom_filters_score": {
"filters": [
{
"boost": 1.5,
"filter": {
"term": {
"format": "test1"
}
}
},
{
"boost": 1.5,
"filter": {
"term": {
"format": "test2"
}
}
}
],
"query": {
"bool": {
"must": {
"query_string": {
"analyzer": "query_default",
"fields": [
"title^5",
"description^2",
"indexable_content"
],
"query": "blah"
}
},
"should": []
}
}
}
},
"size": 50
}
如果我正确阅读文档,那么应该在其中增加{"format":"test1"}
的内容。
但是,使用explain
告诉我"custom score, no filter match, product of:"
是结果,此过滤器不会更改与过滤器匹配的返回文档的分数。
我做错了什么?
编辑:这是架构:
mapping:
edition:
_all: { enabled: true }
properties:
title: { type: string, index: analyzed }
description: { type: string, index: analyzed }
format: { type: string, index: not_analyzed, include_in_all: false }
section: { type: string, index: not_analyzed, include_in_all: false }
subsection: { type: string, index: not_analyzed, include_in_all: false }
subsubsection: { type: string, index: not_analyzed, include_in_all: false }
link: { type: string, index: not_analyzed, include_in_all: false }
indexable_content: { type: string, index: analyzed }
让我们假设一个典型的文档是:
{
"format": "test1",
"title": "blah",
"description": "blah",
"indexable_content": "keywords here",
"section": "section",
"subsection": "child-section",
"link":"/section/child-section/blah"
}
答案 0 :(得分:0)
如果显示“没有过滤匹配”,则表示它与查询中的任何过滤器都不匹配。最可能的原因是与您的查询匹配的记录中没有术语“test1”。不幸的是,您没有提供映射和测试数据,因此很难确定那里发生了什么。
尝试运行此查询,看看您是否可以找到符合搜索条件的任何记录,并且应该提升:
{
"from": 0,
"query": {
"bool": {
"must": [{
"query_string": {
"analyzer": "query_default",
"fields": ["title^5", "description^2", "indexable_content"],
"query": "blah"
}
}, {
"term": {
"format": "test1"
}
}]
}
},
"size": 50
}
您的查询看起来很好,并且根据提供的信息,它应该有效:https://gist.github.com/4448954