First of all we have to install the solr service in Ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
(This command may take a while. Accept the licence agreement also)
sudo apt-get install oracle-java8-installer
tar xzf solr-6.0.0.tgz solr-6.0.0/bin/install_solr_service.sh --strip-components=2
sudo bash ./install_solr_service.sh solr-6.0.0.tgz
check if the server is running:
sudo service solr status
To install Search API and Solr Search run these commands in the Drupal root folder (recommended method).
First add the Drupal 8 Composer repository:
composer config repositories.drupal composer https://packages.drupal.org/8
Download the module Search API
composer require drupal/search_api
Download the module Search API Solr
composer require drupal/search_api_solr
Enable modules and clear cache
drush en -y search_api_solr
Verify Solarium Client has been added to vendor folder.
Next we have to create the solr collection where indexed data will be stored. There is a config folder for each version of solr inside Search API Solr module. Copy the config module apt for your setup and move it to config folder of solr collection folder.
Solr will be installed /opt/solr-6.0.0 and a symbolic link with solr will be created to link with it.
solr symbolic link will have user and group as solr. Configuration and collection will be at /var/solr with user and group as solr. Therefore when you cd to it even if we use sudo will be permission denied.
We have to use the format below to execute as solr user:
sudo su - solr -c "command to execute"
Now we will create a testdata collection and also copy the config from Search API solr module to here.
sudo su - solr -c "/opt/solr/bin/solr create -c testdata -n data_driven_schema_configs"
sudo su - solr -c "mkdir /var/solr/data/testdata/conf"
sudo su - solr -c "cp ~/drupalroot/modules/contrib/search_api_solr/solr-conf/6.x/* /var/solr/data/testdata/conf"
Go to Configurate->Search API->Add Server and give a name and click on Solr and you will get the screen as below. (otherwise there is someerror in your installation of search api and search api solr module using composer)
Add testdata as core and you click save and you should have everything working. Then you have to add an index and set the just created solr server as backend. After that click the fields tab and add the fields required and Processor tab to add processors.Then click Edit tab to index the data to server.
There you have the Solr backend.
Now create a Search View page with the just created Index(Here Default Solr index) as shown below in picture.
Select Unformatted List of Rendered Entity and then you can style it as and how you like it.
Thats it, Cheers, you have done it!!