使用function_score的简单查询在Elasticsearch中不起作用

时间:2016-05-27 11:13:14

标签: elasticsearch

我对Elasticsearch很新,这应该很简单,但我找不到问题......

我希望排序顺序是Elasticsearch '_score'和给定整数字段'note'的值的组合。所以我尝试使用功能评分查询'field_value_factor',如下所示:

{
  "query": {
    "function_score": {
      "query": {
        "match_all": {}
      },
      "functions": [
        {
          "field_value_factor": {
            "field": "note"
          }
        }
      ]
    }
  }
}

以下是结果的第一行:

{
"took": 2,
"timed_out": false,
"_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
},
"hits": {
    "total": 195574,
    "max_score": 1,
    "hits": [
        {
            "_index": "app",
            "_type": "city",
            "_id": "1705",
            "_score": 1,
            "_source": {
                "note": 89,
                "postcode": "04320",
                "names": [
                    {
                        "name": "Sausses"
                    }
                ]
            }
        }
        ,
        {
            "_index": "app",
            "_type": "city",
            "_id": "1712",
            "_score": 1,
            "_source": {
                "note": 61,
                "postcode": "04330",
                "names": [
                    {
                        "name": "Blieux"
                    }
                ]
            }
        }
        ,
        {
            "_index": "app",
            "_type": "city",
            "_id": "1717",
            "_score": 1,
            "_source": {
                "note": 253,
                "postcode": "04340",
                "names": [
                    {
                        "name": "Saint-Vincent-les-Forts"
                    }
                ]
            }
        }

_score始终为1,note的值未被考虑在内,结果未按我希望的方式排序。

有关我做错的任何提示?

Elasticsearch的版本:1.7.5

0 个答案:

没有答案