elasticsearch,Python,Python 3.x,elasticsearch" /> elasticsearch,Python,Python 3.x,elasticsearch" />

Python Elasticsearch-同义词分析器在分析中似乎没有效果

Python Elasticsearch-同义词分析器在分析中似乎没有效果,python,python-3.x,elasticsearch,Python,Python 3.x,elasticsearch,我正在尝试更新其中一个索引的设置(具体来说,我想更新我的自定义分析器以使用自定义同义词过滤器)。我编写了以下内容来更新设置,它编译时没有出现错误,但同义词过滤器似乎没有按预期工作(我指定的同义词似乎没有效果)。我希望哈利波特和惠普是同一件事,而终结者和TM也是同一件事(顺便说一句,我正在关闭索引,然后更新索引,然后再次打开索引) 下面是我的原始索引设置和映射: client.create( index = "movies", body= { "settings":

我正在尝试更新其中一个索引的设置(具体来说,我想更新我的自定义分析器以使用自定义同义词过滤器)。我编写了以下内容来更新设置,它编译时没有出现错误,但同义词过滤器似乎没有按预期工作(我指定的同义词似乎没有效果)。我希望哈利波特和惠普是同一件事,而终结者和TM也是同一件事(顺便说一句,我正在关闭索引,然后更新索引,然后再次打开索引)

下面是我的原始索引设置和映射:

client.create(
    index = "movies",
    body= {
        "settings": {
            "analysis": {
                "analyzer": {
                    "custom_analyzer": {
                        "type": "custom",
                        "tokenizer": "standard",
                        "filter": "lowercase"
                    }
                } 
            }
        },
        "mappings": {
            "properties": {
                "body": {
                    "type": "text",
                    "analyzer": "custom_analyzer",
                    "search_analyzer": "custom_analyzer",
                    "search_quote_analyzer": "custom_analyzer"
                }
            }
        }
    },

    ignore=400 
) 

谢谢你的帮助

要生效,您需要重新索引整个数据。 重新编制索引将映射这些同义词。
仅仅打开和关闭是没有帮助的。

您如何验证它是否工作?我有一个搜索查询(搜索“HP”),它查询电影索引,我正在尝试对文档进行排序,以便将包含“哈利波特”5次的文档列为列表中的顶部元素。现在,似乎有3次“HP”的文档排在列表的首位。您还应该显示您的查询。
client.create(
    index = "movies",
    body= {
        "settings": {
            "analysis": {
                "analyzer": {
                    "custom_analyzer": {
                        "type": "custom",
                        "tokenizer": "standard",
                        "filter": "lowercase"
                    }
                } 
            }
        },
        "mappings": {
            "properties": {
                "body": {
                    "type": "text",
                    "analyzer": "custom_analyzer",
                    "search_analyzer": "custom_analyzer",
                    "search_quote_analyzer": "custom_analyzer"
                }
            }
        }
    },

    ignore=400 
)