What are the allowed characters in field names?


(datadev) #1

What are the allowed characters in field names? Specifically, are
hyphens allowed in field names? I currently have a term facet that has
a 'script' attribute being "term + 'aaa' + _source.foo-bar" and I am
getting the following exception: Query Failed [Failed to execute main
query]]; nested: PropertyAccessException[[Error: could not access:
[bar; in class: org.elasticsearch.search.lookup.SourceLookup]

Based on this exception, it seems that ES is treating the hyphen as a
delimiter between 2 fields?

If hyphens are not allowed in field names, is there definitive
documentation on what characters (ideally in a regex if there are also
rules about acceptable first characters, etc...) are allowed in field
names?

Thanks.


(datadev) #2

BTW, here is a link regarding field names in solr for reference:
https://issues.apache.org/jira/browse/SOLR-2606

On Oct 18, 3:39 am, datadev n...@adinfocenter.com wrote:

What are the allowed characters in field names? Specifically, are
hyphens allowed in field names? I currently have a term facet that has
a 'script' attribute being "term + 'aaa' + _source.foo-bar" and I am
getting the following exception: Query Failed [Failed to execute main
query]]; nested: PropertyAccessException[[Error: could not access:
[bar; in class: org.elasticsearch.search.lookup.SourceLookup]

Based on this exception, it seems that ES is treating the hyphen as a
delimiter between 2 fields?

If hyphens are not allowed in field names, is there definitive
documentation on what characters (ideally in a regex if there are also
rules about acceptable first characters, etc...) are allowed in field
names?

Thanks.


(Shay Banon) #3

There isn't really a limit on what can be in a field name. In your case, the
script is actually a script (by default, mvel). Since _source is actually
treated as a Map lookup, you can do _source['foo-bar'].

On Tue, Oct 18, 2011 at 9:39 AM, datadev nji@adinfocenter.com wrote:

What are the allowed characters in field names? Specifically, are
hyphens allowed in field names? I currently have a term facet that has
a 'script' attribute being "term + 'aaa' + _source.foo-bar" and I am
getting the following exception: Query Failed [Failed to execute main
query]]; nested: PropertyAccessException[[Error: could not access:
[bar; in class: org.elasticsearch.search.lookup.SourceLookup]

Based on this exception, it seems that ES is treating the hyphen as a
delimiter between 2 fields?

If hyphens are not allowed in field names, is there definitive
documentation on what characters (ideally in a regex if there are also
rules about acceptable first characters, etc...) are allowed in field
names?

Thanks.


(system) #4