4 Mapping
This chapter covers
- Filed data types
- Implicit and explicit mapping
- Core data types
- Advanced data types
- APIs to create/access the mappings
Data is like a rainbow—it comes in all sorts of “colors”. Business data comes in various shapes and forms, usually represented as textual information, dates, numbers, inner objects, booleans, geo-locations, IP addresses, and so on. In Elasticsearch, we model and index data as JSON documents, with each document consisting of a number of fields, and every field of a certain type of data. For example, a movie document consists of a title and synopsis represented as textual data, a release date as date, gross earnings as floating-point data, and so on.
In our earlier chapters, when we indexed sample documents, we did not bother about the data type of the fields. That’s because Elasticsearch derived these types implicitly by looking at the field and the type of information in it. Elasticsearch created a schema for us without us having to do any up front work unlike in a relational database. It is mandatory to have the table schema defined and developed in a database before proceeding to retrieve or persist the data.