Using geodistancefilter


(Warner Onstine) #1

Ok, been trying to get the geo distance filter working properly, after
dealing with several mapping issues I finally got a manual query
working:

     {
      "geo_distance" : {
        "location" : { "lat":32.2217429, "lon":-110.926479},
        "distance" : "25.0mi"
      }

But, when I use the java api:
geoDistanceFilter("location").lat(coordinates[0]).lon(coordinates[1])
.distance(25, org.elasticsearch.common.unit.DistanceUnit.MILES)

This generates json code that won't work:
{
"geo_distance" : {
"location" : [ 32.2217429,-110.926479 ],
"distance" : "25.0mi"
}

How do I tell ES to generate the first type (where lat and lon are
spelled out as fields) and not the second type?

Thanks!

-warner

--


(Warner Onstine) #2

Ok, I found this in the javadocs:
GeoPointFieldMapper

but I'm not sure exactly how to configure this and inject it into the
GeoDistanceFilter, any pointers?

-warner

On Wed, Aug 15, 2012 at 8:46 PM, Warner Onstine warnero@gmail.com wrote:

Ok, been trying to get the geo distance filter working properly, after
dealing with several mapping issues I finally got a manual query
working:

     {
      "geo_distance" : {
        "location" : { "lat":32.2217429, "lon":-110.926479},
        "distance" : "25.0mi"
      }

But, when I use the java api:
geoDistanceFilter("location").lat(coordinates[0]).lon(coordinates[1])
.distance(25, org.elasticsearch.common.unit.DistanceUnit.MILES)

This generates json code that won't work:
{
"geo_distance" : {
"location" : [ 32.2217429,-110.926479 ],
"distance" : "25.0mi"
}

How do I tell ES to generate the first type (where lat and lon are
spelled out as fields) and not the second type?

Thanks!

-warner

--


(Warner Onstine) #3

Ahh, looks like I was bitten by the reverse lat/lon stuff in my
hand-written query. I reversed the order and my manual query works now
(and the generated query code should also work as well).

Never mind!

-warner

On Wed, Aug 15, 2012 at 8:59 PM, Warner Onstine warnero@gmail.com wrote:

Ok, I found this in the javadocs:
GeoPointFieldMapper

but I'm not sure exactly how to configure this and inject it into the
GeoDistanceFilter, any pointers?

-warner

On Wed, Aug 15, 2012 at 8:46 PM, Warner Onstine warnero@gmail.com wrote:

Ok, been trying to get the geo distance filter working properly, after
dealing with several mapping issues I finally got a manual query
working:

     {
      "geo_distance" : {
        "location" : { "lat":32.2217429, "lon":-110.926479},
        "distance" : "25.0mi"
      }

But, when I use the java api:
geoDistanceFilter("location").lat(coordinates[0]).lon(coordinates[1])
.distance(25, org.elasticsearch.common.unit.DistanceUnit.MILES)

This generates json code that won't work:
{
"geo_distance" : {
"location" : [ 32.2217429,-110.926479 ],
"distance" : "25.0mi"
}

How do I tell ES to generate the first type (where lat and lon are
spelled out as fields) and not the second type?

Thanks!

-warner

--


(system) #4