Mapping

In RDBMS analogy, mapping means defining a table schema. We always define a table structure, that is, column data types. In Elasticsearch, we also need to define the data type for each field. But then comes another question. Why did we not define it before when we ingested three documents into the my_index index? The answer is simple. Elasticsearch doesn't care. It is claimed that Elasticsearch is a schema-less data model.

If we don't define a mapping, Elasticsearch dynamically creates a mapping for us by defining all fields as text. Elasticsearch is intelligent enough to find out date fields to assign the date data type to them.

Let's find the existing dynamic mapping of index my_index:

curl -XGET 'localhost:9200/my_index2/_mapping/?pretty' ...

Get Modern Big Data Processing with Hadoop now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.