Geo_distance Filter with Multiple Locations


(Mike S Craig) #1

So I'd like to be able to index this document:

{"name":"Starbucks",
"locations":["40.741047,-74.001439", "40.6774,-75.146613"]}

And query it like this:

{"filter":{"geo_distance":
{"locations":"40.7405,-74.0068","distance":"1km"}}}

But I get QueryParsingExceptions that say "locations" is not a
geo_point field. Generically speaking, I want to index a document with
an arbitrary number of locations and then do a geo_distance filter
over those locations. Can it be done?

Cheers,
Mike


(Mike S Craig) #2

Answered my own question: I'd forgotten to set the field type as geo_point.

Cheers,
Mike

On Tue, Dec 20, 2011 at 3:43 PM, Mike S Craig mkscrg@gmail.com wrote:

So I'd like to be able to index this document:

{"name":"Starbucks",
"locations":["40.741047,-74.001439", "40.6774,-75.146613"]}

And query it like this:

{"filter":{"geo_distance":
{"locations":"40.7405,-74.0068","distance":"1km"}}}

But I get QueryParsingExceptions that say "locations" is not a
geo_point field. Generically speaking, I want to index a document with
an arbitrary number of locations and then do a geo_distance filter
over those locations. Can it be done?

Cheers,
Mike


(system) #3