# Index name, type name and field name rules

**URL:** <https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039>\
**Category:** Elasticsearch\
**Created:** [May 23, 2018, 6:49pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039 "2018-05-23T18:49:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prathap\_BN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathap_bn/32/30903_2.png) [@Prathap\_BN](https://discuss.elastic.co/u/Prathap_BN)\
**Post date:** [May 23, 2018, 6:49pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039/1 "2018-05-23T18:49:24Z")

</div>

I am using ES 6. What are exact rules regarding formation of index name, type name and field name strings.. I know ES only takes lower case.. Does it apply to field names too?

Is this documented officially somewhere? I couldnt find it anywhere

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 23, 2018, 8:19pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039/2 "2018-05-23T20:19:55Z")

</div>

I'm not actually sure it's documented anywhere... still looking myself. I'll open a PR to add them to the docs if I don't find anything.

The rules for index names are encoded in [`MetaDataCreateIndexService`](https://github.com/elastic/elasticsearch/blob/6.x/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java#L159). Essentially:

- Lowercase only
- Cannot include `\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, `space` (the character, not the word), `,`, `#`
- Indices prior to 7.0 could contain a colon (`:`), but that's been deprecated and won't be supported in 7.0+
- Cannot start with `-`, `_`, `+`
- Cannot be `.` or `..`
- Cannot be longer than 255 characters

Many of these naming restrictions were put in place when Elasticsearch used the index name as the directory name to store data on disk, so the names had to be conservative to play nicely with different file systems (that's why there are restrictions with not allowing `..` as a name, etc).

I suspect these might loosen up in the future, since we've moved to associating indices with a UUID which is used on-disk now, instead of the index name.

I believe the only restriction on field names is that it can't be entirely whitespace. Periods are allowed, but they are short-hand for objects. E.g.

```auto
"foo.bar.baz": "abc"

```

is equivalent to:

```auto
"foo": {
  "bar": {
    "baz": "abc"
  }
}

```

Which has the knock-on effect that "object paths" have to be valid. So `foo..bar.baz` is not allowed because it doesn't resolve to a valid path. Similarly:

```auto
"foo.": {
  "bar": {
    "baz": "abc"
  }
}

```

isn't allowed for the same reason (the trailing period on `foo.` makes it ambiguous).

I'll see what I can do about the docs 🙂

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 23, 2018, 8:22pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039/3 "2018-05-23T20:22:47Z")

</div>

Also note: both index names and field names support full unicode, so you technically can have 💩 as a field name... but it's not encouraged because it can lead to a lot of subtle irritations (accents vs unaccented characters, etc). Plain ASCII is the easiest unless there's a compelling reason otherwise 🙂

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 25, 2018, 2:24pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039/4 "2018-05-25T14:24:21Z")

</div>

Just merged in some documentation improvements, sorry for the confusion!

> <https://github.com/elastic/elasticsearch/pull/30826>

---

<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:** [June 22, 2018, 2:24pm UTC](https://discuss.elastic.co/t/index-name-type-name-and-field-name-rules/133039/5 "2018-06-22T14:24:21Z")

</div>

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