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 ?
Hi @Idorasi_Paul It is a bit unclear what you are asking with respec to this
However The docs here show the proper syntax
These are variations of proper syntax
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
# Create index with out "settings"
PUT /my-index-000001/
{
"index": {
"number_of_replicas": 2
}
}
What I'm asking is if
PUT /my-index-000001/
{
"settings": {
"index": {
"number_of_replicas": 2
}
}
}
or
PUT /my-index-000001/
{
"settings": {
"number_of_replicas": 2
}
}
are equivalent?
Yes they are equivalent
Easy to check
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
# 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
PUT /my-index-000001/
{
"settings": {
"index": {
"number_of_replicas": 3
}
}
}
But that is just me
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.