Closed (fixed)
Project:
Search API Database Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Dec 2011 at 15:33 UTC
Updated:
25 Mar 2014 at 11:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damien tournoud commentedHere is an implementation. Depends on #1390598: Add a way to easily identify facet filters inside the query.
Comment #2
damien tournoud commentedSame patch with an additional exception thrown if the facet operator is unknown.
Comment #3
evanbarter commentedI've tried this patch and the dependency and found that they both apply cleanly, however I'm running in to an issue which might just be my understanding but perhaps not.
Currently I'm trying this on a View (of commerce products) with 3 facets (color, manufacturer, type), each of which is set up as an 'or' thanks to this patch. The goal was a "free form" list of products which should never return an empty set. For example, if I select the colours "red" and "blue", ideally the manufacturers facet options should be reduced to the manufacturers that offer red and blue products (and similarly for type). If I then select "manufacturer A" and "manufacturer B" the type facet options should be reduced to types of products which are offered by "manufacturer A" or "manufacturer B" and are "red" or "blue".
The behaviour I'm seeing at the moment is if I select the colours "red" and "blue", there are type options that aren't removed from the facet options, even though there are no "red" or "blue" products with that type, thus it's possible to get to an empty result.
If this doesn't make sense please let me know I'll try and get in touch with you on IRC with an example site. I'm setting this to needs work but if my understanding of how this should work is wrong please set it back and I'll do my best to give it a proper review. Thanks!
Comment #4
evanbarter commentedJust saw http://drupal.org/node/1204966#comment-5417670 which I guess could be related?
Comment #5
jax commentedMarked #1424690: Support for OR (inclusive) facets as dupe of this one.
Comment #6
restyler commentedis this supposed to be working with FacetAPI?
I get "operator not defined" error all the time, since there is no $facet['operator'] at all.
Comment #7
restyler commentedokay, I see it uses FacetAPI constants :) how can I define "operator" element in facet array?
Comment #8
drunken monkeyI'll postpone this now, until we commit #1390598: Add a way to easily identify facet filters inside the query.
I'll also take a closer look at the patch then, I've now just skimmed over it.
Thanks, in any case!
Comment #9
pacufist commentedBug in #2 patch.
Need handle clone somehow. Now this code, doesn't clone filters of the object.
$or_query = clone $query;As result we looses filters in $query after unset it in $or_query
unset($filters[$filter_id]);Comment #10
pacufist commentedFast patch. Extended class SearchApiQuery with __clone() function.
Comment #11
pacufist commentedAlso $fields initialization missed after patch. This part was moved to function buildDatabaseQuery :
But due the fact that this array used in next part of code, we need initialize $fields in function search() as well.
Comment #12
yaelsho commentedHello,
Is there any news regarding this issue? bit confused from the patch parts mentioned above.
If there is a patch file that worked for you, I'll be happy to test it.
Thanks, Yael
Comment #13
farez commentedEchoing yaelsho... any news on this one? Is "OR" supported now for DB search?
Comment #14
irowboat commentedSame question as the previous askers - any updates on this issue? Thanks.
Comment #15
drunken monkeySorry for leaving this lying here for so long, it was high up on my TODO list, I've just got very little time for such larger feature requests. But I'm sure we can now get this committed in the coming weeks!
I've moved the cloning problem to a new issue (since it has to be handled in the Search API itself anyways) and provided a complete patch there: #2144531: Fix cloning of queries to clone filters, too.
Regarding the patch by Damien itself, that already works and looks brilliantly, thanks a lot again! It of course needed a re-roll, but other than that there was only one tiny mistake (the
operatorkey for facets is optional). I also added some tests, and I think we should now be all set.Please test/review!
Comment #18
drunken monkeyAh. Yes. Of course. We'll have to wait (at least) for Search API 1.10 to be released before we can commit this. We maybe should add a versioned dependency there, too. On the other hand, the error is only triggered when using OR facets, so maybe documenting this is enough.
Comment #19
drunken monkeySo, does anyone want to test or review this?
(Will let the test bot test in a few days.)
Comment #23
antonnaviHere is my implementation of Search API DB module OR logic (inside 1 facet).
It's based on posted patches adapted to last module version + additional logic for handling "No results" case and display all facets (have ability unselect it).
Patch required current latest Search API (7.x-1.10) and Search API DB (7.x-1.1) modules version.
Sponsored by Skilld
Comment #26
antonnaviFixed path to patched file.
Comment #28
antonnaviUsing facet operator exceptions fixed.
Comment #29
antonnaviComment #31
antonnaviPatch format fixed.
Comment #32
andypostAnton, you forget to add test for patch
do we really need to skip throwing excepion in case od unknown operator?
do tags enough to unset?
Anton's patch review
is this change related?
this could be moved out of internal loop
loops is not needed here
Comment #33
antonnavi1.1 Anton, you forget to add test for patch
-> Patch was updated and now it is combination of previous version + 1390586-15--or_facets.patch
2.1 is this change related?
-> This change related because it handle "No results" case and help "end user": Give ability uncheck incorrect facet items and not lose already selected filters. This part was reworked on current patch.
2.2 this could be moved out of internal loop
-> Fixed.
2.3 loops is not needed here
-> Fixed.
Comment #35
antonnaviFixed test error.
Comment #36
antonnaviFixed path to patched files.
Comment #38
andypostAnd let's get rid of
drupal_map_assoc()as wellComment #39
drunken monkey@ Antonnavi, andypost: Thanks a lot for your work on this!
However, Antonnavi's additional change is definitely not in the scope of this issue! Please create a new one for that, elaborate on your reasoning and amend the patch with a server option to turn this behavior on and off.
As all other changes were, I think, only related to the new code, a re-roll of my patch in #15 should be OK, right? (I actually found a bug in one of the new tests, maybe that was the cause of the previous fails.)
Please find it attached and see if it works for you, or you find anything wrong with it. Then I can hopefully finally commit this.
Comment #40
antonnaviLast added patch #39 works fine for me.
New issue No facets on no results was created (with detailed description and patch for fix it).
Comment #41
drunken monkeyOK, great to hear!
Committed.
Thanks a lot again to everyone who worked on this – especially, of course, to Damien!