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 during parent/child query (ES 0.20.2) #2536

Closed
mashudong opened this issue Jan 11, 2013 · 1 comment
Closed

NullPointerException during parent/child query (ES 0.20.2) #2536

mashudong opened this issue Jan 11, 2013 · 1 comment

Comments

@mashudong
Copy link
Contributor

  1. create mapping
    curl -XPUT localhost:9200/index1/
    curl localhost:9200/index1/Parent/_mapping?pretty -d '
    {
    "Parent" : {
    "_all" : {
    "enabled" : false
    },
    "_source" : {
    "compress" : true
    },
    "properties" : {
    "_tenantid" : {
    "type" : "long",
    "store" : "yes"
    },
    "age" : {
    "type" : "long"
    },
    "name" : {
    "type" : "string"
    },
    "sex" : {
    "type" : "string"
    }
    }
    }
    }
    '
    curl localhost:9200/index1/Child/_mapping?pretty -d '
    {
    "Child" : {
    "_all" : {
    "enabled" : false
    },
    "_parent" : {
    "type" : "Parent"
    },
    "_routing" : {
    "required" : true
    },
    "_source" : {
    "compress" : true
    },
    "properties" : {
    "_tenantid" : {
    "type" : "long",
    "store" : "yes"
    },
    "age" : {
    "type" : "long"
    },
    "name" : {
    "type" : "string"
    },
    "shangshi" : {
    "type" : "boolean"
    }
    }
    }
    }
    '
  2. Query

curl localhost:9200/index1/Parent/_search?pretty -d '
{ "sort" : [{ "age" : {"order" : "desc"} }],"query": { "filtered": { "query": { "has_child": { "type": "Child", "query": { "query_string": { "query": "+_tenantid:100002 +(-age:20)"} } } },
"filter": { "fquery": { "query": { "query_string": { "query": "+_tenantid:100002 +(name:dog OR age:[10 TO 2147483647])" } }, "_cache": true } } } } }
'

OK, no result found, of course

  1. Index one doc in an irrelevant type

curl localhost:9200/index1/Type1/key0 -d '
{"_tenantid": 100002, "name": "lilei", "age": -2, "sex": "f", "marry": false, "weight": 2.3, "height": 2.7E+23, "grade": 123, "bill": -120, "fee": 245, "money": 3453, "number": 65333,
"phone": 4200000000, "small": 123.123456789123456789, "birthday": 20120306000000}
'

  1. Exactly the same query again

curl localhost:9200/index1/Parent/_search?pretty -d '
{ "sort" : [{ "age" : {"order" : "desc"} }],"query": { "filtered": { "query": { "has_child": { "type": "Child", "query": { "query_string": { "query": "+_tenantid:100002 +(-age:20)"} } } },
"filter": { "fquery": { "query": { "query_string": { "query": "+_tenantid:100002 +(name:dog OR age:[10 TO 2147483647])" } }, "_cache": true } } } } }
'

Now, NullPointerException!

"reason" : "QueryPhaseExecutionException[[index1][2]: query[filtered(filtered(ConstantScore(child_filter[Child/Parent](+_tenantid:[100002 TO 100002] +%28-age:[20 TO 20] +ConstantScore%28NotDeleted%28*:*%29%29%29)))->cache(QueryWrapperFilter(+_tenantid:[100002 TO 100002] +(name:dog age:[10 TO 2147483647]))))->cache(type:Parent)],from[0],size[10],sort[<custom:"age": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@1663108>!]: Query Failed [Failed to execute child query [+tenantid:[100002 TO 100002] +(-age:[20 TO 20] +ConstantScore(NotDeleted(:)))]]]; nested: NullPointerException; "

@martijnvg
Copy link
Member

Thanks for reporting this issue! I've been able to reproduce this issue on both 0.20.x and master. This issue also occurs with the has_child filter and has_parent query and filter.

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

2 participants