# Searching on Email id's not happening in 16.0

**URL:** <https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342>\
**Category:** Elasticsearch\
**Created:** [May 4, 2011, 10:08am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342 "2011-05-04T10:08:04Z")\
**Posts on this page:** 8\
**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:** [May 4, 2011, 10:08am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/1 "2011-05-04T10:08:04Z")

</div>

Hi All,

I am using the below mapping in both version 15.2 and 16.0

"mail\_from" : {"type" :"string","store" :"yes","format" :"MMM/dd/yyyy  
HH:mm:ss","term\_vector" :"with\_positions\_offsets","index" :"analyzed","index\_name" :"mail\_from","omit\_term\_freq\_and\_positions" :false,"omit\_norms" :false,"precision\_step" :  
4,"index\_analyzer" :"standard" }

But I didn't retrieve any documents while searching for email id's in  
version 16.0.

---

<div class="post-metadata">

**Author:** ![ofavre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ofavre/32/116819_2.png) [@ofavre](https://discuss.elastic.co/u/ofavre)\
**Post date:** [May 4, 2011, 10:18am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/2 "2011-05-04T10:18:14Z")

</div>

Hi,

You should use the ids query.  
See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/ids-query.html)

The \_id field is no longer indexed, see the first breaking change listed  
here:

> **[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.

Regards,  
Olivier @Yakaz

2011/5/4 senthil prabhu [via Elasticsearch Users] \<  
[ml-node+2898126-1082462395-393975@n3.nabble.com](mailto:ml-node+2898126-1082462395-393975@n3.nabble.com)\>

> Hi All,
> 
> I am using the below mapping in both version 15.2 and 16.0
> 
> "mail\_from" : {"type" :"string","store" :"yes","format" :"MMM/dd/yyyy  
> HH:mm:ss","term\_vector" :"with\_positions\_offsets","index"  
> :"analyzed","index\_name" :"mail\_from","omit\_term\_freq\_and\_positions"  
> :false,"omit\_norms" :false,"precision\_step" :  
> 4,"index\_analyzer" :"standard" }
> 
> But I didn't retrieve any documents while searching for email id's in  
> version 16.0.
> 
> * * *
> 
> If you reply to this email, your message will be added to the discussion  
> below:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id-s-not-happening-in-16-0-tp2898126p2898126.html](http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id-s-not-happening-in-16-0-tp2898126p2898126.html)  
> To start a new topic under Elasticsearch Users, email  
> [ml-node+115913-1699315842-393975@n3.nabble.com](mailto:ml-node+115913-1699315842-393975@n3.nabble.com)  
> To unsubscribe from Elasticsearch Users, click here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe\_by\_code&node=115913&code=b2xpdmllckB5YWthei5jb218MTE1OTEzfDIxMjI2MTYwOTc=](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=115913&code=b2xpdmllckB5YWthei5jb218MTE1OTEzfDIxMjI2MTYwOTc=).

---

<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:** [May 4, 2011, 10:50am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/3 "2011-05-04T10:50:06Z")

</div>

thank you.... My doubt is searching on emails ("senthil@gamil") not  
working in version 16.0... What i need to do ...?

On May 4, 3:18 pm, ofavre [oliv...@yakaz.com](mailto:oliv...@yakaz.com) wrote:

