- Elasticsearch - Discussion
- Elasticsearch - Useful Resources
- Elasticsearch - Quick Guide
- Elasticsearch - Logs UI
- Elasticsearch - Canvas
- Elasticsearch - Heat Maps
- Elasticsearch - Tag Clouds
- Elasticsearch - Time Series
- Elasticsearch - Area and Bar Charts
- Elasticsearch - Pie Charts
- Elasticsearch - Region Maps
- Elasticsearch - Data Tables
- Elasticsearch - Filtering by Field
- Elasticsearch - Kibana Dashboard
- Elasticsearch - Testing
- Elasticsearch - Frozen Indices
- Elasticsearch - Rollup Data
- Elasticsearch - Monitoring
- Elasticsearch - SQL Access
- Elasticsearch - Managing Index Lifecycle
- Elasticsearch - Ingest Node
- Elasticsearch - Index Modules
- Elasticsearch - Modules
- Elasticsearch - Analysis
- Elasticsearch - Mapping
- Elasticsearch - Query DSL
- Elasticsearch - Cluster APIs
- Elasticsearch - CAT APIs
- Elasticsearch - Index APIs
- Elasticsearch - Aggregations
- Elasticsearch - Search APIs
- Elasticsearch - Document APIs
- Elasticsearch - API Conventions
- Migration between Versions
- Elasticsearch - Populate
- Elasticsearch - Installation
- Elasticsearch - Basic Concepts
- Elasticsearch - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Elasticsearch - Mapping
Mapping is the outpne of the documents stored in an index. It defines the data type pke geo_point or string and format of the fields present in the documents and rules to control the mapping of dynamically added fields.
PUT bankaccountdetails { "mappings":{ "properties":{ "name": { "type":"text"}, "date":{ "type":"date"}, "balance":{ "type":"double"}, "pabipty":{ "type":"double"} } } }
When we run the above code, we get the response as shown below −
{ "acknowledged" : true, "shards_acknowledged" : true, "index" : "bankaccountdetails" }
Field Data Types
Elasticsearch supports a number of different datatypes for the fields in a document. The data types used to store fields in Elasticsearch are discussed in detail here.
Core Data Types
These are the basic data types such as text, keyword, date, long, double, boolean or ip, which are supported by almost all the systems.
Complex Data Types
These data types are a combination of core data types. These include array, JSON object and nested data type. An example of nested data type is shown below &minus
POST /tabletennis/_doc/1 { "group" : "players", "user" : [ { "first" : "dave", "last" : "jones" }, { "first" : "kevin", "last" : "morris" } ] }
When we run the above code, we get the response as shown below −
{ "_index" : "tabletennis", "_type" : "_doc", "_id" : "1", _version" : 2, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 1 }
Another sample code is shown below −
POST /accountdetails/_doc/1 { "from_acc":"7056443341", "to_acc":"7032460534", "date":"11/1/2016", "amount":10000 }
When we run the above code, we get the response as shown below −
{ "_index" : "accountdetails", "_type" : "_doc", "_id" : "1", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 1 }
We can check the above document by using the following command −
GET /accountdetails/_mappings?include_type_name=false
Removal of Mapping Types
Indices created in Elasticsearch 7.0.0 or later no longer accept a _default_ mapping. Indices created in 6.x will continue to function as before in Elasticsearch 6.x. Types are deprecated in APIs in 7.0.
Advertisements