ElasticSearch: Keyword Query Does not Work ElasticSearch: Keyword Query Does not Work elasticsearch elasticsearch

ElasticSearch: Keyword Query Does not Work


I resolved my problem. You can look at the real answer: Elastic Discuss Forum

According to Mark response, I changed my mapping.New Mapping

{    "favoritesearchsearchmodelindex_2": {        "mappings": {            "favoritesearchsearchmodel": {                "properties": {                    "searchQuery": {                        "type": "nested",                        "properties": {                            "categoryProperties": {                                "properties": {                                    "key": {                                        "type": "keyword"                                    },                                    "numberValue": {                                        "type": "double"                                    },                                    "values": {                                        "properties": {                                            "value": {                                                "type": "keyword"                                            }                                        }                                    }                                }                            },                            "keyList": {                                "properties": {                                    "value": {                                        "type": "keyword"                                    }                                }                            }                        }                    }                }            }        }    }}

After changing mapping i realized that;I'm searching for searchQuery.categoryProperties.key is not color. I have an array and if one of the key is not colorits ok for search, but not for me.I created a keyList array and put all grouped keys of searchQuery.categoryProperties.key to keyListobject.Now I'm searching for keyListfirst. It gives me the correct response. This resolved my problem.

Here is the correct REQUEST

{    "query": {        "bool": {            "must": [{                "nested": {                    "query": {                        "bool": {                            "filter": [{                                "bool": {                                    "should": [{                                        "bool": {                                            "must_not": [{                                                "term": {                                                    "searchQuery.keyList.value": {                                                        "value": "color"                                                    }                                                }                                            }]                                        }                                    },                                    {                                        "bool": {                                            "must": [{                                                "term": {                                                    "searchQuery.categoryProperties.key": {                                                        "value": "color"                                                    }                                                }                                            },                                            {                                                "term": {                                                    "searchQuery.categoryProperties.values.value": {                                                        "value": "Mavi"                                                    }                                                }                                            }]                                        }                                    }]                                }                            }]                        }                    },                    "path": "searchQuery"                }            }]        }    }}