ES 状态命令
测试命令
curl -X GET "localhost:9200/

官方文档
查看健康状态
curl localhost:9200/_cat/health?v

查看节点状态
curl localhost:9200/_cat/nodes?v

查看索引状态
curl localhost:9200/_cat/indices?v

索引相关命令(官方文档)
创建索引
curl -XPUT localhost:9200/books

删除索引
curl -XDELETE localhost:9200/books?pretty

document相关
插入数据
curl -H"Content-Type:application/json" -XPOST localhost:9200/books/book/1?pretty -d"{\"title\":\"test\",\"price\":100}"

其中,books代表索引,book代表type,1是生成的document的id(如果不指定,会自动生成),pretty是用于调整返回值的展示
根据ID查询
curl -XGET localhost:9200/books/book/1?pretty

删除数据
curl -XDELETE localhost:9200/books/book/1?pretty

search相关
URL查询(官方文档)
curl -XGET localhost:9200/books/book/_search?q=_id:1

报文体搜索
curl -XPOST -H"Content-Type:application/json" localhost:9200/books/book/_search?pretty -d "{\"query\":{\"term\":{\"title\":\"1247\"}}}"

网友评论