Simple query, unexpected result

Hey all,

I'm using ES 0.20.5 and noticed this behavior.

  1. Create simple index:

POST http://localhost:9200/foo/foo/1
{
"name": "John Doe"
}

  1. Create simple query:

POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane)"
}
}
}

And I get back the above document. Good.

  1. Then I modify above query slightly:

POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane) OR name:zzz"
}
}
}

And I get no results. Is there something about ES/Lucene that I am just not
understanding?

This one works though and returns the document correctly.

{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "NOT(name:Jane)"
}
},
{
"query_string": {
"query": "name:zzz"
}
}
]
}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

This should work:
(NOT(name:Jane)) OR name:zzz

Here's an older discussion on it:
http://elasticsearch-users.115913.n3.nabble.com/ES-s-handling-of-negative-queries-td1122757.html

Best Regards,
Paul

On Tuesday, March 5, 2013 8:00:38 PM UTC-7, Ben wrote:

Hey all,

I'm using ES 0.20.5 and noticed this behavior.

  1. Create simple index:

POST http://localhost:9200/foo/foo/1
{
"name": "John Doe"
}

  1. Create simple query:

POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane)"
}
}
}

And I get back the above document. Good.

  1. Then I modify above query slightly:

POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane) OR name:zzz"
}
}
}

And I get no results. Is there something about ES/Lucene that I am just
not understanding?

This one works though and returns the document correctly.

{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "NOT(name:Jane)"
}
},
{
"query_string": {
"query": "name:zzz"
}
}
]
}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Paul, thank you very much! Good to know there is a workaround!

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

You may want to have a read of this, which explains why + and - should be
preferred over AND/OR/NOT:

http://searchhub.org/2011/12/28/why-not-and-or-and-not/

clint

On Wed, Mar 6, 2013 at 2:02 PM, Ben binh@hibalo.com wrote:

Paul, thank you very much! Good to know there is a workaround!

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.