In the previous blog, we have learned how to configure Solr Server with Drupal8 system. In this blog, we will learn how to index the contents of Drupal with our Solr server and display them using views.

Step 1. Add Index

Go to Admin > Configuration >  SEARCH AND METADATA > Search API and click on  Add Index.

Assign it a name and select the data sources that you want to index. Data sources are nothing but the various entities available in the Drupal8 e.g contents, blocks, comments, users etc. Assuming we want to index only the nodes of content type “Article” select the data source as Content and from the CONFIGURE THE CONTENT DATASOURCE section choose the bundle as “Article”. Select the respective Solr server and click on save. 

Step 2. Configure Fields

Once the index is successfully added we need to add/remove the fields of the content types that we want to index i.e push to the Solr server.

Go to Admin > Configuration >  SEARCH AND METADATA > Search API. Select the Field Link next to the newly added index. Here we can manage the content fields that we want to index.

For the Article bundle, we have chosen the following fields:

  • ID
  • Title
  • Body
  • Tags
  • Search Category(Custom taxonomy term reference field)

Step 3. Configure Processors

In this section, we can modify the data before indexing and search for better search experience.

Step 4. Index the items

Now, go to the ‘View’ tab of your index and click the ‘Index now’ button to get all the contents indexed.

We can verify the weather data actually has been indexed from the Solr admin panel.

Step 5. Create a view to display the indexed data

Now to display the indexed articles from the Solr server, let’s create new view. Go to Admin > Structure > Views and click on Add View.  From the Views Settings select show:”Index Articles” and create a Page as follows.

After configuring various views settings the page will look like follows:

About The Author

Leave a Reply