Wildcard search and trim normalizer behaving strangley together

If a have an index with a trim normalizer and try and use a wildcard search with it, I am seeing behaviour that I would not expect to see

// create an index and populate it with a document    
PUT /test-normalizer-index
{
  "settings": {
    "analysis": {
      "normalizer": {
        "trimming_normalizer": {
          "filter": [
            "trim"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name": {
        "type": "keyword",
        "normalizer": "trimming_normalizer"
      }
    }
  }
}

POST /test-normalizer-index/_doc/
{
  "name": "elastic search"
}

If I then send the following query I would expect it to match elasti? search should match elastic search however the following query returns 0 hits

GET /test-normalizer-index/_search
{
  "query": {
    "wildcard": {
      "name": {
        "value": "elasti? search"
      }
    }
  }
}
-- returns --
 "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }

These are the behaviours:

  1. elast?c search -> finds a document
  2. elastic searc? -> finds a document
  3. ?lastic search -> finds a document
  4. elastic ?earch -> fails to find a document
  5. elastic ??earch -> finds a document
  6. elasti? search -> fails to find a document
  7. elasti?? search -> finds a document

Tests 4 to 7 are the opposite behaviours to what I would expect. Is this a problem with elasticsearch or is this expected behaviour?

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