'wildcard and term search returning different results based on case

I am using OpenSearch version 1.3.1 via the Docker image.

Here is my index and a document:

PUT index_0
{
   "settings":{
      "analysis":{
         "analyzer":{
            "keyword_lower":{
               "type":"custom",
               "tokenizer":"keyword",
               "filter":"lowercase"
            }
         }
      }
   },
   "mappings":{
      "properties":{
         "id":{
            "type":"text",
            "index":true
         },
         "name":{
            "type":"text",
            "index":true,
            "analyzer":"keyword_lower"
         }
      }
   }
}

PUT index_0/_doc/1
{
  "id":"123",
  "name":"FooBar"
}

If I run this query, I get results (notice the difference in case, lowercase b):

GET index_0/_search?pretty
{"query":{"wildcard":{"name":"Foobar"}}}

But if I run this query, I do not:

GET index_0/_search?pretty
{"query":{"term":{"name":"Foobar"}}}

Why does a term search seem to be case sensitive whereas a wildcard one is not, given the same field?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source