# Index Allocation based on attribute not working

**URL:** <https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147>\
**Category:** Elasticsearch\
**Created:** [September 10, 2020, 10:40am UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147 "2020-09-10T10:40:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 10, 2020, 10:40am UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/1 "2020-09-10T10:40:16Z")

</div>

Hi!

Can someone pls explain to me why some shards dont get relocated to the correct node in my cluster? I want no shard on node-4 at the moment.

Infos:

```auto
GET _cat/nodeattrs

node-4 172.21.2.174 172.21.2.174 ml.machine_memory 17179869184
node-4 172.21.2.174 172.21.2.174 ml.max_open_jobs 20
node-4 172.21.2.174 172.21.2.174 xpack.installed true
node-4 172.21.2.174 172.21.2.174 store_type warm
node-4 172.21.2.174 172.21.2.174 transform.node true
node-1 172.21.2.120 172.21.2.120 ml.machine_memory 33620926464
node-1 172.21.2.120 172.21.2.120 xpack.installed true
node-1 172.21.2.120 172.21.2.120 transform.node true
node-1 172.21.2.120 172.21.2.120 ml.max_open_jobs 20
node-1 172.21.2.120 172.21.2.120 store_type hot
node-3 172.21.3.14 172.21.3.14 ml.machine_memory 17179869184
node-3 172.21.3.14 172.21.3.14 ml.max_open_jobs 20
node-3 172.21.3.14 172.21.3.14 xpack.installed true
node-3 172.21.3.14 172.21.3.14 store_type hot
node-3 172.21.3.14 172.21.3.14 transform.node true
node-2 172.21.2.86 172.21.2.86 ml.machine_memory 33613492224
node-2 172.21.2.86 172.21.2.86 ml.max_open_jobs 20
node-2 172.21.2.86 172.21.2.86 xpack.installed true
node-2 172.21.2.86 172.21.2.86 store_type hot
node-2 172.21.2.86 172.21.2.86 transform.node true

```

shards on node-4:

```auto
ppr-ecs-test-2020.09	0	p	STARTED	249	261.5kb	172.21.2.174	node-4

```

index settings:

```auto
{
  "ppr-ecs-test-2020.09" : {
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "include" : {
              "store_type" : "hot"
            }
          }
        },
        "number_of_shards" : "1",
        "provided_name" : "ppr-ecs-test-2020.09",
        "creation_date" : "1599654541084",
        "number_of_replicas" : "1",
        "uuid" : "CS-UYQWcSCKdi-NAFGTsdQ",
        "version" : {
          "created" : "7080099"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 10, 2020, 1:08pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/2 "2020-09-10T13:08:42Z")

</div>

Try the following

```auto
{
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "require" : {
              "store_type" : "hot"
            }
          }
        },
        "number_of_shards" : "1",
        "number_of_replicas" : "1"
        }
      }
    }
}

```

The difference between include and require:  
Include means nodes may have that attribute  
Require means nodes must have that attribute

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 10, 2020, 1:40pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/3 "2020-09-10T13:40:17Z")

</div>

Can i overwrite the setting somehow? or delete the old one?

Because now i have this:

```auto
{
  "ppr-ecs-test-2020.09" : {
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "include" : {
              "store_type" : "hot"
            },
            "require" : {
              "store_type" : "hot"
            }
          }
        },
        "number_of_shards" : "1",
        "provided_name" : "ppr-ecs-test-2020.09",
        "creation_date" : "1599654541084",
        "number_of_replicas" : "1",
        "uuid" : "CS-UYQWcSCKdi-NAFGTsdQ",
        "version" : {
          "created" : "7080099"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 10, 2020, 2:00pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/4 "2020-09-10T14:00:58Z")

</div>

```auto
"include" : {
              "store_type" : ""
            }

```

setting null value will essentially remove the setting

I would also recommend using index template for configuring this setting for all newly created indices where this setting is required.

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 10, 2020, 2:03pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/5 "2020-09-10T14:03:31Z")

</div>

OK, now with:

```auto
{
  "ppr-ecs-test-2020.09" : {
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "include" : {
              "store_type" : ""
            },
            "require" : {
              "store_type" : "hot"
            }
          }
        },
        "number_of_shards" : "1",
        "provided_name" : "ppr-ecs-test-2020.09",
        "creation_date" : "1599654541084",
        "number_of_replicas" : "1",
        "uuid" : "CS-UYQWcSCKdi-NAFGTsdQ",
        "version" : {
          "created" : "7080099"
        }
      }
    }
  }
}

```

Its the same. Shard is on node-4 pretty much ignoring the setting.

Yeah for the new ones i do it via the template.

---

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 10, 2020, 2:12pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/6 "2020-09-10T14:12:11Z")

</div>

Can you post the output of:  
GET /\_cat/recovery/ppr-ecs-test-2020.09

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 10, 2020, 2:22pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/7 "2020-09-10T14:22:23Z")

</div>

> [@lzukel](#):
>
> GET /\_cat/recovery/ppr-ecs-test-2020.09

```auto
ppr-ecs-test-2020.09 0 576ms peer done 172.21.2.120 node-1 172.21.3.14 node-3 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
ppr-ecs-test-2020.09 0 2.5s peer done 172.21.2.120 node-1 172.21.2.174 node-4 n/a n/a 16 16 100.0% 16 267821 267821 100.0% 267821 0 0 100.0%

```

---

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 10, 2020, 2:30pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/8 "2020-09-10T14:30:03Z")

</div>

Can you share response of:  
GET /allocation/explain?pretty

Can also try:  
POST /\_cluster/reroute?retry\_failed=true

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 10, 2020, 2:34pm UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/9 "2020-09-10T14:34:20Z")

</div>

GET /\_cat/allocation/explain?pretty

EMPTY response

POST /\_cluster/reroute?retry\_failed=true

```auto
...
"ppr-ecs-test-2020.09" : {
          "shards" : {
            "0" : [
              {
                "state" : "STARTED",
                "primary" : false,
                "node" : "foRZv0ngQieXX3uwSXrZZg",
                "relocating_node" : null,
                "shard" : 0,
                "index" : "ppr-ecs-test-2020.09",
                "allocation_id" : {
                  "id" : "NP22yUdkTkmpCM4vvzrF7A"
                }
              },
              {
                "state" : "STARTED",
                "primary" : true,
                "node" : "zlcwsGyVSxOSE4c8I7MeVw",
                "relocating_node" : null,
                "shard" : 0,
                "index" : "ppr-ecs-test-2020.09",
                "allocation_id" : {
                  "id" : "On_WcGlVT9KJd-_tM06MYA"
                }
              }
            ]
          }
        }
...

```

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [September 11, 2020, 6:25am UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/10 "2020-09-11T06:25:38Z")

</div>

After the upgrade to 7.9.1 the shards got assigned on the correct node

---

<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:** [October 9, 2020, 6:26am UTC](https://discuss.elastic.co/t/index-allocation-based-on-attribute-not-working/248147/11 "2020-10-09T06:26:01Z")

</div>

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