{"id":58603,"date":"2023-09-28T21:16:02","date_gmt":"2023-09-28T15:46:02","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=58603"},"modified":"2023-10-05T21:28:11","modified_gmt":"2023-10-05T15:58:11","slug":"integrate-drupal-with-apache-solr","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/integrate-drupal-with-apache-solr\/","title":{"rendered":"Integrate Drupal with Apache Solr"},"content":{"rendered":"<h2><strong>What is Apache Solr?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Apache Solr is an open-source search platform developed by the Apache Software Foundation. It&#8217;s based on the Apache Lucene library and provides powerful search and indexing capabilities for websites, databases, and other content.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For Drupal users, it is possible to integrate your site with Solr. The <\/span><a href=\"https:\/\/www.drupal.org\/project\/search_api_solr\"><span style=\"font-weight: 400;\">Search API Solr Search<\/span><\/a><span style=\"font-weight: 400;\"> module provides a Solr backend for the Drupal <\/span><a href=\"https:\/\/www.drupal.org\/project\/search_api\"><span style=\"font-weight: 400;\">Search API<\/span><\/a><span style=\"font-weight: 400;\"> module.<\/span><\/p>\n<h2><strong>Why Apache Solr\u00a0<\/strong><\/h2>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It allows for Full-text searches that offer precise results along with its near real-time indexing and searching capabilities. Indexing with Drupal Apache Solr is not only faster, it can also be merged and further optimized.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Drupal Apache Solr offers Faceted navigation to let users add multiple filters that can help them navigate easily through piles of information. Facets are elements for navigation that can be queried.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Using Drupal Apache Solr enables better control over your website search and offers an interactive admin interface.<\/span><\/p>\n<h2><b>Implementing Apache Solr in Drupal<\/b><\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Install Apache Solr<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Install the Drupal Solr Module\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Configure Apache Solr with Drupal Module<\/span><\/li>\n<\/ol>\n<h4><span style=\"text-decoration: underline;\"><b>1. Install Apache Solr<\/b><\/span><\/h4>\n<p><b>\u00a0 \u00a0 Step 1<\/b><span style=\"font-weight: 400;\">: Install JAVA :\u00a0<\/span><\/p>\n<pre><b>  \u00a0 \u00a0 \u00a0 \u00a0$sudo apt install openjdk-11-jdk<\/b>\r\n<b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0$java -version<\/b><\/pre>\n<p>&nbsp;<\/p>\n<p><b>\u00a0 \u00a0 Step 2: Download Solr :\u00a0<\/b><a href=\"https:\/\/solr.apache.org\/downloads.html\"><span style=\"font-weight: 400;\">https:\/\/solr.apache.org\/downloads.html<\/span><\/a><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58591 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/cmd.png\" alt=\"\" width=\"934\" height=\"475\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/cmd.png 934w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/cmd-300x153.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/cmd-768x391.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/cmd-624x317.png 624w\" sizes=\"(max-width: 934px) 100vw, 934px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58592 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/solr.png\" alt=\"\" width=\"846\" height=\"506\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/solr.png 846w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/solr-300x179.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/solr-768x459.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/solr-624x373.png 624w\" sizes=\"(max-width: 846px) 100vw, 846px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, Solr should be installed on your system. You can use these commands to Start, Stop, and check the status of the Solr service \u2013<\/span><\/p>\n<pre>$sudo service solr stop\r\n$sudo service solr start\r\n$sudo service solr status<\/pre>\n<h4><b>\u00a0 \u00a0<span style=\"text-decoration: underline;\">2. Installing the Search API Solr module in Drupal<\/span><\/b><\/h4>\n<p>composer require drupal\/search_api_solr:^4.1. <span style=\"font-weight: 400;\">Once it is done, enable the module. <\/span><span style=\"font-weight: 400;\">Go to <\/span><b>Extend \u2192 Search Search API Solr Search \u2192 Enable it<\/b><\/p>\n<h4><b>\u00a0 \u00a0<span style=\"text-decoration: underline;\">3. Configure Apache Solr with the Drupal Search API Solr Module<\/span><\/b><\/h4>\n<p><b>Step 1: Create a core in Apache Solr<\/b><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58593 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/addCore.png\" alt=\"\" width=\"948\" height=\"504\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/addCore.png 948w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/addCore-300x159.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/addCore-768x408.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/addCore-624x332.png 624w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/p>\n<p><b>Step 2:\u00a0 Create a Solr Server<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In this step you need to create a Solr server and index in your Drupal website. To create a Solr server \u2013<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Go to <\/span><b>Configuration -&gt; Search And Metadata -&gt; Search API -&gt; click on Add server<\/b><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58594 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/server-1024x363.png\" alt=\"\" width=\"625\" height=\"222\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/server-1024x363.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/server-300x106.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/server-768x272.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/server-624x221.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/server.png 1333w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">When you click on the Add server, you will get one form you need to fill out form\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">\u00a0Server name: Enter the Server name<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Enable: You need to check the Enable check box. If you don\u2019t enable it, you cannot index the items<\/span><\/li>\n<li style=\"font-weight: 400;\">Add server description: A brief description of the server.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58595 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/configuresolr.png\" alt=\"\" width=\"813\" height=\"464\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/configuresolr.png 813w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/configuresolr-300x171.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/configuresolr-768x438.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/configuresolr-624x356.png 624w\" sizes=\"(max-width: 813px) 100vw, 813px\" \/><\/p>\n<p>Next, you need to configure the Solr backend. Click on the\u00a0<strong>CONFIGURE SOLR BACKEND<\/strong>\u00a0in the form. You can see the form elements as shown in the image below:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58596 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee.png\" alt=\"\" width=\"796\" height=\"483\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee.png 796w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-300x182.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-768x466.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-624x379.png 624w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/p>\n<p><strong>HTTP protocol:<\/strong> Choose https or Http (depending on whether your server uses SSL or not).<br \/>\n<strong>Solr host: <\/strong>localhost (if your Solr Server is on a different machine, please enter the IP or hostname of that host here)<br \/>\n<strong>Solr port: <\/strong>8983 (This is the Default port)<br \/>\n<strong>Solr path:<\/strong> &#8220;\/&#8221; (The path to locate the server, and this is based on the Solr server version. If the Solr server version is 6.6.4, in this case, the Solr path is different like &#8220;\/solr&#8221; ).<br \/>\n<strong>Solr core:<\/strong> Enter the Solr core name that you created before.<br \/>\nThe values as defined default work fine. However, you can also change them accordingly.<\/p>\n<h4>Step 3: Create the Search Index<\/h4>\n<p>Here, we are going to create a Search API index that will index the Datasources that you selected in the index. To create an index \u2013<\/p>\n<p>Go to <strong>Configuration -&gt;<\/strong>\u00a0<strong>Search and Metadata -&gt; Search API -&gt; Add index<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58597 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1.png\" alt=\"\" width=\"768\" height=\"659\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-300x257.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-624x535.png 624w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/p>\n<p>After successfully creating an index, you now need to add fields to the index. To add the field that you need, go back to the search API and click on Edit the index that you have created. You will then see the Fields tab. Click on the fields tab, and you will see a window, as shown in the image below.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58599 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-1.png\" alt=\"\" width=\"809\" height=\"274\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-1.png 809w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-1-300x102.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-1-768x260.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-1-1-624x211.png 624w\" sizes=\"(max-width: 809px) 100vw, 809px\" \/><\/p>\n<p>Next, click on the Add fields. In the popup that appears, you need to add the fields you need. After adding the fields, click on Done and then Save.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58598 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-2.png\" alt=\"\" width=\"730\" height=\"565\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-2.png 730w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-2-300x232.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-2-624x483.png 624w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/p>\n<p>Now, the Index and server are created on the website. After this, the next important step is to copy the configuration files to the Solr core. For this, you need to download the config files from the server on the website.<\/p>\n<p>Go to <strong>Configuration -&gt; Search and Metadata -&gt; Search API -&gt; &lt;Server name&gt;\u00a0<\/strong><\/p>\n<p>You will get a window as shown in the image below \u2013<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58601 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-3.png\" alt=\"\" width=\"801\" height=\"296\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-3.png 801w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-3-300x111.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-3-768x284.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-3-624x231.png 624w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><\/p>\n<p>Next, click on the \u201c<strong>Get config.zip<\/strong>\u201d button. This will download the config folder. Once done, extract the zip folder and copy all the files into the conf folder in the core.<\/p>\n<p>In the data folder, you will see the Solr core folder, which you had created earlier. Go to that Solr core folder, and you will find a folder with the name <strong>conf<\/strong>. In this folder, you will find some files. Delete those files and copy all the files from the config folder that is downloaded from the website server. Once done, you need to restart your Solr server in the terminal.<\/p>\n<p>The next step is to index the contents \u2013<\/p>\n<p>Go to<strong>\u00a0Configuration -&gt; Search and Metadata -&gt; Search API\u00a0<\/strong>-&gt; click on the index that you have created. You will see a window, as shown in the image below.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-58600 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-4.png\" alt=\"\" width=\"790\" height=\"370\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-4.png 790w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-4-300x141.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-4-768x360.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/09\/More-than-just-How-to-Configure-Apache-Solr-in-Drupal-8-for-a-Powerful-Search-Experience-Specbee-4-624x292.png 624w\" sizes=\"(max-width: 790px) 100vw, 790px\" \/><\/p>\n<p>Next, click on the index to index the contents. Now, all the contents are indexed in the Solr core. Now, you can create a view of the Solr index and add the indexed fields to the view to get the results from the Drupal Solr.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>What is Apache Solr? Apache Solr is an open-source search platform developed by the Apache Software Foundation. It&#8217;s based on the Apache Lucene library and provides powerful search and indexing capabilities for websites, databases, and other content.\u00a0 For Drupal users, it is possible to integrate your site with Solr. The Search API Solr Search module [&hellip;]<\/p>\n","protected":false},"author":1620,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":60},"categories":[3602],"tags":[1874,4862,5457],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58603"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1620"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=58603"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58603\/revisions"}],"predecessor-version":[{"id":59105,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58603\/revisions\/59105"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=58603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=58603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=58603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}