1.elasticsearch-sql在线安装
$./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.2.3.0/elasticsearch-sql-6.2.3.0.zip
2.elasticsearch-sql离线安装
$./elasticsearch-plugin install file:/home/bdp/shangeshishi/elasticsearch-6.5.4/elasticsearch-sql-6.5.4.0.zip
3.elasticsearch-sql的postMan请求
请求地址
http://10.45.47.66:9200/_sql
注:es7的为:
http://10.45.47.66:9200/_nlpcn/sql
请求头
Content-Type:application/json
Authorization:Basic ZWxhc3RpYzpiZHAxMjM=
请求参数
{
"sql":"desc label_user_info_base_es_20190729"
}
请求效果
低于6.5版本的查询方式略有不同,查询方式为:
http://10.45.47.66:9200/_sql?sql=select * from label_user_info_base_es_20190729
附Base64加密获取代码示例:
String authString = userName + ":" + password;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes("utf-8"));
String authStringEnc =new String(authEncBytes);
相关pom依赖
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>