INDEX CONFIGURATIONS :

  • date 3rd November, 2019 |
  • by Prwatech |
  • 0 Comments

Index configurations are usually automatically specified by Elasticsearch. we can define our own index configurations to have an understanding of our data to be indexed. There are two configurations we can define for a particular index.

►Mappings

Mapping is the process of defining or specifying how a document, and the fields it contains, are stored and indexed in an index. Basically, It is a process of defining the schema of an index. For instance, use mappings to define:





 

►Mapping types :

There are two types of mappings in Elasticsearch.

►Meta-fields

Meta-fields are used to define how a document’s metadata associated is treated. Examples of meta-fields include the document’s _index, _type, _id, and _source fields.

►Fields or Properties

Properties contain a list of fields and their characteristics.

►Field datatypes :

text, keyword, long, date, double, Boolean, IP, nested, geo_point, geo_shape, completion.

You can index string fields like text & keyword with the standard analyzer, English analyzer, simple analyzer or any other analyzer as well.

Example.

PUT BankAccountDetails

{

“mappings”:{

“properties”:{

“name”: {

“type”:    “text”

“analyzer”:  ”standard”   },

“date”: {

“type”:    “date”                   },

“balance”: {

“type”:   “double”               },

“liability”: {

“type”:   “double”               }

}

}

}

►Settings

You can configure shards, replicas, custom analyzers and many more settings related to an Index which we’re going to store in ElasticSearch.

Example:

Here, we are defining how many shards, replicas we want and our own custom analyzer for a index BankAccountDetails                             PUT /BankAccountDetails/_settings

{

“index”:{

“number_of_shards”: 3,

“number_of_replicas”: 2,

“analysis”:{

“analyzer”:{

“content”:{

“type”: “custom”,

“tokenizer”: “whitespace”

}

}              }              }               }





Leave a Reply

Your email address will not be published. Required fields are marked *

Quick Support

image image