Elasticsearch
Introduction
Elasticsearch is a powerful distributed search engine and NoSQL database. Its data storage approach, similar to MongoDB, can be seen as document-oriented, focusing on storing and retrieving documents efficiently.
Why Use Elasticsearch for Queries?
While traditional databases like MySQL support querying, their performance can degrade significantly with large datasets. Elasticsearch, however, leverages Lucene's inverted index technology for querying.
In comparison, relational databases rely on B-tree indexes, which are optimized for write operations rather than search speed.
In scenarios where quick data retrieval is crucial, Elasticsearch offers advantages over relational databases due to its efficient search capabilities.
Why Not Use Elasticsearch for Financial Systems?
For systems requiring fast transaction processing, such as financial systems, Elasticsearch may not be the optimal choice. Tasks involving rapid edits or transactions are better suited for databases like PostgreSQL, which excel in handling transactional operations.
Key Operations in Elasticsearch
1. Create Index:
In Elasticsearch, an index is akin to a database in traditional systems. It serves as a logical namespace that maps to one or more primary shards and optionally multiple replica shards.
2. Mapping:
Mapping in Elasticsearch defines how documents and their fields are indexed and stored. It allows users to specify the data type of each field and control how fields are tokenized and indexed.
3. Search:
Elasticsearch provides a rich query language for performing full-text searches, structured queries, and aggregations. Queries can be executed against one or more indices, enabling flexible and efficient search operations.
4. Delete:
Elasticsearch allows documents to be deleted from an index using various methods, including individual document deletion, bulk deletion, or query-based deletion.
留言
張貼留言