Multiple geo_points per document

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'
{
"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 ]
}
...

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.

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 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'
{
"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 ]
}
...

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.

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 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'
{
"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 ]
}
...

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.

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 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 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=truehttp://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=truehttp://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.

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'
{
"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 ]
}
...

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'
{
"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 ]
}
...

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'
{
"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 ]
}
...

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'
{
"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 ]
}
...

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.

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 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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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.

Thanks, done!

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.comwrote:

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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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.

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

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<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/**
offices/_mapping?pretty=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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=truehttp://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.

--