0

我有以下查询:

{
"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"}如果我正确阅读文档,这应该会提升其中的内容。

但是, usingexplain告诉我这"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"
}
4

1 回答 1

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

于 2013-01-04T00:52:10.193 回答