KEMBAR78
Introduction to Elasticsearch Mapping | PPTX
INTRODUCTION TO
MAPPINGby Bo Andersen - codingexplained.com
OUTLINE
➤ What is mapping in Elasticsearch?
➤ Field data types
➤ Meta fields
➤ Dynamic mapping
➤ Explicit mapping
➤ Mapping gotchas
WHAT IS MAPPING IN ELASTICSEARCH?
➤ Defines how documents and their fields are stored and indexed
➤ Most commonly involves defining the data types for fields
➤ Quite similar to database schemas for relational databases
➤ Can also be used to
➤ Define the format of date fields
➤ Define whether or not field values should be indexed into the catch-all _all field
➤ ... and more!
FIELD DATA TYPES
➤ A mapping type contains fields
➤ E.g. title, category, content for an "article" type
➤ Each field has a data type
➤ E.g. string, long, double, boolean, date, ...
➤ These data types can be defined in the mapping
➤ Similar to data types for columns in relational databases
META FIELDS
➤ A mapping type also contains meta fields
➤ The behavior of some of the meta fields can be customized
➤ Examples
➤ _id
➤ _type
➤ _uid
➤ _index
DYNAMIC MAPPING
➤ The automatic detection and addition of new types and fields
➤ Fields and mapping types do not need to be defined before being used
➤ You can add a document without first defining a mapping type and defining its
fields
➤ You can even add a document without creating an index
➤ Elasticsearch will create the index, mapping type and fields automatically
➤ Elasticsearch will infer the data types based on the document's data
EXPLICIT MAPPING
➤ Enables you to specify explicit mappings
➤ When creating an index, mapping types and field mappings can be created
➤ These can also be added to existing indexes by issuing a PUT request
➤ Useful if you have some requirements for the data (e.g. specific date formats)
➤ Useful if Elasticsearch cannot guess or infer the correct mapping information
➤ Dynamic mapping is great for getting started, but eventually you will probably want to
add explicit mappings
MAPPING GOTCHAS
➤ Existing type and field mappings cannot be updated
➤ Create a new index and reindex your data into that index
➤ Fields are shared across mapping types
➤ If a title field exists in both an employee and article mapping type, the fields
must have exactly the same mapping in each type
➤ Can be resolved by choosing more descriptive names, e.g. employee_title and
article_title
THANK YOU FOR
WATCHING!

Introduction to Elasticsearch Mapping

  • 1.
    INTRODUCTION TO MAPPINGby BoAndersen - codingexplained.com
  • 2.
    OUTLINE ➤ What ismapping in Elasticsearch? ➤ Field data types ➤ Meta fields ➤ Dynamic mapping ➤ Explicit mapping ➤ Mapping gotchas
  • 3.
    WHAT IS MAPPINGIN ELASTICSEARCH? ➤ Defines how documents and their fields are stored and indexed ➤ Most commonly involves defining the data types for fields ➤ Quite similar to database schemas for relational databases ➤ Can also be used to ➤ Define the format of date fields ➤ Define whether or not field values should be indexed into the catch-all _all field ➤ ... and more!
  • 4.
    FIELD DATA TYPES ➤A mapping type contains fields ➤ E.g. title, category, content for an "article" type ➤ Each field has a data type ➤ E.g. string, long, double, boolean, date, ... ➤ These data types can be defined in the mapping ➤ Similar to data types for columns in relational databases
  • 5.
    META FIELDS ➤ Amapping type also contains meta fields ➤ The behavior of some of the meta fields can be customized ➤ Examples ➤ _id ➤ _type ➤ _uid ➤ _index
  • 6.
    DYNAMIC MAPPING ➤ Theautomatic detection and addition of new types and fields ➤ Fields and mapping types do not need to be defined before being used ➤ You can add a document without first defining a mapping type and defining its fields ➤ You can even add a document without creating an index ➤ Elasticsearch will create the index, mapping type and fields automatically ➤ Elasticsearch will infer the data types based on the document's data
  • 7.
    EXPLICIT MAPPING ➤ Enablesyou to specify explicit mappings ➤ When creating an index, mapping types and field mappings can be created ➤ These can also be added to existing indexes by issuing a PUT request ➤ Useful if you have some requirements for the data (e.g. specific date formats) ➤ Useful if Elasticsearch cannot guess or infer the correct mapping information ➤ Dynamic mapping is great for getting started, but eventually you will probably want to add explicit mappings
  • 8.
    MAPPING GOTCHAS ➤ Existingtype and field mappings cannot be updated ➤ Create a new index and reindex your data into that index ➤ Fields are shared across mapping types ➤ If a title field exists in both an employee and article mapping type, the fields must have exactly the same mapping in each type ➤ Can be resolved by choosing more descriptive names, e.g. employee_title and article_title
  • 9.