Skip to content

Inconsistent wildcard search results when combined with a trim normalizer #73138

@ACassells

Description

@ACassells

Tested using clean docker 7.12.1

version: Version: 7.12.1, Build: default/docker/3186837139b9c6b6d23c3200870651f10d3343b7/2021-04-20T20:56:39.040728659Z, JVM: 16
on
Linux 0ca876ff72e4 4.19.121-linuxkit #1 SMP Thu Jan 21 15:36:34 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

When using a trim normalizer in combination of a keyword wildcard search, the search fails at the end or beginning of words when using a single wildcard. In those situations you need to add a double wild card.

Steps to reproduce:

  1. Create index
PUT /test-normalizer-index
{
  "settings": {
    "analysis": {
      "normalizer": {
        "trimming_normalizer": {
          "filter": [
            "trim"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name": {
        "type": "keyword",
        "normalizer": "trimming_normalizer"
      }
    }
  }
}
  1. Add doc to index
POST /test-normalizer-index/_doc/
{
  "name": "elastic search"
}
  1. Search for an entry that would expect to get a result
GET /test-normalizer-index/_search
{
  "query": {
    "wildcard": {
      "name": {
        "value": "elasti? search"
      }
    }
  }
}

this provides 0 results

These are some other tests results:

elast?c search -> finds a document - EXPECTED
elastic searc? -> finds a document - EXPECTED
?lastic search -> finds a document - EXPECTED
elastic ?earch -> fails to find a document - UNEXPECTED
elastic ??earch -> finds a document - UNEXPECTED
elasti? search -> fails to find a document - UNEXPECTED
elasti?? search -> finds a document - UNEXPECTED

The first three tests are as expected. The last 4 tests seem incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search Relevance/AnalysisHow text is split into tokens>bugTeam:Search RelevanceMeta label for the Search Relevance team in Elasticsearchpriority:normalA label for assessing bug priority to be used by ES engineers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions