Lowercase analyzer filter with nested field and queries

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?

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:

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

"_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.

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:

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

Any ideas?

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