簡體   English   中英

ElasticSearch Python客戶端在創建索引時如何定義分片數量

[英]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://github.com/elastic/elasticsearch-py/blob/32239539f9c1f502c1506977f7a19d6bef4ccbfd/elasticsearch/client/indices.py#L74

https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/indices-create-index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM