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_

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David Lesieur’s picture

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?

janusman’s picture

Title: Drill down on same-level taxonomy » Cutting down clutter

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

# 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(" ","&nbsp;", $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 =)

David Lesieur’s picture

Title: Cutting down clutter » Drill down on same-level taxonomy
zxombie’s picture

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.

David Lesieur’s picture

Version: 5.x-0.4 » 6.x-1.x-dev
Christefano-oldaccount’s picture

This is a mighty useful idea. Taxonomy Filter can do this and may be a useful reference point.

asak’s picture

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?

drupaloSa’s picture

Great idea, subscribing.

David Lesieur’s picture

In terms of UI, the guys at FaceTag seem to drill multiple terms per facet the right way. Have a look at their demo.

drupaloSa’s picture

That was awesome. I hope this can be implemented, certainly it would be of great use.

asak’s picture

Very nicely done indeed.

mooffie’s picture

In terms of UI, the guys at FaceTag seem to drill multiple terms per facet the right way. Have a look at their demo.

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

David Lesieur’s picture

FileSize
64.55 KB

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.

David Lesieur’s picture

FileSize
46.44 KB

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.

mooffie’s picture

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

sagannotcarl’s picture

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.

John Bickar’s picture

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?

David Lesieur’s picture

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

Katinka’s picture

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.

chuntley’s picture

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:

  1. Noticed that repeating categories already "just works" as far as search is concerned. If you give a search URL that includes two taxomony terms from the same vocabulary, you get the correct search result and the proper remover links in the "Current Search" block. Thus the most potentially hairy part, dealing with the SQL generation code, was already working just fine without any changes.
  2. In order to allow multiple filters for the same vocabulary, added a "$vocabulary->multiple ||" clause to the if statement just below the comment "// If the vocabulary's corresponding facet is allowed" in taxonomy_facets_faceted_search_collect(). This short-circuits the logic preventing two filters/facets for the same vocabulary. A this point we're half-way home except for some UI changes.
  3. Added some logic to faceted_search_ui_build_categories() to eliminate any duplicate categories (i.e., those that have already been selected) from being displayed. (Why there? Because it was a place where we could get at all of the facets and categories at once.) I had to assume that two categories from the same vocabulary with the same label were equivalent and thus duplicate. This might cause some problems in hierarchical taxonomies where labels can be duplicated at different points in the tree. API suggestion: how about adding an equals() method to categories to make detecting duplicates easier? The method could be over-ridden for classes that need to do anything more sophisticated than compare labels.
  4. To avoid some UI confusion, disabled the showing of filters with active categories in the Guided Search block. This of course means that I have to use the Current Search block to broaden the search, but that works o.k. for me. I actually prefer it that way anyway.

I've attached a snapshot of the end result.

sagannotcarl’s picture

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.

chuntley’s picture

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.

asak’s picture

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.

gengel’s picture

Bump because I need this...also can we put this in 5.x-dev as well?

coupet’s picture

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

vitzo.com’s picture

+1 vote to implement this.

rokr’s picture

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

rokr’s picture

duplicate deleted. since the first comment disappeared (and appeared later). sorry

sagannotcarl’s picture

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.

rokr’s picture

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

josoal’s picture

subscribe

pianomansam’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Active » Needs review
FileSize
2.3 KB
251 bytes

Bump because I need this...also can we put this in 5.x-dev as well?

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!

pianomansam’s picture

FileSize
2.31 KB

Small bug in faceted_search_ui.module patch... use this newer patch instead

e-boyz’s picture

Bump it. I need this for drupal 6. Keep the good work! Subscribing.

David Lesieur’s picture

@e-boyz: A good way to help this happen is to test the patch and report back your successes or failures with it. :-)

David Lesieur’s picture

e-boyz’s picture

@e-boyz: A good way to help this happen is to test the patch and report back your successes or failures with it. :-)

But the patch is for drupal 6? I think it's only for the drupal 5 version, isn't it?

Thanks!

