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

common terms query containing only stopwords with a _name causes a null pointer exception #12683

Closed
brettrp opened this issue Aug 6, 2015 · 1 comment
Assignees
Labels
>bug good first issue low hanging fruit :Search/Search Search-related issues that do not fall into other categories

Comments

@brettrp
Copy link

brettrp commented Aug 6, 2015

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"
            }
        }
    }
}'
@jasontedor
Copy link
Member

@brettrp Thank you for reporting this issue! The underlying issue is that because of the analyzer you have configured (the stop analyzer), the query is parsed to the null query. This issue helped us uncover a deeper bug in our handling of named queries that are null. We will have a fix in place soon.

jasontedor added a commit that referenced this issue Aug 6, 2015
This commit backports the fix #12691 for #12683 from master to 1.7.
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug good first issue low hanging fruit :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants