# Multiple geo\_points per document

**URL:** <https://discuss.elastic.co/t/multiple-geo-points-per-document/7154>\
**Category:** Elasticsearch\
**Created:** [March 27, 2012, 10:23pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154 "2012-03-27T22:23:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommyvn](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tommyvn](https://discuss.elastic.co/u/tommyvn)\
**Post date:** [March 27, 2012, 10:23pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/1 "2012-03-27T22:23:20Z")

</div>

Hi all

My geo\_distance sort is not returning things in the order I'd expect. Am I  
doing something silly?

I have the following mapping:  
$ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
{  
"offices" : {  
"properties" : {  
"location" : {  
"properties" : {  
"address" : {  
"type" : "string"  
},  
"point" : {  
"type" : "geo\_point"  
}  
}  
},  
"name" : {  
"type" : "string"  
}  
}  
}  
}

Then I have the following query and response (I've only included hits to  
cut down on noise):  
$ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d '{  
"fields": ["name", "location"], "query": { "match\_all": {} }, "sort": {  
"\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
"asc", "unit": "km"} }}'  
...  
"hits" : [ {  
"\_index" : "work",  
"\_type" : "offices",  
"\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
"\_score" : null,  
"fields" : {  
"location" : [ {  
"point" : [-0.01655, 51.5007324],  
"address" : "E14 9SH"  
}, {  
"point" : [-0.0976398, 51.4962307],  
"address" : "SE1 6PL"  
} ],  
"name" : "office3"  
},  
"sort" : [0.0]  
}, {  
"\_index" : "work",  
"\_type" : "offices",  
"\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
"\_score" : null,  
"fields" : {  
"location" : [ {  
"point" : [-0.01655, 51.5007324],  
"address" : "E14 9SH"  
}, {  
"point" : [-0.0684337, 51.4843866],  
"address" : "SE1 5BA"  
} ],  
"name" : "office10"  
},  
"sort" : [2.413161036894697]  
}, {  
"\_index" : "work",  
"\_type" : "offices",  
"\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
"\_score" : null,  
"fields" : {  
"location" : [ {  
"point" : [-0.0976398, 51.4962307],  
"address" : "SE1 6PL"  
}, {  
"point" : [-0.0684337, 51.4843866],  
"address" : "SE1 5BA"  
} ],  
"name" : "office8"  
},  
"sort" : [2.413161036894697]  
}  
...

Specifically both office8 and office3 have locations 0km away from my  
search point, yet office10 is sneaking in between the two at 2.4km away and  
office8 is also placing itself 2.4km away (which it is, but but only on the  
further location point). It's as if it only looks at the last geo\_point in  
the location array.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 28, 2012, 10:41am UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/2 "2012-03-28T10:41:07Z")

</div>

Geo sorting does not support multiple values per doc, so it will choose  
(arbitrarily) one of the points and use them. We could potentially support  
multiple points, but its not there...

On Wed, Mar 28, 2012 at 12:23 AM, tommyvn [tom@tomvn.com](mailto:tom@tomvn.com) wrote:

