Index sorting in rollover request not supported?

ES 7.3.0
I'm trying to issue rollover command with index sorting. But I'm getting status 400 with "reason": "unknown index sort field:[ts]"

This is my payload:

POST test/_rollover
{
    "conditions": {
    "max_size": "0gb"
  },
  "settings": {
    "index.number_of_shards": 2,
    "index.sort.field": "ts",
    "index.sort.order": "desc"
  },
  "mappings": {
    "properties": {
      "ts": {
        "type": "date"
      }
    }
  }
}

When the condition is not met, then it just returns good status with "conditions" rc set to false.
But if the condition is met (notice I use 0gb to test empty index), I'm getting the above error code.
If I remove the sort.field and sort.order in "settings", then the rollover api creates the new index.

It looks like the "mappings" field is not applied for the rollover API.

you may want to take a look at index templates to always apply some mapping when a certain index gets created.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.3/indices-templates.html

Actually I justed tested your example on 7.3.1 and it works as expected.

Can you show a full recreation including all the responses?

 PUT test-000001
    {
      "aliases": {
      "test": {}
      }
    }

POST test/_rollover
{
  "conditions": {
    "max_size": "0gb"
  },
  "mappings": {
    "properties": {
      "ts": {
        "type": "date"
      }
    }
  },
  "settings": {
    "index.number_of_shards": 2,
    "index.sort.field": "ts",
    "index.sort.order": "desc"
  }
}

I might give 7.3.1 a try.

Yup. Just confirmed 7.3.1 works.

1 Like

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