Drupal offers an in-built Search module that can be helpful for basic and small websites. As a standalone, it is competent enough to deliver quick search results. But it doesn't provide the sophistication and customization sought by customers in search results today.A suitable alternative will give you control over what gets displayed in search results on your site. For example, you may want only a specific product to display for a search while not displaying other active ones. You can achieve this and a lot more customized functionality by combining Drupal's Search API with a 3rd party search tool.Search API is a competent module offered by Drupal to help deliver the best search results. It understands Drupal's content architecture thoroughly. This module is primarily used by Drupal users to show and filter search results. You will have to download, unzip and enable it on your Drupal site. This will be covered soon.Search API works perfectly with 3rd-party search servers such as Apache Solr, Xapian and Sphinx. This article will discuss Drupal's integration with Elasticsearch to deliver exceptional search results.Ever since its launch in 2010, Elasticsearch has gained a reputation as an efficient real-time search server. Deployed by companies such as Facebook, WordPress, Netflix and StumbleUpon, Elasticsearch's popularity will continue to grow in the years to come.Let's get started!The goal of this article is to use Elasticsearch to power the Facet search functionality on a Drupal site.Facet search is popularly used online, especially on sites such as Amazon.com to filter search results. For example, in the screenshot below, only sugar-free chocolates belonging to the Hershey brand are displayed:We will achieve the same functionality in this article by combining Elasticsearch with Drupal's very own Search API. Here is the kind of view we will be creating in this article:This view features a collection of some great songs from the past. A user will be able to choose a product based on the Facet filters provided on the left.Configuring Elasticsearch to search a Drupal site1. Installing ElasticsearchIt's easy to install Elasticsearch. Visit https://www.elastic.co/downloads/elasticsearch to download and unzip the Elasticsearch distribution of your choice:Use the command prompt to go to the newly created Elasticsearch folder. Run any of the following commands:bin/elasticsearch (for UNIX users)bin/elasticsearch.bat (for Windows users)This command installs Elasticsearch on your machine.2. Copying Elastica to your Drupal installation's Libraries folderBefore we proceed to configuring Elasticsearch with Drupal, you must copy Elastica's files to your Libraries folder (//drupal/sites/all/libraries/). Elastica is a competent PHP client that works with Elasticsearch.You can accomplish this by downloading the files from Github (https://github.com/ruflin/Elastica).3. Downloading and enabling necessary Drupal modulesYou will have to download and copy the following modules to your Drupal install's Modules folder:EntitySearch APIFacet APIViewsElasticsearch ConnectorDownloading is easy. For example, clicking on any of the above links will take you to a Drupal.org page for the module. Go to the bottom of the page and download the version you would like to work with. In my case, I downloaded the tar.gz version as shown below:The next step is to unzip these files to your Modules folder. I have used an SSH tool for this purpose.After you are done extracting the files, you will have to enable the modules shown in the screenshots below. For this, click "Modules" on the top-level menu of your Drupal application:You will be directed to a page featuring modules. The recently unzipped modules will be shown here. Enable the modules by ticking the boxes next to them. Here are the modules you will have to enable:Click "Save configuration" at the bottom of the page.4. Adding an Elasticsearch clusterJust like Drupal, a node plays a central role in Elasticsearch terminology. It represents a working instance of Elasticsearch. The cluster we are going to add below represents a collection of such nodes.A cluster is smart and can balance its workload to accommodate addition and removal of nodes.Let's now add the cluster. Click "Configuration" on the top level menu:Search for "Elasticsearch Clusters" under ELASTICSEARCH CONNECTOR:In the new page, click "Add cluster":Fill in the following values:Administrator cluster name: Give a symbolic name to your cluster. I have named it as "Elasticsearch Cluster Demo".Server URL: Provide the URL and the port that attends to Elasticsearch server. Most likely, the value will be "localhost:9200". You can verify this by running the lsof -i :9200 command on your command prompt as shown below:Leave the other values as default. Look at the screen below for more information:Click "Save". The cluster has been saved:Click "Info" in the Edit dropdown on the right to view details of the newly added cluster:A screen similar to the one below will be displayed:5. Adding a Search API ServerSearch API provides a handy framework that facilitates complex searches of Drupal entities. It offers support for displaying results by using Views, apart from other functionality.Search API offers effortless integration with Elasticsearch. The first step is to add a Search API server.Let's start by going to the Configuration page again. Search for "Search API" under SEARCH AND METADATA:In the new page, click "Add server":Fill in the following values:Server name: Give a symbolic name to the server. I have named it as "Demo Search Saver".Service class: Select "Elasticsearch Connector" service from the dropdown.Cluster: Select the newly created cluster from the dropdown. In my case, it is "Elasticsearch Cluster Demo".Click "Create server":The server has been created:6. Adding a Search API IndexGo to Configuration and click "Search API" like you did in the preceding step. Click "Add index":Fill in the following details:Index name: Give a symbolic name to the index. I have named it as "demo index".Item type: Choose the kind of content you would like to apply the search functionality for. I chose "Node" from the dropdown. As soon as you choose this value, two new check boxes will appear under the title Bundles. I have ticked both the boxes for "Basic page" and a new content type created solely to showcase faceted search - "Music For The soul".Enable: Tick this box if you want to make the index functional.Server: Select the recently created server - "Demo Search Server".Go further below the page to view the following fields:Index items immediately: I have ticked this box to ensure faster indexing of updates made to the site.Cron batch size: I have kept the default value "50".Select index: This dropdown is a required field. I created a random index named "demoindex".Click "Create index" to save your settings. Refer the screenshot below for more info:After you create the index, you should specify the fields you wish to be indexed. In my case, I am ticking the boxes for fields associated with the "Music for the soul" content type:The index has been saved.7. Creating taxonomy tagsIt's now time to create content that can be found through Facet search.The first step is to create Taxonomy tags that will be used as filters to enable enhanced search functionality.Click "Structure":Click "Taxonomy":Click "Add vocabulary":Provide a name for the vocabulary to be used as filters:I have created 2 Vocabulary types. They are "Genre" and "Price ($)":Let's add tags for each vocabulary. Click "edit vocabulary" against the newly created Vocabulary.Click "LIST" on the top-right:Click "Add term":Add the tags you want to filter the final search results. These are the tags I have chosen:For "Genre":For "Price ($)":8. Configuring fields for "Music for the soul" content typeGo to "Administration" -> "Structure" -> "Content types"Let's create a unique content type for this project.This can be done by clicking "Structure" on the top-level menu:Click "Content types":Click "Add Content type":You will get a screen similar to the one below. Give an appropriate name for your content type. I have named mine as "Music For The Soul". I intend to create content nodes featuring some of America's biggest hit numbers. Click "Save and add fields" at the bottom of the page:You will be taken to a page that asks you to specify fields for your content type. These are the fields I chose:TitleArtistCD CoverAbout the songGenreYear of releasePriceLet's take a closer look at them in the screenshot below:Notice the field type for "Genre" and "Price ($)". Selecting "Term reference" from the dropdown will allow you to associate these fields with the Taxonomy terms created by you above.For example, the Vocabulary dropdown you see in the next screen is where you specify the reference tag. This is for mapping "Price ($)" with the "Price($)" vocabulary type created in Step 7 of this article:8. Creating content based on the new content typeWith the fields ready, I can now create new content based on this content type.Click "Content" on the top-level menu:Click "Add content":Choose the content type. I am selecting the newly created one "Music For The Soul":You will get the following screen with the newly created fields. Provide values as required:Further below on the page, you will be able to associate the song with Genre and Price tags. Choose a genre and price. The values you provide here will help with the facet search later in the article:I am going to add different artists and their hit songs. Here is "Run To You" by Bryan Adams:I have created 8 entries in total. Some of them can be viewed below:9. Further Configuring The Search API IndexLet's configure our custom index "demo index".Go to "Configuration" and click "Search API" under "SEARCH AND METADATA" like you did before:Click "demo index":You will get the following screen. Notice the tabs on the top-right. Click "FIELDS".Select the fields of you