Elasticsearch is a background tool that can only store data but cannot visualize it. So, it requires a data visualization tool or plugins to execute query and display data. There are various plugins available for elasticsearch users, such as Kibana, analysis-icu, head plugin, etc. It provides a developer interface for developers. You can either install plugins or data visualization tool, which you prefer.
In this chapter, we are going to use elasticsearch head extension of elasticsearch plugin in chrome web browser. It is a developer tool.
What is Elasticsearch head?
Elasticsearch head is a data visualization plugin that provides an attractive interface to the elasticsearch users. It allows us to perform CRUD operations on data. It is a visualization tool used as Elasticsearch plugin. It is also available as an extension in chrome web store. You can add this extension directly to your browser. So, you do not need to install it through the command prompt.
Although, Kibana is also a visualization tool that works with Elasticsearch in ELK stack for visualizing data. Elasticsearch head plugin saves us for installing Kibana (visualization tool) with its more than 50,000 files.
Note: This plugin requires that the elasticsearch server must be running before using it.
In this tutorial, we will add the elasticsearch-head plugin extension to the chrome web browser instead of installing it.
Add elasticsearch head plugin
In previous page, we see that Elasticsearch was running successfully. Now turn to add the elasticsearch-head plugin extension in browser. Follow the below steps to add elasticsearch plugin extension to chrome.
Step 1: Open the web browser and go to the web store inside the app section.
Step 2: Here, search for elasticsearch head extension. Type elasticsearch head in the search box.
Step 3: Click on the Add to Chrome button.
Step 4: Click on Add Extension and move ahead.
Step 5: Once the plugin is added to the chrome successfully, you can directly use it from the following icon as shown in the below screenshot.
Here, click on the head plugin icon.
Step 6: A web user interface will display on the screen. See the screenshot below, the cluster is not connected yet. Click on the Connect button to connect elasticsearch with cluster.
Remember that Elasticsearch must be running before using the elasticsearch-head plugin.
Step 7: Now, it is connected with elasticsearch server successfully.
This is an interactive interface for elasticsearch users, where they can execute queries. Click on Any Request button to perform queries.
UI Familiarity - Home Page
The screen that displayed after connecting with elasticsearch server is the user interface of elasticsearch head plugin to which a developer interacts. It contains various components. So, let's explore the head plugin to understand them. Following is the home page of the interface.
1. Connection bar
The connection bar contains the URL to connect with elasticsearch server. This URL specifies the connection string containing the host machine and port number of elasticsearch. Here, we are using localhost as a host machine and 9200 default port number of elasticsearch. The connection URL is http://localhost/9200/
2. Cluster health
It shows the health of the cluster. The health status is defined with three colors: red, yellow, and green, where each color has a different meaning.
Red - The red color indicates that some nodes or primary shards in the cluster are not available yet. All or some of the primary shards are not ready.
Yellow - The yellow color indicates the some or all shards are not allocated to any node.
Green - If all shards are ready and allocated to any node, the color will be green.
The learn nodes, clusters, and shards see the previous tutorial.
Info is a drop-down tab that provides different options to see the stats on cluster health, nodes, plugins, templates, and some other things related to elasticsearch.
This shows which tab the UI is currently on.
5. Index name and other information
This section shows the index name, size of the index, and number of documents present in index.
6. Info and action tab
This shows the info and action tab. The info tab provides a list of metadata, where "mapping" is one of the most useful metadata. Each index has metadata and allows some action to be performed. Metadata resides inside the info tab.
7. Node list
In the earlier tutorial, we already discussed that Elasticsearch is a distributed system that can be deployed on multiple nodes. It shows the list of nodes, where info and actions provide options to view the node details.
8. Shard info
An index can be divided into shards, which are the basic storage unit of elasticsearch. These shards can be further distributed among several nodes or a single node. You can get the state and information about each shard by double-clicking on it. Here are 5 shards on a single node for the index "schools".
UI Familiarity - Request Page
Request page is another page of elasticsearch-head UI that allows the user to perform the CRUD operation. It is an important page of elasticsearch-head because the requests and queries are made at this page. Click on Any Request button to move on the request page. Request page looks like as shown in below screenshot:
1. Request String
The request string is a place where the request is made. It also contains the connection URL of elasticsearch. We add our request string in this connection URL. You can see the index name, type name, and id of the document in the above screenshot.
2. API Column
In API column, we specify the API (if any) to interact with elasticsearch. The API column can be blank. In the above screenshot, we have not called any API methods with the request made.
3. Request type specifier
It is a drop-down that contains the list of type of requests. POST, GET, PUT, HEAD, and DELETE are the request types.
4. Query space
The Query space is a place where we can provide the query associated with the request. In other words, we can say that if there is any query associated with request, we can place it here (in query space section).
5. Response area
The response area is a block where the output of the request is generated. It displays the response of the request made by the user.
6. Request button
The Request button helps to process the requests. So, after made a query request click on the request button to execute it.
Now, we will create and execute request queries using this elasticsearch plugin.