Select multiple terms per facet
janusman - September 6, 2007 - 14:38
| Project: | Faceted Search |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
A node might have 2 or more categories from the same vocabulary, and right now faceted_search does not let you add limits from a vocabulary once a certain category has been selected.
For example I have a library catalog where all the subjects for a book are under the same vocabulary (which is free tagging), but since books have a lot of subjects, selecting only one can produce a large result list (sometimes 30, 100 or more). It would be nice if I could limit like this:
Current search
[–] Subjects: Development
Guided search
Subjects: all » Development
_Software_
_Computer systems_
_Embedded computer systems_
_System Design_

#1
Yes, selecting more than one category per facet... I've been thinking about this too. ;-) It would certainly be a very useful feature.
This is also an interesting user-interface challenge... Any ideas on how to offer this feature without making the UI look too cluttered or complicated?
#2
My opinion is that it won't look cluttered (at least not "noticeably more").
If you look at my above example, there´s only one extra line to the subjects already offered when there is no search active... and the number of those subjects is defined by the site admin...
I also think that, as per another suggestion, if you sorted facets by "most frequent first" then it would make more sense to the user, since this would provide something (in large datasets) that makes a LOT more sense than alphabetical sorting... if there's a performance penalty to this kind of sort then perhaps a caching function [even a simple "dumb" one] would help out!
To also make the interface "easier" (less cognitive load) I'd also add a classname to the facet links so that we can specify font sizes via CSS. Say, instead of:
<span class="faceted-search-category">...facet link here... (facet freq. here)</span>
we could have something like:
<span class="faceted-search-category faceted-search-freq-N">...facet link here... (facet freq. here)</span>
where "faceted-search-freq-N" would be calculated from some algorithm. (Here's a simple one that I use elsewhere.. but it might need tweaking, and I also specify font size directly instead of a classname) :)
<?php
# Some assumptions:
# $numtags (int) has the number of unique tags found in current result set
# $total_results (int) has the total number of results in current result set
# $tags is an array of "taginfo".
foreach ($tags as $taginfo) {
list($tagfreq, $tagtext)=$taginfo; #$taginfo has 2 elements, first if frequency, second is tag's value
if ($tagfreq<4) continue; #don't show tag if not frequent enough (4)
$pct1=($tagfreq/$total_results)*100;
if ($pct1<3) continue;
$pct2=$tagfreq/$numtags;
if ($pct2<0.05) continue;
$tagsize=1+($pct2*0.2); #This is the font size measured in EM
if ($tagsize>2.2) $tagsize=2.2; #Font size limit
$url="[compute destination URL for tag here]";
echo "<a href=".$url." style='font-size:".sprintf("%.2f",$tagsize)."em' title=\"$tagfreq records (".sprintf("%.1f%%",$pct1)." of total)\">".str_replace(" "," ", $tagtext)."</a>\n";
}
?>
If the facet terms (or values) are short enough, you can then now show facets as a tagcloud, which takes a bit less space... and since you are relating font-size with "importantness" then you can do away with the (XX) text you are now putting after each facet. Of course, not everyone would like or want this, so it should be a switch for admins =)
#3
#4
I'd like this. I've looked at implementing it however I wasn't sure where to start. If anyone has any ideas I would like to hear them.
#5
#6
This is a mighty useful idea. Taxonomy Filter can do this and may be a useful reference point.
#7
This is exactly what i'm looking for.
Thinking some more - How about adding an (optional) button for "Select multiple", which leads to a page similar to the one you get when clicking on "more..." - but with checkboxes and a submit button?
#8
Great idea, subscribing.
#9
In terms of UI, the guys at FaceTag seem to drill multiple terms per facet the right way. Have a look at their demo.
#10
That was awesome. I hope this can be implemented, certainly it would be of great use.
#11
Very nicely done indeed.
#12
(Anybody has screenshots? I had a hard time trying to get this .swf to work.)
"eBay express" too faced this problem. Here's how they solve it:
http://search.express.ebay.com/Toys-Hobbies_Action-Figures_
Clicking "More choices..." brings up a box with checkboxes. It's quite similar to what 'asak', in comment #7, suggested.
#13
Here's a snapshot of the UI mentioned above. I think FaceTag's approach is more in the "spirit" of Faceted Search since it is more interactive than a list of checkboxes. However there is a fundamental difference: FaceTag (at least from what I understand from the online demo) adds multiple terms with AND operators, while eBay can add lists of terms that are OR'ed together. Both are valid use cases. Which feature do we want? Mmmh... I'd take both, but which one is the most desirable? ;)
I'd be more inclined to go with the AND, because in Faceted Search we can already OR terms together through term hierarchies. Searching with a parent term is like doing an OR on all its children. Being able to AND multiple terms belonging to the same facet seems to add more value to the system than being able to OR arbitrary lists of terms.
#14
Here's a snapshot of FaceTag, taken from their screencast. Look at where the cursor is: It is possible to drill down multiple hierarchies within the same facet by clicking the '+' symbol.
#15
David, thanks for the time you took to prepare the screenshot.
I don't quite "get" FaceTag's interface yet, so I'll do my best to watch this '.swf'.
(Yes, I agree that AND is more useful than OR. It's also easier to program. But... you know....)
#16
This seems like a good addition to an awesome module!
AND'ing together the terms makes much more sense. That is what happens when you click on any other facet option (Content Type X AND Term Y) and therefore would be expected behavior when drilling down through multiple taxonomy terms as well.
By the same token a separate page of checkboxes would seem out of place when you already have an interface to present the user with facets to click on.
#17
Why not have the interface continue to look the same? I.e., when you select a category from the guided search, then click "more options" from the search block, is it possible for you to be presented with the remaining categories from the already-selected vocabulary, much as you're (currently) presented with a list of terms from other vocabularies?
#18
@cubbtech: This is also very interesting, and I'd certainly like to preserve the current interface's simplicity. One limitation: Not being able to select multiple terms at different depths from the same vocabulary.
A nice trick could be to allow users to open new "instances" of the same vocabulary in the Guided search, each with its own current term and path. Search results would only show items that match the terms in all instances.
#19
I'm interested in the feature of selecting multiple terms of one vocabulary too. I also think, that AND'ing of the terms is the behavior expected of faceted search. It would be great if, by selecting a term of one vocabulary, the terms of the blocks will be reduced to exactly the terms remaining in the search result.
Example:
Vocabularies: Country, City, Category
The Nodes can have multiple terms of the vocabulary "Category" like being a hotel and a restaurant at the same time.
So if the user selects USA in the Country block, Chicago in the City block and restaurant in the Category block, hotel
should still remain in the Category block to be choosen to reduce the search result to only those which are a hotel and
a restaurant at the same time.
So the interface would look the same.
#20
After a bit of fiddling, I tried David's solution in #18 to cubbtech's request from #17. While it only required a few lines of code (maybe 20 or so all told), the changes were scattered about several files. Given the hacky nature of the changes to my already-patched Drupal 6 version I won't submit a patch here.
Nonetheless, here's a rundown of how I got it to work for multiple-select taxonomies:
I've attached a snapshot of the end result.
#21
chuntley: looking at your attached image, does this mean that there are 3 items that are tagged Direct Service, Education/Teaching, and Legal? Is the number next to Legal in your image taking into account the previously selected search refinements?
If so this would go a long way to solving my problem as well.
#22
Yes, your interpretation is correct.
There are three current selections (i.e., filters with active paths):
1. "Direct Service" from vocabulary "Instruments"
2. "Education/teaching" from vocabulary "Instruments"
3. "African Americans" from vocabulary "Interest Groups"
If you also select "Legal" from the "Instruments" vocabulary then the results narrow down to three nodes. So yes, it does take into account the previous selections.
David wrote some very elegant search code that happens to work in this case. All I did was tweak the interface to reveal what it was already capable of doing anyway. I'll post my patch when there is a developer release of faceted search for Drupal 6. Until then I think it would just confuse people and make David's work more difficult. Anyway, the mods outlined in comment #20 amount to a few lines of code in the places indicated.
#23
From what I can tell, Solr search solves this nicely: after selecting a term from a group, the group block appears with the selected term on the top, with a (-) sign to remove it, and if there are any results which include additional terms from that group (in addition to the selected one), it displays the terms with a node count. Simple & nice.
The downside is that some users would like the option to select multiple term at once, and not one by one with page reloads.
#24
Bump because I need this...also can we put this in 5.x-dev as well?
#25
One key problem to building a faceted search interface is selecting which facets and facet-values to make available to the user at any one time. This is especially important when the document domain is very large.
Some systems show users all available facets and facet-values. This approach can quickly overwhelm the users and lead to diminished user performance.
Other systems such as eBay Express1 present a manually chosen subset of facets to the user, and the facet-values are ranked based on their frequency.
Other systems, such as Flamenco, simply present the first few facet-values in an alphabetized list.
Personalized Interactive Faceted Search
http://www2008.org/papers/pdf/p477-korenA.pdf
#26
+1 vote to implement this.
#27
Is there a patch around for this issue already? I can see the behaviour at the demo site but not on my test-site using 6.x-1.x-dev. Or do i miss a setting for this?
cheers, Ronald
#28
duplicate deleted. since the first comment disappeared (and appeared later). sorry
#29
rkr: I can't be totally sure but it's possible that what you are seeing is drilling down into hierarchical tags rather than the ability to see content that was tagged with two tags on the same level. Maybe the maintainer of that site can confirm, but that's what it looks like to me.
#30
Thanks sagannotcarl,
you are right. Its just the taxonomy hierarchy which allows multiple items per taxonomy (one per level).
It would be nice to see multiple items at one level.
Configuration per facet would be the way to go as mentioned here before.
Sorry for confusion.
cheers, Ronald
#31
subscribe
#32
Have no fear. In my usability testing, users were confused about not being able to select multiple terms from the same vocabulary, even if it was a multiselect. I took it upon myself to fix this. Since I use Drupal 5 still, my work was done for 5.x. I appreciate the direction you give, chuntley, but making this happen in 5.x was a little more labor intensive.
Here's the patch files. Enjoy!
#33
Small bug in faceted_search_ui.module patch... use this newer patch instead
#34
Bump it. I need this for drupal 6. Keep the good work! Subscribing.
#35
@e-boyz: A good way to help this happen is to test the patch and report back your successes or failures with it. :-)
#36
Marked #372427: Enabling user to select several 'terms' within single Vocabulary as duplicate.
#37
But the patch is for drupal 6? I think it's only for the drupal 5 version, isn't it?
Thanks!
#38
My patch above is for drupal 5. The instructions given by chuntley are for drupal 6.
#39
Thanks for the clarification. I don't have any idea of php, but I have read carefully the chuntley instructions and I was able to get results from it.
But I'm stuck on the third point:
I assume that the code is somehow basic for a programmer, but I'm not capable of writing that logic. Please can someone help me, or at least give me some direction?
Thanks!
#40
Found a bug that stopped author and type facets from showing up in the guided search. This updated patch file should fix the issue. If you don't want to reapply this patch to the original faceted_search_ui.module, you can fix the problem on line 1085 removing the isset($category->_tid) requirement for the statement to be true.
#41
Marked the following issues as duplicates:
#412930: Select Children
#417084: refining: multiple terms per facet
#42
We ran into the same problem for multiple terms, and found the original suggestion by chuntley ended up showing disabled
vocabs, so I added a is_multiple method to filters, and a taxonomy facet can return true if it is multi-select vocab.
Then in facet_search.inc around line 1015 in function prepare, I check if the filter returns is_multiple is FALSE and then
do the unset, otherwise leave it there. This seems to be working well.
For multiple terms, it turns out we need both AND and OR semantics depending on the Vocabulary, so we're thinking to 'Use OR Operator' checkbox in the Facet admin settings, but don't know yet how to modify the resulting queries.
If anyone is interested, we're actually doing an AJAX version of the Guided Search box with checkboxes. When you a toggle a checkbox, the query is run and counts updated in place. We update a GMAP in place with the new output, but it can be any View output. We also need to incorporate Views filters, so looking at this next.
#43
Duplicate #472620: Free-Tagging Facets
#44
This feature request (subscribing !) reminds me of an Exhibit/Simile's interface from the MIT. Hope that could help...
#45
This issue applies to any type of facet, not just taxonomy facets.
#46
#47
Marked the following issues as duplicates:
#489596: Select multiple terms in Guided search
#495058: Allow multiple terms per vocabulary to be included
#48
Since my issue was merged into this one, and I just had a quick read at this entire page, it would seem that I'm looking for exactly what this person has posted (comment 20):
http://drupal.org/node/173524#comment-954838
You should attempt to work this into the next release, it's a needed feature.
Edit: I've tried following his instructions, but I don't have the knowledge to follow them without PHP code examples or "Find X Replace With Y" instructions.
#49
Hi - my post here http://drupal.org/node/372427 was merged with this one - which if fine - except that I was looking for an 'or' solution and much of discussion above is 'and'. Maybe the underlying issue is still aimed at both but keen not to lose sight of 'or'.
So, to use a US example, within a Vocab of States, I would want to be able to select eg California, Portland, Oregon, and therefore get results for all 'entities' that are tagged as being on the West Coast. not only those that exist in Ca AND Po and Or. cheers
#50
This is exactly what I'm looking for. The icing to make an already awesome module even better.
Will try the patch/instructions and let you guys know of problems.
Cheers
#51
subscribing (D6)
#52
I have rolled part of the instructions from http://drupal.org/node/173524#comment-954838 and http://drupal.org/node/173524#comment-1667662 into a patch. So far it's step 2 only so it displays an already selected vocabulary (if it's set to multiple). Any comments - especially from the posters - are welcome. I'm puzzled by the instructions for "adding some logic to faceted_search_ui_build_categories) and what is done in the patch for D5. So if you could give a bit of help for this that would be much appreciated.
#53
update #1
#54
Update #2. This is pretty much working, including the changes to the user interface. I decided to display each facet only once. Thanks to original patchers.
#55
Just tried this patch, and its definitely going somewhere, good work!
After adding a second term from a single vocabulary to the search, the list of remaining terms is no longer available.
#56
So I did a little digging and it seems this happens because the selected terms appear alphabetically, and my vocabulary name comes *after* the terms I searched for. By commenting out line 605 in faceted_search_ui.module I get the block in the screenshot. (this line stores which facets have already been processed)
With that line uncommented, and I only select terms that come after the vocabulary alphabetically, it works no problem.
I'll continue investigating...
#57
Update #3
OK. I modified the code that checks if the facet should be displayed. It now ignores any facet that has a non-empty path, so it will only show: vocabularies with no term selected (empty path variable), and any other facet (no path variable).
Thanks to miiimooo and original patchers!
#58
Thanks. That's much better. Not sure your patch includes the commenting out of the line 605 stuff I had added before
<?phpif (!$facet->is_browsable()) {
continue; // Not a facet.
}
// if (in_array($facet->get_id(), $facets_processed)) { // ignore facets already processed
// continue;
// }
// $facets_processed[] = $facet->get_id();
if (!empty($facet->_path)) { // ignore taxonomy facets that have terms already selected
continue;
}
?>
Any ideas how to add a tick box or something to select the multiple behaviour for a taxonomy facet?
#59
I worked my way through the patch by hand, partly because I have to create a different UI from the standard for a particular application and needed to understand it for my own facets.
It looks to me like the addition of:
... || $vocabulary->multiplein taxonomy_facets.module, is incorrect because essentially it adds *any* vocabulary that is a multiple whether or not it's been included as one of the facets in the environment.
What should happen, and this deals with miiimooo's question, is the addition of
function is_multiple() {return $this->_vocabulary->multiple ;
}
In the taxonomy_facet class in the taxonomy_facets.module. This ensures that vocabularies that are multiple get treated as such, and are included iff they are defined as one of the environment facets.
I'm sure this is what you intended originally.
@miiimooo: You don't need a checkbox for marking a vocabulary as multiple, if it is defined as multiple then it should be treated as such, if it isn't defined as multiple then it shouldn't be allowed to be treated as multiple in a faceted search.
Steve
#60
I would also like to try out this multiple term selection. Unfortunately I don't have direct acces to my server as I'm on a hosted environment so I cannot run the patch command.
Would anyone be so kind to upload the non-patch version of the modified files?
I'm using the latest 6.0 version (6.x-1.0-beta2).
Thanks a lot!
#61
I would like to pick this up again, because I just spent two days researching which module can provide functions that are necessary for my site.
I would like to quote indianroo in post #42:
For multiple terms, it turns out we need both AND and OR semantics depending on the Vocabulary, so we're thinking to 'Use OR Operator' checkbox in the Facet admin settings, but don't know yet how to modify the resulting queries.
If anyone is interested, we're actually doing an AJAX version of the Guided Search box with checkboxes. When you a toggle a checkbox, the query is run and counts updated in place. We update a GMAP in place with the new output, but it can be any View output. We also need to incorporate Views filters, so looking at this next.
This is EXACTLY what I need (except GMAP)! Can anyone tell me if there's any progress, or similar module? Thank you very much!
#62
Is this going to be patched into the dev branch? I want this on my site, but I don't want to mess around with patch files and whatnot (plus this issue is kind of a clusterf**k of ideas, I don't know whic hpatch file to use, or which one does what).
#63
Also it would be awesome if this path would not only work for taxonomy terms but for all fields.
For example to CCK fields that can have fixed values.
Also I have a computed field created for number ranges, so it would be very nice to have multiple facets possibility for each field.
#64
I have manually patched the (attached) files and uploaded them to the modules/faceted search folder, since I also do not have direct access to my server. Multiple select from one vocabulary works fine now, but... I'm experiencing a new problem after patching the files:
Faceted search does not allow selection of sub-terms any more, e.g.
Term A
- sub term A1
- sub term A2
Term B
- sub term B1
- sub term B2
It only selects Term A, but does not allow selection of any of the sub-terms... It does allow selection of multiple 'main' terms of one vocabulary.
Anyone any thoughts on this?...
#65
millmoo wrote:
This was answered in the earlier post by coastwise (#56):
Any chance we can get this tested and committed by the maintainer?
#66
Multiple selections in one vocabulary with hierarchy still does not work flawlessly:
I tested the commenting out option of line 605 in the faceted_search_ui.module: It does allow you to select a child underneath the first parent selection, but still I can not selet multiple childs...
Commenting out line 605 also generates an error while using faceted search (see attached).
Ideas?
#67
@miiimooo: this took me a bit, but figured out you have to check the "Multiple select" checkbox in each vocabulary's "edit" form. You have to do this even if your vocabulary is set to "tags" (like mine).
This is clearly a problem in the patch =|
#68
+++ faceted_search.inc 2009-07-30 16:47:20.000000000 +0100@@ -166,6 +166,10 @@
+ /** see http://drupal.org/node/173524#comment-1667662 **/
+ function is_multiple() {
+ return false;
+ }
Please remove comments referring to issue.
+++ faceted_search.inc 2009-07-30 16:47:20.000000000 +0100@@ -1006,8 +1010,11 @@
+ // see http://drupal.org/node/173524#comment-1667662
ditto
+++ faceted_search_ui.module Thu Jul 30 14:59:52 2009@@ -579,20 +579,36 @@ function faceted_search_ui_keyword_block
+ $categories = faceted_search_ui_build_categories($search, $index, 0, $max_count, TRUE,$searched_tids);
Missed a space after TRUE.
+++ faceted_search_ui.module Thu Jul 30 14:59:52 2009@@ -1058,7 +1074,7 @@ function faceted_search_ui_build_breadcr
+function faceted_search_ui_build_categories($search, $index, $from = NULL, $max_count = NULL, $links = TRUE, $searched_tids=array()) {
Code style: $searched_tids = array()
This review is powered by Dreditor.
#69
+++ taxonomy_facets.module 2009-07-30 16:03:35.000000000 +0100@@ -133,7 +133,7 @@
+ if (!isset($selection) || isset($selection['taxonomy'][$vocabulary->vid]) || $vocabulary->multiple) {
I'd change this adding a check for $vocabulary->tags (since all "tags" vocabularies are multiple-choice by default)
+++ taxonomy_facets.module 2009-07-30 16:03:35.000000000 +0100@@ -133,7 +133,7 @@
+ if (!isset($selection) || isset($selection['taxonomy'][$vocabulary->vid]) || $vocabulary->multiple || $vocabulary->tags) {
This review is powered by Dreditor.