# How to match a field exactly

**URL:** <https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436>\
**Category:** Elasticsearch\
**Created:** [January 19, 2012, 6:40am UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436 "2012-01-19T06:40:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [January 19, 2012, 6:40am UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436/1 "2012-01-19T06:40:38Z")

</div>

Hey guys. To search for documents that have an exact value in a certain  
field, is a query\_string query the appropriate solution?

For example, after indexing this document:  
{ name : "Super Grimlock", properties : { class: "Deluxe" } }  
I can find it like this:  
curl 'localhost:9200/test/products/\_search' -d '  
{ query: { query\_string: { fields: ["name"], query: "Super Grimlock"  
} } }'

Are there any other ways to perform this search? I've tried term queries  
and term filters, but I assume they didn't work because terms aren't  
analyzed.

Thanks!  
Nick

---

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [January 19, 2012, 6:49am UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436/2 "2012-01-19T06:49:28Z")

</div>

I just found the "field" query. Eg:

curl 'localhost:9200/test/products/\_search' -d '{  
query: { field: { name: "Super Grimlock" } }  
}'

Are there any other ways?

---

<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:** [January 19, 2012, 6:55am UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436/3 "2012-01-19T06:55:04Z")

</div>

If you are using default mapping, your field has been tokenized in two terms.  
You can use a keyword analyzer in the mapping for that field.

David 😉  
@dadoonet

Le 19 janv. 2012 à 07:40, Nick Hoffman [nick@deadorange.com](mailto:nick@deadorange.com) a écrit :

> Hey guys. To search for documents that have an exact value in a certain field, is a query\_string query the appropriate solution?
> 
> For example, after indexing this document:  
> { name : "Super Grimlock", properties : { class: "Deluxe" } }  
> I can find it like this:  
> curl 'localhost:9200/test/products/\_search' -d '  
> { query: { query\_string: { fields: ["name"], query: "Super Grimlock" } } }'
> 
> Are there any other ways to perform this search? I've tried term queries and term filters, but I assume they didn't work because terms aren't analyzed.
> 
> Thanks!  
> Nick

---

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [January 19, 2012, 4:02pm UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436/4 "2012-01-19T16:02:55Z")

</div>

Thanks, David. The keyword analyzer makes a lot of sense.

---

<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, 3:42am UTC](https://discuss.elastic.co/t/how-to-match-a-field-exactly/6436/5 "2017-07-06T03:42:08Z")

</div>


