Example Search Page using Search API with Solr and Views

David G - DrupalIntegrating Solr with Drupal is not altogether difficult but there can be quite a few steps. If you opted to install Solr yourself in your network environment that is 1 requirement to using Solr. Then you must Indexes for content you wish to search. Having done all that you can then setup a View or Search page to make use of Solr. In this blog post I’ll briefly cover how to use Views with Search Api Solr.

Creating a View Page for Searching

I previously covered installing and configuring Solr with Drupal. If you haven’t done so already — please go do that.

For Solr, Search and Views to all work properly you need at least the following modules installed: Search API, Search API Solr and Search Views (apart of the Search API set of modules). With these modules enabled you can then create a View to use your Search Index.

You can head over the Views -> Add New and you will see that a new option for a new kind of View is available, namely a Search Index.

Example of adding a new Search Index view type page.

Example of adding a new Search Index view type page.

After selecting Search Index you can then create a View that makes use of Fields you defined in the Search API Index fields configuration. For example you can create a full-text search (exposed) view filter which will scan the Title and Body field of your content type:

Example of adding a full-text search field to a View which scans through Title and Body fields.

Example of adding a full-text search field to a View which scans through Title and Body fields.

Once you’ve accomplished this you simply give your page a page path as you would any View page. An example of a completed view could look like this with additional fields.

Example "Advanced Search" page with a fulltext search, and a date range search also using the search index.

Example “Advanced Search” page with a fulltext search, and a date range search also using the search index.

Typically a Search page will only have a limited number of fields, and your site could make use of Faceted Searching through Search Results — which I will cover in a later blog post. In general the goal is leverage full text searching outside of the Drupal application to speed up the website.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *