How to create an index on Elasticsearch

Wolf
4 min readFeb 3, 2023

In the last post I explain how we can put elasticsearch running with custom synonyms, configs and plugins on docker.

Now, let’s see what are the types we can use to define a data model in Elasticsearch.

We don’t need to define our data model in detail if we don’t want custom and advanced search or if our data is simple, we can simply send a request to insert the document in one index that is not yet created and Elasticsearch will automatically create the index with default definition in each field.

But if we want something more custom and improve our search, we should disable the index autocreation in Elasticsearch Cluster Settings and make a PUT request to create the index with custom definition.

Disable Automatic Index creation

To disable the automatic index creation, we should add the following setting to the Elasticsearch Cluster, in our elasticsearch.yaml:

action.auto_create_index: "+.*"

This line will allow Elasticsearch create some internal indexes that are required to run starting with “.” like “.monitoring” and will block the other ones.

Types of fields

Each field has its own type. Next, we will do a small resume about what type we can use, what each fields accepts and what we can do with it:

  • Binary → Accepts a Base64 encoded string and is not searchable, however could be…

--

--

Wolf

A software engineer looking for learning more and share my knowledge.