> Hi,
> 
> You should use the ids query.  
> Seehttp://www.elasticsearch.org/guide/reference/query-dsl/ids-query.html
> 
> The \_id field is no longer indexed, see the first breaking change listed  
> here:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/download/2011/04/23/0.16.0.html)
> 
> Regards,  
> Olivier @Yakaz
> 
> 2011/5/4 senthil prabhu [via Elasticsearch Users] \<  
> [ml-node+2898126-1082462395-393...@n3.nabble.com](mailto:ml-node+2898126-1082462395-393...@n3.nabble.com)\>
> 
> > Hi All,
> 
> > I am using the below mapping in both version 15.2 and 16.0
> 
> > "mail\_from" : {"type" :"string","store" :"yes","format" :"MMM/dd/yyyy  
> > HH:mm:ss","term\_vector" :"with\_positions\_offsets","index"  
> > :"analyzed","index\_name" :"mail\_from","omit\_term\_freq\_and\_positions"  
> > :false,"omit\_norms" :false,"precision\_step" :  
> > 4,"index\_analyzer" :"standard" }
> 
> > But I didn't retrieve any documents while searching for email id's in  
> > version 16.0.
> 
> > * * *
> > 
> > If you reply to this email, your message will be added to the discussion  
> > below:
> 
> > [http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id](http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id)...  
> > To start a new topic under Elasticsearch Users, email  
> > [ml-node+115913-1699315842-393...@n3.nabble.com](mailto:ml-node+115913-1699315842-393...@n3.nabble.com)  
> > To unsubscribe from Elasticsearch Users, click here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....).
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id](http://elasticsearch-users.115913.n3.nabble.com/Searching-on-Email-id)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:** [May 4, 2011, 10:57am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/4 "2011-05-04T10:57:47Z")

</div>

On Wed, 2011-05-04 at 03:50 -0700, senthil prabhu wrote:

> thank you.... My doubt is searching on emails ("senthil@gamil") not  
> working in version 16.0... What i need to do ...?

The first thing that you need to do is to provide an example of what you  
are already doing. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

Also, why do you have a date format in a string property?

> > > "mail\_from" : {"type" :"string","store" :"yes","format" :"MMM/dd/yyyy  
> > > HH:mm:ss","term\_vector" :"with\_positions\_offsets","index"  
> > > :"analyzed","index\_name" :"mail\_from","omit\_term\_freq\_and\_positions"  
> > > :false,"omit\_norms" :false,"precision\_step" :  
> > > 4,"index\_analyzer" :"standard" }

Emails are analyzed differently in 0.16, using the standard analyzer.

So if you are doing a term query for the email, you won't find it. In  
0.15, the email "[senthil@gmail.com](mailto:senthil@gmail.com)" would have resulted in the term  
"[senthil@gmail.com](mailto:senthil@gmail.com)". In 0.16, it results in the terms  
"senthil","gmail","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:** [May 4, 2011, 11:18am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/5 "2011-05-04T11:18:18Z")

</div>

Ya you are exactly right...

1.) What type of mapping that i need to use to get the full email  
while search?  
or what type search query that i need to use instead of term  
query ?

On May 4, 3:57 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> On Wed, 2011-05-04 at 03:50 -0700, senthil prabhu wrote:
> 
> > thank you.... My doubt is searching on emails ("senthil@gamil") not  
> > working in version 16.0... What i need to do ...?
> 
> The first thing that you need to do is to provide an example of what you  
> are already doing. Seehttp://www.elasticsearch.org/help
> 
> Also, why do you have a date format in a string property?
> 
> > > > "mail\_from" : {"type" :"string","store" :"yes","format" :"MMM/dd/yyyy  
> > > > HH:mm:ss","term\_vector" :"with\_positions\_offsets","index"  
> > > > :"analyzed","index\_name" :"mail\_from","omit\_term\_freq\_and\_positions"  
> > > > :false,"omit\_norms" :false,"precision\_step" :  
> > > > 4,"index\_analyzer" :"standard" }
> 
> Emails are analyzed differently in 0.16, using the standard analyzer.
> 
> So if you are doing a term query for the email, you won't find it. In  
> 0.15, the email "[sent...@gmail.com](mailto:sent...@gmail.com)" would have resulted in the term  
> "[sent...@gmail.com](mailto:sent...@gmail.com)". In 0.16, it results in the terms  
> "senthil","gmail","com"
> 
> 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:** [May 4, 2011, 11:35am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/6 "2011-05-04T11:35:49Z")

</div>

On Wed, 2011-05-04 at 04:18 -0700, senthil prabhu wrote:

> Ya you are exactly right...
> 
> 1.) What type of mapping that i need to use to get the full email  
> while search?  
> or what type search query that i need to use instead of term  
> query ?

You have a few choices.

With your existing mapping, if your mail\_from field contains exactly one  
email address, then you could use a query string search, and put the  
email address into double quotes, eg: '"[senthil@gmail.com](mailto:senthil@gmail.com)"'

However that would also find "[foobar.senthil@gmail.com](mailto:foobar.senthil@gmail.com)"

So if you want to use the email address as a unique ID, you probably do  
want to do a term query, and you could set the mail\_from property to  
{"type": "string", "index":"not\_analyzed"}

However, the term "[senthil@gmail.com](mailto:senthil@gmail.com)" is not the same as the term  
"[Senthil@GMAIL.com](mailto:Senthil@GMAIL.com)"

So make sure that you lowercase both the data that you index, and the  
term that you search for. (and you may need to trim any leading or  
trailing whitespace as well)

Also, would you want to do searches for any email address containing  
"senthil" or "gmail"?

