See screenshot to illustrate what's going on.
Since we are using Solr field "tid" for filtering with fq=tid:XXX params, having multiple "Filter by taxonomy XXX" filters active causes OR operators to not be applied properly.
We are using Solr localparams tagging functionality, but all terms get tagged as "tid" and then OR'ed regardless of their VID.
The attached patch properly tags each fq (I'm assuming one FQ per vocab ID) for non-exclusion in facet counts using im_vid_XX instead of tid. See resulting blocks in screenshot.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | apachesolr_search.module.patch | 2.93 KB | timmetj |
| apachesolr-taxonomy-or-facet-comparison.png | 379.25 KB | janusman | |
| apachesolr-fix-or-taxonomy-facets.patch | 2.8 KB | janusman |
Comments
Comment #1
janusman commentedI forgot to mention that both vocabularies shown above on the screenshot are set to "OR" in their block's config.
If we switch to using fq=im_vid_XX:YY instead of the current fq=tid:YY for queries, we can clean up lots of code; we end up loading terms and looking up their vocabularies on several places anyways. Of course, this is non-trivial.
@pwolanin mentioned on IRC he's trying to make the switch on the 7.x branch (which we sould definitely backport to 2.x)
Comment #2
janusman commentedBetter title. Thought it through and the above behavior really means "taxonomy OR facets do not work correctly" vs. CCK text fields which do work OK.
Comment #3
mustanggb commentedWhen children are selected, ancestors should be ignored
Actual
Select "red" to find 231 items
Select "dark red" to find 231 items
Expected
Select "red" to find 231 items
Select "dark red" to find 72 items
Comment #4
mustanggb commentedComment #5
jpmckinney commentedMarked #918024: $ors array in apachesolr_modify_query duplicate.
Comment #6
qasimzee commentedThis patch added to the code? I also have the same concern(that OR operator is not working properly) for CCK facets
Comment #7
mustanggb commentedA fix for this has not yet been committed as it still "needs work"
Comment #8
qasimzee commentedIs there a quick work around for this? I tried using URL query like
filters=ss_cck_field_myfield:("a" OR "b")but solr server crashed :(Comment #9
jpmckinney commented@qasimzee: that's not what this issue is about.
@janusman; can you re-roll without the whitespace flag? the patch is misindented currently. Likely to be fixed in 6.x-3.x by backporting the superior handling from 7.x
Comment #10
marthinal commented@ qasimzee :
Try (a OR b) without " and with spaces between.
Comment #11
qasimzee commentedI actually got it fixed. Will come back to you again
Comment #12
Anonymous (not verified) commentedIs there a patch available yet?
Comment #13
janusman commentedThis is fixed in 7.x ... the patch at the beginning of this post might still apply to the 6.x-2.x branch.
Comment #14
timmetj commentedDoes this also work on the 6.x-2.0-beta5 version? This is just what i was looking for.
Comment #15
timmetj commentedDamn, sorry for my mistake :) It works in beta5 also!
But i may have another question for help. Normally if you use the AND operator the counter behind the taxonomy will only show the remaining items.
If you use this patch for the OR operator the counter keeps showing the total items, instead of the remaining items.
To make this more clear i'll example with the screenshot from above:
- lets say there are 200 red thirts, 100 green tshirts but also 50 red/green tshirts.
So when i check the taxonomy red/green, i get 50 results, but i want to counter behind red, and behind green to show red (150) and green (50), now it shows: red (200) and green (100).
Can somebody help me on this?
Comment #16
mustanggb commented@janusman
You say this has been fixed in D7, has the issue highlighted in #3 been resolved?
Comment #17
janusman commented@akamustang: Not quite sure. For D7, though, these issues (if they exist) should probably be moved to the Facet API issue queue. This issue is about 6.x, though, so this one shouldn't be moved just yet =)
Comment #18
timmetj commentedCan this also be changed to work with other filter types? Like the apache ubercart module. If filtering by Price, now the taxonomies get hidden if they don't match the price. This when the block settings are all set to OR operation.
Would really help.
and maybe also nice to have is that the remaining items are shown behind the filters (), instead of the total items. mentioned in previous comment :)
Comment #19
rjbrown99 commented@janusman would you consider upgrading the patch for 6.x-2.0-beta5? It seems a number of things have changed in the module code since the initial patch which make it not cleanly apply. Thanks!
Comment #20
timmetj commented@rjbrown99 here is the patch for 6.X-2.0-beta5. Just added the code manually to the correct .module file
#18 isn't in this patch, still hoping somebody can add this
Comment #21
rjbrown99 commentedThanks, my OR problem turned out to be related to apachesolr_views and not apachesolr - #1211276: Taxonomy filter adds duplicates. This may also fix other issues but my main problem was having duplicate ORs added when unfaceting.
Comment #22
blauerberg commentedsubscribe.
#20 patch works completely for me in 6.X-2.0-beta5.
Comment #23
gaëlg#20 works for me too (beta5). And #3 is resolved afaik. I switched the issue status to "needs review" as I'm not sure I understood the #3 problem, but if I'm right this could be RTBC.
Comment #24
nick_vhThe 6.x-2.x version has been deprecated. Moving this to 6.x-1.x-dev
Comment #26
sdemi commentedapachesolr-fix-or-taxonomy-facets.patch queued for re-testing.
Comment #27
pwolanin commentedI don't think 6.x-1.x has any support for OR facets, so we should close this unless the bug is present in 6.x-3.x
Comment #28
nick_vhClosing in favor of 6.x-3.x and because nobody seems to care (time of last response) or cannot reproduce. If you think this is still an issue in 6.x-3.x, feel free to re-open!
Comment #29
mustanggb commentedThe not seeming to care part isn't true, more than happy to see if the issue is fixed in 6.x-3.x though.
Comment #30
nick_vh(Sorry if I offended anyone, it was a copy/paste for a lot of old issues. Notice the or ;-) )