Binh_Ly
(Binh Ly)
March 6, 2013, 3:00am
1
Hey all,
I'm using ES 0.20.5 and noticed this behavior.
Create simple index:
POST http://localhost:9200/foo/foo/1
{
"name": "John Doe"
}
Create simple query:
POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane)"
}
}
}
And I get back the above document. Good.
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 .
ppearcy
(ppearcy)
March 6, 2013, 6:15am
2
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
opened 06:40PM - 13 Aug 10 UTC
closed 01:44PM - 25 Jan 14 UTC
Here are the details:
May want to consider adding logic in the case of non-neste… d negatives
in OR clauses.
For example
indexid:"test" OR -indexid:"test"
->
indexid:"test" OR (-indexid:"test" AND _:_)
Right now, with ES when doing query generation from a syntax tree with
this, I am adding grouping around negative OR clauses to accommodate.
So:
indexid:"test" OR -indexid:"test"
->
indexid:"test" OR (-indexid:"test")
Which I believe ES then interprets as:
indexid:"test" OR (-indexid:"test" AND _:_)
A few more details are here:
http://groups.google.com/a/elasticsearch.com/group/users/browse_thread/thread/9e80a32a3e8827f1/5e48ef4c9f596b16#5e48ef4c9f596b16
I would consider this a low priority request.
Thanks!
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.
Create simple index:
POST http://localhost:9200/foo/foo/1
{
"name": "John Doe"
}
Create simple query:
POST http://localhost:9200/_search
{
"query": {
"query_string": {
"query": "NOT(name:Jane)"
}
}
}
And I get back the above document. Good.
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 .
Binh_Ly
(Binh Ly)
March 6, 2013, 1:02pm
3
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 .