Last updated March 12, 2012. Created by ronan on April 16, 2010.
Edited by sdemi, qasimzee, rayvan. Log in to edit this page.
Search facets are a way to let your users filter search results in interesting ways. Some facets included with Apache Solr are filtering by content author or by content type. The Apache Solr Facet Builder module allows you to create your own facets, describing each filter option using the Views UI. This article lists the steps to set up custom faceted search filters with this module.
As an example, imagine you want to filter your site by it's various sections: 'About Us', 'Articles', 'News' and 'Events', but these sections are not accurately described by any of the available Apache Solr facets.
- Install and enable the Apache Solr Facet Builder module as well as the Views and Views UI modules (You will also need to enable and set up Apache Solr).
- Create a new View to represent your facet type (eg: 'Filter by Section').
- Set the name under Basic Settings of the Default display to the name of your facet type. In our example the name would be 'Section'.
- Create one or more displays in the view of type 'facet'. Each of these facets will represent a different option in your facet type. In our example we might create 'About Us', 'Articles', 'News', 'Events'.
- Override the filters in each facet display and use them to specify what content should appear in each facet. For our example lets say 'About Us' contains all content of type Page with the taxonomy term 'About', 'Articles' contains any node of type 'Blog Post' or 'Article', 'News' is any Article with the 'Article' taxonomy term and 'Events' is any node whose 'Event Date' field is not empty. You can check if each facet contains the appropriate content by using the Preview function of the Views UI. You may also add arguments to your facets as long as they have some sort of default argument handling.
Your new facet filter will be available to Apache Solr and will act like any other available facet. You will need to enable it in the Apache Solr settings as you would any other new filter:
- Go to the Enabled filters tab of the Apache Solr module settings (admin/settings/apachesolr/enabled-filters) and enable your new facet (in our example it will be called 'Apache Solr Facet Builder: Filter by Section (view_name)'
- Enable the facet block for your new facet at admin/build/blocks
Your new facet block should show up now when you perform a search with Solr on your Drupal site.
Comments
Thanks
Awesome. Thanks for sharing ronan.
---
How to contribute to Drupal.
Works well for the default
Works well for the default search, search/apachesolr_search, but does not work with my custom searches made with Apache Solr Views.
How to build Facet builder facets to work with Apache Solr Views?
I think it amounts to being
I think it amounts to being able to add facet builder arguments to the view, but I don't see how to do that. I currently use Apache Solr: Taxonomy terms arguments. No facet builder facet argument show up in the Views UI to add argument for.
faceted searches with Views results
My standard Solr Search creates faceted search paths like this which do work properly
/?filters=tid:220%20tid:41
My Views based faceted search page creates paths like below which break when a second argument is added
/solr-search/220,41
Changing the argument setting from default "Term ID" to "Term Id's, separated by , or +" did the trick and got faceted views working with the simple coma separation
Location Apache Solr
To me is not appearing.
I added this module. I created Location CCK field which contains: Country, Province and city.
I created a views, which contains 3 facets, one for each location cck field. finally i added block to a correct reagion (header).
Nothing appears.
Is it compatible with Location cck?
Raul Muroc
http://www.metaverso.es
http://www.mydinamic.com
http://www.raulrodriguezcabestany.com
This doesnt work for me,
This doesnt work for me, because we need to add custom arguments to the view if we are using ApacheSolr Views module to show the results as views...any ideas to add custom arguments?
Versions, compatibility?
It'd be good to know how compatible is this module.
I'm currently working with the following versions:
* apachesolr_integration 1.2
* views 2.2
* apachesolr_facetbuilder 1.x
I've tried a few combinations and I can't make it work. I am thinking maybe this module it's only compatible with views 3x...