Elasticsearch-js: How to restrict only for one shard at the time of creation of new Index?

Created on 5 Nov 2018  路  4Comments  路  Source: elastic/elasticsearch-js

question

All 4 comments

You should configure it in the body of the API call, as documented here :)

But how do I add in npm package configuration, This is my code :

const elasticsearch = require('elasticsearch')
const client = new elasticsearch.Client({ host: { host, port } })
await client.indices.create({ index })

As you can see in the docs, you just need to pass the body to the API method.

client.indices.create({
  index: 'my-index',
  body: {
    settings: {
      index: {
        number_of_shards: 1, 
        number_of_replicas: 1 
      }
    }
  }
}, console.log)

Thanks

Was this page helpful?
0 / 5 - 0 ratings