Getting the Most Out of Search API, Solr, and Views
0 min read
I had the opportunity to present on Search API, Solr, and Views at this year's Pacific North West Drupal Summit. These are technologies that we use regularly for our client sites. Search can be a huge part of a site, and solr is a great way to implement search. In drupal there are two ways to implement Solr, there's the Apache Solr module, which was the first module to provide solr integration, and the Search API module which integrates solr with the Search API Solr module. My presentation was about the Search API implementation. Here are the slides for my presentation. Most of my presentation was a hands-on demo, during which I took a bare bones site and implemented Search API with solr and then configured additional functionality. If you are interested in using my content types and sample content to do the same things you can use the following files:
The username and password for each of these is "pnwds"
A database dump with just the sample dataA database dump with solr config and view where solr returns the search results, but the displayed content comes from the database. This is a typical use case. A database dump with solr config and views where all data is coming from solr with no database queries. This is an atypical use case, but does provide performance improvements and the ability to use solr to search a remote site. A feature module containing the content types as they were used in the no sql instances (more on this below) A feature module containing the solr config as used in the no sql instances (more on this below)
When using the above you will need to edit the solr server config to update the host and path to match your local solr install. A sharp eye, looking at the no-sql output will see that the Prov/State facets include a number in front of the name. This is a result of having used a List (text) field for holding the Prov/State data, both the label and the key are put into solr in the same field. I tried to get rid of this and in doing so tried changing the keys. Sadly this didn't fix the issue, but it explains why the content types changed from the start point to the end. Lesson here, taxonomies are a better choice for this sort of thing and there's an issue queue post in the future.
Remote Site Search
If you would like to set up a remote site that searches the main site, use the content type feature module and the solr config module. When you do this, the facet blocks will be created, but you will need to place them on the search page manually... because blocks aren't featurable :-(.