为什么ElasticSearch没有显示分数?

时间:2016-06-21 12:24:24

标签: java elasticsearch elasticsearch-mapping

我在Ubuntu 16.04上使用ElasticSearch 2.3.1。

映射是:

{
    "settings": {
        "analysis": {
            "filter": {             
                "2gramsto3_filter": {
                    "type":     "ngram",
                    "min_gram": 2,
                    "max_gram": 3
                }                
            },        
            "analyzer": {
                "2gramsto3": {
                    "type":      "custom",
                    "tokenizer": "standard",
                    "filter":   [
                        "lowercase",
                        "2gramsto3_filter"
                    ]
                }
            }
        }
    },  
    "mappings": {
        "agents": {
            "properties": {                             
                "presentation": {
                    "type": "string",
                    "analyzer": "2gramsto3"                 
                },
                "cv": {
                    "type": "string",
                    "analyzer": "2gramsto3"                 
                }
        }
    }
}

查询是:

{
  "size": 20,
  "from": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              [
                {
                  "match": {
                    "cv": "folletto"
                  }
                },
                {
                  "match": {
                    "cv": " psicologia"
                  }
                },
                {
                  "match": {
                    "cv": " tenacia"
                  }
                }
              ]
            ]
          }
        }
      ]
    }
  }
}

它找到了14567份文件但分数总是 "_score": 0

我看过滤器有分数,所以,为什么不在这种情况下?

谢谢!

1 个答案:

答案 0 :(得分:2)

过滤器的分数不计算。如果需要分数,则需要使用普通查询。

请考虑下面文档中指出的含义。 参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html