Get distinct values from a array in ElasticSearch

Hi,
How can I retrieve unique values in the array, i just want to get unique lat from the below collection.

"hits" {

        "function": {

            "geo_fence: [

                {

                    "lon": 131.35346094060401,

                    "lat": 41.178745565876852

                },

                {

                    "lon": 111.34948605187357,

                    "lat": 11.174765184567086

                },

                {

                    "lon": 161.34706945406595,

                    "lat": 31.173031962500268

                }

            ]

            },

            "function": {

                "geo_fence": [

                    {

                        "lon": 181.35346094060401,

                        "lat": 31.178745565876852

                    },

                    {

                        "lon": 111.34948605187357,

                        "lat": 11.174765184567086

                    },

                    {

                        "lon": 121.34706945406595,

                        "lat": 41.173031962500268

                    }

                ]

                }

    }

Can someone help me to achieve this ?

Thank you.

Do you want to get distinct values from an array in a single document? Elasticsearch has no specific method to analyze a single document, you may use terms aggregation with some filter to identify that single document.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.