Elasticsearch结合2种参数

时间:2019-01-29 11:57:27

标签: javascript node.js elasticsearch elasticsearch.js

我有一个像这样的ElasticSearch查询:

{
    "query": {
        "match": {
            "text": "some text"
        }
    },
    "sort": [
        "_score",
        {
          "_geo_distance": {
            "geoLocation": {
              "lat": 24.47051149893434,
              "lon": 54.37345332058612
            },
            "order": "asc",
            "unit": "km",
            "distance_type": "arc"
          }
       }
    ]

}

作为回应,我收到了:

{
        "hits": {
                "total": 1,
                "max_score": null,
                "hits": [
                    {
                        "_index": "searfi",
                        "_type": "business",
                        "_id": "5",
                        "_score": 7.6979322,
                        "_source": {
                            "text": "some text"
                        },
                        "sort": [
                            7.6,
                            20
                        ]
                    }
                ]
        }

}

问题是如何在接收之前合并“ sort”数组中的元素,如sort [0] + sort [1](7.6 + 20 = 27.6,“ sort”:[27.6])并按接收值对所有结果进行排序来自elasticsearch的答案?

0 个答案:

没有答案