# Exact field value match

**URL:** <https://discuss.elastic.co/t/exact-field-value-match/276852>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [June 23, 2021, 9:23pm UTC](https://discuss.elastic.co/t/exact-field-value-match/276852 "2021-06-23T21:23:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Shinde](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Abhishek\_Shinde](https://discuss.elastic.co/u/Abhishek_Shinde)\
**Post date:** [June 23, 2021, 9:23pm UTC](https://discuss.elastic.co/t/exact-field-value-match/276852/1 "2021-06-23T21:23:40Z")

</div>

I’m trying to achieve Exact field value match,  
E.g.  
“content” : “how are you” : find all the documents which exactly have the value “how are you” inside the entire field “content”  
What we tried in elasticsearch:  
{  
"query": {  
"bool": {  
"must": [  
{  
"script": {  
"script": {  
"inline": "doc['content.keyword'].getValue().length() == 11 ",  
"lang": "painless"  
}  
}  
},  
{  
"match\_phrase": {  
"testfield": "how are you"  
}  
}]  
}  
}  
}

Problem observed:  
Scripting is slow and this will require per document field data and test fields are not optimized for such operations. So we had to either use via keyword (we want full text) or enable fielddata (this will use more memory).

Any guidance would be helpful here.

---

<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 21, 2021, 9:24pm UTC](https://discuss.elastic.co/t/exact-field-value-match/276852/2 "2021-07-21T21:24:07Z")

</div>

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