# Elasticsearch splits field by space on facets

**URL:** https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992
**Category:** Elasticsearch
**Created:** [September 11, 2012, 2:14pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992 "2012-09-11T14:14:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pere\_roca\_ristol](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@pere\_roca\_ristol](https://discuss.elastic.co/u/pere_roca_ristol)
#### Post date: [September 11, 2012, 2:14pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/1 "2012-09-11T14:14:28Z")

</div>

I am tryingo to do a simple facet request over a field having more than a  
simple word (simply 'Name1 Name2', sometimes with dots and commas inside)  
but what I get is...

"terms" : [{  
"term" : "Name1",  
"count" : 15  
},  
{  
"term" : "Name2",  
"count" : 15  
}]

so my field is splitted by spaces and then runs the facet request...

Query example:

curl -XGET http://my\_server:9200/idx\_occurrence/Occurrence/\_search?pretty=true  
-d '{ "query": { "query\_string" :{ "fields" : ["dataset"], "query": "2",  
"default\_operator" : "AND" } }, "facets": { "test": { "terms":  
{ "field" :["speciesName"],"size" : 50000 } } } }'

thanks in advance

--

---

<div class="post-metadata">

### Author: ![Rio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rio/32/2728_2.png) [@Rio](https://discuss.elastic.co/u/Rio)
#### Post date: [September 11, 2012, 2:32pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/2 "2012-09-11T14:32:32Z")

</div>

So you want to get the facets returned based on the full key field?

I'm actually try to do the same thing and didn't get any response:  
[https://groups.google.com/forum/?fromgroups=#!topic/elasticsearch/TEcXc4UhXTI](https://groups.google.com/forum/?fromgroups=#!topic/elasticsearch/TEcXc4UhXTI)

Hopefully someone has some helpful suggestions.

-Mario

--

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [September 11, 2012, 3:01pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/3 "2012-09-11T15:01:58Z")

</div>

The speciesName field needs to be not analyzed. All the tokens are  
tokens are appearing because the field is being analyzed.

--  
Ivan

On Tue, Sep 11, 2012 at 7:14 AM, pere roca ristol [peroc79@gmail.com](mailto:peroc79@gmail.com) wrote:

> I am tryingo to do a simple facet request over a field having more than a  
> simple word (simply 'Name1 Name2', sometimes with dots and commas inside)  
> but what I get is...
> 
> "terms" : [{  
> "term" : "Name1",  
> "count" : 15  
> },  
> {  
> "term" : "Name2",  
> "count" : 15  
> }]
> 
> so my field is splitted by spaces and then runs the facet request...
> 
> Query example:
> 
> curl -XGET  
> http://my\_server:9200/idx\_occurrence/Occurrence/\_search?pretty=true  
> -d '{ "query": { "query\_string" :{ "fields" : ["dataset"], "query": "2",  
> "default\_operator" : "AND" } }, "facets": { "test": { "terms":  
> { "field" :["speciesName"],"size" : 50000 } } } }'
> 
> thanks in advance
> 
> --

--

---

<div class="post-metadata">

### Author: ![pere\_roca\_ristol](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@pere\_roca\_ristol](https://discuss.elastic.co/u/pere_roca_ristol)
#### Post date: [September 11, 2012, 3:28pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/4 "2012-09-11T15:28:11Z")

</div>

thanks Ivan.

In fact I need it to be analyzed for other operations. So I think I  
should apply the multi-field [http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)

I'am afraid i have no alternative than re-constructing the data with this  
multi-field option or there is some way to avoid that?

thanks,

Pere

On Tuesday, 11 September 2012 17:02:02 UTC+2, Ivan Brusic wrote:

> The speciesName field needs to be not analyzed. All the tokens are  
> tokens are appearing because the field is being analyzed.
> 
> --  
> Ivan
> 
> On Tue, Sep 11, 2012 at 7:14 AM, pere roca ristol \<[per...@gmail.com](mailto:per...@gmail.com)\<javascript:\>\>  
> wrote:
> 
> > I am tryingo to do a simple facet request over a field having more than  
> > a  
> > simple word (simply 'Name1 Name2', sometimes with dots and commas  
> > inside)  
> > but what I get is...
> > 
> > "terms" : [{  
> > "term" : "Name1",  
> > "count" : 15  
> > },  
> > {  
> > "term" : "Name2",  
> > "count" : 15  
> > }]
> > 
> > so my field is splitted by spaces and then runs the facet request...
> > 
> > Query example:
> > 
> > curl -XGET  
> > http://my\_server:9200/idx\_occurrence/Occurrence/\_search?pretty=true  
> > -d '{ "query": { "query\_string" :{ "fields" : ["dataset"], "query": "2",  
> > "default\_operator" : "AND" } }, "facets": { "test": { "terms":  
> > { "field" :["speciesName"],"size" : 50000 } } } }'
> > 
> > thanks in advance
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [September 11, 2012, 4:15pm UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/5 "2012-09-11T16:15:58Z")

</div>

Pere,

Your use case is exactly why multi-field is used: the field needs to  
be analyzed for some situations and not analyzed for others.

You can simply create another field in your indexing code instead of  
using Elasticsearch's built-in multi-field, but in either way you  
would need to reindex your data.

--  
Ivan

On Tue, Sep 11, 2012 at 8:28 AM, pere roca ristol [peroc79@gmail.com](mailto:peroc79@gmail.com) wrote:

> thanks Ivan.
> 
> In fact I need it to be analyzed for other operations. So I think I should  
> apply the multi-field
> 
> I'am afraid i have no alternative than re-constructing the data with this  
> multi-field option or there is some way to avoid that?
> 
> thanks,
> 
> Pere
> 
> On Tuesday, 11 September 2012 17:02:02 UTC+2, Ivan Brusic wrote:
> 
> > The speciesName field needs to be not analyzed. All the tokens are  
> > tokens are appearing because the field is being analyzed.
> > 
> > --  
> > Ivan
> > 
> > On Tue, Sep 11, 2012 at 7:14 AM, pere roca ristol [per...@gmail.com](mailto:per...@gmail.com)  
> > wrote:
> > 
> > > I am tryingo to do a simple facet request over a field having more than  
> > > a  
> > > simple word (simply 'Name1 Name2', sometimes with dots and commas  
> > > inside)  
> > > but what I get is...
> > > 
> > > "terms" : [{  
> > > "term" : "Name1",  
> > > "count" : 15  
> > > },  
> > > {  
> > > "term" : "Name2",  
> > > "count" : 15  
> > > }]
> > > 
> > > so my field is splitted by spaces and then runs the facet request...
> > > 
> > > Query example:
> > > 
> > > curl -XGET  
> > > http://my\_server:9200/idx\_occurrence/Occurrence/\_search?pretty=true  
> > > -d '{ "query": { "query\_string" :{ "fields" : ["dataset"], "query": "2",  
> > > "default\_operator" : "AND" } }, "facets": { "test": { "terms":  
> > > { "field" :["speciesName"],"size" : 50000 } } } }'
> > > 
> > > thanks in advance
> > > 
> > > --
> 
> --

--

---

<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:13am UTC](https://discuss.elastic.co/t/elasticsearch-splits-field-by-space-on-facets/8992/6 "2017-07-06T03:13:10Z")

</div>


