elasticsearch,stop-words,Python,elasticsearch,Stop Words" /> elasticsearch,stop-words,Python,elasticsearch,Stop Words" />

如何使用python在Elasticsearch映射中指定Stopwords

如何使用python在Elasticsearch映射中指定Stopwords,python,elasticsearch,stop-words,Python,elasticsearch,Stop Words,我有一个python代码,首先创建Elasticsearch映射,然后在插入数据后搜索该数据: # Create Data mapping data_mapping = { "mappings": { (doc_type): { "properties": { "data_id": { "type": "string",

我有一个
python
代码,首先创建
Elasticsearch
映射,然后在插入数据后搜索该数据:

# Create Data mapping
data_mapping = {
        "mappings": {
            (doc_type): {
                "properties": {
                    "data_id": {
                        "type": "string",
                        "fields": {
                            "stemmed": {
                                "type": "string",
                                "analyzer": "english"
                            }
                        }
                    },
                    "data":{
                        "type": "array",
                        "fields": {
                            "stemmed": {
                                "type": "string",
                                "analyzer": "english"
                            }
                        }
                    },
                    "resp": {
                        "type": "string",
                        "fields": {
                            "stemmed": {
                                "type": "string",
                                "analyzer": "english"
                            }
                        }
                    },
                    "update": {
                        "type": "integer",
                        "fields": {
                            "stemmed": {
                                "type": "integer",
                                "analyzer": "english"
                            }
                        }
                    }

                }
            }
        }
    }
#Search
data_search = {
        "query": {
            "function_score": {
                "query": {

                    "match": {
                        'data': question
                    }
                },
                "field_value_factor": {
                    "field": "update",
                    "modifier": "log2p"
                }
            }
        }
        }
response = es.search(index=doc_type, body=data_search)
现在,我无法找出在上述代码中指定
stopwords
的位置和方式是什么?link给出了一个使用
stopwords
的示例,但我无法将其与我的代码联系起来。我需要在
数据映射
部分、搜索部分或两者中指定吗?我如何指定它

任何例子的帮助将不胜感激


更新:根据一些评论,建议添加
分析
部分或
设置
部分,但我不确定如何将它们添加到我上面写的
映射
部分。

您缺少所提供链接的
分析
部分。在那里,您可以定义自定义分析器并为该自定义分析器设置停止工作令牌筛选器。您错过了
设置
部分,对于英语分析器,请转到。@MohammadMazraeh如何将分析部分添加到我上面代码中的映射部分?@AshwaniShakya如何将设置部分添加到我在中的映射部分上面的我的代码?
PUT/_设置{“映射”:{you_映射},“设置”:{your设置}}
有关更多信息,请遵循以下内容