如何在没有归一化因子的情况下使用 search_analyzer?

How to use search_analyzer with no normalization factors?

我配置了我的索引:

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

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

但似乎它在搜索时间中使用了归一化因子。

我的索引中有 3 个文档:

  1. 迈克尔·乔丹和斯科蒂·皮蓬 - NBA 是北美的职业篮球联赛。
  2. 迈克尔·乔丹和斯科蒂·皮蓬 - 美国国家篮球协会
  3. 迈克尔·乔丹和斯科蒂·皮蓬

我搜索了 michael jordan and scottie pippen:

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

我希望得到 3 个相同分数的结果,但我得到了 3 个不同分数的结果。

如何忽略搜索时间中的归一化因素?

AFAIK,norms 是在字段级别而不是分析器级别定义的,您可以尝试在 content 字段上禁用 norms 吗,您也可以在运行时进行如 official doc 中所述,您会看到预期的结果。