Error: Unknown key for a VALUE_STRING in [analyzer]

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)

{

    "query": {

        "terms": {

            "username": [

                "منشآت",

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

            ],

            "boost": 1.0

        }

    },

    "analyzer":"keyword",

    "size": "10000",

    "sort": [

        {

            "date": "desc"

        }

    ]

}

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

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

Here it is: search_analyzer | Elasticsearch Guide [8.11] | Elastic
There's a full example.

I'd recommend to provide a full recreation script as described in About the Elasticsearch category. 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.

1 Like

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

{

    "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

{

    "query": {

        "terms": {

            "username": [

                "منشآت",

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

            ],

            "boost": 1.0

        }

        

    },

    "size": "10000",

    "sort": [

        {

            "date": "desc"

        }

    ]

}

Please provide a full reproduction script.

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

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.

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

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

1 Like

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

 "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

{

    "query": {

        "terms": {

            "username.keyword": [

                "منشآت",

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

            ],

            "boost": 1.0

        }

        
}
    }

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