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); + } }