# Using space characters in a field's name

**URL:** <https://discuss.elastic.co/t/using-space-characters-in-a-fields-name/4177>\
**Category:** Elasticsearch\
**Created:** [March 31, 2011, 8:41pm UTC](https://discuss.elastic.co/t/using-space-characters-in-a-fields-name/4177 "2011-03-31T20:41:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lar\_Mader](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lar\_Mader](https://discuss.elastic.co/u/Lar_Mader)\
**Post date:** [March 31, 2011, 8:41pm UTC](https://discuss.elastic.co/t/using-space-characters-in-a-fields-name/4177/1 "2011-03-31T20:41:05Z")

</div>

I apologize in advance if this question has been addressed, but I  
haven't been able to find it.

I have a document that I want to index that would look something like  
this:

{  
"description":"foo",  
"field name with spaces in it":"test"  
}

Note that the second field name has spaces in it. This seems to break  
the ability to then query on that field name. That is, I am  
constructing a QueryStringQueryBuilder using the Java API like this:

QueryBuilders.queryString("field name with spaces in it:"test"");

But this query never finds the document. Is there a way to do this?  
Perhaps there is a way to escape the space characters or something?

Thanks,  
lmader

---

<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:** [March 31, 2011, 9:05pm UTC](https://discuss.elastic.co/t/using-space-characters-in-a-fields-name/4177/2 "2011-03-31T21:05:33Z")

</div>

Spaces in field names will lead to all sorts of problems, its best/crucial to avoid them.  
On Thursday, March 31, 2011 at 10:41 PM, lmader wrote:

> I apologize in advance if this question has been addressed, but I  
> haven't been able to find it.
> 
> I have a document that I want to index that would look something like  
> this:
> 
> {  
> "description":"foo",  
> "field name with spaces in it":"test"  
> }
> 
> Note that the second field name has spaces in it. This seems to break  
> the ability to then query on that field name. That is, I am  
> constructing a QueryStringQueryBuilder using the Java API like this:
> 
> QueryBuilders.queryString("field name with spaces in it:"test"");
> 
> But this query never finds the document. Is there a way to do this?  
> Perhaps there is a way to escape the space characters or something?
> 
> Thanks,  
> lmader

---

<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, 4:09am UTC](https://discuss.elastic.co/t/using-space-characters-in-a-fields-name/4177/3 "2017-07-06T04:09:01Z")

</div>


