elasticsearch,Python,elasticsearch" /> elasticsearch,Python,elasticsearch" />

ElasticSearch Python客户端如何在创建索引时定义碎片数

ElasticSearch Python客户端如何在创建索引时定义碎片数,python,elasticsearch,Python,elasticsearch,我的索引只需要一个shard,但是浏览一下和google搜索并没有给出任何关于如何通过python客户端而不使用原始json格式的线索 我希望有这样的情况: from elasticsearch import Elasticsearch es = Elasticsearch() es.indices.create(index='test-index', shards=1) 如果您有任何想法,我们将不胜感激。我还没有测试过它,但请尝试在正文中指定设置: es.indices.create(in

我的索引只需要一个shard,但是浏览一下和google搜索并没有给出任何关于如何通过python客户端而不使用原始json格式的线索

我希望有这样的情况:

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 
         }
   }
})


我没有测试它,但尝试在正文中指定设置:

es.indices.create(index='test-index', body={
   'settings' : {
         'index' : {
              'number_of_shards':1 
         }
   }
})