ES在linux系统中的实操命令
warning:
这篇文章距离上次修改已过206天,其中的内容可能已经有所变动。
Elasticsearch (ES) 是一个基于Lucene的搜索和分析引擎,它被用作全文检索、结构化搜索和分析等多种场合。在Linux系统中,我们可以通过命令行来操作ES。
以下是一些常见的ES操作命令:
- 启动Elasticsearch服务
./bin/elasticsearch
- 检查Elasticsearch服务状态
curl -X GET "localhost:9200/"
- 创建一个索引
curl -X PUT "localhost:9200/customer?pretty"
- 获取所有索引
curl -X GET "localhost:9200/_cat/indices?v&pretty"
- 添加或更新一个文档
curl -X POST "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}'
- 获取一个文档
curl -X GET "localhost:9200/customer/_doc/1?pretty"
- 更新一个文档
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"doc": { "name": "Jane Doe" }
}'
- 删除一个文档
curl -X DELETE "localhost:9200/customer/_doc/1?pretty"
- 删除索引
curl -X DELETE "localhost:9200/customer?pretty"
- 使用Elasticsearch的查询语言(Query DSL)进行搜索
curl -X POST "localhost:9200/customer/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"name": "John"
}
}
}'
注意:在使用这些命令之前,你需要确保Elasticsearch已经正确安装,并且你有相应的权限来执行这些操作。
以上就是Elasticsearch在Linux系统中的一些基本操作命令。实际使用时,你可能需要根据自己的需求来调整这些命令,或者使用Elasticsearch的其他功能,如集群管理、监控等。
评论已关闭