[英]How to handle try catch exception when creating an index with python elasticsearch?
[英]ElasticSearch Python client how to define number of shards when creating index
我只需要為索引分配1個碎片,但是瀏覽文檔和google搜索不會提供任何關於如何在不使用原始json格式的情況下通過python客戶端進行操作的線索。
我希望這樣的事情:
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.create(index='test-index', shards=1)
任何想法,將不勝感激。
我尚未測試過,但嘗試在正文中指定設置:
es.indices.create(index='test-index', body={
'settings' : {
'index' : {
'number_of_shards':1
}
}
})
https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/indices-create-index.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.