我有这个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
的位置和方式? This链接提供了使用stopwords
的示例,但我无法将其与我的代码相关联。我是否需要在data mapping
部分,搜索部分或两者中指定?我该如何指定呢?
任何示例帮助都将不胜感激!
更新:根据一些评论建议添加analysis
部分或settings
部分,但我不确定如何将其添加到{{1}我已在上面写过。