2013-01-03 88 views
0

我有以下查询:ElasticSearch过滤器升压的字段值

{ 
"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

如果说“不匹配的过滤器”,这意味着它不匹配查询中的任何过滤器。最有可能的原因是与您的查询匹配的记录中没有术语“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

+0

我已经更新了我的问题,包括架构和编辑的示例文档,如果这改变了任何东西。 –

+0

我已经用您提供的信息更新了要点。它仍然有效。我用0.20.2测试了它。所以,我猜想你要么编辑了一些重要的信息,要么就是使用了一些老版本的elasticsearch,这些功能被破坏了。你可以创建一个完全不重要的repro吗? – imotov

+0

原来我是个白痴,索引没有加载。查询确实起作用了! –