This tutorial shows how you correctly add negated terms to a query with multiple terms, whether linked with OR or linked with AND.
Sometimes you may need to formulate queries that include a negation. For example, you could be interested in all products that are either in stock or have no information about availability. The problem is that you cannot use the normal query syntax for tasks like that. Typing in
q=inStock:true OR -inStock:*
does not work the way you might expect it to.
The solution is to query the negated part against a whole result set and link it with AND. The correct formulation of the query to receive products that are either in stock or have no availability information is therefore:
q=inStock:true OR (*:* AND -inStock:*)
This syntax is to be used for queries (q) and filterqueries (fq) likewise.