[英]Python Elasticsearch create index mapping
I am trying to create a ES index with custom mapping with elasticsearch python to increase the size of text in each document:我正在尝试使用 elasticsearch python 创建具有自定义映射的 ES 索引,以增加每个文档中文本的大小:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text","ignore_above":1000},
"Mango":{"type":"text","ignore_above":1000}
}
}}
Creation:创建:
from elasticsearch import Elasticsearch
es1 = Elasticsearch([{"host":"localhost","port":9200}])
es1.indices.create(index="hello",body=mapping)
Error:错误:
RequestError: RequestError(400, 'mapper_parsing_exception', 'Mapping definition for [Apple] has unsupported parameters: [ignore_above : 10000]')
But I checked the elasticsearch website on how to increase the text length limit and ignore_above
was the option given there.但是我查看了 elasticsearch 网站关于如何增加文本长度限制,并且
ignore_above
是那里给出的选项。 https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-above.html https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-above.html
Any suggestions on how to rectify this will be great.任何关于如何纠正这个问题的建议都会很棒。
The ignore_above
setting is only for keyword
types not text
, so just change your mapping to this and it will work: ignore_above
设置仅适用于keyword
类型而不是text
,因此只需将映射更改为此即可:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text"},
"Mango":{"type":"text"}
}
}}
If you absolutely need to be able to specify ignore_above
then you need to change the type to keyword
, like this:如果您绝对需要能够指定
ignore_above
那么您需要将类型更改为keyword
,如下所示:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"keyword","ignore_above":1000},
"Mango":{"type":"keyword","ignore_above":1000}
}
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.