elasticsearch,Php,elasticsearch" /> elasticsearch,Php,elasticsearch" />

Php 对数组中的elasticsearch数据进行排序

Php 对数组中的elasticsearch数据进行排序,php,elasticsearch,Php,elasticsearch,我有elasticsearch中的数据 "id": "edff12sd3", "desc": "elastic_data" "main_array": [ { "id": "2308", "name": "Grey Area", "location": { "lat": 28.5696577, "lon": 77.3229933 } }, { "id": "2274", "name": "Tribute to The Beatles by Atul Ahuja- Live Music

我有elasticsearch中的数据

"id": "edff12sd3",
"desc": "elastic_data"
"main_array": [
{
"id": "2308",
"name": "Grey Area",
"location": {
  "lat": 28.5696577,
  "lon": 77.3229933
 }
},
{ 
"id": "2274",
"name": "Tribute to The Beatles by Atul Ahuja- Live Music",
"location": {
  "lat": 29.5696577,
  "lon": 77.3229933
}
},
{ 
"id": "2275",
"name": "Tribute to Music",
"location": {
  "lat": 29.9696577,
  "lon": 77.3229933
}
}
现在我必须按距离对数组对象进行排序 我试过这样做

{
"query": {
"filtered": {
  "query": {
    "multi_match": {
      "query": "elastic_data",
      "fields": [
        "desc"
      ]
    }
  }
}
},"sort": [
      {
    "_geo_distance": {
      "main_array.location": {
        "lat": 28.613939,
        "lon": 77.209021
      }
      },
      "order": "asc",
      "unit": "km"
    }
      }
    ]
}
我曾尝试按距离对main_数组中的所有对象进行排序,但它不起作用,它显示的是总体距离,而不是main_数组中存在的单个数据

请帮帮我。谢谢