pianomansam’s picture

My patch above is for drupal 5. The instructions given by chuntley are for drupal 6.

e-boyz’s picture

My patch above is for drupal 5. The instructions given by chuntley are for drupal 6.

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:

3. Added some logic to faceted_search_ui_build_categories() to eliminate any duplicate categories (i.e., those that have already been selected) from being displayed. (Why there? Because it was a place where we could get at all of the facets and categories at once.) I had to assume that two categories from the same vocabulary with the same label were equivalent and thus duplicate. This might cause some problems in hierarchical taxonomies where labels can be duplicated at different points in the tree. API suggestion: how about adding an equals() method to categories to make detecting duplicates easier? The method could be over-ridden for classes that need to do anything more sophisticated than compare labels.

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!

pianomansam’s picture

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.

David Lesieur’s picture

indianroo’s picture

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.

philbar’s picture

Title: Drill down on same-level taxonomy » Drill Down Taxonomy Terms (Free-Tagging Facets)
Version: 5.x-1.x-dev » 6.x-1.x-dev
ErwanF’s picture

This feature request (subscribing !) reminds me of an Exhibit/Simile's interface from the MIT. Hope that could help...

David Lesieur’s picture

Title: Drill Down Taxonomy Terms (Free-Tagging Facets) » Select multiple terms per facet

This issue applies to any type of facet, not just taxonomy facets.

David Lesieur’s picture

Status: Needs review » Needs work
David Lesieur’s picture

SpikeX’s picture

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.

petednz’s picture

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

halfiranian’s picture

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

miiimooo’s picture

subscribing (D6)

miiimooo’s picture

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.

miiimooo’s picture

update #1

still not quite sure what 'm doing
miiimooo’s picture

Status: Needs work » Needs review
FileSize
4.62 KB

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.

coastwise’s picture

Status: Needs review » Needs work
FileSize
109.16 KB

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.

coastwise’s picture

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

coastwise’s picture

Status: Needs work » Needs review
FileSize
4.7 KB

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!

miiimooo’s picture

Thanks. That's much better. Not sure your patch includes the commenting out of the line 605 stuff I had added before

    if (!$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?

steveturnbull-2’s picture

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->multiple

in 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

bbence’s picture

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!

Anonymous’s picture

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!

SpikeX’s picture

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

bbence’s picture

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.

Quentin’s picture

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

philbar’s picture

millmoo wrote:

Not sure your patch includes the commenting out of the line 605 stuff I had added before

This was answered in the earlier post by coastwise (#56):

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)

Any chance we can get this tested and committed by the maintainer?

Quentin’s picture

FileSize
26.58 KB

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?

janusman’s picture

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

janusman’s picture

Status: Needs review » Needs work
+++ 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.

janusman’s picture

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

tomcom2k’s picture

Sorry if i've missed something but I've applied all the patches and multiple taxonomy works but sadly I cannot now select more than 1 different CCK field in guided search?

For example (purely fictional to demonstrate what I mean)

CCK Field - Country - France England
CCK Field - Job - Engineer Tailor
Taxonomy for multiselect - Age bracket - 10-20 21-30 31-40

If I selected England the options for both Engineer and Tailor disappear

I can select all 3 Age Brackets fine

Any ideas?

nakhnoukh’s picture

Hi, so using the latest patch in this thread (or actually the files in the zip from #64) I'm seeing the behavior where you can select multiple terms from a single vocabulary, but you can only select the parent terms.

Is everyone else seeing the same? Anyone know of a fix for this?

nakhnoukh’s picture

In case anyone's curious, I was able to get multiple selection of terms within a hierarchical taxonomy to work, by using the patched files in comment #64 and commenting out two sections in faceted_search_ui_guided_block (I'd make a patch but this code is already so patched, that it's hard to tell what the starting point is). Hopefully this makes it into the next official release.

1) You will have more than one search path object when drilling down into the hierarchy

/*
      if (count($search_path) > 1) {
        drupal_set_message("Warning: more than one search_path object: " . print_r($search_path,TRUE));
      }
*/

2) You don't want to ignore facets that have terms selected

