# Problem with colon ':' in fieldname. Where can I find naming guidelines?

**URL:** https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437
**Category:** Elasticsearch
**Created:** [September 22, 2011, 6:08pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437 "2011-09-22T18:08:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vinhphu1711](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vinhphu1711](https://discuss.elastic.co/u/vinhphu1711)
#### Post date: [September 22, 2011, 6:08pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/1 "2011-09-22T18:08:01Z")

</div>

Hi,  
Firstly, many thanks to Kimchy for very cool stuff.  
I have a small (hopefully not silly) question. We attempted to use  
colon in a field name. Nothing strange happened until we tried to pass  
that field name to "fields" parameter in a query.

curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
{  
"fields": ["abcd:field1", "field2", "field3"],  
"query": {  
"query\_string": {  
"query": "Bonsai cool"  
}  
}  
}  
'  
In the result set, only "field2" and "field3" are included in \_source.  
Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
In our context, we really need a special character to act as a prefix  
namespace separator, and don't want to do the boring replace() process  
all the time.  
I've thoroughly noticed your advice here:  
[http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)  
. So, can you please show me where I can find naming guidelines for  
field name?  
Thanks a lot.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [September 22, 2011, 6:12pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/2 "2011-09-22T18:12:20Z")

</div>

Can't you use underscore \_ ?

David 😉

Le 22 sept. 2011 à 20:08, Phu Le [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com) a écrit :

> Hi,  
> Firstly, many thanks to Kimchy for very cool stuff.  
> I have a small (hopefully not silly) question. We attempted to use  
> colon in a field name. Nothing strange happened until we tried to pass  
> that field name to "fields" parameter in a query.
> 
> curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> {  
> "fields": ["abcd:field1", "field2", "field3"],  
> "query": {  
> "query\_string": {  
> "query": "Bonsai cool"  
> }  
> }  
> }  
> '  
> In the result set, only "field2" and "field3" are included in \_source.  
> Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> In our context, we really need a special character to act as a prefix  
> namespace separator, and don't want to do the boring replace() process  
> all the time.  
> I've thoroughly noticed your advice here:  
> [http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)  
> . So, can you please show me where I can find naming guidelines for  
> field name?  
> Thanks a lot.

---

<div class="post-metadata">

### Author: ![vinhphu1711](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vinhphu1711](https://discuss.elastic.co/u/vinhphu1711)
#### Post date: [September 22, 2011, 6:18pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/3 "2011-09-22T18:18:50Z")

</div>

@David: thanks for the quick reply.  
Yes, it's a nice option. However, since underscore is pretty _popular_, and  
can be part of the original fieldname as well, I prefer a special character  
(if possible).  
Anyway, would be great if it is explicitly stated somewhere what we should  
(and shouldn't) use for field name. Besides, the indexing process doesn't  
complain... :P.

Thanks,  
LTVP

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-colon-in-fieldname-Where-can-I-find-naming-guidelines-tp3359628p3359660.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-colon-in-fieldname-Where-can-I-find-naming-guidelines-tp3359628p3359660.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

### Author: ![vinhphu1711](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vinhphu1711](https://discuss.elastic.co/u/vinhphu1711)
#### Post date: [September 22, 2011, 6:19pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/4 "2011-09-22T18:19:54Z")

</div>

@David: thanks for the quick reply.  
Yes, it's a nice option. However, since underscore is pretty _popular_, and  
can be part of the original fieldname as well, I prefer a special character  
(if possible).  
Anyway, would be great if it is explicitly stated somewhere what we should  
(and shouldn't) use for field name. Besides, the indexing process doesn't  
complain... :P.

Thanks,  
LTVP

On Fri, Sep 23, 2011 at 2:12 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Can't you use underscore \_ ?
> 
> David 😉
> 
> Le 22 sept. 2011 à 20:08, Phu Le [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com) a écrit :
> 
> > Hi,  
> > Firstly, many thanks to Kimchy for very cool stuff.  
> > I have a small (hopefully not silly) question. We attempted to use  
> > colon in a field name. Nothing strange happened until we tried to pass  
> > that field name to "fields" parameter in a query.
> > 
> > curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> > {  
> > "fields": ["abcd:field1", "field2", "field3"],  
> > "query": {  
> > "query\_string": {  
> > "query": "Bonsai cool"  
> > }  
> > }  
> > }  
> > '  
> > In the result set, only "field2" and "field3" are included in \_source.  
> > Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> > In our context, we really need a special character to act as a prefix  
> > namespace separator, and don't want to do the boring replace() process  
> > all the time.  
> > I've thoroughly noticed your advice here:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)
> 
> > . So, can you please show me where I can find naming guidelines for  
> > field name?  
> > Thanks a lot.

--  
Le Truong Vinh Phu

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [September 22, 2011, 6:27pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/5 "2011-09-22T18:27:04Z")

</div>

Not sure that document exists but I wouldn't recommand using : - + ^ . as they can be used in queries.

Perhaps ; have no side effects.

David 😉

Le 22 sept. 2011 à 20:19, Le Truong Vinh Phu [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com) a écrit :

> @David: thanks for the quick reply.  
> Yes, it's a nice option. However, since underscore is pretty _popular_, and can be part of the original fieldname as well, I prefer a special character (if possible).  
> Anyway, would be great if it is explicitly stated somewhere what we should (and shouldn't) use for field name. Besides, the indexing process doesn't complain... :P.
> 
> Thanks,  
> LTVP
> 
> On Fri, Sep 23, 2011 at 2:12 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Can't you use underscore \_ ?
> 
> David 😉
> 
> Le 22 sept. 2011 à 20:08, Phu Le [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com) a écrit :
> 
> > Hi,  
> > Firstly, many thanks to Kimchy for very cool stuff.  
> > I have a small (hopefully not silly) question. We attempted to use  
> > colon in a field name. Nothing strange happened until we tried to pass  
> > that field name to "fields" parameter in a query.
> > 
> > curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> > {  
> > "fields": ["abcd:field1", "field2", "field3"],  
> > "query": {  
> > "query\_string": {  
> > "query": "Bonsai cool"  
> > }  
> > }  
> > }  
> > '  
> > In the result set, only "field2" and "field3" are included in \_source.  
> > Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> > In our context, we really need a special character to act as a prefix  
> > namespace separator, and don't want to do the boring replace() process  
> > all the time.  
> > I've thoroughly noticed your advice here:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)  
> > . So, can you please show me where I can find naming guidelines for  
> > field name?  
> > Thanks a lot.
> 
> --  
> Le Truong Vinh Phu

---

<div class="post-metadata">

### Author: ![vinhphu1711](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vinhphu1711](https://discuss.elastic.co/u/vinhphu1711)
#### Post date: [September 22, 2011, 6:30pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/6 "2011-09-22T18:30:12Z")

</div>

Thanks a lot!  
I'll try and put up some notes here.

LTVP  
On Fri, Sep 23, 2011 at 2:27 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Not sure that document exists but I wouldn't recommand using : - + ^ . as  
> they can be used in queries.
> 
> Perhaps ; have no side effects.
> 
> David 😉
> 
> Le 22 sept. 2011 à 20:19, Le Truong Vinh Phu [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com)  
> a écrit :
> 
> @David: thanks for the quick reply.  
> Yes, it's a nice option. However, since underscore is pretty _popular_, and  
> can be part of the original fieldname as well, I prefer a special  
> character (if possible).  
> Anyway, would be great if it is explicitly stated somewhere what we should  
> (and shouldn't) use for field name. Besides, the indexing process doesn't  
> complain... :P.
> 
> Thanks,  
> LTVP
> 
> On Fri, Sep 23, 2011 at 2:12 AM, David Pilato \< [david@pilato.fr](mailto:david@pilato.fr)  
> [david@pilato.fr](mailto:david@pilato.fr)\> wrote:
> 
> > Can't you use underscore \_ ?
> > 
> > David 😉
> > 
> > Le 22 sept. 2011 à 20:08, Phu Le \< [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com)  
> > [le.truong.vinh.phu@gmail.com](mailto:le.truong.vinh.phu@gmail.com)\> a écrit :
> > 
> > > Hi,  
> > > Firstly, many thanks to Kimchy for very cool stuff.  
> > > I have a small (hopefully not silly) question. We attempted to use  
> > > colon in a field name. Nothing strange happened until we tried to pass  
> > > that field name to "fields" parameter in a query.
> > > 
> > > curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> > > {  
> > > "fields": ["abcd:field1", "field2", "field3"],  
> > > "query": {  
> > > "query\_string": {  
> > > "query": "Bonsai cool"  
> > > }  
> > > }  
> > > }  
> > > '  
> > > In the result set, only "field2" and "field3" are included in \_source.  
> > > Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> > > In our context, we really need a special character to act as a prefix  
> > > namespace separator, and don't want to do the boring replace() process  
> > > all the time.  
> > > I've thoroughly noticed your advice here:
> > 
> > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)  
> > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html](http://elasticsearch-users.115913.n3.nabble.com/Using-space-characters-in-a-field-s-name-td2760404.html)
> > 
> > > . So, can you please show me where I can find naming guidelines for  
> > > field name?  
> > > Thanks a lot.
> 
> --  
> Le Truong Vinh Phu

--  
Le Truong Vinh Phu

---

<div class="post-metadata">

### Author: ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)
#### Post date: [September 22, 2011, 8:26pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/7 "2011-09-22T20:26:26Z")

</div>

I guess you want "someExternalfieldname:otherInfo":"value" ? why not  
feed it as object

"someExternalfieldname":{"otherInfo":"value"}

On 22 Sep., 20:30, Le Truong Vinh Phu [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)  
wrote:

> Thanks a lot!  
> I'll try and put up some notes here.
> 
> LTVP
> 
> On Fri, Sep 23, 2011 at 2:27 AM, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> 
> > Not sure that document exists but I wouldn't recommand using : - + ^ . as  
> > they can be used in queries.
> 
> > Perhaps ; have no side effects.
> 
> > David 😉
> 
> > Le 22 sept. 2011 à 20:19, Le Truong Vinh Phu [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)  
> > a écrit :
> 
> > @David: thanks for the quick reply.  
> > Yes, it's a nice option. However, since underscore is pretty _popular_, and  
> > can be part of the original fieldname as well, I prefer a special  
> > character (if possible).  
> > Anyway, would be great if it is explicitly stated somewhere what we should  
> > (and shouldn't) use for field name. Besides, the indexing process doesn't  
> > complain... :P.
> 
> > Thanks,  
> > LTVP
> 
> > On Fri, Sep 23, 2011 at 2:12 AM, David Pilato \< [da...@pilato.fr](mailto:da...@pilato.fr)  
> > [da...@pilato.fr](mailto:da...@pilato.fr)\> wrote:
> 
> > > Can't you use underscore \_ ?
> 
> > > David 😉
> 
> > > Le 22 sept. 2011 à 20:08, Phu Le \< [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)  
> > > [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)\> a écrit :
> 
> > > > Hi,  
> > > > Firstly, many thanks to Kimchy for very cool stuff.  
> > > > I have a small (hopefully not silly) question. We attempted to use  
> > > > colon in a field name. Nothing strange happened until we tried to pass  
> > > > that field name to "fields" parameter in a query.
> 
> > > > curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> > > > {  
> > > > "fields": ["abcd:field1", "field2", "field3"],  
> > > > "query": {  
> > > > "query\_string": {  
> > > > "query": "Bonsai cool"  
> > > > }  
> > > > }  
> > > > }  
> > > > '  
> > > > In the result set, only "field2" and "field3" are included in \_source.  
> > > > Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> > > > In our context, we really need a special character to act as a prefix  
> > > > namespace separator, and don't want to do the boring replace() process  
> > > > all the time.  
> > > > I've thoroughly noticed your advice here:
> 
> > > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-character...](http://elasticsearch-users.115913.n3.nabble.com/Using-space-character...)  
> > > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-character](http://elasticsearch-users.115913.n3.nabble.com/Using-space-character)...
> > > 
> > > > . So, can you please show me where I can find naming guidelines for  
> > > > field name?  
> > > > Thanks a lot.
> 
> > --  
> > Le Truong Vinh Phu
> 
> --  
> Le Truong Vinh Phu

---

<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: [September 23, 2011, 11:19pm UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/8 "2011-09-23T23:19:44Z")

</div>

Using a field called "some:field" in the fields and wanting to load it from  
source itself will fail in 0.17 because it is, internally, uses scripting to  
extract the value from source. In master, it will not fail. Having said  
that, I think that its better not to use ':' as the separator, as when you  
try and use things like query\_string on it, you will run into quirks.

On Thu, Sep 22, 2011 at 11:26 PM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> I guess you want "someExternalfieldname:otherInfo":"value" ? why not  
> feed it as object
> 
> "someExternalfieldname":{"otherInfo":"value"}
> 
> On 22 Sep., 20:30, Le Truong Vinh Phu [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)  
> wrote:
> 
> > Thanks a lot!  
> > I'll try and put up some notes here.
> > 
> > LTVP
> > 
> > On Fri, Sep 23, 2011 at 2:27 AM, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> > 
> > > Not sure that document exists but I wouldn't recommand using : - + ^ .  
> > > as  
> > > they can be used in queries.
> > 
> > > Perhaps ; have no side effects.
> > 
> > > David 😉
> > 
> > > Le 22 sept. 2011 à 20:19, Le Truong Vinh Phu \<  
> > > [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)\>  
> > > a écrit :
> > 
> > > @David: thanks for the quick reply.  
> > > Yes, it's a nice option. However, since underscore is pretty _popular_,  
> > > and  
> > > can be part of the original fieldname as well, I prefer a special  
> > > character (if possible).  
> > > Anyway, would be great if it is explicitly stated somewhere what we  
> > > should  
> > > (and shouldn't) use for field name. Besides, the indexing process  
> > > doesn't  
> > > complain... :P.
> > 
> > > Thanks,  
> > > LTVP
> > 
> > > On Fri, Sep 23, 2011 at 2:12 AM, David Pilato \< [da...@pilato.fr](mailto:da...@pilato.fr)  
> > > [da...@pilato.fr](mailto:da...@pilato.fr)\> wrote:
> > 
> > > > Can't you use underscore \_ ?
> > 
> > > > David 😉
> > 
> > > > Le 22 sept. 2011 à 20:08, Phu Le \< [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)  
> > > > [le.truong.vinh....@gmail.com](mailto:le.truong.vinh....@gmail.com)\> a écrit :
> > 
> > > > > Hi,  
> > > > > Firstly, many thanks to Kimchy for very cool stuff.  
> > > > > I have a small (hopefully not silly) question. We attempted to use  
> > > > > colon in a field name. Nothing strange happened until we tried to  
> > > > > pass  
> > > > > that field name to "fields" parameter in a query.
> > 
> > > > > curl -XPOST 'localhost:9200/myIndex/myType/\_search?pretty=on' -d '  
> > > > > {  
> > > > > "fields": ["abcd:field1", "field2", "field3"],  
> > > > > "query": {  
> > > > > "query\_string": {  
> > > > > "query": "Bonsai cool"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > '  
> > > > > In the result set, only "field2" and "field3" are included in  
> > > > > \_source.  
> > > > > Seems that ES simply ignore the "abcd:field1". Anyway to workaround?  
> > > > > In our context, we really need a special character to act as a  
> > > > > prefix  
> > > > > namespace separator, and don't want to do the boring replace()  
> > > > > process  
> > > > > all the time.  
> > > > > I've thoroughly noticed your advice here:
> > 
> > > > \<  
> > > > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-character](http://elasticsearch-users.115913.n3.nabble.com/Using-space-character)...\>  
> > > > [http://elasticsearch-users.115913.n3.nabble.com/Using-space-character](http://elasticsearch-users.115913.n3.nabble.com/Using-space-character).  
> > > > ..
> > > > 
> > > > > . So, can you please show me where I can find naming guidelines for  
> > > > > field name?  
> > > > > Thanks a lot.
> > 
> > > --  
> > > Le Truong Vinh Phu
> > 
> > --  
> > Le Truong Vinh Phu

---

<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, 3:53am UTC](https://discuss.elastic.co/t/problem-with-colon-in-fieldname-where-can-i-find-naming-guidelines/5437/9 "2017-07-06T03:53:40Z")

</div>


