elasticsearch meta fields
TRANSCRIPT
META FIELDSby Bo Andersen - codingexplained.com
OUTLINE➤ Introduction to meta fields➤ Meta fields categories
➤ Identity➤ Document source➤ Indexing➤ Routing➤ Other
INTRODUCTION TO META FIELDS➤ Each document has metadata associated with it
➤ E.g. the _index, _type, and _id meta fields.➤ The behavior of some of these meta-fields can be customized
➤ This is done when creating a mapping type
IDENTITY META FIELDS
IDENTITY META FIELDS (PART 1)➤ _index
➤ Allows matching documents based on their indexes➤ _index is exposed as a virtual field and is not added to the Lucene index
as a real field
➤ _type
➤ The type of the document➤ Indexed in order to make searching by type name fast
IDENTITY META FIELDS (PART 2)➤ _id
➤ The ID of the document➤ Not indexed, because its value can be automatically derived from the _uid field
➤ _uid
➤ The values of _type and _id are combined as {type}#{id} and indexed
DOCUMENT SOURCE
META FIELDS
DOCUMENT SOURCE META FIELDS➤ _source
➤ Contains the JSON that was passed at index time (unless updated)➤ The field is not indexed and is therefore not searchable➤ It is stored so that it can be returned when executing fetch requests➤ Can be disabled to save storage space
➤ _size
➤ Indexes the size of the _source field in bytes➤ Available as a plugin that must be installed before the field is available➤ sudo bin/plugin install mapper-size
INDEXING META
FIELDS
_ALL➤ A special field that concatenates the values of all of the other fields into
one string➤ Uses space as a delimiter➤ The field is analyzed and indexed, but not stored
➤ This means that it can be searched, but not retrieved➤ The field allows you to search for values in documents without knowing
which field contains the value
_FIELD_NAMES➤ Indexes the names of every field in a document that contains a value other
than NULL➤ Used by the exists and missing queries
➤ To find documents that either have or do not have a non-null value for a particular field
ROUTING META
FIELDS
_PARENT➤ Can be used to establish a parent-child relationship between documents in
an index➤ This is done by making one mapping type the parent of another
"mappings": {
"employee": {
"_parent": {
"type": "person"
}
}
}
When adding an index:
_ROUTING➤ Used to route a document to a particular shard within an index➤ Enables you to define rules that control in which shards documents are
stored➤ For advanced use cases!
OTHER META
FIELDS
_META➤ Each mapping type can have custom meta data associated with it➤ Elasticsearch does not use this meta data at all➤ Can be used to store application-specific meta data
➤ This can be anything you want
THANK YOU FOR WATCHING!