/*   
 if (!empty($facet->_path)) { // ignore taxonomy facets that have terms already selected
      continue;
    }
*/

The only less then perfect effect of this is that a facet shows up once in Guided Search for each "branch" of the hierarchy that you select. The multiple display in Current Search seems like a fine behavior to me.

Attached is a screenshot of what this looks like along with a screenshot of the taxonomy I was testing with. And here is a video of the selection process: http://screencast.com/t/YmFhMjU2

Hope this helps someone.

miiimooo’s picture

This looks very good. Any chance you could just download the last official release or dev version and run a recursive diff against your version?

nakhnoukh’s picture

FileSize
5.55 KB

This patch is between the two faceted_search module directories, the "old" one is the latest release version 6.x-1.0-beta2.

janusman’s picture

Status: Needs work » Needs review

Marking as needs review

tdimg’s picture

FileSize
5.01 KB

Thanks everyone for doing this, its exactly what I need now, and I got it to work by applying the patch provided in #74 to 6.x-1.0-beta2 with additional changes as per #68 and #69 so that it's also working with free tagging vocabularies and cleaning up the comments.

I've tried to create a patch (to be used instead of patch in #74), first time ever I think, using WinMerge, hope it's correct - of course I tested it by reapplying it to beta2 but any pointers as to what I should've done differently would be appreciated.

vatavale’s picture

(subscribe)

koyama’s picture

+1 subscribe

swentel’s picture

Patch in #76 works fine for me!

swentel’s picture

Ok, I was to fast - when using cck facets and trying to expose a date field, this patch breaks date facets - I'll look into this further!

swentel’s picture

Ok, to fast, was due to a core bug (taxonomy and hiearchy)

swentel’s picture

However, if anyone could test out date_facets (from http://drupal.org/project/cck_facets) and give me a pointer to make date facets work again, that would be great :)

swentel’s picture

Status: Needs review » Needs work

Ok: following code breaks date facets:

  if (in_array($category->_tid, $searched_tids) !== FALSE) {
      continue;
  }

Should be something like

  if (isset($category->_tid) && in_array($category->_tid, $searched_tids) !== FALSE) {
      continue;
  }
vlad.k’s picture

I use the patch in #76 and it works great!
I don't have cck facets nor exposed date fields, I only have taxonomies. This should definitily be commited soon because I initially wanted to throw away Faceted Search for lack of this functionality in the first place and I think that many others have the same issue.

swentel’s picture

This patch also breaks another fundamental thing: with multiple environments, disabling a taxonomy facet won't work. So if you have 3 taxonomies and only want to show 2, you'll still see 3 listed and clicking on it won't work at all. Will add some debug info later on.

swentel’s picture

Ok, couldn't find a solution to make this work perfectly for my comment in #85 so I had to make an ugly hack instead in faceted_search_ui to look at the path of my environment and stop the the facet vid if needed

And while we're at it: this patch also breaks the 'more' link, specifically when going to 'path/facet/taxonomy:1' where the taxonomy is the root term which has more child terms than defined to show in the facet block. So lots of work todo here. The fundamental solution simply breaks other facets functionality, so be warned when installing this patch. I haven't got time right now to get to the bottom of this, maybe in a week or two.

swentel’s picture

Ok, the breaking of the more link (browse be path/facet) is caused by adding the '|| $vocabulary->multiple || $vocabulary->tags' in the taxonomy_facets.module

dopedwizard’s picture

Looking for the exact same thing hopefully this can be solved.

milesw’s picture

Subscribing, as this is the only reason I can't use this great module yet.

Just tried the patch from #76 and technically it works, but the behavior is a little strange. It's actually creating a duplicate facet for every selected facet item. This seems awkward, but maybe it could be done nicely with theming.

dopedwizard’s picture

Mh not sure what you mean, I treid it as well just now and it seems to work, maybe i just dont see what you are saying. Could you explain?
thanx

milesw’s picture

Here is a sample of what gets displayed for a facet as I click items. Is this the behavior you're getting?

Countries
United States (229)
Canada (85)
Mexico (49)

***** (click: United States) *****

Countries
Canada (8)
China (8)
United Kingdom (7)
India (6)

Countries: all » United States

***** (click: Canada) ******

Countries: all » Canada

Countries
Mexico (5)
Australia (1)
Japan (1)

Countries: all » United States

dopedwizard’s picture

Yes and i guess it should be that way.. but what he means is if you search for something it does not make it one term but 2 or three

if you search for restaurant mexico tasty

it will not be

x restaurant mexico tasty

but

x restaurant
x mexico
x tasty

which still gives the same result its just a pain for someone to than remove the terms manually

heatherann’s picture

Using the patch in 76, I thought that it hadn't done anything at all. Now I've discovered that if I click a term in one of my multiple-select taxonomies on the main faceted search page, this doesn't work (i.e. it refines by that term but doesn't let me further refine with another term in that vocabulary). From the main page, if I click on a term in a single-select vocabulary and then refine by a term in a multiple-select vocabulary, I get the multiple selection behaviour that we've all been hoping for.

