Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The addFilter function for building Solr queries gives us the ability to use it as an exclude filter ($exclude = TRUE).
Is it possible to exclude a addFilterSubQuery as a whole? eg. fq=-(myfield:value1 OR myfield:value2)
You'd think: why not just exclude one by one, thus fq=(-myfield:value1 OR -myfield:value2), but that doesn't always work so it seems: http://stackoverflow.com/questions/1343794/searching-for-date-range-or-n... (tested & I can confirm)
Comment | File | Size | Author |
---|---|---|---|
#7 | exclude-solrfiltersubquery-1543156-7.patch | 2.82 KB | geertvd |
#7 | interdiff-1543156-4-7.txt | 1.05 KB | geertvd |
#4 | exclude-solrfiltersubquery-1543156-4.patch | 2.34 KB | geertvd |
Comments
Comment #1
rp7 CreditAttribution: rp7 commentedOh btw, I solved the linked issue within Drupal, by not using a FilterSubQuery, but by just adding a normal fq Filter and somewhat abuse it:
Comment #2
pwolanin CreditAttribution: pwolanin commentedWell, I can see where that might be a useful feature. I guess we'd need to add another property to the subquery object class and/or take in another param to the constructor.
Comment #3
pwolanin CreditAttribution: pwolanin commentedComment #4
geertvd CreditAttribution: geertvd at XIO commentedI needed this feature so wrote a patch to add this.
Comment #5
Nick_vhCan you add a better explanation what to expect? Something along the likes of "Expect the exclusion of the bar and baz label".
Also, when talking to you, you explained you wanted to exclude empty fields. Is that a useful example to add here also?
Comment #6
geertvd CreditAttribution: geertvd at XIO commentedThe use case I was talking about is explained here http://stackoverflow.com/questions/634765/using-or-and-not-in-solr-query/
I'll add that to the test later and add some more comments explaining the reasoning.
Unless there is a better way to do this kind of query off course.
Comment #7
geertvd CreditAttribution: geertvd at XIO commentedAdded the logic explained in http://stackoverflow.com/questions/634765/using-or-and-not-in-solr-query/ and changed my assert message.
Comment #9
Nick_vh