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

Exception from geohash_grid aggregation with array of points (ES 1.4.0) #8507

Closed
mvdz opened this issue Nov 17, 2014 · 1 comment
Closed
Assignees
Labels

Comments

@mvdz
Copy link

mvdz commented Nov 17, 2014

Using a geohash_grid aggregation used to work on arrays of points, but with ES 1.4.0 an exception occurs instead. The following curl commands reproduce the issue on a clean installation of ES:

# create index with geo_point mapping
curl -XPUT localhost:9200/test -d '{
  "mappings": {
    "test": {
      "properties": {
        "points": {
          "type": "geo_point",
          "geohash_prefix": true
        }
      }
    }
  }
}'

# insert documents
curl -XPUT localhost:9200/test/test/1?refresh=true -d '{ "points": [[1,2], [2,3]] }'
curl -XPUT localhost:9200/test/test/2?refresh=true -d '{ "points": [[2,3], [3,4]] }'

# perform aggregation
curl -XGET localhost:9200/test/test/_search?pretty -d '{
  "size": 0,
  "aggs": {
    "a1": {
      "geohash_grid": {
        "field": "points",
        "precision": 3
      }
    }
  }
}'

On Elasticsearch 1.3.5 this produces the expected result:

...
  "aggregations" : {
    "a1" : {
      "buckets" : [ {
        "key" : "s09",
        "doc_count" : 2
      }, {
        "key" : "s0d",
        "doc_count" : 1
      }, {
        "key" : "s02",
        "doc_count" : 1
      } ]
    }
  }
...

However on Elasticsearch 1.4.0 this triggers a failure:

{
  "took" : 76,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 3,
    "failed" : 2,
    "failures" : [ {
      "index" : "test",
      "shard" : 2,
      "status" : 500,
      "reason" : "QueryPhaseExecutionException[[test][2]: query[ConstantScore(cache(_type:test))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: ArrayIndexOutOfBoundsException[1]; "
    }, {
      "index" : "test",
      "shard" : 3,
      "status" : 500,
      "reason" : "QueryPhaseExecutionException[[test][3]: query[ConstantScore(cache(_type:test))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: ArrayIndexOutOfBoundsException[1]; "
    } ]
  },
  "hits" : {
    "total" : 0,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "aggregations" : {
    "a1" : {
      "buckets" : [ ]
    }
  }
}

The log contains this exception:

[2014-11-17 17:28:25,121][DEBUG][action.search.type       ] [Franklin Storm] [test][3], node[-S9ijRKKQH-IEAr3sUW14Q], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@1fa40d49]
org.elasticsearch.search.query.QueryPhaseExecutionException: [test][3]: query[ConstantScore(cache(_type:test))],from[0],size[0]: Query Failed [Failed to execute main query]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:163)
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:275)
    at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:231)
    at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:228)
    at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridParser$GeoGridFactory$CellValues.setDocument(GeoHashGridParser.java:154)
    at org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridAggregator.collect(GeoHashGridAggregator.java:73)
    at org.elasticsearch.search.aggregations.AggregationPhase$AggregationsCollector.collect(AggregationPhase.java:161)
    at org.elasticsearch.common.lucene.MultiCollector.collect(MultiCollector.java:60)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:193)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:163)
    at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:35)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:621)
    at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:309)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:117)
    ... 7 more
@jpountz
Copy link
Contributor

jpountz commented Nov 17, 2014

We did quite a significant refactoring of fielddata in 1.4 in order to better integrate with Lucene, I'm wondering that this could be related. I'm looking into it...

@jpountz jpountz assigned jpountz and unassigned markharwood Nov 17, 2014
jpountz added a commit to jpountz/elasticsearch that referenced this issue Nov 17, 2014
This aggregation creates an anonymous fielddata instance that takes geo points
and turns them into a geo hash encoded as a long. A bug was introduced in 1.4
because of a fielddata refactoring: the fielddata instance tries to populate
an array with values without first making sure that it is large enough.

Close elastic#8507
jpountz added a commit that referenced this issue Nov 20, 2014
This aggregation creates an anonymous fielddata instance that takes geo points
and turns them into a geo hash encoded as a long. A bug was introduced in 1.4
because of a fielddata refactoring: the fielddata instance tries to populate
an array with values without first making sure that it is large enough.

Close #8507
jpountz added a commit that referenced this issue Nov 20, 2014
This aggregation creates an anonymous fielddata instance that takes geo points
and turns them into a geo hash encoded as a long. A bug was introduced in 1.4
because of a fielddata refactoring: the fielddata instance tries to populate
an array with values without first making sure that it is large enough.

Close #8507
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This aggregation creates an anonymous fielddata instance that takes geo points
and turns them into a geo hash encoded as a long. A bug was introduced in 1.4
because of a fielddata refactoring: the fielddata instance tries to populate
an array with values without first making sure that it is large enough.

Close elastic#8507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants