# Exact match using a term query is not working if the field has numbers in it

**URL:** <https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196>\
**Category:** Elasticsearch\
**Created:** [December 28, 2012, 8:59pm UTC](https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196 "2012-12-28T20:59:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick\_Devinsus](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@Rick\_Devinsus](https://discuss.elastic.co/u/Rick_Devinsus)\
**Post date:** [December 28, 2012, 8:59pm UTC](https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196/1 "2012-12-28T20:59:41Z")

</div>

1. I have a mapping set up for a field called "sku". It is configured as  
not\_analyzed such that I can do exact matches on it

.startObject("sku")  
.field("index", "not\_analyzed")  
.field("type", "string")  
.endObject()

1. The database contains a document where sku=test1.test and one where  
sku=testx.test

2. This query returns 0 results  
{  
"query": {  
"term": {  
"sku": "test1.test"  
}  
}  
}

3. This query returns 1 result  
{  
"query": {  
"term": {  
"sku": "testx.test"  
}  
}  
}

4. This query returns 1 result  
{  
"query": {  
"term": {  
"sku": "test1"  
}  
}  
}

My question is, how come I can only do an exact match query if the field  
(keyword) has no numbers in it? I cant find documents where the sku field  
is test1.test

Thanks

--

---

<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:** [December 28, 2012, 9:12pm UTC](https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196/2 "2012-12-28T21:12:51Z")

</div>

Interesting and strange. IMHO, it should work. Can you gist a full curl recreation for this case?

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

Le 28 déc. 2012 à 21:59, Rick Devinsus [rick.devinsus@gmail.com](mailto:rick.devinsus@gmail.com) a écrit :

1. I have a mapping set up for a field called "sku". It is configured as not\_analyzed such that I can do exact matches on it

2. The database contains a document where sku=test1.test and one where sku=testx.test

3. This query returns 0 results  
{  
"query": {  
"term": {  
"sku": "test1.test"  
}  
}  
}

4. This query returns 1 result  
{  
"query": {  
"term": {  
"sku": "testx.test"  
}  
}  
}

5. This query returns 1 result  
{  
"query": {  
"term": {  
"sku": "test1"  
}  
}  
}

My question is, how come I can only do an exact match query if the field (keyword) has no numbers in it? I cant find documents where the sku field is test1.test

Thanks

--

--

---

<div class="post-metadata">

**Author:** ![Rick\_Devinsus](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@Rick\_Devinsus](https://discuss.elastic.co/u/Rick_Devinsus)\
**Post date:** [December 28, 2012, 9:51pm UTC](https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196/3 "2012-12-28T21:51:20Z")

</div>

Thanks David. I found my problem, there was more than one field in my  
mapping which was done using Jackson via the java API. I was missing  
an .endObject() call which meant the JSON generated was incorrect. The  
interesting thing is that the mapping was successful for all fields above  
the JSON error.

On Friday, December 28, 2012 3:59:41 PM UTC-5, Rick Devinsus wrote:

> 1. I have a mapping set up for a field called "sku". It is configured as  
> not\_analyzed such that I can do exact matches on it
> 
> .startObject("sku")  
> .field("index", "not\_analyzed")  
> .field("type", "string")  
> .endObject()
> 
> 1. The database contains a document where sku=test1.test and one where  
> sku=testx.test
> 
> 2. This query returns 0 results  
> {  
> "query": {  
> "term": {  
> "sku": "test1.test"  
> }  
> }  
> }
> 
> 3. This query returns 1 result  
> {  
> "query": {  
> "term": {  
> "sku": "testx.test"  
> }  
> }  
> }
> 
> 4. This query returns 1 result  
> {  
> "query": {  
> "term": {  
> "sku": "test1"  
> }  
> }  
> }
> 
> My question is, how come I can only do an exact match query if the field  
> (keyword) has no numbers in it? I cant find documents where the sku field  
> is test1.test
> 
> Thanks

--

---

<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:58am UTC](https://discuss.elastic.co/t/exact-match-using-a-term-query-is-not-working-if-the-field-has-numbers-in-it/10196/4 "2017-07-06T02:58:16Z")

</div>


