# Valid mapping type and field names?

**URL:** <https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530>\
**Category:** Elasticsearch\
**Created:** [January 28, 2012, 12:10am UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530 "2012-01-28T00:10:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_jain/32/834_2.png) [@Eric\_Jain](https://discuss.elastic.co/u/Eric_Jain)\
**Post date:** [January 28, 2012, 12:10am UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530/1 "2012-01-28T00:10:50Z")

</div>

What characters (other than [\w]) can I use in in type and field names  
without causing trouble? Lucene itself doesn't seem to have any  
restrictions (outside of the QueryParser), but elasticsearch appears  
to have special use for characters such as '.' and '#'.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 29, 2012, 6:20pm UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530/2 "2012-01-29T18:20:15Z")

</div>

There isn't realyl a restriction. '.' is used to try and derive navigation aspect, so its best to avoid it (though things won't break if you have it in your field name), and # is used in the _value_ of the internal \_uid, but you can safely use it as well. I would recommend against using wildcard '_' as a future version of ES might support things like searching for obj1._.field1

On Saturday, January 28, 2012 at 2:10 AM, Eric Jain wrote:

> What characters (other than [\w]) can I use in in type and field names  
> without causing trouble? Lucene itself doesn't seem to have any  
> restrictions (outside of the QueryParser), but elasticsearch appears  
> to have special use for characters such as '.' and '#'.

---

<div class="post-metadata">

**Author:** ![Frank\_Budinsky](https://avatars.discourse-cdn.com/v4/letter/f/919ad9/32.png) [@Frank\_Budinsky](https://discuss.elastic.co/u/Frank_Budinsky)\
**Post date:** [March 19, 2013, 9:37pm UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530/3 "2013-03-19T21:37:05Z")

</div>

I'm not sure I understand how "." won't break things if used in field names. Is there a way to specify nested fields in queries or mappings without using "." characters, or is the parser smart enough to know the difference? For example, assume I use a URI for a field name, something like this:

{ "[http://example.org#foo](http://example.org#foo)": { "bar": "test" } }

and I want to refer to the nested "bar" field in a query, like this:

{ "term": { "[http://example.org#foo.bar](http://example.org#foo.bar)": "test" } }

Should this work, or is there another way to do it that doesn't use two "." characters with different meanings?

Thanks, Frank.

---

<div class="post-metadata">

**Author:** ![charlez](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@charlez](https://discuss.elastic.co/u/charlez)\
**Post date:** [February 18, 2014, 10:08pm UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530/4 "2014-02-18T22:08:45Z")

</div>

FYI: comma ',' certainly isn't permitted within a type name based upon the following response from ElasticSearch when attempting to create the type "Students, Owns a Car"

"InvalidTypeNameException[mapping type name [Students, Owns a Car] should not include ',' in it]"

Does ElasticSearch documentation provide a definitive list of what characters can (or can't) be used for type names?

TIA,  
charlez

---

<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:** [July 6, 2017, 1:49am UTC](https://discuss.elastic.co/t/valid-mapping-type-and-field-names/6530/5 "2017-07-06T01:49:16Z")

</div>


