Phrase match with filters

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?

--

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:

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 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?

--

--