# Query\_string in 5.1 is case sensitive

**URL:** <https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886>\
**Category:** Elasticsearch\
**Created:** [March 16, 2017, 3:07pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886 "2017-03-16T15:07:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)\
**Post date:** [March 16, 2017, 3:07pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/1 "2017-03-16T15:07:50Z")

</div>

Hi There,

I am using AWS ElasticSearch Service. at first i had version "2.3". when using "query\_string to search for a field as follows. even authorlast name starts with uppercase "S" , but it is mapped to lowercase as per explanation result below, so i got the result. but after switch to ES "5.1" this no longer work. it does not map "S" to lowercase "s" so i did not get result. is any change in query\_string parsing in 2.3 than 5.1?

```auto
{
    "query": {
        "bool": {
            "must": [{
                "query_string": {
                    "query": "S?ith",
                    "fields": ["authlast"]
                }
            }]
        }
    }
}

```

```auto
"explanations": [
    {
      "index": "myindex",
      "valid": true,
      "explanation": "+authlast:S?ith"
    }
  ]

```

Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 16, 2017, 7:25pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/2 "2017-03-16T19:25:20Z")

</div>

Have a look at [this](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_wildcards). It looks like it should work if the `analyzer` for the field lowercases it.

---

<div class="post-metadata">

**Author:** ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)\
**Post date:** [March 16, 2017, 7:30pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/3 "2017-03-16T19:30:39Z")

</div>

Yes, i have a custom analyzer that looks as follows

"field\_analyzer":  
{  
"type": "custom",  
"char\_filter": "html\_strip",  
"tokenizer": "whitespace",  
"filter": ["lowercase", "asciifolding", "trim"]  
}

field:

"authfirst":  
{  
"type": "string",  
"analyzer": "field\_analyzer",  
"search\_analyzer": "field\_analyzer"  
}

still does not work!!!?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 16, 2017, 8:08pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/4 "2017-03-16T20:08:39Z")

</div>

You should really wrap code in ``` so it is more readable.

Could you try setting `analyze_wildcard` to `true` in the `query_string`?

---

<div class="post-metadata">

**Author:** ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)\
**Post date:** [March 16, 2017, 8:13pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/5 "2017-03-16T20:13:43Z")

</div>

added as follows, still no difference

```auto
{
    "query": {
        "bool": {
            "must": [{
                "query_string": {
                    "query": "S?ith",
                    "fields": ["authfirst"],
                    "analyzer": "field_analyzer",
                    "analyze_wildcard": true,
                    "lowercase_expanded_terms": "true"
                   
                }
            }]
        }
    }

}

```

examination Output:

```auto
"explanations": [
    {
      "index": "myindex",
      "valid": true,
      "explanation": "+authfirst:S?ith"
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 16, 2017, 8:29pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/6 "2017-03-16T20:29:50Z")

</div>

Weird. Can you file an issue? I'm fairly sure `analyze_wildcard` should make that work. At least it looks like it should from the docs.

---

<div class="post-metadata">

**Author:** ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)\
**Post date:** [March 16, 2017, 8:31pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/7 "2017-03-16T20:31:59Z")

</div>

Thanks Nik for your quick response. am still newbie to ES forum, please could you provide me details how to file an issue? the interesting thing i have same mapping file that used for ES "2.3" and that worked fine, but in ES "5.1" does not work!!!!

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 16, 2017, 8:48pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/8 "2017-03-16T20:48:21Z")

</div>

The text in the issue box on [https://github.com/elastic/elasticsearch/issues/new](https://github.com/elastic/elasticsearch/issues/new) should guide you through it pretty well. It is super important to have steps to reproduce the issue - either in the form of CONSOLE syntax or `curl` commands that you could paste into bash.

---

<div class="post-metadata">

**Author:** ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)\
**Post date:** [March 17, 2017, 1:24pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/9 "2017-03-17T13:24:17Z")

</div>

Thanks Nik. i have opened an issue @ [https://github.com/elastic/elasticsearch/issues/23620](https://github.com/elastic/elasticsearch/issues/23620)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 14, 2017, 1:24pm UTC](https://discuss.elastic.co/t/query-string-in-5-1-is-case-sensitive/78886/10 "2017-04-14T13:24:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
