# Index settings in elasticsearch 8+

**URL:** <https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027>\
**Category:** Elasticsearch\
**Created:** [January 12, 2023, 1:36pm UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027 "2023-01-12T13:36:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Idorasi\_Paul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/idorasi_paul/32/107909_2.png) [@Idorasi\_Paul](https://discuss.elastic.co/u/Idorasi_Paul)\
**Post date:** [January 12, 2023, 1:36pm UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027/1 "2023-01-12T13:36:14Z")

</div>

Hello, from what I see, IndexSettings has a field of the same type called index. What is the difference if I set, for example, number\_of\_replicas like: index.number\_of\_replicas: 2 or directly: number\_of\_replicas: 2 ?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 13, 2023, 2:37am UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027/2 "2023-01-13T02:37:11Z")

</div>

Hi @Idorasi_Paul It is a bit unclear what you are asking with respec to this

> [@Idorasi\_Paul](#):
>
> IndexSettings

However The docs [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html#indices-update-settings) show the proper syntax

These are variations of proper syntax

```auto
DELETE my-index-000001

# Create Index with settings
PUT /my-index-000001/
{
  "settings": {
    "index": {
      "number_of_replicas": 2
    }
  }
}

# Create Index with settings
PUT /my-index-000001/
{
  "settings": {
    "index.number_of_replicas": 2
  }
}

# Update Index with settings
PUT /my-index-000001/_settings
{
  "index.number_of_replicas": 2
}

# Update Index with settings
PUT /my-index-000001/_settings
{
  "index": {
    "number_of_replicas": 2
  }
}

# This is valid as well... kind of shorthand I do not use this as it is confusing
PUT /my-index-000001/_settings
{
    "number_of_replicas" : 3
}

```

This is not valid

```auto
# Create index with out "settings" 
PUT /my-index-000001/
{
  "index": {
    "number_of_replicas": 2
  }
}

```

---

<div class="post-metadata">

**Author:** ![Idorasi\_Paul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/idorasi_paul/32/107909_2.png) [@Idorasi\_Paul](https://discuss.elastic.co/u/Idorasi_Paul)\
**Post date:** [January 13, 2023, 7:21am UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027/3 "2023-01-13T07:21:36Z")

</div>

What I'm asking is if

```auto
PUT /my-index-000001/
{
  "settings": {
    "index": {
      "number_of_replicas": 2
    }
  }
}

```

or

```auto
PUT /my-index-000001/
{
  "settings": {
     "number_of_replicas": 2
  }
}

```

are equivalent?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 13, 2023, 3:20pm UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027/4 "2023-01-13T15:20:13Z")

</div>

Yes they are equivalent

Easy to check

```auto
DELETE my-index-000001

PUT /my-index-000001/
{
  "settings": {
    "index": {
      "number_of_replicas": 3
    }
  }
}

GET my-index-000001

DELETE my-index-000001

PUT /my-index-000001/
{
  "settings": {
     "number_of_replicas": 3
  }
}

GET my-index-000001

```

Results

```auto
# DELETE my-index-000001 200 OK
{
  "acknowledged": true
}
# PUT /my-index-000001/ 200 OK
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "my-index-000001"
}
# GET my-index-000001 200 OK
{
  "my-index-000001": {
    "aliases": {},
    "mappings": {},
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "my-index-000001",
        "creation_date": "1673623169768",
        "number_of_replicas": "3",
        "uuid": "MR7r0U3cRXKGGW_DRGVpqg",
        "version": {
          "created": "8050399"
        }
      }
    }
  }
}
# DELETE my-index-000001 200 OK
{
  "acknowledged": true
}
# PUT /my-index-000001/ 200 OK
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "my-index-000001"
}
# GET my-index-000001 200 OK
{
  "my-index-000001": {
    "aliases": {},
    "mappings": {},
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "my-index-000001",
        "creation_date": "1673623169887",
        "number_of_replicas": "3",
        "uuid": "4khEVPoJQMeWMlSbdHni4A",
        "version": {
          "created": "8050399"
        }
      }
    }
  }
}

```

For Clarity I always use

```auto
PUT /my-index-000001/
{
  "settings": {
    "index": {
      "number_of_replicas": 3
    }
  }
}

```

But that is just me

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 10, 2023, 3:20pm UTC](https://discuss.elastic.co/t/index-settings-in-elasticsearch-8/323027/5 "2023-02-10T15:20:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
