Elasticsearch Query: search result not same when am searching for wooden door and wooden doors

when am search for wooden door and wooden doors results not show the same.

Query which i have used to fetch the data

{
    "query": {
        "bool": {
            "should": [
                {
                    "match": {
                        "keywords.keyword_values": {
                            "query": "wooden door",
                            "operator": "and",
                            "prefix_length": 0,
                            "max_expansions": 50,
                            "fuzzy_transpositions": "true",
                            "lenient": "false",
                            "zero_terms_query": "NONE",
                            "auto_generate_synonyms_phrase_query": "true",
                            "boost": 7.0
                        }
                    }
                }
            ],
            "adjust_pure_negative": true,
            "minimum_should_match": "1",
            "boost": 1.0
        }
    }
}

Document settings and mappings below:

mappings = {
    "properties": {
        "keywords": {
            "type": "object",
            "enabled": True,
            "properties": {
                "name": {
                    "type": "text",
                    "analyzer": "synonym_stemmer_bad_words_analyzer"
                }
            }
        }
    }
settings = {
        "analysis": {
            "analyzer": {
                "synonym_stemmer_bad_words_analyzer": {
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "synonym_filter",
                        "bad_words_filter",
                        "stemmer_filter"
                    ]
                }
            },
            "filter": {
                "bad_words_filter": {
                    "type": "stop",
                    "stopwords_path": "bannedwords.txt"
                },
                "synonym_filter": {
                    "type": "synonym",
                    "synonyms_path": "synonyms.txt"
                },
                "stemmer_filter": {
                    "type": "stemmer",
                    "name": "english"
                }
            }
        }
    }

Document which is stored format:

**Doc 1**

"keywords": [
    {
        "keyword_values": "wooden doors"
    }
]

**Doc 2**

"keywords": [
    {
        "keyword_values": "wooden door"
    }
]

in _analyze when searching for a wooden door below is the result

{
    "tokens": [
        {
            "token": "wooden",
            "start_offset": 0,
            "end_offset": 6,
            "type": "<ALPHANUM>",
            "position": 0
        },
        {
            "token": "door",
            "start_offset": 7,
            "end_offset": 11,
            "type": "<ALPHANUM>",
            "position": 1
        }
    ]
}

But am not getting the wooden doors data in the search query

It looks like you are queryinga. field for which you have not provided the mapping. When you minimize an example, please make sure you include all the relevant pieces of information.

It looks like the keywords.name field has the analyzer and stemmer you are looking to use, but that field is not the one you are querying.

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