Home > Back-end >  How to use search_analyzer with no normalization factors?
How to use search_analyzer with no normalization factors?

Time:04-06

  • I want to use search_analyzer while disabling normalization factors.
  • I'm using elasticsearch:7.6.2

I configured my index:

        "settings": {
            "analysis": {
                "analyzer": {
                    "my_analyzer": {
                        "type": "custom",
                        "tokenizer": "standard",
                        "norms": "false",

                    }
                }
            }
        },
        "mappings": {
            "properties": {
                "content": {"type": "text",
                            "search_analyzer": "my_analyzer",
                            "analyzer": "standard"},
            }
        }

but is seems that it is using the normalization factors in searching time.

I have 3 documents in my index:

  1. michael jordan and scottie pippen - NBA is a professional basketball league in North America.
  2. michael jordan and scottie pippen - National Basketball Association
  3. michael jordan and scottie pippen

I searched for michael jordan and scottie pippen:

"query": {
            "bool": {
                "must":
                    [{
                        "query_string": {
                            "default_field": "content",
                            "query":  "michael jordan and scottie pippen"
                            }
                    }]
            }
        }

And I expected to get 3 results with same score, but I got 3 results with a different scores.

How can I ignore normalization factors in search time ?

CodePudding user response:

AFAIK, norms are defined at the field level and not at the analyzer level, can you try disabling norms on your content field, you can do it runtime as well as mentioned in official doc and see you are getting expected results.

  • Related