Elasticsearch¶
Elasticsearch is a distributed, open-source search and analytics engine designed for a variety of data types, including textual, numerical, and geospatial data.^[600-developer-elasticsearch.md]
Core Concepts¶
Elasticsearch is developed in Java and built on the foundation of the Lucene library^[600-developer-elasticsearch.md]. It functions as a non-relational document database, capable of handling search, aggregation, analysis, and storage tasks^[600-developer-elasticsearch.md]. The system is characterized by high performance, high availability, ease of scalability, and maintainability^[600-developer-elasticsearch.md].
Data Model¶
The data architecture in Elasticsearch differs significantly from traditional Relational Database Management Systems (RDBMS).^[600-developer-elasticsearch.md]
| RDBMS Concept | Elasticsearch Concept |
|---|---|
| Table | Index |
| Row | Document |
| Column | Field |
| Schema | Mapping |
| SQL | DSL |
- Documents: Data is stored as JSON-like objects^[600-developer-elasticsearch.md].
- Fields: These are analogous to columns in MySQL^[600-developer-elasticsearch.md].
- Mapping: This defines the document structure (schema)^[600-developer-elasticsearch.md].
Mapping and Data Types¶
Mapping determines how documents and their fields are stored and indexed^[600-developer-elasticsearch.md].
keyword: Used for exact queries where the value is treated as a single token and is not analyzed for full-text search^[600-developer-elasticsearch.md].text: Used for full-text search; the data is analyzed and tokenized into an inverted index^[600-developer-elasticsearch.md].- Dynamic Mapping: Mapping can be defined manually or configured dynamically^[600-developer-elasticsearch.md].
Search Capabilities¶
Elasticsearch provides powerful full-text retrieval capabilities, utilizing tokenization (analysis) to calculate relevance scores for search results^[600-developer-elasticsearch.md].
Query Types¶
Queries are constructed using DSL (Domain Specific Language), typically via the Kibana Dev Tools^[600-developer-elasticsearch.md]. Two fundamental query types include:
term: Treats the entire query string (e.g., "iphone 手機") as a single token without processing^[600-developer-elasticsearch.md].match: Analyzes the query string and performs tokenization for searching^[600-developer-elasticsearch.md].
Architecture¶
The system is built using Nodes and Shards^[600-developer-elasticsearch.md].
Sources¶
^[600-developer-elasticsearch.md]