Characters to avoid in field names


(Nick Hoffman) #1

Hey guys. After reading this threadhttp://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.htmlwhere kimchy said to avoid spaces in field names, I'm wondering what other
characters should not be included in field names.

Thanks,
Nick


(Gabriel Farrell) #2

On Sun, Nov 6, 2011 at 2:58 PM, Nick Hoffman nick@deadorange.com wrote:

Hey guys. After reading this thread where kimchy said to avoid spaces in
field names, I'm wondering what other characters should not be included in
field names.

Also discussed in this thread:
https://groups.google.com/forum/#!topic/elasticsearch/-nR-O3RVjyM

As mentioned there, Solr has dealt with this a bit:
https://issues.apache.org/jira/browse/SOLR-2606

Since Lucene puts no restrictions on field name characters when you
create the index, you'll only run into the problem when using certain
features, such as the query parser. For starters, you'll probably want
to avoid the special characters used in the query parser syntax
(http://lucene.apache.org/java/3_4_0/queryparsersyntax.html). There's
a list at the end of that page, and note they can be escaped, but
better not to need a bunch of backslashes, right?

Since ElasticSearch uses JSON for mapping and searching you won't run
into some of the Solr issues, but since it uses dot notation for typed
navigation and multi_field access, you may want to avoid the dot as
well.

In general, stick to alphanumeric and the underscore if possible.


(Nick Hoffman) #3

Thanks, Gabriel. That's really helpful, mate.


(system) #4