If so, then you need both the not\_analyzed field, and an analyzed field.  
You could do this with a multi field:

curl -XPUT '[http://127.0.0.1:9200/foo/email/\_mapping?pretty=1](http://127.0.0.1:9200/foo/email/_mapping?pretty=1)' -d '  
{  
"email" : {  
"properties" : {  
"mail\_from" : {  
"fields" : {  
"id" : {  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"mail\_from" : {  
"index" : "analyzed",  
"type" : "string"  
}  
},  
"type" : "multi\_field"  
}  
}  
}  
}  
'

See [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)

Then you can use these as follows:

## Search for "gmail":

curl -XGET '[http://127.0.0.1:9200/foo/mail/\_search?pretty=1](http://127.0.0.1:9200/foo/mail/_search?pretty=1)' -d '  
{  
"query" : {  
"field" : {  
"mail\_from" : "gmail"  
}  
}  
}  
'

## Find exactly "[senthil@gmail.com](mailto:senthil@gmail.com)":

curl -XGET '[http://127.0.0.1:9200/foo/mail/\_search?pretty=1](http://127.0.0.1:9200/foo/mail/_search?pretty=1)' -d '  
{  
"query" : {  
"constant\_score" : {  
"filter" : {  
"term" : {  
"mail\_from.id" : "[senthil@gmail.com](mailto:senthil@gmail.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:** [May 4, 2011, 11:46am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/7 "2011-05-04T11:46:32Z")

</div>

thank you very Clinton....

On May 4, 4:35 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> On Wed, 2011-05-04 at 04:18 -0700, senthil prabhu wrote:
> 
> > Ya you are exactly right...
> 
> > 1.) What type of mapping that i need to use to get the full email  
> > while search?  
> > or what type search query that i need to use instead of term  
> > query ?
> 
> You have a few choices.
> 
> With your existing mapping, if your mail\_from field contains exactly one  
> email address, then you could use a query string search, and put the  
> email address into double quotes, eg: '"[sent...@gmail.com](mailto:sent...@gmail.com)"'
> 
> However that would also find "[foobar.sent...@gmail.com](mailto:foobar.sent...@gmail.com)"
> 
> So if you want to use the email address as a unique ID, you probably do  
> want to do a term query, and you could set the mail\_from property to  
> {"type": "string", "index":"not\_analyzed"}
> 
> However, the term "[sent...@gmail.com](mailto:sent...@gmail.com)" is not the same as the term  
> "[Sent...@GMAIL.com](mailto:Sent...@GMAIL.com)"
> 
> So make sure that you lowercase both the data that you index, and the  
> term that you search for. (and you may need to trim any leading or  
> trailing whitespace as well)
> 
> Also, would you want to do searches for any email address containing  
> "senthil" or "gmail"?
> 
> If so, then you need both the not\_analyzed field, and an analyzed field.  
> You could do this with a multi field:
> 
> curl -XPUT '[http://127.0.0.1:9200/foo/email/\_mapping?pretty=1](http://127.0.0.1:9200/foo/email/_mapping?pretty=1)' -d '  
> {  
> "email" : {  
> "properties" : {  
> "mail\_from" : {  
> "fields" : {  
> "id" : {  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "mail\_from" : {  
> "index" : "analyzed",  
> "type" : "string"  
> }  
> },  
> "type" : "multi\_field"  
> }  
> }  
> }}
> 
> '
> 
> Seehttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type...
> 
> Then you can use these as follows:
> 
> ## Search for "gmail":
> 
> curl -XGET '[http://127.0.0.1:9200/foo/mail/\_search?pretty=1](http://127.0.0.1:9200/foo/mail/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "field" : {  
> "mail\_from" : "gmail"  
> }  
> }}
> 
> '
> 
> ## Find exactly "[sent...@gmail.com](mailto:sent...@gmail.com)":
> 
> curl -XGET '[http://127.0.0.1:9200/foo/mail/\_search?pretty=1](http://127.0.0.1:9200/foo/mail/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "constant\_score" : {  
> "filter" : {  
> "term" : {  
> "mail\_from.id" : "[sent...@gmail.com](mailto:sent...@gmail.com)"  
> }  
> }  
> }  
> }}
> 
> '
> 
> 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, 4:06am UTC](https://discuss.elastic.co/t/searching-on-email-ids-not-happening-in-16-0/4342/8 "2017-07-06T04:06:59Z")

</div>


