Elasticsearch DSL¶
Elasticsearch DSL (Domain Specific Language) is the query syntax used in Elasticsearch to interact with the data stored in the engine^[600-developer-elasticsearch.md]. It serves a role comparable to SQL in relational databases, allowing users to perform full-text searches and retrieve specific documents^[600-developer-elasticsearch.md].
Comparison with SQL¶
In the context of database operations, Elasticsearch DSL acts as the counterpart to SQL^[600-developer-elasticsearch.md]. While SQL is used to query data in tables, DSL is used to query documents within indices^[600-developer-elasticsearch.md].
| RDBMS | Elasticsearch |
|---|---|
| SQL | DSL |
| Table | Index |
| Row | Document |
Execution¶
DSL queries are typically constructed as JSON-formatted query strings^[600-developer-elasticsearch.md]. Users often execute these queries using tools such as the Kibana Dev Tools interface^[600-developer-elasticsearch.md].
Query Types¶
Elasticsearch DSL provides various methods for querying data, primarily distinguished by how they handle text analysis^[600-developer-elasticsearch.md].
- match: Used for full-text search. This query analyzes the input string, performing tokenization (分詞) before searching^[600-developer-elasticsearch.md].
- term: Used for exact matching. This query treats the input (e.g., "iphone 手機") as a single token and does not perform analysis or tokenization^[600-developer-elasticsearch.md].
Related Concepts¶
Sources¶
^[600-developer-elasticsearch.md]