Valid mapping type and field names?


(Eric Jain) #1

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 '#'.


(Shay Banon) #2

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 '#'.


(Frank Budinsky) #3

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": { "bar": "test" } }

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

{ "term": { "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.


(charlez) #4

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


(system) #5