Term filter for array list not working

can someone tell me what i am doing wrong?
basically i have an index of documents that have a field called "tags". it
is a list of strings.
one of the documents has
"tags" : ["spam"]

but this filter in java is not taking effect -

            FilterBuilder noSpamFilter = FilterBuilders.orFilter(
                    FilterBuilders.missingFilter("tags")
                    ,FilterBuilders.notFilter(FilterBuilders.termFilter(
                    "tags", "spam")));

when i do a search with this filter, the document with spam tag is still
being returned. am i using it incorrectly?

thanks

--

Hi

On Fri, Sep 14, 2012 at 11:33 PM, T Vinod Gupta tvinod@readypulse.com wrote:

can someone tell me what i am doing wrong?
basically i have an index of documents that have a field called "tags". it is a list of strings.
one of the documents has
"tags" : ["spam"]

but this filter in java is not taking effect -

            FilterBuilder noSpamFilter = FilterBuilders.orFilter(
                    FilterBuilders.missingFilter("tags")
                    ,FilterBuilders.notFilter(FilterBuilders.termFilter(
                    "tags", "spam")));

when i do a search with this filter, the document with spam tag is still being returned. am i using it incorrectly?

Testing it with ES 0.19.8 works flawlessly for me. You are sure

This is my sample source

    FilterBuilder noSpamFilter = FilterBuilders.orFilter(
            FilterBuilders.missingFilter("tags")
            ,FilterBuilders.notFilter(FilterBuilders.termFilter(
            "tags", "spam")));

    SearchRequestBuilder searchReq = new SearchRequestBuilder(client)
        .setQuery(QueryBuilders.matchAllQuery())
        .setFilter(noSpamFilter)
        .setIndices("products")
        .setTypes("product");

    SearchResponse resp = searchReq.execute().actionGet();

I had indexed four products, three with tags, one without the field
product 1 tags: "a", "b", "spam"
product 2 tags: "d", "e", "e"
product 3 tags: "a", "b", "spam"
product 4 had no tags field

reply was product2 and product4 - do you have any special mappings or
any other special configuration?

--Alexander

--

im still confused.. i see that is working for you..
but in my case, i have no clue why its not working..

e.g., i have a document like this -
curl -XGET 'http://localhost:9200/capture-widget/content/161_89?pretty=true'
{
"_index" : "capture-widget",
"_type" : "content",
"_id" : "161_89",
"_version" : 3,
"exists" : true, "_source" :
{"tags":["SPAM"],"moderated_and_approved":true,"brand_id":"161","actor_id":"1","score":0.0}
}

and my search query looks like this -
curl -XGET 'http://localhost:9200/capture-widge/content/_search?pretty=true'
-d '
{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"term":{"brand_id":"161"}},
{"not": {"terms":{"tags": ["SPAM"] }}} ]}}}}}}'

the results contain 161_89..
how is it possible?

thanks

On Sat, Sep 15, 2012 at 6:18 AM, Alexander Reelsen alr@spinscale.de wrote:

Hi

On Fri, Sep 14, 2012 at 11:33 PM, T Vinod Gupta tvinod@readypulse.com
wrote:

can someone tell me what i am doing wrong?
basically i have an index of documents that have a field called "tags".
it is a list of strings.
one of the documents has
"tags" : ["spam"]

but this filter in java is not taking effect -

            FilterBuilder noSpamFilter = FilterBuilders.orFilter(
                    FilterBuilders.missingFilter("tags")

,FilterBuilders.notFilter(FilterBuilders.termFilter(

                    "tags", "spam")));

when i do a search with this filter, the document with spam tag is still
being returned. am i using it incorrectly?

Testing it with ES 0.19.8 works flawlessly for me. You are sure

This is my sample source

    FilterBuilder noSpamFilter = FilterBuilders.orFilter(
            FilterBuilders.missingFilter("tags")
            ,FilterBuilders.notFilter(FilterBuilders.termFilter(
            "tags", "spam")));

    SearchRequestBuilder searchReq = new SearchRequestBuilder(client)
        .setQuery(QueryBuilders.matchAllQuery())
        .setFilter(noSpamFilter)
        .setIndices("products")
        .setTypes("product");

    SearchResponse resp = searchReq.execute().actionGet();

I had indexed four products, three with tags, one without the field
product 1 tags: "a", "b", "spam"
product 2 tags: "d", "e", "e"
product 3 tags: "a", "b", "spam"
product 4 had no tags field

reply was product2 and product4 - do you have any special mappings or
any other special configuration?

--Alexander

--

--

How are tags mapped? If tags are analyzed (which is default), "SPAM"
would be indexed as "spam" and as a result your filter "terms":{"tags":
["SPAM"] }} wouldn't match anything

On Wednesday, October 31, 2012 10:07:45 PM UTC-4, T Vinod Gupta wrote:

im still confused.. i see that is working for you..
but in my case, i have no clue why its not working..

e.g., i have a document like this -
curl -XGET '
http://localhost:9200/capture-widget/content/161_89?pretty=true'
{
"_index" : "capture-widget",
"_type" : "content",
"_id" : "161_89",
"_version" : 3,
"exists" : true, "_source" :
{"tags":["SPAM"],"moderated_and_approved":true,"brand_id":"161","actor_id":"1","score":0.0}
}

and my search query looks like this -
curl -XGET '
http://localhost:9200/capture-widge/content/_search?pretty=true' -d '
{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"term":{"brand_id":"161"}},
{"not": {"terms":{"tags": ["SPAM"] }}} ]}}}}}}'

the results contain 161_89..
how is it possible?

thanks

On Sat, Sep 15, 2012 at 6:18 AM, Alexander Reelsen <a...@spinscale.de<javascript:>

wrote:

Hi

On Fri, Sep 14, 2012 at 11:33 PM, T Vinod Gupta <tvi...@readypulse.com<javascript:>>
wrote:

can someone tell me what i am doing wrong?
basically i have an index of documents that have a field called "tags".
it is a list of strings.
one of the documents has
"tags" : ["spam"]

but this filter in java is not taking effect -

            FilterBuilder noSpamFilter = FilterBuilders.orFilter(
                    FilterBuilders.missingFilter("tags")

,FilterBuilders.notFilter(FilterBuilders.termFilter(

                    "tags", "spam")));

when i do a search with this filter, the document with spam tag is
still being returned. am i using it incorrectly?

Testing it with ES 0.19.8 works flawlessly for me. You are sure

This is my sample source

    FilterBuilder noSpamFilter = FilterBuilders.orFilter(
            FilterBuilders.missingFilter("tags")
            ,FilterBuilders.notFilter(FilterBuilders.termFilter(
            "tags", "spam")));

    SearchRequestBuilder searchReq = new SearchRequestBuilder(client)
        .setQuery(QueryBuilders.matchAllQuery())
        .setFilter(noSpamFilter)
        .setIndices("products")
        .setTypes("product");

    SearchResponse resp = searchReq.execute().actionGet();

I had indexed four products, three with tags, one without the field
product 1 tags: "a", "b", "spam"
product 2 tags: "d", "e", "e"
product 3 tags: "a", "b", "spam"
product 4 had no tags field

reply was product2 and product4 - do you have any special mappings or
any other special configuration?

--Alexander

--

--