elasticsearch populate


Mapping is the outline of the documents stored in an index. It defines the data type like geo_point or string and format of the fields present in the documents and rules to control the mapping of dynamically added fields. For example,

POST http://localhost:9200/bankaccountdetails

Request Body

{
   "mappings":{
      "report":{
         "_all":{
            "enabled":true
         },
			
         "properties":{
            "name":{ "type":"string"}, "date":{ "type":"date"},
            "balance":{ "type":"double"}, "liability":{ "type":"double"}
         }
      }
   }
}

Response

{"acknowledged":true}

Field Data Types

Elasticsearch supports a number of different datatypes for the fields in a document. The following data types are used to store fields in Elasticsearch −

Core Data Types

These are the basic data types supported by almost all the systems like integer, long, double, short, byte, double, float, string, date, Boolean and binary.

Complex Data Types

These data types are a combination of core data types. Like array, JSON object and nested data type. Following is the example of nested data type −

POST http://localhost:9200/tabletennis/team/1

Request Body

{
   "group" : "players",
   "user" : [
      {
         "first" : "dave", "last" : "jones"
      },
			
      {
         "first" : "kevin", "last" : "morris"
      }
   ]
}

Response

{
   "_index":"tabletennis", "_type":"team", "_id":"1", "_version":1, 
   "_shards":{"total":2, "successful":1, "failed":0}, "created":true
}

Geo Data Types

These data types are used for defining geographic properties. For instance, geo_point is used for defining longitude and latitude, and geo_shape for defining different geometric shapes like rectangle.

Specialized Data Types

These data types are used for special purposes like IPv4 (“ip”) accepts IP address, completion data type is used to support auto-complete suggestions and token_count for counting the number of tokens in a string.

Mapping Types

Each index has one or more mapping types, which are used to divide the documents of an index into logical groups. Mapping can be different from each other on the basis of the following parameters −

Meta-Fields

These fields provide information about the mappings and the other objects associated with it. Like _index, _type, _id, and _source fields.

Fields

Different mapping contains different number of fields and fields with different data types.

Dynamic Mapping

Elasticsearch provides a user-friendly mechanism for the automatic creation of mapping. A user can post the data directly to any undefined mapping and Elasticsearch will automatically create the mapping, which is called dynamic mapping. For example,

POST http://localhost:9200/accountdetails/tansferreport

Request Body

{
   "from_acc":"7056443341", "to_acc":"7032460534",
   "date":"11/1/2016", "amount":10000
}

Response

{
   "_index":"accountdetails", "_type":"tansferreport",
   "_id":"AVI3FeH0icjGpNBI4ake", "_version":1,
   "_shards":{"total":2, "successful":1, "failed":0},
   "created":true
}

Mapping Parameters

The mapping parameters define the structure of mapping, information about fields and about storage and how the mapped data will be analyzed at the time of searching. These are the following mapping parameters −

  • analyzer
  • boost
  • coerce
  • copy_to
  • doc_values
  • dynamic
  • enabled
  • fielddata
  • geohash
  • geohash_precision
  • geohash_prefix
  • format
  • ignore_above
  • ignore_malformed
  • include_in_all
  • index_options
  • lat_lon
  • index
  • fields
  • norms
  • null_value
  • position_increment_gap
  • properties
  • search_analyzer
  • similarity
  • store
  • term_vector

Table of Contents
1.elasticsearch tutorial

2.elasticsearch basic concepts

3.elasticsearch installation

4.elasticsearch populate

5.elasticsearch migration between versions

6.elasticsearch api conventions

7.elasticsearch document apis

8.elasticsearch search apis

9.elasticsearch aggregations

10.elasticsearch index apis

11.elasticsearch cluster apis

12.elasticsearch query dsl

13.elasticsearch mapping

14.elasticsearch analysis

15.elasticsearch modules

16.elasticsearch testing

17.elasticsearch quick guide

18.elasticsearch useful resources

19.discuss elasticsearch


Leave a Reply

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