# Simple equality filter

**URL:** https://discuss.elastic.co/t/simple-equality-filter/4617
**Category:** Elasticsearch
**Created:** [June 14, 2011, 4:38pm UTC](https://discuss.elastic.co/t/simple-equality-filter/4617 "2011-06-14T16:38:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Mill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_mill/32/3124_2.png) [@Eric\_Mill](https://discuss.elastic.co/u/Eric_Mill)
#### Post date: [June 14, 2011, 4:38pm UTC](https://discuss.elastic.co/t/simple-equality-filter/4617/1 "2011-06-14T16:38:34Z")

</div>

I feel like I must be missing something, but how do I filter on an exact  
string match? In other words, I want either the entire field to match or not  
at all.

The "text" filter of type "phrase" will match even when the query string is  
only a subset of the field, and the "term" filter won't work when the field  
is an identifier with hyphens in it.

Relatedly, is there a way to do an exact match on number and boolean fields?

-- Eric

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 14, 2011, 4:52pm UTC](https://discuss.elastic.co/t/simple-equality-filter/4617/2 "2011-06-14T16:52:12Z")

</div>

You always do exact matches on number and boolean fields (using either term query or term filter). For text, you can make the field as `index` set to `not_analyzed` in order for it not to be analyzed and treated as a single token.

On Tuesday, June 14, 2011 at 7:38 PM, Eric Mill wrote:

> I feel like I must be missing something, but how do I filter on an exact string match? In other words, I want either the entire field to match or not at all.
> 
> The "text" filter of type "phrase" will match even when the query string is only a subset of the field, and the "term" filter won't work when the field is an identifier with hyphens in it.
> 
> Relatedly, is there a way to do an exact match on number and boolean fields?
> 
> -- Eric

---

<div class="post-metadata">

### Author: ![Eric\_Mill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_mill/32/3124_2.png) [@Eric\_Mill](https://discuss.elastic.co/u/Eric_Mill)
#### Post date: [June 14, 2011, 5:53pm UTC](https://discuss.elastic.co/t/simple-equality-filter/4617/3 "2011-06-14T17:53:58Z")

</div>

Thanks, that was what I was looking for!

On Tue, Jun 14, 2011 at 12:52 PM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> You always do exact matches on number and boolean fields (using either  
> term query or term filter). For text, you can make the field as `index` set  
> to `not_analyzed` in order for it not to be analyzed and treated as a single  
> token.
> 
> On Tuesday, June 14, 2011 at 7:38 PM, Eric Mill wrote:
> 
> I feel like I must be missing something, but how do I filter on an exact  
> string match? In other words, I want either the entire field to match or not  
> at all.
> 
> The "text" filter of type "phrase" will match even when the query string is  
> only a subset of the field, and the "term" filter won't work when the field  
> is an identifier with hyphens in it.
> 
> Relatedly, is there a way to do an exact match on number and boolean  
> fields?
> 
> -- Eric

---

<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, 4:03am UTC](https://discuss.elastic.co/t/simple-equality-filter/4617/4 "2017-07-06T04:03:38Z")

</div>


