课程进度 83% · 第5/6章第5/6章 · 标签 1/1
— 1 —
Elasticsearch基础
Elasticsearch 是一个基于 Lucene 的分布式搜索和分析引擎,广泛用于企业级搜索、日志分析和数据可视化场景。
Elasticsearch 的核心概念:
- Elasticsearch 的定义与作用
- Elasticsearch 的基本组成(节点、集群、索引、分片)
- Elasticsearch 的工作流程(索引写入、搜索分发)
- Elasticsearch 的生态(Kibana、Logstash、Beats)
📖ES 采用 RESTful API 设计,所有操作均可通过 HTTP 请求完成。
— 2 —
Elasticsearch示例
以下示例演示 Elasticsearch 的索引创建和文档搜索操作:
json
1
# 创建索引
2
PUT /my_index
3
{
4
"mappings": {
5
"properties": {
6
"title": { "type": "text" },
7
"content": { "type": "text" }
8
}
9
}
10
}
11
12
# 搜索文档
13
GET /my_index/_search
14
{
15
"query": {
16
"match": {
17
"content": "搜索关键词"
18
}
19
}
20
}
✓ES 7.x 及以上版本移除了 mapping type,一个索引仅包含一个文档类型。