From a45e1cc75026500705de0e51f660fd2857beca40 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 10 May 2016 08:00:36 -0600 Subject: [PATCH] Add test for NullPointerException in SQS when analyzing text produces null query --- .../search/query/SimpleQueryStringIT.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java index ffaebecf89a..687e8e52186 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java @@ -370,4 +370,31 @@ public class SimpleQueryStringIT extends ESIntegTestCase { assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); } + + public void testEmptySimpleQueryStringWithAnalysis() throws Exception { + // https://github.com/elastic/elasticsearch/issues/18202 + String mapping = XContentFactory.jsonBuilder() + .startObject() + .startObject("type1") + .startObject("properties") + .startObject("body") + .field("type", "string") + .field("analyzer", "stop") + .endObject() + .endObject() + .endObject() + .endObject().string(); + + CreateIndexRequestBuilder mappingRequest = client().admin().indices() + .prepareCreate("test1") + .addMapping("type1", mapping); + mappingRequest.execute().actionGet(); + indexRandom(true, client().prepareIndex("test1", "type1", "1").setSource("body", "Some Text")); + refresh(); + + SearchResponse searchResponse = client().prepareSearch() + .setQuery(simpleQueryStringQuery("the*").analyzeWildcard(true).field("body")).get(); + assertNoFailures(searchResponse); + assertHitCount(searchResponse, 0l); + } }