Closed
Description
A common query containing only stopwords causes a NullPointerException if the query has a _name property. This doesn't happen without the _name property, and doesn't happen with other types of queries.
# create index
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"name" : { "type" : "string", "analyzer" : "stop" }
}
}
}
}'
# common query with a stop word correctly returns no results
curl -XGET localhost:9200/test/type1/_search -d '{
"query": {
"common": {
"name": {
"query": "the"
}
}
}
}'
{"took":35,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},
"hits":{"total":0,"max_score":null,"hits":[]}}
# common query with a _name causes a null pointer exception
curl -XGET localhost:9200/test/type1/_search -d '{
"query": {
"common": {
"name": {
"query": "the",
"_name": "queryname"
}
}
}
}'
{"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[vFIFOFczQTSxJJO-kobPBQ][test][0]: SearchParseException[[test][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
\"query\": {
\"common\": {
\"name\": {
\"query\": \"the\",
\"_name\": \"queryname\"
}
}
}
}]]]; nested: NullPointerException[Query may not be null]; }]","status":400}muzio:~ brett$
# a regular match query doesn't have this problem
curl -XGET 10.4.4.118:9200/test/type1/_search -d '{
"query": {
"match": {
"name": {
"query": "the",
"_name": "queryname"
}
}
}
}'