Simple addition to add support for taxonomy terms as filters. There is still weirdness with the urls generated in the facet blocks. All tids are collected into one url argument regardless of if they come from a filter or different arguments (Same as: #566618: Are multiple separate taxonomy arguments possible?)
Not very tested, so let me know if I'm missing something in how this should work.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | apachesolr_views_taxonomy.patch | 2.54 KB | njbooher |
| #25 | apachesolr_views_taxonomy.patch | 2.48 KB | njbooher |
| #21 | apachesolr_views_taxonomy.patch | 2.64 KB | njbooher |
| #20 | apachesolr_views_taxonomy.patch | 2.66 KB | njbooher |
| #18 | apachesolr_views_tid_filter.patch | 2.39 KB | njbooher |
Comments
Comment #1
jtsnow commentedI also created a filter for taxonomy terms along with a field handler. My filter looks similar to the first patch. I have tested mine fairly thoroughly and it works for me.
Comment #2
Remon commentedpatch of #1 works
Comment #3
Scott Reynolds commentedcool queuing this up to be committed.
Comment #4
tauno commentedShould the taxonomy term selected in the filter be showing up in facet block links? Using the patch from #1 I get links like:
/url/arg1/(515),7426 (where 515 is the term in my non-exposed filter) instead of /url/arg1/7426
It also causes no results to be returned even though there should be some. Does the (tid) format only work with the 2.x branch of apachesolr?
Comment #5
Scott Reynolds commentedThis should be independent of the apache solr version. So there must be a bug in the patch. It shouldn't make a difference which apache solr integration version you are using.
The only thing really that the apache solr search integration module provides for Solr Views is indexing and some default values.
Comment #6
tauno commentedIt looks like the issue is that the taxonomy term filter was getting grouped in with the taxonomy term argument when generating the url. The reason my initial patch worked and #1 didn't is that I was not properly grouping the selected terms into a sub query.
This patch adds an argument to add_filter() to keep track of if a filter is a views filter or not and then uses that to check if the filter should be added to the argument.
Does this seem like the right approach? Another option I came up with was to check for the presence of ( ) instead of adding an additional value to the _facets array - but that seems like a bad option.
Comment #7
drupalusering commentedreally cool filter feature you are implementing, but for some reason i get this error message when selecting a filter "Error: handler for apachesolr > tid doesn't exist! "
Comment #8
tauno commentedviktor, in your apachesolr_views/handlers folder, is there a file named: apachesolr_views_handler_filter_tid.inc?
This patch still needs work though, exposed taxonomy filters don't seem to work properly with the facet blocks.
Comment #9
drupalusering commentedno the patch for some reason fails to create the file. When i manually created it the view still gets invalid handler error
Comment #10
domidc commentedIf you expose taxonomy filter, it doesnt play nicely with the facets.
I have applied the patch in #6
The links in my taxonomy facets are build like this: installation/pathtosolrview/[tid]?tid=[tid] , so clicking this I get the tid in my exposed field resulting in "the term not found" because it expects the name of term in ?tid=term_name
When I filter with the exposed form it filters down nicely resulting in following url installation/pathtosolrview/?tid='term_name' Then again the facets links are build wrong resulting in installation/pathtosolrview/[tid]?tid=[tid]
Also when I use the exposed filter of my vocabulairy the facet of the same vocabulairy does not drill down the results.
Comment #11
rssfrrst commenteddoes this patch need updating for the new version released in march? I keep getting errors when I attempt to apply the patch in #6.
Comment #12
torgospizzaYeah, the patch breaks almost completely for me. I'm attempting to roll one that works with the latest version. I really need this functionality in apachesolr_views to create a catalog view using solr as the backend.
Will post ASAP.
Comment #13
colinsherry commentedPatch works for me but the facets break.
Comment #14
toemaz commentedApplied the patch from #6 and hacked my way to a solution
Added template file apachesolr-facet-link.tpl.php and added
before
Better solution is obviously required.
Comment #15
zualas commentedApart from breaking the facets, the filter has other issues:
1) incompatible with "apachesolr:Search" filter. Gives a PHP error if both taxonomy filter and also the Search filter are filled.
2) Gives a PHP error after clicking "apply" if the term is not present in the vocabulary.
The error in both cases is:
Comment #16
torgospizzaThe changes in the latest dev build of apachesolr_views has broken the Taxonomy facets for me. (I had them working at one point, using the code from the patch in #6).
Any update to this would be most appreciated.
Comment #17
Scott Reynolds commentedThe patch from 6 is very broken and I really don't like the change to the add_filter function
This is out of scope. Not yet ready to expose subquery support in the Views ui. Its getting there but not there yet (you can do it with filters).
I would like to get #1, without the field stuff, because we already have that set up.
Comment #18
njbooher commentedThis patch fixes the PHP error when the provided term doesn't belong to the filter's vocabulary. I don't know how to go about fixing the facet blocks.
Comment #19
zualas commentedPatch from #18 doesn't work for me. After applying it, every time I set up an exposed autocomplete filter and try to find something with it, it gives me a blank page.
At the same time, if I have the tid filter and the Solr Seach filter exposed for the same view, it will give an error 'The Apache Solr search engine is not available. Please contact your site administrator.' if I leave the tid filter blank and enter data in search filter. If I enter both or only the tid filter, I am given a blank results page.
Comment #20
njbooher commentedSorry, I hadn't tested it with autocomplete enabled. Try this one.
Comment #21
njbooher commentedOops, small problem with that one too. Try this instead.
Comment #22
zualas commented@njbooher: thanks for your work! I tested the latest patch and was able to search by taxonomy terms successfully.
As a next step, I would suggest looking into a possibility to search for node by the taxonomy term translation from the i18 tables, similar to what has been done here for the Content Taxonomy autocomplete. Not sure I can come up with a patch, but I will try to take a look if I can port some code from there.
Comment #23
torgospizzaQuestion, does the filter need to be "Exposed" for this to work? I had one of the earlier patches working just by having the Taxonomy Terms Argument in place, but that doesn't seem to work either. (By "doesn't seem to work" I mean, the Facet Block either has a link to the current View I'm on, or it links to a long URL but when you click on it, it doesn't do any actual filtering.
Suggestions? Otherwise thanks for working on this! Really need this functionality something fierce :)
Comment #24
Maikel commentedI applied the patch from #21 but when i try to add the filter 'Apache Solr: Taxonomy terms' i get the following message 'Configure filter Broken/missing handler'.
Is there something i am overlooking?
Comment #25
njbooher commented@torgosPizza: I haven't tested the patch with facet blocks; however, exposing the filter would be required for them to work.
@Maikel: The patch from #21 works for me, though I have since removed some duplicate code locally. See if the attached updated patch makes any difference.
Comment #26
digi24 commented@njbooher
Your filter seems only to search for terms, would it be possible to add a filter for tids
like it was the case in the first patches?Or is your patch just an addition to other patches?Comment #27
njbooher commentedWhich widget are you using? Dropdown displays term names but works with term ids. If you expose the form you can direct people to pages with certain filters enabled by passing ids through the url. (Eg. http://mysite/insects?type[]=157).
Comment #28
digi24 commented@njbooher
Thank you very much, the dropdown solved my problem, I did not realise the difference between the two widgets.
The patch in #25 is working fine.
Comment #29
torgospizzaThanks for the patch! It seems to work well with an exposed form (even an exposed form in a block). Haven't yet tested it with multiple terms yet. However it's only halfway there - getting the facets to work is my next step, and one I'm really hoping to fix. For now I could hard-code some URLs in there as described in #27, but in the end that's not a good solution, since adding new terms becomes a chore when you have to add links all over.
Since the facets still don't work, and having an exposed form of any kind is kind of...ugly, I'm going to try and figure out why the facets were working for me at one point and see if I can roll a patch that will solve it. If others get there before me, even better. :)
EDIT: Unless, Scott, you're still not ready to expose some of the subquery stuff. I read through this thread again and it sounds like there are still some things that need to be fixed/cleaned up before we can have solid taxonomy term filtering happening. Is this true? What can we do to help get it there? Thanks again for the great module.
Comment #30
kenorb commentedURL for Taxonomy terms as exposed filters looks weird:
&tid[0][value]=366&tid[0][exclude]=&sort_by=changed&sort_order=ASC
Related issue: #856522: Taxonomy facet blocks no longer working
Comment #31
floretan commentedNote that the patch from #25 uses an "or" operator even when the filter settings are set to "and".
Comment #32
njbooher commentedPatch updated to use the correct operator. For those seeking facet block support, see #906508: Fix exposed filter facet blocks.
Comment #33
digi24 commentedThanks njbooher, filter now works as expected.
Comment #34
kenorb commentedComment #35
tauno commentedUnassigning from me.
Comment #36
dstuart commentedHave Applied the Patch and works as expected other than the uglyness that is brought up in #30
Comment #37
ordually commentedThanks for the great patch! It's working great with #906508: Fix exposed filter facet blocks. Fit the bill for just what I needed, to allow users to filter the view results by multiple vocabularies.
@Maikal in #24: I had the same issue you're seeing. Turned out to be an issue with how I was applying the patch file. The patch is 2 changes, one of which is the creation of a new file "handlers/apachesolr_views_handler_filter_tid.inc". When I ran
it created the file "apachesolr_views_handler_filter_tid.inc". Note the missing "handlers/" in the path! Reading the patch man page makes me suspect that it *should* have put it in the proper path. Check if your file is in the "apachesolr_views" directory instead of the proper "apachesolr_views/handlers" directory.
Comment #38
kenorb commentedFilter support:
http://drupal.org/cvs?commit=464680
Field support:
http://drupal.org/cvs?commit=464726
Comment #39
kenorb commentedRelated: #919154: Embedded views and faceted search filter blocks do not work well together
Comment #41
Rajesh Ashok commented#32 works for me