# Facet not working for Email fields in ES version 16.0

**URL:** <https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302>\
**Category:** Elasticsearch\
**Created:** [April 27, 2011, 12:15pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302 "2011-04-27T12:15:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [April 27, 2011, 12:15pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/1 "2011-04-27T12:15:37Z")

</div>

Hi All,

I had inserted a value "xxxx@gmail.com,yyyy@yahoo.com,zzzz@rediff.com"  
for a field named  
"fromfield"

1. I am using the below query for faceting in ES15.2 version and also  
in ES16.0 version

{ "query" : { "match\_all" : { } }, "from" : 0, "size" : 0, "facets" :  
{"tagfromfield" : { "terms" : { "field" :"fromfield" ,"regex" :  
".\*" ,"regex\_flags" : "DOTALL","size" : 1000 } } , "global" : false },  
"explain" : false }

In ES 15.2 I am getting the result as

[xxxx@gmail.com](mailto:xxxx@gmail.com)  
[yyyy@yahoo.com](mailto:yyyy@yahoo.com)  
[zzzz@rediff.com](mailto:zzzz@rediff.com)

but in ES 16.0 version I am getting the result as

xxxx  
[gmail.com](http://gmail.com)  
yyyy

> **[Yahoo](https://www.yahoo.com/)**
>
> News, email and search are just the beginning. Discover more every day. Find your yodel.

  
zzzz  
[rediff.com](http://rediff.com)

What is solution to get separate email id's while faceting in ES  
16.0 ...........

---

<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:** [April 27, 2011, 12:21pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/2 "2011-04-27T12:21:00Z")

</div>

Hi Senthil

> I had inserted a value "[xxxx@gmail.com](mailto:xxxx@gmail.com),yyyy@yahoo.com,zzzz@rediff.com"  
> for a field named  
> "fromfield"

> but in ES 16.0 version I am getting the result as
> 
> xxxx  
> [gmail.com](http://gmail.com)  
> yyyy  
> [yahoo.com](http://yahoo.com)  
> zzzz  
> [rediff.com](http://rediff.com)

You will need to set the mapping for the fromfield to use  
{"type": "string", "index": "not\_analyzed"}

clint

---

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [April 27, 2011, 12:52pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/3 "2011-04-27T12:52:05Z")

</div>

Hi Clinton

I have tried the below Gist query but i am getting the same problem  
with not\_analyzed mapping...

$ curl -XPUT '[http://localhost:9200/dbmail1/](http://localhost:9200/dbmail1/)'  
{"ok":true,"acknowledged":true}

$ curl -XPUT '[http://localhost:9200/dbmail1/metadata/\_mapping](http://localhost:9200/dbmail1/metadata/_mapping)' -d  
'{"metadata" : {"dynamic" :"true","\_source" :  
{"enabled" :true },"properties" : {"fromfi  
eld" : {"type" :"string","index" :"not\_analyzed"}} } }'  
{"ok":true,"acknowledged":true}

$ curl -XPUT '[http://localhost:9200/dbmail1/metadata/1](http://localhost:9200/dbmail1/metadata/1)' -d  
'{"fromfield":"[zzzz@rediff.com,aaaa@hhh.com,llll@kkkk.com]"}'  
{"ok":true,"\_index":"dbmail1","\_type":"metadata","\_id":"4","\_version":  
1}

$ curl -XPUT '[http://localhost:9200/dbmail1/metadata/2](http://localhost:9200/dbmail1/metadata/2)' -d  
'{"[fromfield":"zzzz@rediff.com](mailto:fromfield%22:%22zzzz@rediff.com),aaaa@hhh.com,llll@kkkk.com"}'  
{"ok":true,"\_index":"dbmail1","\_type":"metadata","\_id":"5","\_version":  
1}

$ curl -XGET '[http://localhost:9200/dbmail1/metadata/\_search](http://localhost:9200/dbmail1/metadata/_search)' -d  
'{ "query" : { "match\_all" : { } }, "from" : 0, "size" : 0, "facets" :  
{"tagfromfield" : {  
"terms" : { "field" :"fromfield" ,"regex" :".\*" ,"regex\_flags" :  
"DOTALL","size" : 1000 } } , "global" : false },"explain" : false }'

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
5,"failed":0},"hits":{"total":5,"max\_score":1.0,"hits":},"facets":  
{"tagfromfield":{"\_type":"term  
s","missing":0,"terms":  
[{"[term":"zzzz@rediff.com](mailto:term%22:%22zzzz@rediff.com),aaaa@hhh.com,llll@kkkk.com","count":1},  
{"term":"[zzzz@rediff.com,aaaa@hhh.com,llll@kkkk.com]","count":1}]}}}

I need the result like...

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
5,"failed":0},"hits":{"total":5,"max\_score":1.0,"hits":},"facets":  
{"tagfromfield":{"\_type":"term  
s","missing":0,"terms":[{"[term":"zzzz@rediff.com](mailto:term%22:%22zzzz@rediff.com)","count":2},  
{"[term":"aaaa@hhh.com](mailto:term%22:%22aaaa@hhh.com)","count":2},{"[term":"llll@kkkk.com](mailto:term%22:%22llll@kkkk.com)","count":  
2}]}}}

On Apr 27, 5:21 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi Senthil
> 
> > I had inserted a value "[x...@gmail.com](mailto:x...@gmail.com),y...@yahoo.com,z...@rediff.com"  
> > for a field named  
> > "fromfield"  
> > but in ES 16.0 version I am getting the result as
> 
> > xxxx  
> > [gmail.com](http://gmail.com)  
> > yyyy  
> > [yahoo.com](http://yahoo.com)  
> > zzzz  
> > [rediff.com](http://rediff.com)
> 
> You will need to set the mapping for the fromfield to use  
> {"type": "string", "index": "not\_analyzed"}
> 
> clint

---

<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:** [April 27, 2011, 1:03pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/4 "2011-04-27T13:03:07Z")

</div>

Hi Senthil

> $ curl -XPUT '[http://localhost:9200/dbmail1/metadata/1](http://localhost:9200/dbmail1/metadata/1)' -d   
> '{"fromfield":"[zzzz@rediff.com,aaaa@hhh.com,llll@kkkk.com]"}'

Your JSON is wrong. It should be:

curl -XPUT '[http://localhost:9200/dbmail1/metadata/1](http://localhost:9200/dbmail1/metadata/1)' -d   
'{"fromfield":["[zzzz@rediff.com](mailto:zzzz@rediff.com)","aaaa@hhh.com","llll@kkkk.com"]}'

clint

---

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [April 27, 2011, 1:28pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/5 "2011-04-27T13:28:52Z")

</div>

But i have tried the same query in version 15.2 it's working fine....

On Apr 27, 6:03 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi Senthil
> 
> > $ curl -XPUT '[http://localhost:9200/dbmail1/metadata/1'-d](http://localhost:9200/dbmail1/metadata/1'-d)   
> > '{"fromfield":"[z...@rediff.com,a...@hhh.com,l...@kkkk.com]"}'
> 
> Your JSON is wrong. It should be:
> 
> curl -XPUT '[http://localhost:9200/dbmail1/metadata/1'-d](http://localhost:9200/dbmail1/metadata/1'-d)   
> '{"fromfield":["[z...@rediff.com](mailto:z...@rediff.com)","a...@hhh.com","l...@kkkk.com"]}'
> 
> clint

---

<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:** [April 28, 2011, 11:38am UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/6 "2011-04-28T11:38:12Z")

</div>

The way emails are broken down into terms has changed. Before, the mail was a single token/term, now, its broken down into several terms. You should specify it as not\_analyzed.  
On Wednesday, April 27, 2011 at 4:28 PM, senthil prabhu wrote:

> But i have tried the same query in version 15.2 it's working fine....
> 
> On Apr 27, 6:03 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:
> 
> > Hi Senthil
> > 
> > > $ curl -XPUT '[http://localhost:9200/dbmail1/metadata/1'-d](http://localhost:9200/dbmail1/metadata/1'-d)   
> > > '{"fromfield":"[z...@rediff.com,a...@hhh.com,l...@kkkk.com]"}'
> > 
> > Your JSON is wrong. It should be:
> > 
> > curl -XPUT '[http://localhost:9200/dbmail1/metadata/1'-d](http://localhost:9200/dbmail1/metadata/1'-d)   
> > '{"fromfield":["[z...@rediff.com](mailto:z...@rediff.com)","a...@hhh.com","l...@kkkk.com"]}'
> > 
> > clint

---

<div class="post-metadata">

**Author:** ![srrin](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@srrin](https://discuss.elastic.co/u/srrin)\
**Post date:** [April 30, 2011, 3:13pm UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/7 "2011-04-30T15:13:58Z")

</div>

Hi Shay,  
Thank you. Since the emails are broken in to multiple terms, do we need to re-index the existing indexes if I upgrade to 0.16.0?

Is there any other work around to achieve this without re-indexing?

Thanks  
SRR

---

<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:** [May 1, 2011, 7:26am UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/8 "2011-05-01T07:26:33Z")

</div>

You can keep the same analysis logic you had before in 0.15. Not sure regarding your analysis configuration, but a simple option can be to set the default analyzer to work in a similar manner to Lucene 3.0. Here is a sample of how to do it: [gist:950318 · GitHub](https://gist.github.com/950318) (you can configure it on the elasticsearch.json config file, or convert it to a yaml file).  
On Saturday, April 30, 2011 at 6:13 PM, srrIN wrote:

> Hi Shay, Thank you. Since the emails are broken in to multiple terms, do we need to re-index the existing indexes if I upgrade to 0.16.0? Is there any other work around to achieve this without re-indexing? Thanks SRR  
> View this message in context: Re: Facet not working for Email fields in ES version 16.0  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:07am UTC](https://discuss.elastic.co/t/facet-not-working-for-email-fields-in-es-version-16-0/4302/9 "2017-07-06T04:07:14Z")

</div>


