# Error: Unknown key for a VALUE\_STRING in \[analyzer\]

**URL:** <https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105>\
**Category:** Elasticsearch\
**Created:** [October 7, 2021, 8:07am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105 "2021-10-07T08:07:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 7, 2021, 8:07am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/1 "2021-10-07T08:07:04Z")

</div>

Hi, I'm having this error in postman

> Unknown key for a VALUE\_STRING in [analyzer].

when I search like this:  
(note I get this after I add the analyzer)

```auto
{

    "query": {

        "terms": {

            "username": [

                "منشآت",

                "الرياض غرفة"

            ],

            "boost": 1.0

        }

    },

    "analyzer":"keyword",

    "size": "10000",

    "sort": [

        {

            "date": "desc"

        }

    ]

}

```

---

<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:** [October 7, 2021, 9:04am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/2 "2021-10-07T09:04:52Z")

</div>

Where did you find in the documentation that you could do such a thing?  
What are you trying to do here?

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 7, 2021, 10:04am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/4 "2021-10-07T10:04:10Z")

</div>

I read about search\_analyzer and I want to implement it in my search query I didn't follow a documentation because I didn't find one that do exact as I want.

The full problem is I'm new to Elasticsearch and I'm trying to do terms query, I found out that when I try to search for a term that consist of two words and on of these words are common it will not be specifc and the reason of that is the field type is text. I try to re mapping it and reindex it and it didn't work, so now I try if I can apply the search analyzer keyword

---

<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:** [October 7, 2021, 10:36am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/5 "2021-10-07T10:36:31Z")

</div>

> [@Drsaud](#):
>
> I read about search\_analyzer and I want to implement it in my search query I didn't follow a documentation because I didn't find one that do exact as I want.

Here it is: [search\_analyzer | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html)  
There's a full example.

> [@Drsaud](#):
>
> The full problem is I'm new to Elasticsearch and I'm trying to do terms query, I found out that when I try to search for a term that consist of two words and on of these words are common it will not be specifc and the reason of that is the field type is text. I try to re mapping it and reindex it and it didn't work, so now I try if I can apply the search analyzer keyword

I'd recommend to provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can **copy and paste in Kibana dev console** , click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 7, 2021, 10:50am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/7 "2021-10-07T10:50:30Z")

</div>

The problem is I want to use terms query but not working  
My index mapping now is this:

```auto
{

    "tweets_index": {

        "mappings": {

            "properties": {

                "date": {

                    "type": "date"

                },

                "id": {

                    "type": "long"

                },

                "tweet": {

                    "type": "text",

                    "fields": {

                        "keyword": {

                            "type": "keyword",

                            "ignore_above": 256

                        }

                    }

                },

                "url": {

                    "type": "text",

                    "fields": {

                        "keyword": {

                            "type": "keyword",

                            "ignore_above": 256

                        }

                    }

                },

                "username": {

                    "type": "text",

                    "fields": {

                        "keyword": {

                            "type": "keyword",

                            "ignore_above": 256

                        }

                    }

                }

            }

        }

    }

}

```

I try to use terms query and the second term didn't show up because its consist of two words

```auto
{

    "query": {

        "terms": {

            "username": [

                "منشآت",

                "الرياض غرفة "

            ],

            "boost": 1.0

        }

        

    },

    "size": "10000",

    "sort": [

        {

            "date": "desc"

        }

    ]

}

```

---

<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:** [October 7, 2021, 10:53am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/8 "2021-10-07T10:53:53Z")

</div>

Please provide a full reproduction script.

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 7, 2021, 10:56am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/9 "2021-10-07T10:56:31Z")

</div>

Sorry I'm not understanding what excatly you mean, all my code is consist of two things: the second one in my replay is the query, and the other one is javascript code that index my data from json file

---

<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:** [October 7, 2021, 10:57am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/10 "2021-10-07T10:57:50Z")

</div>

A full reproduction script is something anyone can **copy and paste in Kibana dev console** , click on the run button to reproduce your use case.

Here I can not copy paste your example and run it.

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 7, 2021, 11:00am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/11 "2021-10-07T11:00:09Z")

</div>

I get it now, but literally my process is start my JavaScript code that read the data and load to Elasticsearch and Elasticsearch map it by default, then I run my query using postman

---

<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:** [October 7, 2021, 11:02am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/12 "2021-10-07T11:02:50Z")

</div>

I'd recommend using Kibana and its dev console.  
Reproduce the issue with a simple script. And share it here.

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [October 10, 2021, 7:37am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/13 "2021-10-10T07:37:23Z")

</div>

I solve the main the problem here that I want to use terms query but my field is text,  
I check my index mapping for that specifc field and it looks like this

```auto
 "username": {

                    "type": "text",

                    "fields": {

                        "keyword": {

                            "type": "keyword",

                            "ignore_above": 256

                        }

                    }

                }

```

and I found out that if I want to search it like a keyword using terms query I can do this

```auto
{

    "query": {

        "terms": {

            "username.keyword": [

                "منشآت",

                "غرفة الرياض"

            ],

            "boost": 1.0

        }

        
}
    }

```

---

<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:** [November 7, 2021, 7:38am UTC](https://discuss.elastic.co/t/error-unknown-key-for-a-value-string-in-analyzer/286105/14 "2021-11-07T07:38:15Z")

</div>

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