Development

Elasticsearch Create Index

Captain Salem 1 min read

Elasticsearch Create Index

Elasticsearch is a free and open-source search and analytics engine that is powered by Apache Lucene technology. Elasticsearch, commonly known as Elastic provides a plethora of tools for collection, cleaning, storing, analyzing and visualizing data. Using the ELK Stack (Elasticsearch, Kibana, and Logstash) you can build a fully-fledged search engine that is compatible with a wide collection of data types.

In this tutorial, we will show you how to get started with Elasticsearch by learning how to create an view indexes.

Before we can get started, ensure you have Elasticsearch and Kibana installed on your local machine. Feel free to explore the links below to learn more:geekbits.io/install-elk-on-windowsgeekbits.io/install-elk-linuxgeekbits.io/install-elk-macos

Let’s get started.

What is an Elasticsearch index?

The first thing we need to understand is what is an elasticsearch index. An index refers to a collection of documents that are closely related within an Elasticsearch cluster.

An elasticsearch document is comprised of key and value pairs. Each key contains a unique field or property and which points to a specific value. Elasticsearch supports various type such as strings, numbers, arrays, etc.

Elasticsearch then searches the documents and creates a list of all unique words that are located in that document. This allows very fast searches within a large text dataset.

The best way to think about Elasticsearch indicies is to compare them to a relational database.

Therefore the following diagram shows a high-level equivalent of the Elasticsearch search model to relational databases:

PostgreSQL -> Schema -> Table -> Column/Row
Elasticsearch -> Index -> Type ->Document

Therefore, think of an Elasticsearch index as a database schema.

Elasticsearch Create API

Elasticsearch exposes its functionality via a HTTP API. Using various endpoints and HTTP verbs, you can perform actions on the Elasticsearch cluster. Such operations include, creating, deleting, and updating indices and documents on the cluster.

For this article, we will focus on the CREATE API which allows us to create indices on the Elasticsearch cluster.

To create an Elasticsearch index, we use the PUT http verb followed by the name of the index we wish to create.

The syntax is as shown below:

PUT /my_index_name

The query above should create an index with the name my_index_name

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.