Skip to content

Instantly share code, notes, and snippets.

@Alex-Ikanow
Created December 9, 2011 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alex-Ikanow/1453137 to your computer and use it in GitHub Desktop.
Save Alex-Ikanow/1453137 to your computer and use it in GitHub Desktop.
Various "nested" problems with elasticsearch 0.17.9 and 0.18.5 part 1
I managed to get the query to fail a few different ways, one of them appears to be linked to my "random" use of "nested" as the index type while trying to reproduce the "operational" error I occurred.
1] Create an index called "nested_test" (eg I did this from elasticsearch-head) with 5 shards and 0 replicas
(or presumably something like
curl -XPUT 'http://localhost:9200/nested_test/' -d '
index :
number_of_shards : 5
number_of_replicas : 0
'
would be equivalent)
2] Create a type mapping called "nested"
curl -XPUT 'http://localhost:9200/nested_test/nested/_mapping' -d '{"type1":{"properties":{"obj1":{"type":"nested"}}}}'
3] Add a test object
curl -XPOST 'http://localhost:9200/nested_test/nested/' -d '{"obj1":[{"name":"blue",count:4},{"name":"green",count:6}]}'
4] Query for the object without the type specified:
curl -XGET 'http://localhost:9200/nested_test/_search?pretty=true' -d'{"query":{"nested": { "path":"obj1", "query": { "match_all":{}}}}}'
This works fine, eg:
<snip>
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
</snip>
5] Query for the object with the type specified:
curl -XGET 'http://localhost:9200/nested_test/nested/_search?pretty=true' -d'{"query":{"nested": { "path":"obj1", "query": { "match_all":{}}}}}'
This fails every time, eg
<snip>
{
"took" : 14,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "nested_test",
"shard" : 2,
"status" : 500,
"reason" : "QueryPhaseExecutionException[[nested_test][2]: query[BlockJoinQuery (filtered(ConstantScore(*:*))->FilterCacheFilterWrapper(_type:__obj1))],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: "
} ]
</snip>
The elasticsearch.log has a little bit more detail:
<snip>
Caused by: java.lang.NullPointerException
at org.elasticsearch.index.query.NestedQueryParser$LateBindingParentFilter.getDocIdSet(NestedQueryParser.java:170)
at org.elasticsearch.index.search.nested.BlockJoinQuery$BlockJoinWeight.scorer(BlockJoinQuery.java:171)
at org.apache.lucene.search.FilteredQuery.getFilteredScorer(FilteredQuery.java:149)
</snip>
6] Repeat steps [2]-[5] except with the index type "test_type" instead of "nested"
This time it seems to work every time, eg:
curl -XGET 'http://localhost:9200/nested_test/test_type/_search?pretty=true' -d'{"query":{"nested": { "path":"obj1", "query": { "match_all":{}}}}}'
<snip>
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
</snip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment