# Lowercase analyzer filter with nested field and queries

**URL:** <https://discuss.elastic.co/t/lowercase-analyzer-filter-with-nested-field-and-queries/264043>\
**Category:** Elasticsearch\
**Created:** [February 11, 2021, 6:31pm UTC](https://discuss.elastic.co/t/lowercase-analyzer-filter-with-nested-field-and-queries/264043 "2021-02-11T18:31:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgeographer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kgeographer/32/26217_2.png) [@kgeographer](https://discuss.elastic.co/u/kgeographer)\
**Post date:** [February 11, 2021, 6:31pm UTC](https://discuss.elastic.co/t/lowercase-analyzer-filter-with-nested-field-and-queries/264043/1 "2021-02-11T18:31:55Z")

</div>

In v6.6 I can't get a nested query to ignore case on a search of a property in the nested object, whether I specify a custom analyzer or not. Case is ignored on non-nested fields as expected.

Is this expected? Do I have to cast all query terms to lower() prior?

```auto
PUT testy
{ "settings": {
    "analysis": {
       "analyzer": {
          "variants_nocase": {
             "type": "custom",
             "tokenizer": "standard",
             "filter": ["lowercase"]
          }
       }
  }},
  "mappings": {
    "place": {
      "properties": {
        "name": {"type": "text"},
        "variants": {
          "type": "nested",
          "properties": {
            "lang": {"type": "keyword"},
            "names": {
              "analyzer": "variants_nocase",
              "type": "text"
            }
          }
        }
      }
    }
  }
}

```

PUT a single record with values for both fields:

```auto
PUT /testy/place/1
{ 
  "name": "San Marino",
  "variants": [{"lang":"en", "names":["San Marino"]}]
}

```

The \_source of that record looks like this in a search hit

```auto
"_source": {
  "name": "San Marino",
  "variants": [
    {
      "lang": "en",
      "names": [
        "San Marino"
      ]
    }
  ]
}

```

Using mixed case in this nested query, I get no results. If I replace `San Marino` with `san marino` (or `marino`), I get the expected hit.

```auto
GET /testy/_search
{
  "query": {
    "nested": {
      "path": "variants",
      "query": {
        "bool": {
          "must": [
            { "terms": { "variants.names": ["San Marino"] }}
          ]
        }
      }
    }
  }
}

```

Case is ignored on the non-nested field; this query finds the record:

```auto
GET /testy/_search
{"query" : {
  "match" : {"name": "San Marino"}
}}

```

Any ideas?

---

<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:** [March 11, 2021, 6:32pm UTC](https://discuss.elastic.co/t/lowercase-analyzer-filter-with-nested-field-and-queries/264043/2 "2021-03-11T18:32:24Z")

</div>

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