Python Elasticsearch创建索引映射
我正在尝试使用elasticsearch python创建一个带有自定义映射的ES索引,以增加每个文档中文本的大小:Python Elasticsearch创建索引映射,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我正在尝试使用elasticsearch python创建一个带有自定义映射的ES索引,以增加每个文档中文本的大小: mapping = {"mapping":{ "properties":{ "Apple":{"type":"text","ignore_above":1000}, "Mango":{"type":"text","ignore_above":1000} } }}
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\u over
选项。
关于如何纠正此问题的任何建议都将非常有用。上面的
忽略设置仅适用于关键字类型,而不是文本,因此只需将映射更改为此即可:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"text"},
"Mango":{"type":"text"}
}
}}
如果您确实需要能够指定上面的忽略
,则需要将类型更改为关键字
,如下所示:
mapping = {"mapping":{
"properties":{
"Apple":{"type":"keyword","ignore_above":1000},
"Mango":{"type":"keyword","ignore_above":1000}
}
}}
但是我需要将上面的ignore_
更改为1000,因为我正在尝试加载字符串值大于默认长度256的熊猫DF。