Chapter 3. Indexing, updating, and deleting data

 

This chapter covers

  • Using mapping types to define multiple types of documents in the same index
  • Types of fields you can use in mappings
  • Using predefined fields and their options
  • All of the above help with indexing, as well as updating and deleting data

This chapter is all about getting data into and out of Elasticsearch and maintaining it: indexing, updating, and deleting documents. In chapter 1, you learned that Elasticsearch is document-based and that documents are made up of fields and their values, which makes them self-contained, much like having the column names from a table contained in the rows. In chapter 2, you saw how you can index such a document via Elasticsearch’s REST API. Here, we’ll dive deeper into the indexing process by looking at the fields in those documents and what they contain. For example, when you index a document like this

{"name": "Elasticsearch Denver"}

the name field is a string because its value, Elasticsearch Denver, is a string. Other fields could be numbers, booleans, and so on. In this chapter we’ll look at three types of fields:

  • Core— These fields include strings and numbers.
  • Arrays and multi-fields— These fields help you store multiple values of the same core type in the same field. For example, you can have multiple tag strings in your tags field.
  • Predefined— Examples of these fields include _ttl (which stands for “time to live”) and _timestamp.

3.1. Using mappings to define kinds of documents

3.2. Core types for defining your own fields in documents

3.3. Arrays and multi-fields

3.4. Using predefined fields

3.5. Updating existing documents

3.6. Deleting data

3.7. Summary

sitemap