Multiple terms in filter in filtered query

Hi,

Can anyone suggest how i can add multiple terms to my filter in the query
below? Tried one term: "med" and it works, adding yet another as array only
takes the last element and the first one shows up in the hit list. I tried
Bool and "AND" but havent got it to work neither.

Thanks!

GET /teststrings/_search
{
"query" : {

"filtered": {
"query": {
"multi_match" : {
"query": "Decor strip",
"type":"best_fields",
"fields": [ "enstring.name", "enstring.untouched^5" ]
}
},
"filter": {
"not": {
"term": {
"svstring.name": ["med","utan"]
}
}
}
}

}
}

--
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/ee64dc17-1c85-46c7-a144-7b82cb1ad9d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Pontus ,

You need to use terms instead of term filter

TERMS filter -

Thanks
Vineeth

On Thu, Sep 4, 2014 at 7:53 AM, Pontus Lundin lundin.codeitez@gmail.com
wrote:

Hi,

Can anyone suggest how i can add multiple terms to my filter in the query
below? Tried one term: "med" and it works, adding yet another as array only
takes the last element and the first one shows up in the hit list. I tried
Bool and "AND" but havent got it to work neither.

Thanks!

GET /teststrings/_search
{
"query" : {

"filtered": {
"query": {
"multi_match" : {
"query": "Decor strip",
"type":"best_fields",
"fields": [ "enstring.name", "enstring.untouched^5" ]
}
},
"filter": {
"not": {
"term": {
"svstring.name": ["med","utan"]
}
}
}
}

}
}

--
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/ee64dc17-1c85-46c7-a144-7b82cb1ad9d5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/ee64dc17-1c85-46c7-a144-7b82cb1ad9d5%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/CAGdPd5k%3Di1Dx7H%2B2Vv%3DLpHMX5s_FBF8Nu5%2BP-1MsEUiHggjNPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

I just found out a way with bool.

GET /teststrings/_search
{
"query" : {

"filtered": {
"query": {
"multi_match" : {
"query": "Decor strip",
"type":"best_fields",
"fields": [ "enstring.name", "enstring.untouched^5" ]
}
},
"filter": {
"bool": {
"must": {},
"must_not": [
{ "term": { "svstring.name": "med" }},
{ "term": { "svstring.name": "utan" }}
],
"should":
{}

}

}
}

}
}

Den torsdagen den 4:e september 2014 kl. 04:23:16 UTC+2 skrev Pontus Lundin:

Hi,

Can anyone suggest how i can add multiple terms to my filter in the query
below? Tried one term: "med" and it works, adding yet another as array only
takes the last element and the first one shows up in the hit list. I tried
Bool and "AND" but havent got it to work neither.

Thanks!

GET /teststrings/_search
{
"query" : {

"filtered": {
"query": {
"multi_match" : {
"query": "Decor strip",
"type":"best_fields",
"fields": [ "enstring.name", "enstring.untouched^5" ]
}
},
"filter": {
"not": {
"term": {
"svstring.name": ["med","utan"]
}
}
}
}

}
}

--
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/8627aa77-0293-44fd-8be2-0c21b5313590%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ah, Thanks for the hint vineeth!

Den torsdagen den 4:e september 2014 kl. 04:31:31 UTC+2 skrev vineeth mohan:

Hello Pontus ,

You need to use terms instead of term filter

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

Thanks
Vineeth

On Thu, Sep 4, 2014 at 7:53 AM, Pontus Lundin <lundin....@gmail.com
<javascript:>> wrote:

Hi,

Can anyone suggest how i can add multiple terms to my filter in the query
below? Tried one term: "med" and it works, adding yet another as array only
takes the last element and the first one shows up in the hit list. I tried
Bool and "AND" but havent got it to work neither.

Thanks!

GET /teststrings/_search
{
"query" : {

"filtered": {
"query": {
"multi_match" : {
"query": "Decor strip",
"type":"best_fields",
"fields": [ "enstring.name", "enstring.untouched^5" ]
}
},
"filter": {
"not": {
"term": {
"svstring.name": ["med","utan"]
}
}
}
}

}
}

--
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/ee64dc17-1c85-46c7-a144-7b82cb1ad9d5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/ee64dc17-1c85-46c7-a144-7b82cb1ad9d5%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/a00bc37d-a689-4ac9-a607-e0ba064d2099%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.