Visual cue
|
Narration
|
Slide 1:
Solr Search and Facets Implementation in Drupal8
|
Welcome to the spoken tutorial on Solr Search and Facets Implementation.
|
Slide 2:Learning Objectives
- Introduction to Solr search
- Salient features of Solr search
- Installation of Solr search
- Creation of Facets
|
In this tutorial, we will learn about-
- Introduction to Solr search
- Salient features of Solr search
- Installation of Solr search and
- Creation of Facets
|
Slide 3:
System requirement
To record this tutorial, I am using
- Ubuntu Linux 16.04 OS
- Drupal 8
- Firefox web browser
|
To record this tutorial, I am using
- Ubuntu Linux 16.04
- Drupal 8 and
- Firefox web browser
You can use any web browser as per your choice.
|
Slide 4:
Pre-requisites
- You should have basic knowledge of Drupal
- If not, for relevant Drupal tutorials please visit http://spoken-tutorial.org
- A working Internet connection
|
To practise this tutorial, you should have basic knowledge of Drupal.
If not, for relevant Drupal tutorials, please visit the link shown.
You should also have a working Internet connection.
|
Slide 5:
API
- Application Programming Interface
- Set of rules to interact to each other
- For more details, see the “Additional Material” link
|
First let us learn what is an API.
API stands for Application Programming Interface.
It has a set of rules that software programs can follow to interact with each other.
More information on API is given in the Additional Material link of this tutorial.
|
Slide 6:
What is Solr
- Open source search platform used to build Search Application
- Create custom search engine
|
What is Solr Search API?
- Solr is an open source search platform used to build a Search Application.
- It enables us to create custom search engines that index databases, files and websites.
|
Slide 7:
Solr Search API
- The default search does database search
- It leads to slower process and extra load on MySQL
- Solr provides a different server for searching
- It will speed up the search operation.
|
Why do we need Solr Search API?
- The default search that comes with Drupal does database search.
- It leads to slower process and extra load on MySQL.
- But Solr provides a different server for searching. It will speed up the search operation.
|
Slide 8:
Salient Features of Solr
- Scalable
- Full text search capabilities
- Flexible and extensible
- Friendly user interface
- Fault tolerance
|
Some of the features of Solr are listed here.
- It is scalable.
- It has full text search capabilities.
- It is flexible and extensible.
- It has a friendly user interface.
- It has fault tolerance.
<<PAUSE>>
|
Slide 9:
What is Solr core?
|
Next we will learn about Solr core.
- Solr core is used to perform operations like indexing and analyzing
- It is a single index and associated configuration files
- We can index data with different structures
- A Solr server may contain one or multiple cores
- Multiple cores are used when we need multiple versions, languages, or configurations
|
|
In this example there is one core each for Articles and Weblogs in a single Solr Server Instance.
|
Show text Solr implementation process
Show text Bitnami Drupal Stack
|
Next let us learn the Solr implementation process step by step.
The following steps are applicable to Bitnami Drupal Stack.
But most of the steps are applicable to any other Drupal installation, as well.
|
Show text Step No. 1
Type
sudo apt-get update && apt-get upgrade -y
Highlight root
|
Step No. 1
Open your terminal and run the following commands to update and upgrade the machine.
Note that you should run this command as a root user.
|
Show text Step No. 2
Show text JRE or JDK
|
Step No. 2
Since Solr is based on Java, we need to have JRE or JDK installed in our system.
|
Type
sudo apt-get install python-software-properties
|
For this, first we need to install python software properties.
So run the following command.
|
|
Note that you should run the upcoming commands as a normal user.
|
Type sudo add-apt-repository ppa:webupd8team/java
|
Next we will run this command for setting up the Java Runtime Environment.
|
Type sudo add-apt update
|
Then to update the system with the unsupported packages,
type sudo space add hyphen apt space update
Press Enter.
|
Type sudo apt install oracle-java8-installer
|
Finally run the following command to install the latest version of oracle Java8.
|
Type java -version
|
Now we can check the installed Java version by typing java space hyphen version.
Press Enter.
|
Type sudo apt install oracle-java8-set-default
|
Next we have to set-up the default Java environment variable.
So, run the following command.
<<PAUSE>>
|
Show text Step No. 3
|
Step No. 3
Next we will learn to install Solr in our local machine.
|
Type cd /tmp
|
First we have to change the directory to /tmp.
|
Type wget http://www-us.apache.org/dist/lucene/Solr/6.6.2/solr-6.6.3.tgz
Show text
www-us.apache.org/dist/lucene/solr
|
Now we will download the Solr version 6.6.3 from their web page.
Type the following command.
Note that you can download any latest version from their website.
|
Type tar xzf solr-6.6.2.tgz solr-6.6.2/bin/install_solr_service.sh --strip-components=2
|
Next we will extract the downloaded tar file using the following command.
|
Type sudo ./install_Solr_service.sh solr-6.6.2.tgz
|
Now we should install Solr as a service in our system.
So type the following command.
|
Type service Solr status
Highlight the status
|
Then we will check the status of Solr by typing
service space Solr space status
Press Enter.
We can see that the service Solr is installed in our system and activated as well.
<<PAUSE>>
|
Show text Step No. 4
Type sudo su - solr -c "/opt/solr/bin/solr create -c testcollection -n data_driven_schema_configs"
Highlight testcollection
|
Step No. 4
We will now create a new solr core in Solr to index our Drupal content.
Type the following command carefully.
Here I have named the newly created core as testcollection.
|
Type in the URL bar - http://localhost:8983/Solr/
|
By default solr application listens on TCP port 8983.
We can access the Solr admin user interface through the port 8983.
In the URL bar, type http://localhost:8983/Solr/
|
Click Core Selector field
|
In the Core Selector field, we can see the list of all the available core.
|
Click the core testcollection
|
Clicking on any particular core, will give us the associated details.
That is all about Solr installation in our local system.
<<PAUSE>>
|
Show text Step No. 5
Show text mbstring extension of PHP & Composer
Show text Additional Material
|
Step No. 5
Next we will implement the Solr search API in Drupal8.
For this, mbstring extension of PHP and composer should be installed in our machine.
The steps to install the above software are given in the Additional Material link of this tutorial.
|
Type cd /home/spoken/drupal-8.4.4-0/apps/drupal/htdocs
|
Once the required installation is done, change the directory to htdocs of Drupal.
|
Type composer config repositories.drupal composer https://packagist.org
|
After this, we need to install solarium library in Drupal8.
Solarium is a Solr client library for PHP.
Execute the following command to install it.
|
Type composer require “drupal/search_API_solr”
|
Next we will install search API Solr module to Drupal8 via composer.
Type the following command.
|
Type composer require “drupal/facets:^1.0”
|
We will also download Facets module to Drupal8 to be used later on.
Type the following command.
At this point, we have downloaded all the required modules.
<<PAUSE>>
|
Show text Step No. 6
Go to Drupal8 site
|
Step No. 6
Next go to the Drupal8 site and enable the modules that we have installed.
|
Click Extend tab
|
Go to Extend tab.
|
Click Facets, Search API, Solr search, Solr Search Defaults
|
Put a check mark on the modules Facets, Search API, Solr search and Solr Search Defaults.
|
Click Install button
|
Click on the Install button at the bottm, to enable them.
We can see that all the four modules have been enabled.
|
Click Uninstall tab
|
Now we have to disable the default Search module of Drupal8 named Search.
To do so, click on the Uninstall tab in the Extend page.
|
Click Search
Click Uninstall button
|
Put a check mark on the Search module and click on the Uninstall button at the bottom.
Again click on the Uninstall button to confirm.
|
Show text Step No. 6
Switch to terminal
Type cp /home/spoken/drupal-8.4.4-0/apps/drupal/htdocs/modules/contrib/search_api_solr/solr-conf/6.x/* /var/solr/data/testcollection/conf
Highlight source and destination
|
Next we have to allow our Drupal to communicate with Solr.
For that, switch back to terminal and run the following command carefully.
This will copy the configuration files from modules folder of Drupal8 to the core of Solr.
|
Type sudo service solr restart
|
After copying the configuration files, to restart the Solr service, typing sudo space service space solr space restart
Press Enter.
<<PAUSE>>
|
Show text Step No. 7
Go to Configuration tab -> SEARCH AND METADATA → Search API
|
Step No. 7
Next we will configure the Solr server and index the available content in the default search index.
To do so, go to Configuration tab.
Click on the Search API under SEARCH AND METADATA.
|
Highlight Solr server could not be reached
Click on Edit of Solr Server
|
Right now we can see that the Solr server could not be reached.
Click on Edit of Solr Server.
|
Scroll down
Show Solr core field
Type testcollection
|
Scroll down.
In the Solr core field, type your core name.
I will type testcollection.
|
Click Save
Highlight Status: enabled
|
Leave the other settings as default and click on the Save button at the bottom, for saving the configuration.
Now we can see that the server connection could be reached and the core connection could be accessed.
|
Show text Step No. 8
Click Edit of Default Solr content index
|
Step No. 8
Next we will index the available content in the Solr server.
Click on the Edit button of Default Solr content index.
|
Click Save
|
We can change the settings as per our requirements.
For now, I will keep them as it is and click on the Save button at the bottom.
|
Highlight Index Status
Click Index now at the bottom
Highlight Index Status
|
We can see right now 0 items are indexed in the Solr server.
To index all the content, click on the Index now button at the bottom.
Now we can see all the 20 contents are indexed in the Solr server.
With this we have successfully enabled both the Solr server and index.
<<PAUSE>>
|
Show text Step No. 9
Go to Structure → Views
Highlight Solr search content
|
Step No. 9
Next let us learn to search our content using the Solr search.
For that, first go to Structure, then Views.
We can see the Solr search content view here.
|
Click Edit
Highlight Path /solr-search/content
Hover the cursor on preview
|
Click on the Edit button of Solr search content.
Note that Solr search content is a page which can be accessed on the path /Solr-search/content.
We can also see the preview of the view.
|
In the URL, type http://localhost:8080/drupal/solr-search/content
Highlight localhost:8080
|
Next we will access the Solr search content page.
In the URL bar, type http://localhost:8080/drupal/solr-search/content
If you are not using Bitnami Drupal Stack, please use localhost instead of localhost:8080.
|
In the search field, type Drupal.
Show the results
|
The Solr search content page appears now.
In the Search field, type Drupal.
It displays few results which are having the word “Drupal” in their content.
<<PAUSE>>
|
Show text Step No. 10
Go to Configuration → SEARCH AND METADATA → Facets
|
Step No. 10
Next we will learn to create Facets for categorizing the search results.
For doing so, go to Configuration tab.
Click on the Facets under SEARCH AND METADATA.
|
Click Add facet
|
Click on the Add facet button.
|
In Facet source, select source
|
In the Facet source drop down, select the source.
|
In Field, select Title
|
In the Field drop down, we will select the Title as facet field.
|
In Name, type Title
|
In the Name field, I will type Title as a name of this Facet.
|
Click Save
|
Finally click on the Save button to save the configuration.
|
Select List of links
Click Save
|
Here you can select the widget from the available types.
I am selecting List of links for now.
Leave the remaining settings on default and click on the Save button to save the configuration.
|
Show text Step No. 11
Go to Structure → Block layout
|
Step No. 11
Next we will learn to place the Facet which we configured now.
For that go to Structure → Block layout.
|
In the Sidebar second, click Place block
|
To place the block in the Sidebar second region, click on the Place block button.
|
Select Filter by Title facets.
Click Save block button
|
In the dialog box that appears, select the Facet named Title.
Configure the block as per your need.
Click Save block button.
|
Click Save blocks button
|
Now click Save blocks button at the bottom.
|
Show text Step No. 12
In the search field, type Drupal
Point to the results
|
Step No. 12
Next we will go back to our Solr search content page and see how Facet works.
In the Search field, type Drupal.
It displays few results which have the word “Drupal” in their content.
|
Point the Facets
|
We can also see Facet displaying the titles which have Drupal as a word in their content.
|
|
This is all about the implementation of Solr search and Facets in Drupal8.
With this, we come to the end of this tutorial.
<<PAUSE>>
|
Slide 10:
Summary
- Install Solr application
- Install essential modules via composer
- Configure Solr search API
- Configure Facets
|
Let us summarize.
In this tutorial, we have learnt to-
- install Solr application
- install essential modules via composer
- configure Solr search API and
- configure Facets
|
Slide 11:
Acknowledgement
|
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it.
|
Slide 12:
Spoken Tutorial Workshops
|
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
For more details, please write to us.
|
Slide 13:
Acknowledgement
|
Spoken Tutorial Project is funded by
- NMEICT, Ministry of Human Resource Development and
- NVLI, Ministry of Culture
Government of India.
|
|
This tutorial is contributed by Prachi Sharma.
This is Priya from IIT Bombay signing off. Thanks for joining.
|