如何让刚刚从命令行Elasticsearch服务器版本 [英] How to get JUST the Elasticsearch server version from the command line

查看:133
本文介绍了如何让刚刚从命令行Elasticsearch服务器版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法得到公正的版本号为Elasticsearch服务器。我知道你对JSON请求数据,但有一个方法来解析这一请求得到了版本号只。

卷曲本地主机:9200

  {
    ...
    版本:{
        ...
        数字:2.1.1
    }
}


解决方案

如果您有 JQ 工具,你可以用它来解析JSON答复,并输出一个纯文本字符串:

 卷曲-sS本地主机:9200 | JQ -r .version.number

通用脚本语言可以完成相同,但通常比较笨重:

 卷曲-sS本地主机:9200 |蟒蛇-c'进口JSON,SYS;打印(json.loads(sys.stdin.read())版本] [数量])

Is there way to get JUST the version number for an Elasticsearch server. I know you get the JSON request data but is there a way to parse that request get the version number only.

curl localhost:9200

{
    ...
    "version": {
        ...
        "number": "2.1.1"
    }
}

解决方案

If you have the jq utility, you can use it to parse the json reply and output a plain text string:

curl -sS localhost:9200 | jq -r .version.number

General purpose scripting languages can accomplish the same, but are usually more clunky:

curl -sS localhost:9200 | python -c 'import json, sys; print(json.loads(sys.stdin.read())["version"]["number"])'

这篇关于如何让刚刚从命令行Elasticsearch服务器版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