[英]Python Elasticsearch : Index mapping inconsistencies between ‘es.index’ and ‘es.indices.create’
[英]Python Elasticsearch create index mapping
我正在嘗試使用 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}
}
}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.