Query_string search not working on text field

Hi,
I have a field with type

"name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "normalizer": "case_insensitive"
            }
          }
        },

when I try to run a query_string search like so:

"query": {
        "bool": {
            "must": {
                "query_string": {
                    "query": "*test-word*",
                    "fields": [
                        "name",
                    ],
                    "analyze_wildcard": true
                }
            }
        }
    }

it return nothing

only if I search like so:

"query": {
        "bool": {
            "must": {
                "query_string": {
                    "query": "*test-word*",
                    "fields": [
                        "name.keyword",
                    ],
                    "analyze_wildcard": true
                }
            }
        }
    }

it works.

Any advice why query string search only works on keyword fields?
Thanks

Welcome!

It's because of the way you text is analyzed at index time. Try the _analyze API and you will understand.

It's probably analyzed to

  • test
  • word

Which explains why it does not match.

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