我正在尝试使用elasticsearch python创建具有自定义映射的ES索引,以增加每个文档中文本的大小:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text","ignore_above":1000},
"Mango":{"type":"text","ignore_above":1000}
}
}}
创作:
from elasticsearch import Elasticsearch
es1 = Elasticsearch([{"host":"localhost","port":9200}])
es1.indices.create(index="hello",body=mapping)
错误:
RequestError: RequestError(400, 'mapper_parsing_exception', 'Mapping definition for [Apple] has unsupported parameters: [ignore_above : 10000]')
但是我检查了Elasticsearch网站上有关如何增加文本长度限制的信息,其中提供了ignore_above
。
https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-above.html
关于如何纠正这一问题的任何建议都是很好的。
答案 0 :(得分:0)
ignore_above
设置仅适用于keyword
类型,不适用于text
,因此只需将其更改为该映射即可使用:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text"},
"Mango":{"type":"text"}
}
}}
如果您绝对需要指定ignore_above
,则需要将类型更改为keyword
,如下所示:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"keyword","ignore_above":1000},
"Mango":{"type":"keyword","ignore_above":1000}
}
}}