Elasticsearch知识点
Elasticsearch是一个基于Lucene的搜索和分析引擎,它被设计用于云计算中的分布式全文搜索。以下是一些Elasticsearch的常见知识点和示例代码:
- 索引创建:
PUT /my_index
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}
- 文档索引和搜索:
POST /my_index/_doc/1
{
"name": "John Doe",
"age": 30,
"about": "I love to go rock climbing"
}
GET /my_index/_search
{
"query": {
"match": {
"about": "climbing"
}
}
}
- 聚合查询(Aggregations):
GET /my_index/_search
{
"size": 0,
"aggs": {
"age_avg": {
"avg": {
"field": "age"
}
}
}
}
- 更新文档:
POST /my_index/_update/1
{
"doc": {
"age": 31
}
}
- 删除索引:
DELETE /my_index
这些是Elasticsearch的基本操作,实际应用中可能还会涉及到更复杂的查询、分析和设置。
评论已关闭