> Hi all
> 
> My geo\_distance sort is not returning things in the order I'd expect. Am I  
> doing something silly?
> 
> I have the following mapping:  
> $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> {  
> "offices" : {  
> "properties" : {  
> "location" : {  
> "properties" : {  
> "address" : {  
> "type" : "string"  
> },  
> "point" : {  
> "type" : "geo\_point"  
> }  
> }  
> },  
> "name" : {  
> "type" : "string"  
> }  
> }  
> }  
> }
> 
> Then I have the following query and response (I've only included hits to  
> cut down on noise):  
> $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> "asc", "unit": "km"} }}'  
> ...  
> "hits" : [ {  
> "\_index" : "work",  
> "\_type" : "offices",  
> "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> "\_score" : null,  
> "fields" : {  
> "location" : [ {  
> "point" : [-0.01655, 51.5007324],  
> "address" : "E14 9SH"  
> }, {  
> "point" : [-0.0976398, 51.4962307],  
> "address" : "SE1 6PL"  
> } ],  
> "name" : "office3"  
> },  
> "sort" : [0.0]  
> }, {  
> "\_index" : "work",  
> "\_type" : "offices",  
> "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> "\_score" : null,  
> "fields" : {  
> "location" : [ {  
> "point" : [-0.01655, 51.5007324],  
> "address" : "E14 9SH"  
> }, {  
> "point" : [-0.0684337, 51.4843866],  
> "address" : "SE1 5BA"  
> } ],  
> "name" : "office10"  
> },  
> "sort" : [2.413161036894697]  
> }, {  
> "\_index" : "work",  
> "\_type" : "offices",  
> "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> "\_score" : null,  
> "fields" : {  
> "location" : [ {  
> "point" : [-0.0976398, 51.4962307],  
> "address" : "SE1 6PL"  
> }, {  
> "point" : [-0.0684337, 51.4843866],  
> "address" : "SE1 5BA"  
> } ],  
> "name" : "office8"  
> },  
> "sort" : [2.413161036894697]  
> }  
> ...
> 
> Specifically both office8 and office3 have locations 0km away from my  
> search point, yet office10 is sneaking in between the two at 2.4km away and  
> office8 is also placing itself 2.4km away (which it is, but but only on the  
> further location point). It's as if it only looks at the last geo\_point in  
> the location array.

---

<div class="post-metadata">

**Author:** ![tommyvn](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tommyvn](https://discuss.elastic.co/u/tommyvn)\
**Post date:** [March 28, 2012, 5:56pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/3 "2012-03-28T17:56:49Z")

</div>

It's a feature that's got my vote.  
Any suggestions for an ES novice to implement multiple points per document?  
Based on no research so far I'm thinking maybe I can work around this by  
having multiple children with one location each linked to the parent. I  
wonder if that'll mean an office could appear twice in my results as the  
distance expands? I wonder if what I'm thinking is crazy and won't work?  
I'm about to try so I'll post back with my results, but if anyone wants to  
stop me before I get too far, feel free..

On Wednesday, March 28, 2012 11:41:07 AM UTC+1, kimchy wrote:

> Geo sorting does not support multiple values per doc, so it will choose  
> (arbitrarily) one of the points and use them. We could potentially support  
> multiple points, but its not there...
> 
> On Wed, Mar 28, 2012 at 12:23 AM, tommyvn [tom@tomvn.com](mailto:tom@tomvn.com) wrote:
> 
> > Hi all
> > 
> > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > I doing something silly?
> > 
> > I have the following mapping:  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> > {  
> > "offices" : {  
> > "properties" : {  
> > "location" : {  
> > "properties" : {  
> > "address" : {  
> > "type" : "string"  
> > },  
> > "point" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > },  
> > "name" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > Then I have the following query and response (I've only included hits to  
> > cut down on noise):  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> > '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> > { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> > "asc", "unit": "km"} }}'  
> > ...  
> > "hits" : [ {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > } ],  
> > "name" : "office3"  
> > },  
> > "sort" : [0.0]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office10"  
> > },  
> > "sort" : [2.413161036894697]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office8"  
> > },  
> > "sort" : [2.413161036894697]  
> > }  
> > ...
> > 
> > Specifically both office8 and office3 have locations 0km away from my  
> > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > further location point). It's as if it only looks at the last geo\_point in  
> > the location array.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 29, 2012, 2:08pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/4 "2012-03-29T14:08:21Z")

</div>

You can't sort based on child / nested docs (with multiple values) and get  
the parent back, though, you can sort on the "children" and get back the  
children back.

On Wed, Mar 28, 2012 at 7:56 PM, tommyvn [tom@tomvn.com](mailto:tom@tomvn.com) wrote:

> It's a feature that's got my vote.  
> Any suggestions for an ES novice to implement multiple points per document?  
> Based on no research so far I'm thinking maybe I can work around this by  
> having multiple children with one location each linked to the parent. I  
> wonder if that'll mean an office could appear twice in my results as the  
> distance expands? I wonder if what I'm thinking is crazy and won't work?  
> I'm about to try so I'll post back with my results, but if anyone wants to  
> stop me before I get too far, feel free..
> 
> On Wednesday, March 28, 2012 11:41:07 AM UTC+1, kimchy wrote:
> 
> > Geo sorting does not support multiple values per doc, so it will choose  
> > (arbitrarily) one of the points and use them. We could potentially support  
> > multiple points, but its not there...
> > 
> > On Wed, Mar 28, 2012 at 12:23 AM, tommyvn [tom@tomvn.com](mailto:tom@tomvn.com) wrote:
> > 
> > > Hi all
> > > 
> > > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > > I doing something silly?
> > > 
> > > I have the following mapping:  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > '  
> > > {  
> > > "offices" : {  
> > > "properties" : {  
> > > "location" : {  
> > > "properties" : {  
> > > "address" : {  
> > > "type" : "string"  
> > > },  
> > > "point" : {  
> > > "type" : "geo\_point"  
> > > }  
> > > }  
> > > },  
> > > "name" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Then I have the following query and response (I've only included hits to  
> > > cut down on noise):  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > "order": "asc", "unit": "km"} }}'  
> > > ...  
> > > "hits" : [ {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > } ],  
> > > "name" : "office3"  
> > > },  
> > > "sort" : [0.0]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office10"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office8"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }  
> > > ...
> > > 
> > > Specifically both office8 and office3 have locations 0km away from my  
> > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > further location point). It's as if it only looks at the last geo\_point in  
> > > the location array.

