Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in geo_distance_range without to #1865

Closed
phoet opened this issue Apr 17, 2012 · 3 comments
Closed

NullPointerException in geo_distance_range without to #1865

phoet opened this issue Apr 17, 2012 · 3 comments

Comments

@phoet
Copy link

phoet commented Apr 17, 2012

i was trying to use the gt options for the geo_distance_range filter like:

{
  "geo_distance_range": {
    "gt": "50km",
    "location": {
      "lat": "51.16104233",
      "lon": "7.42149815"
    }
}

but it seems that the GeoDistanceRangeFilterParser depends on a to being available:

Caused by: java.lang.NullPointerException
  at org.elasticsearch.common.unit.DistanceUnit.parse(DistanceUnit.java:93)
  at org.elasticsearch.index.query.GeoDistanceRangeFilterParser.parse(GeoDistanceRangeFilterParser.java:224)
  at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
  at org.elasticsearch.index.query.AndFilterParser.parse(AndFilterParser.java:63)
  at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
  at org.elasticsearch.index.query.ConstantScoreQueryParser.parse(ConstantScoreQueryParser.java:66)
  at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)
  at org.elasticsearch.index.query.BoolQueryParser.parse(BoolQueryParser.java:89)
  at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)
  at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)
  at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)
  at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
  at org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)
@clintongormley
Copy link

In 0.19.2, gt works fine, but it appears the the geo_distance_range requires an upper and lower limit. You can't specify just an upper or lower limit, eg: gt: '5km' or ''from: '5km'`

This works:

curl -XGET 'http://127.0.0.1:9200/geonames/_search?pretty=1'  -d '
{
   "filter" : {
      "geo_distance_range" : {
         "from" : "1km",
         "to" : "500km",
         "location" : {
            "lat" : "-6.6",
            "lon" : 54
         }
      }
   }
}
'

This doesn't:

curl -XGET 'http://127.0.0.1:9200/geonames/_search?pretty=1'  -d '
{
   "filter" : {
      "geo_distance_range" : {
         "to" : "500km",
         "location" : {
            "lat" : "-6.6",
            "lon" : 54
         }
      }
   }
}
'

@phoet
Copy link
Author

phoet commented Apr 17, 2012

could you then give a short overview of how to use the lt, gt etc parameters? there is no documentation or example queries in the docs :(

i would like to query all documents that are not within a a certain distance.

@clintongormley
Copy link

Just to note: I still think this is a bug, just a different bug from the one that you described :)

from is equivalent to gte (greater than or equal). to is equivalent lt (less than). You specify 'not within a range' which means that you should wrap your geo distance filter in a not filter

@kimchy kimchy closed this as completed in 03c9eaf Apr 17, 2012
Kami pushed a commit to racker/elasticsearch that referenced this issue May 7, 2012
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants