NOT OR TERM issue?


(Andy Wick) #1

Trying to add simple NOT capability to my elasticsearch interaction and I'm
getting strange errors from using NOT outside of an OR statement, which I
think I'm using correctly from the documentation.

Add just 1 document, no special mapping

curl -XPOST http://localhost:9200/tests/test/1 -d '{v1:"test1", v2:"test2"}'

  1. My normal OR works ok

curl -XPOST http://localhost:9200/tests/test/_search -d ' {"query": {
"filtered": {"query": {"match_all": {}},
"filter": {or: [{"term": {"v1": "test1"}}]}
} } }'

  1. Wrap OR with NOT and get an error
    curl -XPOST http://localhost:9200/tests/test/_search -d ' {"query": {
    "filtered": {"query": {"match_all": {}},
    "filter": {"not": {"or": [{"term": {"v1": "test1"}}]}}
    } } }'

Failed to execute phase [query], total failure; shardFailures
[CUT]
nested: QueryParsingException[[tests] [or] filter does not support [v1]];

  1. If i wrap the inside of the OR with an AND works fine
    curl -XPOST http://locahost:9200/tests/test/_search -d ' {"query": {
    "filtered": {"query": {"match_all": {}},
    "filter": {"not": {"or": [{"and":[{"term": {"v1": "test0"}}]}]}}
    } } }'

Bug? or are you not allowed to NOT certain things?

Thanks,
Andy


(Frederick Cheung) #2

On May 29, 1:41 am, Andy Wick andyw...@gmail.com wrote:

Trying to add simple NOT capability to my elasticsearch interaction and I'm
getting strange errors from using NOT outside of an OR statement, which I
think I'm using correctly from the documentation.

Add just 1 document, no special mapping

curl -XPOSThttp://localhost:9200/tests/test/1-d '{v1:"test1", v2:"test2"}'

  1. My normal OR works ok

curl -XPOSThttp://localhost:9200/tests/test/_search-d ' {"query": {
"filtered": {"query": {"match_all": {}},
"filter": {or: [{"term": {"v1": "test1"}}]}
} } }'

  1. Wrap OR with NOT and get an error
    curl -XPOSThttp://localhost:9200/tests/test/_search-d ' {"query": {
    "filtered": {"query": {"match_all": {}},
    "filter": {"not": {"or": [{"term": {"v1": "test1"}}]}}
    } } }'

Bug? or are you not allowed to NOT certain things?

I've found i\ve needed to do

"filter": {"not": {"filter": {"or": [...]}}}

But I'm not sure why this is needed.

Fred


(Shay Banon) #3

Its a bug in the non "filter" wrapping option in not filter, opened an
issue: https://github.com/elasticsearch/elasticsearch/issues/1987.

On Tue, May 29, 2012 at 3:09 PM, Frederick Cheung <
frederick.cheung@gmail.com> wrote:

On May 29, 1:41 am, Andy Wick andyw...@gmail.com wrote:

Trying to add simple NOT capability to my elasticsearch interaction and
I'm
getting strange errors from using NOT outside of an OR statement, which I
think I'm using correctly from the documentation.

Add just 1 document, no special mapping

curl -XPOSThttp://localhost:9200/tests/test/1-d '{v1:"test1",
v2:"test2"}'

  1. My normal OR works ok

curl -XPOSThttp://localhost:9200/tests/test/_search-d ' {"query": {
"filtered": {"query": {"match_all": {}},
"filter": {or: [{"term": {"v1": "test1"}}]}
} } }'

  1. Wrap OR with NOT and get an error
    curl -XPOSThttp://localhost:9200/tests/test/_search-d ' {"query": {
    "filtered": {"query": {"match_all": {}},
    "filter": {"not": {"or": [{"term": {"v1": "test1"}}]}}
    } } }'

Bug? or are you not allowed to NOT certain things?

I've found i\ve needed to do

"filter": {"not": {"filter": {"or": [...]}}}

But I'm not sure why this is needed.

Fred


(system) #4