Mapping base types
Using explicit mapping allows faster insertion of the data using schema-less approach. Thus to achieve better results and performance in indexing, it's required to manually define mapping.
Fine-tuning mapping brings some advantages such as:
Reducing the index size on disk
Indexing only interesting fields (general speed up)
Precooking data for faster search or real-time analytics (such as facets)
ElasticSearch allows using base fields with a wide range of configurations.
Getting ready
You need a working ElasticSearch cluster and a test
index where to put mappings.
How to do it...
Let's use a semi real-world example of a shop order for our eBay-like shop.
We initially define an order such as:
Name |
Type |
Description |
---|---|---|
|
Identifier |
Order identifier |
|
Date (time) |
Date of order |
|
ID reference |
Customer ID reference |
|
String |
Name of the item |
|
Integer |
Number of items |
|
Double |
VAT for item |
|
Boolean |
The order was sent |
Our order...