# Wildcard search and trim normalizer behaving strangley together

**URL:** https://discuss.elastic.co/t/wildcard-search-and-trim-normalizer-behaving-strangley-together/273025
**Category:** Elasticsearch
**Created:** [May 14, 2021, 1:43pm UTC](https://discuss.elastic.co/t/wildcard-search-and-trim-normalizer-behaving-strangley-together/273025 "2021-05-14T13:43:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexcassells](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@alexcassells](https://discuss.elastic.co/u/alexcassells)
#### Post date: [May 14, 2021, 1:43pm UTC](https://discuss.elastic.co/t/wildcard-search-and-trim-normalizer-behaving-strangley-together/273025/1 "2021-05-14T13:43:51Z")

</div>

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?

---

<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: [June 11, 2021, 1:44pm UTC](https://discuss.elastic.co/t/wildcard-search-and-trim-normalizer-behaving-strangley-together/273025/2 "2021-06-11T13:44:35Z")

</div>

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