命令用法示例

  • curl命令使用账号密码连接es
curl -XGET -u "elastic:changeme" 'http://localhost:9200/' -H 'Content-Type: application/json'
# -u 选项可以帮我们设置用户名及密码来登录我们的elasticsearch
# -u, --user <user:password> Server user and password

# 若是还需要证书的话则使用如下用法
curl -XGET -u "elastic:changeme" --cacert xxx.cert 'http://localhost:9200/' -H 'Content-Type: application/json'
# 其他参数
--cacert <file> CA certificate to verify peer against
--capath <dir>  CA directory to verify peer against
-cert <certificate[:password]> Client certificate file and password
--cert <certificate[:password]> Client certificate file and password
--cert-status   Verify the status of the server certificate
--cert-type <type> Certificate file type (DER/PEM/ENG)
  • pretty的用法
# 创建索引,最后直接加上pretty
curl -XPUT 'http://localhost:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d '
{
    "user": "kimchy",
    "post_date": "2009-11-15T13:12:00",
    "message": "Trying out Elasticsearch, so far so good?"
}'

# 查询,最后需要加上pretty=true,注意,跟上面的不一样
curl -XGET 'http://localhost:9200/twitter/_doc/1?pretty=true'
原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/12079023.html