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

date_histogram against empty index results in ArrayIndexOutOfBoundsException #5179

Closed
bsmid opened this issue Feb 19, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@bsmid
Copy link

commented Feb 19, 2014

Hi,

I am using 1.0.0. and see:

{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[kwtJyjumSJ-DRx68nXaVhw][data][1]: ArrayIndexOutOfBoundsException[0]}{[kwtJyjumSJ-DRx68nXaVhw][data][0]: ArrayIndexOutOfBoundsException[0]}{[kwtJyjumSJ-DRx68nXaVhw][data][4]: ArrayIndexOutOfBoundsException[0]}{[kwtJyjumSJ-DRx68nXaVhw][data][3]: ArrayIndexOutOfBoundsException[0]}{[kwtJyjumSJ-DRx68nXaVhw][data][2]: ArrayIndexOutOfBoundsException[0]}]",
"status" : 500
}

when running date_histogram query. It happens when I run the query on the whole index while index is empty, or when I run the query on some type which has no documents (while other types in the index have docs).

Steps to reproduce:


curl -XDELETE 'http://localhost:9200/_all/'


curl -XPUT 'http://localhost:9200/data/' -d '{    "mappings" : {
      "_default_" : {
        "_source" : { "enabled" : false },
        "_timestamp" : { "enabled" : true, "store" : true },
        "_all" : {"enabled" : false},
        "properties" : {
          "timestamp" : { "type" : "date", "index" : "not_analyzed", "store": "true" },
          "message" : { "type" : "string", "index" : "analyzed", "analyzer" : "standard", "store": "true" },
          "type" : { "type" : "string", "index" : "not_analyzed", "store": "true" }
        }
      }
    }    
}'


curl "http://localhost:9200/data/_search?fields=*&pretty" -d '{"query":{"filtered":{"filter":{"range":{"timestamp":{"gte":1392026400000,"lte":1392631200000}}},"query":{"query_string":{"query":"mesage:*"}}}},"aggs":{"data":{"date_histogram":{"field":"timestamp","interval":"60m"},"aggs":{"data_type":{"terms":{"field":"_type"}}}}}}'

@uboness

This comment has been minimized.

Copy link
Contributor

commented Feb 21, 2014

Hi @bsmid,
This is indeed a bug, but the cause is different than what you describe (also based on your recreation above). It's caused when running a histogram or date_histogram on unmapped fields and then adding a sub-aggregation to them.

In the example above, even though you created a default mapping, you didn't actually index anything and no concrete mappings were created on the index.

In any case... I'll fix it soon...

Thx for reporting!

ps, you can remove the "index" : "not_analyzed" from the timestamp field... this setting only applies to string types

@uboness uboness closed this in 164f7b9 Feb 21, 2014

uboness added a commit that referenced this issue Feb 21, 2014

Fixed an issue where and IndexOutOfBoundsException was thrown when a …
…date_/histogram aggregation was defined on unmapped field and also had a sub aggregation. The root cause there was that in such case, the estimated bucket count was 0, and the code was not designed to handle that well.

Closes #5179

uboness added a commit that referenced this issue Feb 21, 2014

Fixed an issue where and IndexOutOfBoundsException was thrown when a …
…date_/histogram aggregation was defined on unmapped field and also had a sub aggregation. The root cause there was that in such case, the estimated bucket count was 0, and the code was not designed to handle that well.

Closes #5179

@uboness uboness added bug labels Feb 21, 2014

@uboness uboness self-assigned this Feb 21, 2014

@bsmid

This comment has been minimized.

Copy link
Author

commented Feb 21, 2014

Thx for fixing @uboness !

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Fixed an issue where and IndexOutOfBoundsException was thrown when a …
…date_/histogram aggregation was defined on unmapped field and also had a sub aggregation. The root cause there was that in such case, the estimated bucket count was 0, and the code was not designed to handle that well.

Closes elastic#5179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.