ES 状态命令
测试命令
curl -X GET "localhost:9200/
image.png
官方文档
查看健康状态
curl localhost:9200/_cat/health?v
image.png
查看节点状态
curl localhost:9200/_cat/nodes?v
image.png
查看索引状态
curl localhost:9200/_cat/indices?v
image.png
索引相关命令(官方文档)
创建索引
curl -XPUT localhost:9200/books
image.png
删除索引
curl -XDELETE localhost:9200/books?pretty
image.png
document相关
插入数据
curl -H"Content-Type:application/json" -XPOST localhost:9200/books/book/1?pretty -d"{\"title\":\"test\",\"price\":100}"
image.png
其中,books代表索引,book代表type,1是生成的document的id(如果不指定,会自动生成),pretty是用于调整返回值的展示
根据ID查询
curl -XGET localhost:9200/books/book/1?pretty
image.png
删除数据
curl -XDELETE localhost:9200/books/book/1?pretty
image.png
search相关
URL查询(官方文档)
curl -XGET localhost:9200/books/book/_search?q=_id:1
image.png
报文体搜索
curl -XPOST -H"Content-Type:application/json" localhost:9200/books/book/_search?pretty -d "{\"query\":{\"term\":{\"title\":\"1247\"}}}"
image.png