# Phrase match with filters

**URL:** https://discuss.elastic.co/t/phrase-match-with-filters/8817
**Category:** Elasticsearch
**Created:** [August 22, 2012, 5:14pm UTC](https://discuss.elastic.co/t/phrase-match-with-filters/8817 "2012-08-22T17:14:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Josh\_P](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Josh\_P](https://discuss.elastic.co/u/Josh_P)
#### Post date: [August 22, 2012, 5:14pm UTC](https://discuss.elastic.co/t/phrase-match-with-filters/8817/1 "2012-08-22T17:14:53Z")

</div>

I have a schema whereby each document contains a single array field named  
"keywords\_search". I was wondering whether it's possible to perform a  
phrase match using filters alone. I'm using the default tokenizer/analyzer  
and don't need ranking. Here's what I have so far:

{  
"query": {  
"constant\_score": {  
"filter": {  
"term": {  
"keywords\_search": "ford mustang"  
}  
}  
}  
}  
}

I want the following document to match:

{  
"keywords\_search": ["I want a Ford Mustang now", "drivers ed classes"]  
}

Unfortunately it doesn't match under my query. However, if I change my  
query to just "ford", the document does match.

Any ideas on how I can achieve phrase match using filters?

--

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [August 22, 2012, 10:31pm UTC](https://discuss.elastic.co/t/phrase-match-with-filters/8817/2 "2012-08-22T22:31:37Z")

</div>

A term query/filter will only match on an exact match since the term  
is not analyzed (entire string is one token). Your keywords\_search  
field is analyzed (broken down into separate tokens) and therefore it  
would not match (it can in some cases).

For filters, your only option is the Query Filter:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Not sure why Text is not available as a filter.

Cheers,

Ivan

On Wed, Aug 22, 2012 at 10:14 AM, Josh P [josh.poritz@gmail.com](mailto:josh.poritz@gmail.com) wrote:

> I have a schema whereby each document contains a single array field named  
> "keywords\_search". I was wondering whether it's possible to perform a phrase  
> match using filters alone. I'm using the default tokenizer/analyzer and  
> don't need ranking. Here's what I have so far:
> 
> {  
> "query": {  
> "constant\_score": {  
> "filter": {  
> "term": {  
> "keywords\_search": "ford mustang"  
> }  
> }  
> }  
> }  
> }
> 
> I want the following document to match:
> 
> {  
> "keywords\_search": ["I want a Ford Mustang now", "drivers ed classes"]  
> }
> 
> Unfortunately it doesn't match under my query. However, if I change my  
> query to just "ford", the document does match.
> 
> Any ideas on how I can achieve phrase match using filters?
> 
> --

--

---

<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:15am UTC](https://discuss.elastic.co/t/phrase-match-with-filters/8817/3 "2017-07-06T03:15:25Z")

</div>


