# Case insensitive nested query string

**URL:** <https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045>\
**Category:** Elasticsearch\
**Created:** [August 5, 2018, 6:19am UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045 "2018-08-05T06:19:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nipun\_edara](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nipun\_edara](https://discuss.elastic.co/u/nipun_edara)\
**Post date:** [August 5, 2018, 6:19am UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045/1 "2018-08-05T06:19:50Z")

</div>

Hi,

I haven't defined any analyzers and assume it's using the standard analyzer

ES version : 5.6 Lucene\_version : 6.6.1

Normal query string results in case-insensitive search but if the query string is put inside nested query it results in case sensitive search

**Steps to Reproduce**

**Create new index test3**

```
PUT test3
{
  "mappings": {
    "articles_batch":{
      "dynamic": "strict",
      "properties": {
        "articleName":{
          "type": "keyword"
        },
        "comments":{
          "type": "nested",
          "properties": {
            "commentName":{
              "type": "keyword"
            }
          }
        }
      }
    }
  },
  "settings": {
    "index":{
      "mapping":{
        "ignore_malformed": "true"
      },
      "number_of_shards":"5",
      "number_of_replicas":"1"
    }
  }
}

```

**Create a document**

```
POST test3/articles_batch
{
  "articleName": "Name1",
  "comments" : [ {
    "commentName":"Hello1"
    },{
    "commentName":"hello2"
    }]
}

```

Searching for **hello1** results in hits

```
GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "*hello1*",
            "default_operator": "AND",
            "lenient": true
          }
        }
      ]
    }
  }
}

```

**However, nested search for hello1 doesn't provide any hits**

```
GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "comments",
            "inner_hits": {
            },
            "query": {
              "query_string": {
                "query": "*hello1*",
                "default_operator": "AND",
                "lenient": true,
                "fields": ["comments.*"]
              }
            }
          }
        }
      ]
    }
  }
}

```

Any help is greatly appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 5, 2018, 6:32am UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045/2 "2018-08-05T06:32:34Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![nipun\_edara](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nipun\_edara](https://discuss.elastic.co/u/nipun_edara)\
**Post date:** [August 5, 2018, 8:10am UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045/3 "2018-08-05T08:10:53Z")

</div>

Modified the above to include steps to reproduce. Please help.  
Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 6, 2018, 12:23pm UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045/4 "2018-08-06T12:23:08Z")

</div>

This query:

```auto
GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "*hello1*",
            "default_operator": "AND",
            "lenient": true
          }
        }
      ]
    }
  }
}

```

Does not return any hit.

But this one (I modified the text you are searching) does:

```auto
GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "comments",
            "inner_hits": {
            },
            "query": {
              "query_string": {
                "query": "*hello*",
                "default_operator": "AND",
                "lenient": true,
                "fields": ["comments.*"]
              }
            }
          }
        }
      ]
    }
  }
}

```

One of the problem is that wildcards are not analyzed. And that `Hello1` has been indexed as [`hello`, `1`]. So `hello1` does not match.

---

<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:** [September 3, 2018, 12:23pm UTC](https://discuss.elastic.co/t/case-insensitive-nested-query-string/143045/5 "2018-09-03T12:23:15Z")

</div>

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