Good question.
If I recreate your search but in my own database (with only 2 documents
remaining because all the other documents have been expired), with 1
document matching the first term, another document matching the second
term, and both documents matching the text:* term, I see the same behavior
as you do:
- If I omit the third (last) term, I get 2 search hits, as expected.
"query_string" : { "query" : "cn:celeborn OR cn:galadriel" }
{ "cn" : "Celeborn" , "text" : "Lives forever" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
- If I omit the first two terms, I get 2 search hits, as expected:
"query_string" : { "query" : "text:*" }
{ "cn" : "Celeborn" , "text" : "Lives forever" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
- If I surround the first two terms in parenthesis, I get the 2 search
hits as expected.
"query_string" : { "query" : "(cn:celeborn OR cn:galadriel) AND text:*" }
{ "cn" : "Celeborn" , "text" : "Lives forever" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
- If I surround the last two terms in parenthesis, I get the 2 search hits
as expected:
"query_string" : { "query" : "cn:celeborn OR (cn:galadriel AND text:*") }
{ "cn" : "Celeborn" , "text" : "Lives forever" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
But without any parenthesis, I only get one search hit:
"query_string" : { "query" : "cn:celeborn OR cn:galadriel AND text:*" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
It seems that with the AND and OR operators strung along, Lucene's query
parser doesn't know whether to **** or go blind (as the expression goes).
Very sad.
By the way, this is in Lucene 4 inside ES 0.90.3.
It looks like a Lucene query parser bug, not a wildcard bug. For example,
replacing text:* with text:lives I see the same one record returned:
"query_string" : { "query" : "cn:celeborn OR cn:galadriel AND text:lives" }
{ "cn" : "Galadriel" , "text" : "Lives forever" }
Brian
On Monday, September 9, 2013 7:06:16 AM UTC-4, dan wrote:
I have a query that returns results. For example lets say the following
query returns 5 results
{
"from" : 0,
"size" : 20,
"query" : {
"query_string" : {
"query" : "name:elastic OR title:elastic"
}
}
}
If I add an AND wildcard query to the query above it returns zero results.
{
"from" : 0,
"size" : 20,
"query" : {
"query_string" : {
"query" : "name:elastic OR title:elastic AND description:*"
}
}
}
My descripiton field is never null if it doesn't have a value it will be
an empty string.
In the documentation it says:
"Supported wildcards are *, which matches any character sequence
(including the empty one)"
So why isn't the second query returning the same results as the first?
--
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.