elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.98k stars 24.75k forks source link

Aggregation with geodistance sorting #25901

Closed Akshayprmar closed 7 years ago

Akshayprmar commented 7 years ago

Describe the feature: i have need to aggregation for id and sorting to geodistance data... when i try to sorting with sort field that time giving below error.. "reason": "Invalid term-aggregates order path [sort]. Unknown aggregation [sort]"

Elasticsearch version: elasticsearch-5.4.3 Mapping

PUT /museums { "mappings": { "doc": { "properties": { "location": { "type": "geo_point" } } } } }

DATA POST /museums/doc/_bulk?refresh

{"index":{"_id":1}} {"location": "52.374081,4.912350", "name": "NEMO Science Museum"} {"index":{"_id":2}} {"location": "52.369219,4.901618", "name": "Museum Het Rembrandthuis"} {"index":{"_id":3}} {"location": "52.371667,4.914722", "name": "Nederlands Scheepvaartmuseum"} {"index":{"_id":4}} {"location": "51.222900,4.405200", "name": "Letterenhuis"} {"index":{"_id":5}} {"location": "48.861111,2.336389", "name": "Musée du Louvre"} {"index":{"_id":6}} {"location": "48.860000,2.327000", "name": "Musée d'Orsay"} {"index":{"_id":7}} {"location": "52.374081,4.912350", "name": "NEMO Science Museum"} {"index":{"_id":8}} {"location": "48.861111,2.336389", "name": "Musée du Louvre"}

Elastic Query

POST /museums/_search?size=0 { "query": {

    },
    "sort": {
        "_geo_distance": {
            "location": {
                    "lat": 52.3760,
                    "lon": 4.894
            },
            "order": "asc",
            "unit": "km",
            "distance_type": "arc"
        }
    },
    "aggregations": {
        "by_id": {
            "terms": {
                "field": "name.keyword",
                "order": {
                  "_count": "asc"
                },
                "size": 20
            },
            "aggregations":{
              "top":{
                "top_hits":
                {
                  "sort":{
                    "_geo_distance":{

"location":{"lat":19.143172,"lon":72.824966 } } } } } } } } }

danielmitterdorfer commented 7 years ago

Hi @Akshayprmar, we reserve Github for bug reports and feature requests only. Please ask questions like these in the Elasticsearch forum instead. Thank you!

Akshayprmar commented 7 years ago

Hi @danielmitterdorfer thanks for the response.