Can I filter with exact phrases?

How can I exclude exact phrases with a filter?

Lets say I want to search for "heaven is blue" but exclude exact phrase
"nature books". I understand I can use a bool query with must & must_not,
but is there a way to filter exact phrases like the example below, but
instead of terms, I use match_phrase?

"query": {
"query_string": {
"query": "heaven is blue",
"fields": ["content"],
"default_operator": "AND"
}
},
"filter" : {
"not" : {
"terms": { "content": ["book","nature"] }
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/55ec0d35-27b1-447e-9136-d86695e789c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You can wrap any query with a query filter:

--
Ivan

On Wed, Jul 23, 2014 at 1:52 PM, IronMike sabdalla80@gmail.com wrote:

How can I exclude exact phrases with a filter?

Lets say I want to search for "heaven is blue" but exclude exact phrase
"nature books". I understand I can use a bool query with must & must_not,
but is there a way to filter exact phrases like the example below, but
instead of terms, I use match_phrase?

"query": {
"query_string": {
"query": "heaven is blue",
"fields": ["content"],
"default_operator": "AND"
}
},
"filter" : {
"not" : {
"terms": { "content": ["book","nature"] }
}
}

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/55ec0d35-27b1-447e-9136-d86695e789c0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/55ec0d35-27b1-447e-9136-d86695e789c0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAEDKJnE5XNyZ%3DwdmczGiF%3Do_kxbKuAhY6D9D5b2eNPzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brilliant, I will give it a try!

On Wednesday, July 23, 2014 5:08:31 PM UTC-4, Ivan Brusic wrote:

You can wrap any query with a query filter:

Elasticsearch Platform — Find real-time answers at scale | Elastic

--
Ivan

On Wed, Jul 23, 2014 at 1:52 PM, IronMike <sabda...@gmail.com
<javascript:>> wrote:

How can I exclude exact phrases with a filter?

Lets say I want to search for "heaven is blue" but exclude exact phrase
"nature books". I understand I can use a bool query with must & must_not,
but is there a way to filter exact phrases like the example below, but
instead of terms, I use match_phrase?

"query": {
"query_string": {
"query": "heaven is blue",
"fields": ["content"],
"default_operator": "AND"
}
},
"filter" : {
"not" : {
"terms": { "content": ["book","nature"] }
}
}

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/55ec0d35-27b1-447e-9136-d86695e789c0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/55ec0d35-27b1-447e-9136-d86695e789c0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fdf32a51-bcd5-43bc-987a-207c2032fcc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.