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.

Comments

janusman’s picture

I 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)

janusman’s picture

Title: Weird behavior of taxonomy OR facets » Taxonomy OR facets do not work correctly

Better 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.

mustanggb’s picture

Status: Needs review » Needs work

When 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

mustanggb’s picture

Component: Miscellaneous » Code
jpmckinney’s picture

qasimzee’s picture

This patch added to the code? I also have the same concern(that OR operator is not working properly) for CCK facets

mustanggb’s picture

A fix for this has not yet been committed as it still "needs work"

qasimzee’s picture

Is 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 :(

jpmckinney’s picture

@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

marthinal’s picture

@ qasimzee :
Try (a OR b) without " and with spaces between.

qasimzee’s picture

I actually got it fixed. Will come back to you again

Anonymous’s picture

Is there a patch available yet?

janusman’s picture

This is fixed in 7.x ... the patch at the beginning of this post might still apply to the 6.x-2.x branch.

timmetj’s picture

Does this also work on the 6.x-2.0-beta5 version? This is just what i was looking for.

timmetj’s picture

Damn, 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?

mustanggb’s picture

@janusman
You say this has been fixed in D7, has the issue highlighted in #3 been resolved?

janusman’s picture

@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 =)

timmetj’s picture

Can 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 :)

rjbrown99’s picture

@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!

timmetj’s picture

StatusFileSize
new2.93 KB

@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

rjbrown99’s picture

Thanks, 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.

blauerberg’s picture

subscribe.

#20 patch works completely for me in 6.X-2.0-beta5.

gaëlg’s picture

Status: Needs work » Needs review

#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.

nick_vh’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev

The 6.x-2.x version has been deprecated. Moving this to 6.x-1.x-dev

Status: Needs review » Needs work

The last submitted patch, apachesolr_search.module.patch, failed testing.

sdemi’s picture

Status: Needs work » Needs review
pwolanin’s picture

I 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

nick_vh’s picture

Status: Needs review » Closed (cannot reproduce)

Closing 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!

mustanggb’s picture

The not seeming to care part isn't true, more than happy to see if the issue is fixed in 6.x-3.x though.

nick_vh’s picture

(Sorry if I offended anyone, it was a copy/paste for a lot of old issues. Notice the or ;-) )