# Term facets - getting result after splitting the filed WRT space

**URL:** https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025
**Category:** Elasticsearch
**Created:** [November 30, 2011, 1:49pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025 "2011-11-30T13:49:35Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [November 30, 2011, 1:49pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/1 "2011-11-30T13:49:35Z")

</div>

Hi ,  
If i run term facet on a particular field , i am getting the result of  
terms after splitting the filed WRT space.  
For eg :

If the fields are - "Mr King","King Kong","Mr CEO","CEO OF" , "Mr King"  
After running term facet on this

{  
"facets": {  
"Categories": {  
"terms": {  
"field": "Name",  
"size": 10  
}  
}  
}  
}

Am getting the result as

"Mr" - 3  
"King" - 3  
Kong - 1  
CEO - 2  
OF -1

What i expected was

"Mr King" - 2  
"King Kong"-1  
"Mr CEO" - 1

And so on...

Is this the right behavior.  
If it is , what is the other alternative to the desired output.

Thanks  
Vineeth

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [November 30, 2011, 1:58pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/2 "2011-11-30T13:58:40Z")

</div>

On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan wrote:

> Hi ,  
> If i run term facet on a particular field , i am getting the result of  
> terms after splitting the filed WRT space.

This is correct - your field is being analyzed so what is stored is the  
result of that analysis (ie 'mr', 'king', 'kong', etc)

If you want the original phrase to be preserved, then you should map  
that field to have {"index": "not\_analyzed"}

However, that has implications for searching too, because you then  
wouldn't be able to search for "king".

If you want to be able to do both, then you should use multi-fields,  
with one sub-field analyzed (for searching), and one sub-field not  
analyzed (for facets)

clint

> For eg :
> 
> If the fields are - "Mr King","King Kong","Mr CEO","CEO OF" , "Mr  
> King"  
> After running term facet on this
> 
> {  
> "facets": {  
> "Categories": {  
> "terms": {  
> "field": "Name",  
> "size": 10  
> }  
> }  
> }  
> }
> 
> Am getting the result as
> 
> "Mr" - 3  
> "King" - 3  
> Kong - 1  
> CEO - 2  
> OF -1
> 
> What i expected was
> 
> "Mr King" - 2  
> "King Kong"-1  
> "Mr CEO" - 1
> 
> And so on...
> 
> Is this the right behavior.  
> If it is , what is the other alternative to the desired output.
> 
> Thanks  
> Vineeth

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [November 30, 2011, 2:07pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/3 "2011-11-30T14:07:01Z")

</div>

I have a particular field whose key name is not known before hand.

So the scema looks like

Entities : { name : vm , vm : [{name : abc } , {name : bcd}]}

Here VM is not know before hand and i want to make field Entities.X.name as  
faceting field.  
How will i do index: not\_analyzed for name alone ?

Thanks  
Vineeth

On Wed, Nov 30, 2011 at 7:28 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan wrote:
> 
> > Hi ,  
> > If i run term facet on a particular field , i am getting the result of  
> > terms after splitting the filed WRT space.
> 
> This is correct - your field is being analyzed so what is stored is the  
> result of that analysis (ie 'mr', 'king', 'kong', etc)
> 
> If you want the original phrase to be preserved, then you should map  
> that field to have {"index": "not\_analyzed"}
> 
> However, that has implications for searching too, because you then  
> wouldn't be able to search for "king".
> 
> If you want to be able to do both, then you should use multi-fields,  
> with one sub-field analyzed (for searching), and one sub-field not  
> analyzed (for facets)
> 
> clint
> 
> > For eg :
> > 
> > If the fields are - "Mr King","King Kong","Mr CEO","CEO OF" , "Mr  
> > King"  
> > After running term facet on this
> > 
> > {  
> > "facets": {  
> > "Categories": {  
> > "terms": {  
> > "field": "Name",  
> > "size": 10  
> > }  
> > }  
> > }  
> > }
> > 
> > Am getting the result as
> > 
> > "Mr" - 3  
> > "King" - 3  
> > Kong - 1  
> > CEO - 2  
> > OF -1
> > 
> > What i expected was
> > 
> > "Mr King" - 2  
> > "King Kong"-1  
> > "Mr CEO" - 1
> > 
> > And so on...
> > 
> > Is this the right behavior.  
> > If it is , what is the other alternative to the desired output.
> > 
> > Thanks  
> > Vineeth

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [November 30, 2011, 2:14pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/4 "2011-11-30T14:14:33Z")

</div>

So the question is more like how will i change the default of index to  
not\_analyzed for those field which are not specified in the schema.

Thanks  
Vineeth

On Wed, Nov 30, 2011 at 7:37 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> I have a particular field whose key name is not known before hand.
> 
> So the scema looks like
> 
> Entities : { name : vm , vm : [{name : abc } , {name : bcd}]}
> 
> Here VM is not know before hand and i want to make field Entities.X.nameas faceting field.  
> How will i do index: not\_analyzed for name alone ?
> 
> Thanks  
> Vineeth
> 
> On Wed, Nov 30, 2011 at 7:28 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan wrote:
> > 
> > > Hi ,  
> > > If i run term facet on a particular field , i am getting the result of  
> > > terms after splitting the filed WRT space.
> > 
> > This is correct - your field is being analyzed so what is stored is the  
> > result of that analysis (ie 'mr', 'king', 'kong', etc)
> > 
> > If you want the original phrase to be preserved, then you should map  
> > that field to have {"index": "not\_analyzed"}
> > 
> > However, that has implications for searching too, because you then  
> > wouldn't be able to search for "king".
> > 
> > If you want to be able to do both, then you should use multi-fields,  
> > with one sub-field analyzed (for searching), and one sub-field not  
> > analyzed (for facets)
> > 
> > clint
> > 
> > > For eg :
> > > 
> > > If the fields are - "Mr King","King Kong","Mr CEO","CEO OF" , "Mr  
> > > King"  
> > > After running term facet on this
> > > 
> > > {  
> > > "facets": {  
> > > "Categories": {  
> > > "terms": {  
> > > "field": "Name",  
> > > "size": 10  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Am getting the result as
> > > 
> > > "Mr" - 3  
> > > "King" - 3  
> > > Kong - 1  
> > > CEO - 2  
> > > OF -1
> > > 
> > > What i expected was
> > > 
> > > "Mr King" - 2  
> > > "King Kong"-1  
> > > "Mr CEO" - 1
> > > 
> > > And so on...
> > > 
> > > Is this the right behavior.  
> > > If it is , what is the other alternative to the desired output.
> > > 
> > > Thanks  
> > > Vineeth

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [November 30, 2011, 2:49pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/5 "2011-11-30T14:49:41Z")

</div>

On Wed, 2011-11-30 at 19:44 +0530, Vineeth Mohan wrote:

> So the question is more like how will i change the default of index to  
> not\_analyzed for those field which are not specified in the schema.

Have a look at Dynamic Mapping:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

clint

> Thanks  
> Vineeth
> 
> On Wed, Nov 30, 2011 at 7:37 PM, Vineeth Mohan  
> [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> I have a particular field whose key name is not known before  
> hand.
> 
> ```
> So the scema looks like 
>     
> Entities : { name : vm , vm : [ {name : abc } , {name :
> bcd}]}
>     
> Here VM is not know before hand and i want to make field
> Entities.X.name as faceting field.
> How will i do index: not_analyzed for name alone ?
>     
> Thanks
> Vineeth
>     
>     
>     
> On Wed, Nov 30, 2011 at 7:28 PM, Clinton Gormley
> <clint@traveljury.com> wrote:
> On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan
> wrote:
> > Hi ,
> > If i run term facet on a particular field , i am
> getting the result of
> > terms after splitting the filed WRT space.
>             
>             
> This is correct - your field is being analyzed so what
> is stored is the
> result of that analysis (ie 'mr', 'king', 'kong', etc)
>             
> If you want the original phrase to be preserved, then
> you should map
> that field to have {"index": "not_analyzed"}
>             
> However, that has implications for searching too,
> because you then
> wouldn't be able to search for "king".
>             
> If you want to be able to do both, then you should use
> multi-fields,
> with one sub-field analyzed (for searching), and one
> sub-field not
> analyzed (for facets)
>             
> clint
>             
>             
> > For eg :
> >
> > If the fields are - "Mr King","King Kong","Mr
> CEO","CEO OF" , "Mr
> > King"
> > After running term facet on this
> >
> > {
> > "facets": {
> > "Categories": {
> > "terms": {
> > "field": "Name",
> > "size": 10
> > }
> > }
> > }
> > }
> >
> >
> > Am getting the result as
> >
> > "Mr" - 3
> > "King" - 3
> > Kong - 1
> > CEO - 2
> > OF -1
> >
> > What i expected was
> >
> > "Mr King" - 2
> > "King Kong"-1
> > "Mr CEO" - 1
> >
> > And so on...
> >
> > Is this the right behavior.
> > If it is , what is the other alternative to the
> desired output.
> >
> > Thanks
> > Vineeth
> >
> >
> 
> ```

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [November 30, 2011, 3:22pm UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/6 "2011-11-30T15:22:53Z")

</div>

Ok , i have created the following file

XYZ@XYZ:~/elasticSearch$ cat config/default-mapping.json  
{  
"_default_" : {  
"index" : "not\_analyzed"  
}  
}

But its not helping.... ☹

Is there something i have missed out

Thanks  
Vineeth

On Wed, Nov 30, 2011 at 8:19 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Wed, 2011-11-30 at 19:44 +0530, Vineeth Mohan wrote:
> 
> > So the question is more like how will i change the default of index to  
> > not\_analyzed for those field which are not specified in the schema.
> 
> Have a look at Dynamic Mapping:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html)
> 
> clint
> 
> > Thanks  
> > Vineeth
> > 
> > On Wed, Nov 30, 2011 at 7:37 PM, Vineeth Mohan  
> > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > I have a particular field whose key name is not known before  
> > hand.
> > 
> > ```
> > So the scema looks like
> > 
> > Entities : { name : vm , vm : [ {name : abc } , {name :
> > bcd}]}
> > 
> > Here VM is not know before hand and i want to make field
> > Entities.X.name as faceting field.
> > How will i do index: not_analyzed for name alone ?
> > 
> > Thanks
> > Vineeth
> > 
> > On Wed, Nov 30, 2011 at 7:28 PM, Clinton Gormley
> > <clint@traveljury.com> wrote:
> > On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan
> > wrote:
> > > Hi ,
> > > If i run term facet on a particular field , i am
> > getting the result of
> > > terms after splitting the filed WRT space.
> > 
> > This is correct - your field is being analyzed so what
> > is stored is the
> > result of that analysis (ie 'mr', 'king', 'kong', etc)
> > 
> > If you want the original phrase to be preserved, then
> > you should map
> > that field to have {"index": "not_analyzed"}
> > 
> > However, that has implications for searching too,
> > because you then
> > wouldn't be able to search for "king".
> > 
> > If you want to be able to do both, then you should use
> > multi-fields,
> > with one sub-field analyzed (for searching), and one
> > sub-field not
> > analyzed (for facets)
> > 
> > clint
> > 
> > > For eg :
> > >
> > > If the fields are - "Mr King","King Kong","Mr
> > CEO","CEO OF" , "Mr
> > > King"
> > > After running term facet on this
> > >
> > > {
> > > "facets": {
> > > "Categories": {
> > > "terms": {
> > > "field": "Name",
> > > "size": 10
> > > }
> > > }
> > > }
> > > }
> > >
> > >
> > > Am getting the result as
> > >
> > > "Mr" - 3
> > > "King" - 3
> > > Kong - 1
> > > CEO - 2
> > > OF -1
> > >
> > > What i expected was
> > >
> > > "Mr King" - 2
> > > "King Kong"-1
> > > "Mr CEO" - 1
> > >
> > > And so on...
> > >
> > > Is this the right behavior.
> > > If it is , what is the other alternative to the
> > desired output.
> > >
> > > Thanks
> > > Vineeth
> > >
> > >
> > 
> > ```

---

<div class="post-metadata">

### Author: ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)
#### Post date: [December 1, 2011, 6:28am UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/7 "2011-12-01T06:28:14Z")

</div>

Finally i used dynamic template mapping and get the thing working.

Once again clint saved my day 🙂

Thanks  
Vineeth

On Wed, Nov 30, 2011 at 8:52 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Ok , i have created the following file
> 
> XYZ@XYZ:~/elasticSearch$ cat config/default-mapping.json  
> {  
> "_default_" : {  
> "index" : "not\_analyzed"  
> }  
> }
> 
> But its not helping.... ☹
> 
> Is there something i have missed out
> 
> Thanks  
> Vineeth
> 
> On Wed, Nov 30, 2011 at 8:19 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > On Wed, 2011-11-30 at 19:44 +0530, Vineeth Mohan wrote:
> > 
> > > So the question is more like how will i change the default of index to  
> > > not\_analyzed for those field which are not specified in the schema.
> > 
> > Have a look at Dynamic Mapping:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html)
> > 
> > clint
> > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Wed, Nov 30, 2011 at 7:37 PM, Vineeth Mohan  
> > > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > > I have a particular field whose key name is not known before  
> > > hand.
> > > 
> > > ```
> > > So the scema looks like
> > > 
> > > Entities : { name : vm , vm : [ {name : abc } , {name :
> > > bcd}]}
> > > 
> > > Here VM is not know before hand and i want to make field
> > > Entities.X.name as faceting field.
> > > How will i do index: not_analyzed for name alone ?
> > > 
> > > Thanks
> > > Vineeth
> > > 
> > > On Wed, Nov 30, 2011 at 7:28 PM, Clinton Gormley
> > > <clint@traveljury.com> wrote:
> > > On Wed, 2011-11-30 at 19:19 +0530, Vineeth Mohan
> > > wrote:
> > > > Hi ,
> > > > If i run term facet on a particular field , i am
> > > getting the result of
> > > > terms after splitting the filed WRT space.
> > > 
> > > This is correct - your field is being analyzed so what
> > > is stored is the
> > > result of that analysis (ie 'mr', 'king', 'kong', etc)
> > > 
> > > If you want the original phrase to be preserved, then
> > > you should map
> > > that field to have {"index": "not_analyzed"}
> > > 
> > > However, that has implications for searching too,
> > > because you then
> > > wouldn't be able to search for "king".
> > > 
> > > If you want to be able to do both, then you should use
> > > multi-fields,
> > > with one sub-field analyzed (for searching), and one
> > > sub-field not
> > > analyzed (for facets)
> > > 
> > > clint
> > > 
> > > > For eg :
> > > >
> > > > If the fields are - "Mr King","King Kong","Mr
> > > CEO","CEO OF" , "Mr
> > > > King"
> > > > After running term facet on this
> > > >
> > > > {
> > > > "facets": {
> > > > "Categories": {
> > > > "terms": {
> > > > "field": "Name",
> > > > "size": 10
> > > > }
> > > > }
> > > > }
> > > > }
> > > >
> > > >
> > > > Am getting the result as
> > > >
> > > > "Mr" - 3
> > > > "King" - 3
> > > > Kong - 1
> > > > CEO - 2
> > > > OF -1
> > > >
> > > > What i expected was
> > > >
> > > > "Mr King" - 2
> > > > "King Kong"-1
> > > > "Mr CEO" - 1
> > > >
> > > > And so on...
> > > >
> > > > Is this the right behavior.
> > > > If it is , what is the other alternative to the
> > > desired output.
> > > >
> > > > Thanks
> > > > Vineeth
> > > >
> > > >
> > > 
> > > ```

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [December 1, 2011, 9:51am UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/8 "2011-12-01T09:51:52Z")

</div>

On Thu, 2011-12-01 at 11:58 +0530, Vineeth Mohan wrote:

> Finally i used dynamic template mapping and get the thing working.
> 
> Once again clint saved my day 🙂

Perhaps I should do the Elasticsearch thing and take a new super-hero  
name every morning 🙂

glad it helped

clint

---

<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:46am UTC](https://discuss.elastic.co/t/term-facets-getting-result-after-splitting-the-filed-wrt-space/6025/9 "2017-07-06T03:46:48Z")

</div>


