【发布时间】:2020-01-29 20:32:57
【问题描述】:
我正在使用 Elasticsearch 6.8 和 python 3.7
我正在尝试创建自己的同义词,将表情符号称为文本。 例如:“:-)”将指代“happy-smiley”。
我正在尝试使用以下代码构建和创建同义词和索引:
def create_analyzer(es_api, index_name, doc_type):
body = {
"settings": {
"index": {
"analysis": {
"filter": {
"synonym_filter": {
"type": "synonym",
"synonyms": [
":-), happy-smiley",
":-(, sad-smiley"
]
}
},
"analyzer": {
"synonym_analyzer": {
"tokenizer": "standard",
"filter": ["lowercase", "synonym_filter"]
}
}
}
}
},
"mappings": {
doc_type: {
"properties": {
"tweet": {"type": "text", "fielddata": "true"},
"existence": {"type": "text"},
"confidence": {"type": "float"}
}
}}
}
res = es_api.indices.create(index=index_name, body=body)
但我遇到了错误:
lasticsearch.exceptions.RequestError: RequestError(400, 'illegal_argument_exception', 'failed to build synonyms')
出了什么问题,我该如何解决?
【问题讨论】:
标签: elasticsearch