Elasticsearch Meta Fields
-
Upload
bo-andersen -
Category
Technology
-
view
20 -
download
0
Transcript of Elasticsearch Meta Fields
![Page 1: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/1.jpg)
META FIELDSby Bo Andersen - codingexplained.com
![Page 2: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/2.jpg)
OUTLINE➤ Introduction to meta fields➤ Meta fields categories
➤ Identity➤ Document source➤ Indexing➤ Routing➤ Other
![Page 3: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/3.jpg)
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
![Page 4: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/4.jpg)
IDENTITY META FIELDS
![Page 5: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/5.jpg)
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
![Page 6: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/6.jpg)
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
![Page 7: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/7.jpg)
DOCUMENT SOURCE
META FIELDS
![Page 8: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/8.jpg)
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
![Page 9: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/9.jpg)
INDEXING META
FIELDS
![Page 10: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/10.jpg)
_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
![Page 11: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/11.jpg)
_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
![Page 12: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/12.jpg)
ROUTING META
FIELDS
![Page 13: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/13.jpg)
_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:
![Page 14: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/14.jpg)
_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!
![Page 15: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/15.jpg)
OTHER META
FIELDS
![Page 16: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/16.jpg)
_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
![Page 17: Elasticsearch Meta Fields](https://reader035.fdocuments.us/reader035/viewer/2022062503/58ed3dc41a28abc44a8b4607/html5/thumbnails/17.jpg)
THANK YOU FOR WATCHING!