The question have been answered very well in
Solr mailing list. They have also added an entry in the offical FAQ, that says:
Boolean queries must have at least one "positive" expression (ie; MUST or SHOULD) in order to match. Solr tries to help with this, and if asked to execute a BooleanQuery that does contains only negatived clauses at the topmost level, it adds a match all docs query (ie: *:*)
If the top level BoolenQuery contains somewhere inside of it a nested BooleanQuery which contains only negated clauses, that nested query will not be modified, and it (by definition) an't match any documents -- if it is required, that means the outer query will not match.
So expressions with only "negative" values return always 0 results, except at the topmost level, where the parser silently add a *:*
at the beginning of the query.
Therefore -text AND -text
is transformed to *:* -text AND -text
and so it has results, while
(-text)
isn't transformed to (*:* -text)
, because it is not at the topmost level, and so (-text)
gives no results.