---

<div class="post-metadata">

**Author:** ![Maximilian\_Schulz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maximilian_schulz/32/2936_2.png) [@Maximilian\_Schulz](https://discuss.elastic.co/u/Maximilian_Schulz)\
**Post date:** [April 1, 2012, 8:18pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/5 "2012-04-01T20:18:57Z")

</div>

> I just found this discussion while searching a solution for the exact same  
> problem. So my question is, if that feature is on schedule, or if we should  
> file a github issue?

Hi all

> > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > I doing something silly?
> > 
> > I have the following mapping:  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> > {  
> > "offices" : {  
> > "properties" : {  
> > "location" : {  
> > "properties" : {  
> > "address" : {  
> > "type" : "string"  
> > },  
> > "point" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > },  
> > "name" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > Then I have the following query and response (I've only included hits to  
> > cut down on noise):  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> > '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> > { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> > "asc", "unit": "km"} }}'  
> > ...  
> > "hits" : [ {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > } ],  
> > "name" : "office3"  
> > },  
> > "sort" : [0.0]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office10"  
> > },  
> > "sort" : [2.413161036894697]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office8"  
> > },  
> > "sort" : [2.413161036894697]  
> > }  
> > ...
> > 
> > Specifically both office8 and office3 have locations 0km away from my  
> > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > further location point). It's as if it only looks at the last geo\_point in  
> > the location array.

On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:

> Geo sorting does not support multiple values per doc, so it will choose  
> (arbitrarily) one of the points and use them. We could potentially support  
> multiple points, but its not there...
> 
> Hi all
> 
> > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > I doing something silly?
> > 
> > I have the following mapping:  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> > {  
> > "offices" : {  
> > "properties" : {  
> > "location" : {  
> > "properties" : {  
> > "address" : {  
> > "type" : "string"  
> > },  
> > "point" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > },  
> > "name" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > Then I have the following query and response (I've only included hits to  
> > cut down on noise):  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> > '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> > { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> > "asc", "unit": "km"} }}'  
> > ...  
> > "hits" : [ {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > } ],  
> > "name" : "office3"  
> > },  
> > "sort" : [0.0]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office10"  
> > },  
> > "sort" : [2.413161036894697]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office8"  
> > },  
> > "sort" : [2.413161036894697]  
> > }  
> > ...
> > 
> > Specifically both office8 and office3 have locations 0km away from my  
> > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > further location point). It's as if it only looks at the last geo\_point in  
> > the location array.

On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:

> Geo sorting does not support multiple values per doc, so it will choose  
> (arbitrarily) one of the points and use them. We could potentially support  
> multiple points, but its not there...
> 
> Hi all
> 
> > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > I doing something silly?
> > 
> > I have the following mapping:  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> > {  
> > "offices" : {  
> > "properties" : {  
> > "location" : {  
> > "properties" : {  
> > "address" : {  
> > "type" : "string"  
> > },  
> > "point" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > },  
> > "name" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > Then I have the following query and response (I've only included hits to  
> > cut down on noise):  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> > '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> > { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> > "asc", "unit": "km"} }}'  
> > ...  
> > "hits" : [ {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > } ],  
> > "name" : "office3"  
> > },  
> > "sort" : [0.0]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office10"  
> > },  
> > "sort" : [2.413161036894697]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office8"  
> > },  
> > "sort" : [2.413161036894697]  
> > }  
> > ...
> > 
> > Specifically both office8 and office3 have locations 0km away from my  
> > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > further location point). It's as if it only looks at the last geo\_point in  
> > the location array.

On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:

