Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using OR and NOT in solr query

I'm working on a solr query similar to the following:

((myField:superneat AND myOtherField:somethingElse) OR NOT myField:superneat) 

When running this, no results are returned. Using criteria on either side of the OR NOT returns results that I'd expect - they are just not working well together. In the case that myField matches superneat, I'm intending to also ensure that myOtherField is set to somethingElse, but if myField is not superneat, include it in the results.

Can someone explain why solr is not returning results for this kind of query? Should the query be restructured somehow - or is there a different way in which solr can be used to achieve the desired result?

like image 357
stolenricecakes Avatar asked Mar 11 '09 14:03

stolenricecakes


1 Answers

I don't know why that doesn't work, but this one is logically equivalent and it does work:

-(myField:superneat AND -myOtherField:somethingElse) 

Maybe it has something to do with defining the same field twice in the query...

Try asking in the solr-user group, then post back here the final answer!

like image 163
Mauricio Scheffer Avatar answered Oct 03 '22 23:10

Mauricio Scheffer