ElasticSearch ElasticSearch Indexing & Data Management 1 — Questions and Answers
Question 1: What HTTP method is used to index a new document with a specific ID in Elasticsearch?
- POST
- PUT (Correct answer)
- PATCH
- GET
Correct answer: PUT
The PUT method is used to index a document with a specific ID: PUT /index_name/_doc/document_id.
Question 2: What is the Elasticsearch Bulk API used for?
- Increasing shard count on an existing index
- Performing multiple index, update, or delete operations in a single request (Correct answer)
- Running multiple queries at once
- Reindexing large datasets across clusters
Correct answer: Performing multiple index, update, or delete operations in a single request
The Bulk API allows you to perform multiple index, create, update, or delete operations in a single HTTP request, significantly improving throughput.
Question 3: What does 'reindexing' mean in Elasticsearch?
- Deleting and recreating an index with the same settings
- Copying documents from one index to another, often to apply new mappings or settings (Correct answer)
- Rebuilding the inverted index from raw data
- Reassigning shards across nodes
Correct answer: Copying documents from one index to another, often to apply new mappings or settings
Reindexing is the process of copying documents from a source index to a destination index, typically used when you need to change mappings or index settings.
Question 4: What is Index Lifecycle Management (ILM) in Elasticsearch?
- A tool for backing up index data to S3
- A policy system to automate index transitions through phases like hot, warm, cold, and delete (Correct answer)
- A method for distributing shards optimally
- A monitoring tool for index performance
Correct answer: A policy system to automate index transitions through phases like hot, warm, cold, and delete
ILM automates the management of indices over time by defining policies that move indices through lifecycle phases (hot, warm, cold, frozen, delete) based on criteria like age or size.
Question 5: What does the 'update by query' API do in Elasticsearch?
- Updates index mappings in bulk
- Updates all documents that match a query using a script or partial update (Correct answer)
- Renames fields across all documents
- Updates index settings without downtime
Correct answer: Updates all documents that match a query using a script or partial update
The update by query API performs updates on all documents matching a given query, often using a Painless script to modify field values.
Question 6: What is a 'data stream' in Elasticsearch?
- A real-time CDC (change data capture) feed from a database
- An abstraction over time-series indices that handles rollover and ILM automatically (Correct answer)
- A Kafka-compatible message ingestion pipeline
- A type of aggregation for streaming data
Correct answer: An abstraction over time-series indices that handles rollover and ILM automatically
A data stream is an abstraction over a series of time-series indices that automatically handles rollover and integrates with ILM for lifecycle management.
What HTTP method is used to index a new document with a specific ID in Elasticsearch?