# Performing an exact match on a field in a document

**URL:** <https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540>\
**Category:** Elasticsearch\
**Created:** [April 10, 2013, 11:26pm UTC](https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540 "2013-04-10T23:26:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saikat\_Kanjilal](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Saikat\_Kanjilal](https://discuss.elastic.co/u/Saikat_Kanjilal)\
**Post date:** [April 10, 2013, 11:26pm UTC](https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540/1 "2013-04-10T23:26:35Z")

</div>

Hello Folks,  
So I've seen bits and pieces on the mailing list around this topic but have  
not seen a satisfactory solution. I have the following document:

{  
"documents": [  
{  
"id": "8b8ax134-7ad3-4e3c-9e4c-f19a0d4f0009",  
"appliance": "appliance2",  
"application": "test",  
"file":"file1",  
"grid":"grid2",  
"line":"1",  
"sequenceNum":1,  
"start\_time": 1349514767441,  
"thread": "thread1",  
"message": "this is test message",  
"level": "Info",  
"logger": "slogger",  
"time": 1349514767441,  
"timestamp":"NOW",  
"text\_all": "this is test message",  
"batch\_id": "2"  
}  
]  
}

I would like to perform an exact match based on a text string which in this  
case would be id, the id represents a guid which has hyphens in it. In  
reading some other posts I saw that I need to first create the index with  
the following mapping:

curl -XPUT [DN7DMPES01001.starwave.com:9200/myns.myset](http://DN7DMPES01001.starwave.com:9200/myns.myset) -d '{  
"mappings" : {  
"elasticsearch" : {  
"properties" : {  
"id" : { "type": "string", "index" : "not\_analyzed" }  
}  
}  
}  
}'

I did the above, however when I go to view my mapping I see the following:

{"\_index":"myns.myset","\_type":"elasticsearch","\_id":"\_mappings","exists":false}

I'm assuming at this point that my mapping did not take effect, am I missing some steps here, of course as expected when I try to query on the id field I get no match since the field is being tokenized into hyphens and sets of numbers.  
I would appreciate some insight , hopefully its something really obvious.

Regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Saikat\_Kanjilal](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Saikat\_Kanjilal](https://discuss.elastic.co/u/Saikat_Kanjilal)\
**Post date:** [April 10, 2013, 11:29pm UTC](https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540/2 "2013-04-10T23:29:18Z")

</div>

Apologies if part of my message got cut off below, I'm basically unable to  
query based on the id because of the index mapping not taking effect

On Wednesday, April 10, 2013 4:26:35 PM UTC-7, Saikat Kanjilal wrote:

> Hello Folks,  
> So I've seen bits and pieces on the mailing list around this topic but  
> have not seen a satisfactory solution. I have the following document:
> 
> {  
> "documents": [  
> {  
> "id": "8b8ax134-7ad3-4e3c-9e4c-f19a0d4f0009",  
> "appliance": "appliance2",  
> "application": "test",  
> "file":"file1",  
> "grid":"grid2",  
> "line":"1",  
> "sequenceNum":1,  
> "start\_time": 1349514767441,  
> "thread": "thread1",  
> "message": "this is test message",  
> "level": "Info",  
> "logger": "slogger",  
> "time": 1349514767441,  
> "timestamp":"NOW",  
> "text\_all": "this is test message",  
> "batch\_id": "2"  
> }  
> ]  
> }
> 
> I would like to perform an exact match based on a text string which in  
> this case would be id, the id represents a guid which has hyphens in it.  
> In reading some other posts I saw that I need to first create the index  
> with the following mapping:
> 
> curl -XPUT [DN7DMPES01001.starwave.com:9200/myns.myset](http://DN7DMPES01001.starwave.com:9200/myns.myset) -d '{  
> "mappings" : {  
> "elasticsearch" : {  
> "properties" : {  
> "id" : { "type": "string", "index" : "not\_analyzed" }  
> }  
> }  
> }  
> }'
> 
> I did the above, however when I go to view my mapping I see the following:
> 
> {"\_index":"myns.myset","\_type":"elasticsearch","\_id":"\_mappings","exists":false}
> 
> I'm assuming at this point that my mapping did not take effect, am I missing some steps here, of course as expected when I try to query on the id field I get no match since the field is being tokenized into hyphens and sets of numbers.  
> I would appreciate some insight , hopefully its something really obvious.
> 
> Regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 11, 2013, 2:25am UTC](https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540/3 "2013-04-11T02:25:20Z")

</div>

Have a look at this gist. It should help you: [Extract domain name and compute size with terms stat facet · GitHub](https://gist.github.com/dadoonet/5320947)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 11 avr. 2013 à 01:29, Saikat Kanjilal [sxk1969@gmail.com](mailto:sxk1969@gmail.com) a écrit :

Apologies if part of my message got cut off below, I'm basically unable to query based on the id because of the index mapping not taking effect

On Wednesday, April 10, 2013 4:26:35 PM UTC-7, Saikat Kanjilal wrote:

> Hello Folks,  
> So I've seen bits and pieces on the mailing list around this topic but have not seen a satisfactory solution. I have the following document:
> 
> {  
> "documents": [  
> {  
> "id": "8b8ax134-7ad3-4e3c-9e4c-f19a0d4f0009",  
> "appliance": "appliance2",  
> "application": "test",  
> "file":"file1",  
> "grid":"grid2",  
> "line":"1",  
> "sequenceNum":1,  
> "start\_time": 1349514767441,  
> "thread": "thread1",  
> "message": "this is test message",  
> "level": "Info",  
> "logger": "slogger",  
> "time": 1349514767441,  
> "timestamp":"NOW",  
> "text\_all": "this is test message",  
> "batch\_id": "2"  
> }  
> ]  
> }
> 
> I would like to perform an exact match based on a text string which in this case would be id, the id represents a guid which has hyphens in it. In reading some other posts I saw that I need to first create the index with the following mapping:
> 
> curl -XPUT [DN7DMPES01001.starwave.com:9200/myns.myset](http://DN7DMPES01001.starwave.com:9200/myns.myset) -d '{  
> "mappings" : {  
> "elasticsearch" : {  
> "properties" : {  
> "id" : { "type": "string", "index" : "not\_analyzed" }  
> }  
> }  
> }  
> }'
> 
> I did the above, however when I go to view my mapping I see the following:
> 
> {"\_index":"myns.myset","\_type":"elasticsearch","\_id":"\_mappings","exists":false}
> 
> I'm assuming at this point that my mapping did not take effect, am I missing some steps here, of course as expected when I try to query on the id field I get no match since the field is being tokenized into hyphens and sets of numbers.  
> I would appreciate some insight , hopefully its something really obvious.
> 
> Regards  
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:41am UTC](https://discuss.elastic.co/t/performing-an-exact-match-on-a-field-in-a-document/11540/4 "2017-07-06T02:41:38Z")

</div>


