# Query\_string search not working on text field

**URL:** <https://discuss.elastic.co/t/query-string-search-not-working-on-text-field/359166>\
**Category:** Elasticsearch\
**Created:** [May 9, 2024, 10:37am UTC](https://discuss.elastic.co/t/query-string-search-not-working-on-text-field/359166 "2024-05-09T10:37:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanir\_goldin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yanir_goldin/32/122591_2.png) [@yanir\_goldin](https://discuss.elastic.co/u/yanir_goldin)\
**Post date:** [May 9, 2024, 10:37am UTC](https://discuss.elastic.co/t/query-string-search-not-working-on-text-field/359166/1 "2024-05-09T10:37:59Z")

</div>

Hi,  
I have a field with type

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

```

when I try to run a query\_string search like so:

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

```

it return nothing

only if I search like so:

```auto
"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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 9, 2024, 11:46am UTC](https://discuss.elastic.co/t/query-string-search-not-working-on-text-field/359166/2 "2024-05-09T11:46:25Z")

</div>

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.

---

<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 6, 2024, 11:47am UTC](https://discuss.elastic.co/t/query-string-search-not-working-on-text-field/359166/3 "2024-06-06T11:47:10Z")

</div>

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