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

[ES 1.3.2] NullPointerException while parsing hasParent query/filter #7349

Closed
scoro opened this Issue Aug 20, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@scoro

scoro commented Aug 20, 2014

Hi,
I met a strange problem with the latest version of Elasticsearch (1.3.2) - strage as always when NPE occurs :-)
Noticed that Elasticsearch 0.90 did not have such an issue.

Having single incorrect type which references to inexisting parent results in NPE while executing hasParent query/filter on another - correct - type.

To reproduce the issue please refer to description below.

Create index:

POST /test

Correct mapping:

PUT /test/children/_mapping
{
    "children": {
        "_parent": {
            "type": "parents"
        }
    }
}

Mapping for type with missing parent type:

PUT /test/children2/_mapping
{
    "children2": {
        "_parent": {
            "type": "parents2"
        }
    }
}

Add something to parents (corrent one) to create mapping:

POST /test/parents
{
    "someField" : "someValue"
}
POST /test/children/_search
{
    "filter": {
            "has_parent": {
               "type": "parents",
               "query": {
                "query_string": {
                   "query": "*"
                }   
               }
            }
    }
}

Above query is gonna fail with NullPointerException without possiblity to catch a real problem (debug helps here :)),

org.elasticsearch.search.SearchParseException: [test][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "filter": {
                "has_parent": {
                           "type": "parents",
                           "query": {
                    "query_string": {
                       "query": "*"
                    }
                           }
                        }
        }
}
]]
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:664)
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:515)
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:487)
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:256)
        at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)
        at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)
        at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)
        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.NullPointerException
        at org.elasticsearch.index.query.HasParentFilterParser.parse(HasParentFilterParser.java:158)
        at org.elasticsearch.index.query.QueryParseContext.executeFilterParser(QueryParseContext.java:290)
        at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:271)
        at org.elasticsearch.index.query.IndexQueryParserService.parseInnerFilter(IndexQueryParserService.java:282)
        at org.elasticsearch.search.query.PostFilterParseElement.parse(PostFilterParseElement.java:33)
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:648)
        ... 9 more

Btw. Query on incorrect type (children2) fails fine since it throws:

[test] [has_parent] filter configured 'parent_type' [parents2] is not a valid type];
@martijnvg

This comment has been minimized.

Member

martijnvg commented Aug 21, 2014

@scoro Thanks for reporting this! I opened #7362 for this bug.

@martijnvg martijnvg closed this in d414d89 Aug 27, 2014

martijnvg added a commit that referenced this issue Aug 27, 2014

Parent/child: If _parent field points to a non existing parent type, …
…then skip the has_parent query/filter

Closes #7362
Closes #7349

martijnvg added a commit that referenced this issue Aug 27, 2014

Parent/child: If _parent field points to a non existing parent type, …
…then skip the has_parent query/filter

Closes #7362
Closes #7349

martijnvg added a commit that referenced this issue Sep 8, 2014

Parent/child: If _parent field points to a non existing parent type, …
…then skip the has_parent query/filter

Closes #7362
Closes #7349

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