> Geo sorting does not support multiple values per doc, so it will choose  
> (arbitrarily) one of the points and use them. We could potentially support  
> multiple points, but its not there...
> 
> Hi all
> 
> > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > I doing something silly?
> > 
> > I have the following mapping:  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)'  
> > {  
> > "offices" : {  
> > "properties" : {  
> > "location" : {  
> > "properties" : {  
> > "address" : {  
> > "type" : "string"  
> > },  
> > "point" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > },  
> > "name" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > Then I have the following query and response (I've only included hits to  
> > cut down on noise):  
> > $ curl -XGET '[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)' -d  
> > '{ "fields": ["name", "location"], "query": { "match\_all": {} }, "sort":  
> > { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307], "order":  
> > "asc", "unit": "km"} }}'  
> > ...  
> > "hits" : [ {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > } ],  
> > "name" : "office3"  
> > },  
> > "sort" : [0.0]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.01655, 51.5007324],  
> > "address" : "E14 9SH"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office10"  
> > },  
> > "sort" : [2.413161036894697]  
> > }, {  
> > "\_index" : "work",  
> > "\_type" : "offices",  
> > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > "\_score" : null,  
> > "fields" : {  
> > "location" : [ {  
> > "point" : [-0.0976398, 51.4962307],  
> > "address" : "SE1 6PL"  
> > }, {  
> > "point" : [-0.0684337, 51.4843866],  
> > "address" : "SE1 5BA"  
> > } ],  
> > "name" : "office8"  
> > },  
> > "sort" : [2.413161036894697]  
> > }  
> > ...
> > 
> > Specifically both office8 and office3 have locations 0km away from my  
> > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > further location point). It's as if it only looks at the last geo\_point in  
> > the location array.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 3, 2012, 2:06pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/6 "2012-04-03T14:06:07Z")

</div>

File a github issue just in case so we won't loose it.

On Sun, Apr 1, 2012 at 11:18 PM, Maximilian Schulz [namxam@gmail.com](mailto:namxam@gmail.com) wrote:

> > I just found this discussion while searching a solution for the exact  
> > same problem. So my question is, if that feature is on schedule, or if we  
> > should file a github issue?
> 
> Hi all
> 
> > > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > > I doing something silly?
> > > 
> > > I have the following mapping:  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > '  
> > > {  
> > > "offices" : {  
> > > "properties" : {  
> > > "location" : {  
> > > "properties" : {  
> > > "address" : {  
> > > "type" : "string"  
> > > },  
> > > "point" : {  
> > > "type" : "geo\_point"  
> > > }  
> > > }  
> > > },  
> > > "name" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Then I have the following query and response (I've only included hits to  
> > > cut down on noise):  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > "order": "asc", "unit": "km"} }}'  
> > > ...  
> > > "hits" : [ {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > } ],  
> > > "name" : "office3"  
> > > },  
> > > "sort" : [0.0]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office10"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office8"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }  
> > > ...
> > > 
> > > Specifically both office8 and office3 have locations 0km away from my  
> > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > further location point). It's as if it only looks at the last geo\_point in  
> > > the location array.
> 
> On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> 
> > Geo sorting does not support multiple values per doc, so it will choose  
> > (arbitrarily) one of the points and use them. We could potentially support  
> > multiple points, but its not there...
> > 
> > Hi all
> > 
> > > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > > I doing something silly?
> > > 
> > > I have the following mapping:  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > '  
> > > {  
> > > "offices" : {  
> > > "properties" : {  
> > > "location" : {  
> > > "properties" : {  
> > > "address" : {  
> > > "type" : "string"  
> > > },  
> > > "point" : {  
> > > "type" : "geo\_point"  
> > > }  
> > > }  
> > > },  
> > > "name" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Then I have the following query and response (I've only included hits to  
> > > cut down on noise):  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > "order": "asc", "unit": "km"} }}'  
> > > ...  
> > > "hits" : [ {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > } ],  
> > > "name" : "office3"  
> > > },  
> > > "sort" : [0.0]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office10"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office8"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }  
> > > ...
> > > 
> > > Specifically both office8 and office3 have locations 0km away from my  
> > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > further location point). It's as if it only looks at the last geo\_point in  
> > > the location array.
> 
> On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> 
> > Geo sorting does not support multiple values per doc, so it will choose  
> > (arbitrarily) one of the points and use them. We could potentially support  
> > multiple points, but its not there...
> > 
> > Hi all
> > 
> > > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > > I doing something silly?
> > > 
> > > I have the following mapping:  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > '  
> > > {  
> > > "offices" : {  
> > > "properties" : {  
> > > "location" : {  
> > > "properties" : {  
> > > "address" : {  
> > > "type" : "string"  
> > > },  
> > > "point" : {  
> > > "type" : "geo\_point"  
> > > }  
> > > }  
> > > },  
> > > "name" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Then I have the following query and response (I've only included hits to  
> > > cut down on noise):  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > "order": "asc", "unit": "km"} }}'  
> > > ...  
> > > "hits" : [ {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > } ],  
> > > "name" : "office3"  
> > > },  
> > > "sort" : [0.0]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office10"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office8"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }  
> > > ...
> > > 
> > > Specifically both office8 and office3 have locations 0km away from my  
> > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > further location point). It's as if it only looks at the last geo\_point in  
> > > the location array.
> 
> On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> 
> > Geo sorting does not support multiple values per doc, so it will choose  
> > (arbitrarily) one of the points and use them. We could potentially support  
> > multiple points, but its not there...
> > 
> > Hi all
> > 
> > > My geo\_distance sort is not returning things in the order I'd expect. Am  
> > > I doing something silly?
> > > 
> > > I have the following mapping:  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > '  
> > > {  
> > > "offices" : {  
> > > "properties" : {  
> > > "location" : {  
> > > "properties" : {  
> > > "address" : {  
> > > "type" : "string"  
> > > },  
> > > "point" : {  
> > > "type" : "geo\_point"  
> > > }  
> > > }  
> > > },  
> > > "name" : {  
> > > "type" : "string"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Then I have the following query and response (I've only included hits to  
> > > cut down on noise):  
> > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > "order": "asc", "unit": "km"} }}'  
> > > ...  
> > > "hits" : [ {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > } ],  
> > > "name" : "office3"  
> > > },  
> > > "sort" : [0.0]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.01655, 51.5007324],  
> > > "address" : "E14 9SH"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office10"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }, {  
> > > "\_index" : "work",  
> > > "\_type" : "offices",  
> > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > "\_score" : null,  
> > > "fields" : {  
> > > "location" : [ {  
> > > "point" : [-0.0976398, 51.4962307],  
> > > "address" : "SE1 6PL"  
> > > }, {  
> > > "point" : [-0.0684337, 51.4843866],  
> > > "address" : "SE1 5BA"  
> > > } ],  
> > > "name" : "office8"  
> > > },  
> > > "sort" : [2.413161036894697]  
> > > }  
> > > ...
> > > 
> > > Specifically both office8 and office3 have locations 0km away from my  
> > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > further location point). It's as if it only looks at the last geo\_point in  
> > > the location array.

---

<div class="post-metadata">

**Author:** ![tommyvn](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tommyvn](https://discuss.elastic.co/u/tommyvn)\
**Post date:** [April 4, 2012, 9:37pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/7 "2012-04-04T21:37:54Z")

</div>

Thanks, done!

> <https://github.com/elastic/elasticsearch/issues/1846>
>
> I have multiple geo points per document and would like to be able to sort based …on the closest matching location in the document to my center point. Apparently the way things currently work is the sort will be based on a random location on the document, as in the following scenario:
> 
> I have the following mapping:
> 
> \`\`\`
> $ curl -XGET 'http://localhost:9200/work/offices/\_mapping?pretty=true'
> {
> "offices" : {
> "properties" : {
> "location" : {
> "properties" : {
> "address" : {
> "type" : "string"
> },
> "point" : {
> "type" : "geo\_point"
> }
> }
> },
> "name" : {
> "type" : "string"
> }
> }
> }
> }
> \`\`\`
> 
> Then I have the following query and response (I've only included hits to cut down on noise):
> 
> \`\`\`
> $ curl -XGET 'http://localhost:9200/work/offices/\_search?pretty=true' -d '{ "fields": \["name", "location" \], "query": { "match\_all": {} }, "sort": { "\_geo\_distance": {"location.point": \[-0.0976398, 51.4962307\], "order": "asc", "unit": "km"} }}'
> ...
> "hits" : \[ {
> "\_index" : "work",
> "\_type" : "offices",
> "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",
> "\_score" : null,
> "fields" : {
> "location" : \[ {
> "point" : \[-0.01655, 51.5007324 \],
> "address" : "E14 9SH"
> }, {
> "point" : \[-0.0976398, 51.4962307 \],
> "address" : "SE1 6PL"
> } \],
> "name" : "office3"
> },
> "sort" : \[0.0 \]
> }, {
> "\_index" : "work",
> "\_type" : "offices",
> "\_id" : "xzaVAHUoSGON8gY1-ggILQ",
> "\_score" : null,
> "fields" : {
> "location" : \[ {
> "point" : \[-0.01655, 51.5007324 \],
> "address" : "E14 9SH"
> }, {
> "point" : \[-0.0684337, 51.4843866 \],
> "address" : "SE1 5BA"
> } \],
> "name" : "office10"
> },
> "sort" : \[2.413161036894697 \]
> }, {
> "\_index" : "work",
> "\_type" : "offices",
> "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",
> "\_score" : null,
> "fields" : {
> "location" : \[ {
> "point" : \[-0.0976398, 51.4962307 \],
> "address" : "SE1 6PL"
> }, {
> "point" : \[-0.0684337, 51.4843866 \],
> "address" : "SE1 5BA"
> } \],
> "name" : "office8"
> },
> "sort" : \[2.413161036894697 \]
> }
> ...
> \`\`\`
> 
> office8 and office3 both have locations 0km away from my search point, yet office10 is sneaking in between the two at 2.4km away and office8 is also placing itself 2.4km away (which it is, but but only on the further location point).
> 
> This was originally discussed here: https://groups.google.com/forum/?fromgroups#!topic/elasticsearch/DxIUevwZfOs

On Tuesday, April 3, 2012 3:06:07 PM UTC+1, kimchy wrote:

> File a github issue just in case so we won't loose it.
> 
> On Sun, Apr 1, 2012 at 11:18 PM, Maximilian Schulz [namxam@gmail.com](mailto:namxam@gmail.com)wrote:
> 
> > > I just found this discussion while searching a solution for the exact  
> > > same problem. So my question is, if that feature is on schedule, or if we  
> > > should file a github issue?
> > 
> > Hi all
> > 
> > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > Am I doing something silly?
> > > > 
> > > > I have the following mapping:  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > '  
> > > > {  
> > > > "offices" : {  
> > > > "properties" : {  
> > > > "location" : {  
> > > > "properties" : {  
> > > > "address" : {  
> > > > "type" : "string"  
> > > > },  
> > > > "point" : {  
> > > > "type" : "geo\_point"  
> > > > }  
> > > > }  
> > > > },  
> > > > "name" : {  
> > > > "type" : "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Then I have the following query and response (I've only included hits  
> > > > to cut down on noise):  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > "order": "asc", "unit": "km"} }}'  
> > > > ...  
> > > > "hits" : [ {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > } ],  
> > > > "name" : "office3"  
> > > > },  
> > > > "sort" : [0.0]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office10"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office8"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }  
> > > > ...
> > > > 
> > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > the location array.
> > 
> > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > 
> > > Geo sorting does not support multiple values per doc, so it will choose  
> > > (arbitrarily) one of the points and use them. We could potentially support  
> > > multiple points, but its not there...
> > > 
> > > Hi all
> > > 
> > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > Am I doing something silly?
> > > > 
> > > > I have the following mapping:  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > '  
> > > > {  
> > > > "offices" : {  
> > > > "properties" : {  
> > > > "location" : {  
> > > > "properties" : {  
> > > > "address" : {  
> > > > "type" : "string"  
> > > > },  
> > > > "point" : {  
> > > > "type" : "geo\_point"  
> > > > }  
> > > > }  
> > > > },  
> > > > "name" : {  
> > > > "type" : "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Then I have the following query and response (I've only included hits  
> > > > to cut down on noise):  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > "order": "asc", "unit": "km"} }}'  
> > > > ...  
> > > > "hits" : [ {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > } ],  
> > > > "name" : "office3"  
> > > > },  
> > > > "sort" : [0.0]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office10"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office8"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }  
> > > > ...
> > > > 
> > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > the location array.
> > 
> > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > 
> > > Geo sorting does not support multiple values per doc, so it will choose  
> > > (arbitrarily) one of the points and use them. We could potentially support  
> > > multiple points, but its not there...
> > > 
> > > Hi all
> > > 
> > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > Am I doing something silly?
> > > > 
> > > > I have the following mapping:  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > '  
> > > > {  
> > > > "offices" : {  
> > > > "properties" : {  
> > > > "location" : {  
> > > > "properties" : {  
> > > > "address" : {  
> > > > "type" : "string"  
> > > > },  
> > > > "point" : {  
> > > > "type" : "geo\_point"  
> > > > }  
> > > > }  
> > > > },  
> > > > "name" : {  
> > > > "type" : "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Then I have the following query and response (I've only included hits  
> > > > to cut down on noise):  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > "order": "asc", "unit": "km"} }}'  
> > > > ...  
> > > > "hits" : [ {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > } ],  
> > > > "name" : "office3"  
> > > > },  
> > > > "sort" : [0.0]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office10"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office8"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }  
> > > > ...
> > > > 
> > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > the location array.
> > 
> > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > 
> > > Geo sorting does not support multiple values per doc, so it will choose  
> > > (arbitrarily) one of the points and use them. We could potentially support  
> > > multiple points, but its not there...
> > > 
> > > Hi all
> > > 
> > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > Am I doing something silly?
> > > > 
> > > > I have the following mapping:  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_mapping?pretty=true](http://localhost:9200/work/**offices/_mapping?pretty=true)[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > '  
> > > > {  
> > > > "offices" : {  
> > > > "properties" : {  
> > > > "location" : {  
> > > > "properties" : {  
> > > > "address" : {  
> > > > "type" : "string"  
> > > > },  
> > > > "point" : {  
> > > > "type" : "geo\_point"  
> > > > }  
> > > > }  
> > > > },  
> > > > "name" : {  
> > > > "type" : "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Then I have the following query and response (I've only included hits  
> > > > to cut down on noise):  
> > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > "order": "asc", "unit": "km"} }}'  
> > > > ...  
> > > > "hits" : [ {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > } ],  
> > > > "name" : "office3"  
> > > > },  
> > > > "sort" : [0.0]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.01655, 51.5007324],  
> > > > "address" : "E14 9SH"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office10"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }, {  
> > > > "\_index" : "work",  
> > > > "\_type" : "offices",  
> > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > "\_score" : null,  
> > > > "fields" : {  
> > > > "location" : [ {  
> > > > "point" : [-0.0976398, 51.4962307],  
> > > > "address" : "SE1 6PL"  
> > > > }, {  
> > > > "point" : [-0.0684337, 51.4843866],  
> > > > "address" : "SE1 5BA"  
> > > > } ],  
> > > > "name" : "office8"  
> > > > },  
> > > > "sort" : [2.413161036894697]  
> > > > }  
> > > > ...
> > > > 
> > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > the location array.

---

<div class="post-metadata">

**Author:** ![Dominic\_Watson](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Dominic\_Watson](https://discuss.elastic.co/u/Dominic_Watson)\
**Post date:** [September 7, 2012, 10:17pm UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/8 "2012-09-07T22:17:26Z")

</div>

I've just ran into this requirement also. I managed to get it working using  
the scripting API. This probably isn't the best performance wise, but it at  
least works (for me). I've posted a comment to the GitHub issue with my  
code.

Dominic

On Wednesday, 4 April 2012 22:37:54 UTC+1, tommyvn wrote:

> Thanks, done!  
> [support geo sorting on multiple geo point values per doc · Issue #1846 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1846)
> 
> On Tuesday, April 3, 2012 3:06:07 PM UTC+1, kimchy wrote:
> 
> > File a github issue just in case so we won't loose it.
> > 
> > On Sun, Apr 1, 2012 at 11:18 PM, Maximilian Schulz \<[nam...@gmail.com](mailto:nam...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > > I just found this discussion while searching a solution for the exact  
> > > > same problem. So my question is, if that feature is on schedule, or if we  
> > > > should file a github issue?
> > > 
> > > Hi all
> > > 
> > > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > > Am I doing something silly?
> > > > > 
> > > > > I have the following mapping:  
> > > > > $ curl -XGET '[http://localhost:9200/work/](http://localhost:9200/work/)\*\*  
> > > > > offices/\_mapping?pretty=true[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > > '  
> > > > > {  
> > > > > "offices" : {  
> > > > > "properties" : {  
> > > > > "location" : {  
> > > > > "properties" : {  
> > > > > "address" : {  
> > > > > "type" : "string"  
> > > > > },  
> > > > > "point" : {  
> > > > > "type" : "geo\_point"  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "name" : {  
> > > > > "type" : "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Then I have the following query and response (I've only included hits  
> > > > > to cut down on noise):  
> > > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > > "order": "asc", "unit": "km"} }}'  
> > > > > ...  
> > > > > "hits" : [ {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > } ],  
> > > > > "name" : "office3"  
> > > > > },  
> > > > > "sort" : [0.0]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office10"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office8"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }  
> > > > > ...
> > > > > 
> > > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > > the location array.
> > > 
> > > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > > 
> > > > Geo sorting does not support multiple values per doc, so it will choose  
> > > > (arbitrarily) one of the points and use them. We could potentially support  
> > > > multiple points, but its not there...
> > > > 
> > > > Hi all
> > > > 
> > > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > > Am I doing something silly?
> > > > > 
> > > > > I have the following mapping:  
> > > > > $ curl -XGET '[http://localhost:9200/work/](http://localhost:9200/work/)\*\*  
> > > > > offices/\_mapping?pretty=true[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > > '  
> > > > > {  
> > > > > "offices" : {  
> > > > > "properties" : {  
> > > > > "location" : {  
> > > > > "properties" : {  
> > > > > "address" : {  
> > > > > "type" : "string"  
> > > > > },  
> > > > > "point" : {  
> > > > > "type" : "geo\_point"  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "name" : {  
> > > > > "type" : "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Then I have the following query and response (I've only included hits  
> > > > > to cut down on noise):  
> > > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > > "order": "asc", "unit": "km"} }}'  
> > > > > ...  
> > > > > "hits" : [ {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > } ],  
> > > > > "name" : "office3"  
> > > > > },  
> > > > > "sort" : [0.0]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office10"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office8"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }  
> > > > > ...
> > > > > 
> > > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > > the location array.
> > > 
> > > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > > 
> > > > Geo sorting does not support multiple values per doc, so it will choose  
> > > > (arbitrarily) one of the points and use them. We could potentially support  
> > > > multiple points, but its not there...
> > > > 
> > > > Hi all
> > > > 
> > > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > > Am I doing something silly?
> > > > > 
> > > > > I have the following mapping:  
> > > > > $ curl -XGET '[http://localhost:9200/work/](http://localhost:9200/work/)\*\*  
> > > > > offices/\_mapping?pretty=true[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > > '  
> > > > > {  
> > > > > "offices" : {  
> > > > > "properties" : {  
> > > > > "location" : {  
> > > > > "properties" : {  
> > > > > "address" : {  
> > > > > "type" : "string"  
> > > > > },  
> > > > > "point" : {  
> > > > > "type" : "geo\_point"  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "name" : {  
> > > > > "type" : "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Then I have the following query and response (I've only included hits  
> > > > > to cut down on noise):  
> > > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > > "order": "asc", "unit": "km"} }}'  
> > > > > ...  
> > > > > "hits" : [ {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > } ],  
> > > > > "name" : "office3"  
> > > > > },  
> > > > > "sort" : [0.0]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office10"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office8"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }  
> > > > > ...
> > > > > 
> > > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > > the location array.
> > > 
> > > On Wednesday, March 28, 2012 12:41:07 PM UTC+2, kimchy wrote:
> > > 
> > > > Geo sorting does not support multiple values per doc, so it will choose  
> > > > (arbitrarily) one of the points and use them. We could potentially support  
> > > > multiple points, but its not there...
> > > > 
> > > > Hi all
> > > > 
> > > > > My geo\_distance sort is not returning things in the order I'd expect.  
> > > > > Am I doing something silly?
> > > > > 
> > > > > I have the following mapping:  
> > > > > $ curl -XGET '[http://localhost:9200/work/](http://localhost:9200/work/)\*\*  
> > > > > offices/\_mapping?pretty=true[http://localhost:9200/work/offices/\_mapping?pretty=true](http://localhost:9200/work/offices/_mapping?pretty=true)  
> > > > > '  
> > > > > {  
> > > > > "offices" : {  
> > > > > "properties" : {  
> > > > > "location" : {  
> > > > > "properties" : {  
> > > > > "address" : {  
> > > > > "type" : "string"  
> > > > > },  
> > > > > "point" : {  
> > > > > "type" : "geo\_point"  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "name" : {  
> > > > > "type" : "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Then I have the following query and response (I've only included hits  
> > > > > to cut down on noise):  
> > > > > $ curl -XGET '[http://localhost:9200/work/\*\*offices/\_search?pretty=true](http://localhost:9200/work/**offices/_search?pretty=true)[http://localhost:9200/work/offices/\_search?pretty=true](http://localhost:9200/work/offices/_search?pretty=true)'  
> > > > > -d '{ "fields": ["name", "location"], "query": { "match\_all": {} },  
> > > > > "sort": { "\_geo\_distance": {"location.point": [-0.0976398, 51.4962307],  
> > > > > "order": "asc", "unit": "km"} }}'  
> > > > > ...  
> > > > > "hits" : [ {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "IDtt2WnSQnWEhuAxhlbPgw",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > } ],  
> > > > > "name" : "office3"  
> > > > > },  
> > > > > "sort" : [0.0]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "xzaVAHUoSGON8gY1-ggILQ",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.01655, 51.5007324],  
> > > > > "address" : "E14 9SH"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office10"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }, {  
> > > > > "\_index" : "work",  
> > > > > "\_type" : "offices",  
> > > > > "\_id" : "ZWjuiVkWSD6H99ooKcKNuA",  
> > > > > "\_score" : null,  
> > > > > "fields" : {  
> > > > > "location" : [ {  
> > > > > "point" : [-0.0976398, 51.4962307],  
> > > > > "address" : "SE1 6PL"  
> > > > > }, {  
> > > > > "point" : [-0.0684337, 51.4843866],  
> > > > > "address" : "SE1 5BA"  
> > > > > } ],  
> > > > > "name" : "office8"  
> > > > > },  
> > > > > "sort" : [2.413161036894697]  
> > > > > }  
> > > > > ...
> > > > > 
> > > > > Specifically both office8 and office3 have locations 0km away from my  
> > > > > search point, yet office10 is sneaking in between the two at 2.4km away and  
> > > > > office8 is also placing itself 2.4km away (which it is, but but only on the  
> > > > > further location point). It's as if it only looks at the last geo\_point in  
> > > > > the location array.

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:13am UTC](https://discuss.elastic.co/t/multiple-geo-points-per-document/7154/9 "2017-07-06T03:13:37Z")

</div>


