# Term request with normalized keyword behave strangely

**URL:** <https://discuss.elastic.co/t/term-request-with-normalized-keyword-behave-strangely/91120>\
**Category:** Elasticsearch\
**Created:** [June 28, 2017, 2:30pm UTC](https://discuss.elastic.co/t/term-request-with-normalized-keyword-behave-strangely/91120 "2017-06-28T14:30:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toony](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/toony/32/18458_2.png) [@Toony](https://discuss.elastic.co/u/Toony)\
**Post date:** [June 28, 2017, 2:30pm UTC](https://discuss.elastic.co/t/term-request-with-normalized-keyword-behave-strangely/91120/1 "2017-06-28T14:30:09Z")

</div>

After I had a look at this [post](https://discuss.elastic.co/t/match-vs-term-query-on-keyword-datatype/82952), I thought i was dumb

But with the following test, play it in the given order, I think the term query does some normalization even if it should not on a 5.2.2 Elastcisearch installation

Am I wrong ?

Thanks

PUT data  
{  
"mappings": {  
"product": {  
"properties": {  
"code": {  
"type": "keyword"  
}  
}  
}  
},  
"settings": {  
"index": {  
"analysis": {  
"normalizer": {  
"lower": {  
"filter": [  
"lowercase"  
],  
"type": "custom"  
}  
}  
}  
}  
}  
}

PUT data/product/1  
{  
"code": "AbC"  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "abc" //No result as expected  
}  
}  
}  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "Abc" //No result as expected  
}  
}  
}  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "AbC" //One result as expected  
}  
}  
}  
}

DELETE data  
PUT data  
{  
"mappings": {  
"product": {  
"properties": {  
"code": {  
"type": "keyword",  
"normalizer": "lower"  
}  
}  
}  
},  
"settings": {  
"index": {  
"analysis": {  
"normalizer": {  
"lower": {  
"filter": [  
"lowercase"  
],  
"type": "custom"  
}  
}  
}  
}  
}  
}

PUT data/product/1  
{  
"code": "AbC"  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "abc" //One result is not expected here with term query  
}  
}  
}  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "Abc" //One result is not expected here with term query  
}  
}  
}  
}

POST data/product/\_search  
{  
"query": {  
"term": {  
"code": {  
"value": "AbC"  
}  
}  
}  
}

---

<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 26, 2017, 2:30pm UTC](https://discuss.elastic.co/t/term-request-with-normalized-keyword-behave-strangely/91120/2 "2017-07-26T14:30:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
