How to Translate ElasticSearch Commands to NEST and Make Them Idempotent

156 views Asked by At

I am using the ElasticSearch Rollover API and need to setup an index, rollover and alias as shown below:

PUT /foo-000001 
{
  "aliases": {
    "foo-write": {}
  },
  "settings": {
      "index": {
        "number_of_shards": "1",
        "number_of_replicas": "0"
      }
    }
}

POST /foo-write/_rollover 
{
  "conditions": {
    "max_size":  "10kb"
  }
}

POST /_aliases
{
    "actions" : [
        { "add" : { "index" : "foo-*", "alias" : "foo" } }
    ]
}

I'd like to run these commands at app startup, so Elastic Search is initialised. Firstly, are these commands idempotent? If I run them every time the app starts, will it cause problems? How can I make them idempotent?

Secondly, how can I translate these commands to use the ElasticSearch C# NEST client for .NET?

0

There are 0 answers