# Exact match to string

**URL:** <https://discuss.elastic.co/t/exact-match-to-string/231606>\
**Category:** Elasticsearch\
**Created:** [May 7, 2020, 6:38pm UTC](https://discuss.elastic.co/t/exact-match-to-string/231606 "2020-05-07T18:38:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prince\_yadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prince_yadav/32/67909_2.png) [@prince\_yadav](https://discuss.elastic.co/u/prince_yadav)\
**Post date:** [May 7, 2020, 6:38pm UTC](https://discuss.elastic.co/t/exact-match-to-string/231606/1 "2020-05-07T18:38:08Z")

</div>

I have a name field which has string value like

Blue Latest Product (NKK-1294)  
Pink Black Product (NKK-1233)  
Black Pink Stone (SKK-129)

If I search

> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "bool": {  
> "should": [  
> {  
> "match": {  
> "name": {  
> "query": "NKK-1233",  
> "operator":"and"  
> }  
> }  
> }  
> ]  
> }  
> }  
> ]  
> }  
> }  
> }

Gives me correct output "Pink Black Product (NKK-1233)"

But when I run

> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "bool": {  
> "should": [  
> {  
> "match": {  
> "name": {  
> "query": "NKK-12",  
> "operator":"and"  
> }  
> }  
> }  
> ]  
> }  
> }  
> ]  
> }  
> }  
> }

return 0 results but I need  
Blue Latest Product (NKK-1294)  
Pink Black Product (NKK-1233)  
those result ... means I want to apply like query

> {  
> "local": {  
> "mappings": {  
> "document": {  
> "dynamic\_templates": [  
> {  
> "price\_mapping": {  
> "match": "price\__",  
> "match\_mapping\_type": "string",  
> "mapping": {  
> "store": true,  
> "type": "float"  
> }  
> }  
> },  
> {  
> "position\_mapping": {  
> "match": "position\__",  
> "match\_mapping\_type": "string",  
> "mapping": {  
> "index": false,  
> "type": "integer"  
> }  
> }  
> },  
> {  
> "string\_mapping": {  
> "match": "\*",  
> "match\_mapping\_type": "string",  
> "mapping": {  
> "copy\_to": "\_search",  
> "index": false,  
> "type": "text"  
> }  
> }  
> }  
> ],  
> "properties": {  
> "\_search": {  
> "type": "text"  
> },  
> "name": {  
> "type": "text"  
> }  
> }  
> }  
> }  
> }  
> }

---

<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:** [June 4, 2020, 6:47pm UTC](https://discuss.elastic.co/t/exact-match-to-string/231606/2 "2020-06-04T18:47:45Z")

</div>

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