我正在尝试使用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
关于如何纠正此问题的任何建议都将很棒。
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}
}
}}