I'm also getting the behaviour reported in #89. It looks like this for me:

Guided search

Click a term to refine your current search.

Infection                                                                 <-- another vocab
    * HIV (1)

Topic:     
all » Legal issues                                                        <-- first selection from multiple-select vocab 
    * Substance use law (1)                                               <-- child term

Topic:      
all » Programming                                                         <-- second selection from multiple-select vocab 
    * Settings (1)                                                        <-- child term

Topic                                                                     <-- option to further refine from multiple-select vocab
    * Specific populations (1)

Format                                                                    <-- another vocab
    * PDF (1)

Organization                                                              <-- another vocab
    * Canadian HIV/AIDS Legal Network (CHLN) (1)

Resource Category:                                                        <-- selection from single-select vocab
all » Reports and guidelines

Throwing multiple selections into the mix seems out of scope for the current formatting. If I can throw a formatting suggestion into the mix:

Topic:

  • [-] Legal issues
    • [+] Substance use law (1)
  • [-] Programming
    • [+] Settings (1)
  • [+] Specific populations (1)

Format

  • [+] PDF (1)

Organization

  • [+] Canadian HIV/AIDS Legal Network (CHLN) (1)
fowlerjb’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta2

Are there any plans to add the feature to 'select multiple terms per facet' into an upcoming release? I tried using the patch on a 6.x-1.x-dev release to no avail. It would be great if it was included built into the module. Any time frame for this? Thanks!

picxelplay’s picture

Technically, if you expose Views filters, you can achieve this very same thing. It's just very resource intensive..but if you were going to use Views anyway to display the results, I would say there is not much difference.

Also, as I think a comment above said, Solr does drill down, as does Acquia Search (which also uses Solr, but for a price)

BeaPower’s picture

How can I show subcategories by default for each main term?

globallyunique’s picture

I'm using the 6.x-1.x-dev version and AND'ing terms works fine. Is there a way to display the parent to get the OR of all the children as described in #13 above and still be allowed to select individual children?

petelefrank’s picture

Appreciate #64, works fine. Except I would also love to receive a hint on how to enable multiselect with "OR" like requested in #97.
Disagree with #13 that Hierarchies is like "OR", disagree with others who believe that "AND" is more useful than "OR". Think of various makes of Cars. You don't want to have Subaru under Volvo?

YK85’s picture

subscribing

restyler’s picture

I also think that OR operation is really useful. subscribing

Slacky08’s picture

Can anyone give any advice as to how this could work with CCK Facets? I have a single CCK Field with multiple option checkboxes in it - as soon as I select one option I can no longer select the others... This seems a very similar problem to that listed here, but with CCK Facets and not Taxonomy.

Any help is much appreciated.