概述
Elasticsearch-SQL是Elasticsearch的一个插件,它可以让我们通过类似SQL的方式对Elasticsearch中的数据进行查询。
项目地址是:https://github.com/NLPchina/elasticsearch-sql
安装部署
不同Elasticsearch版本需要安装的插件版本也不同,使用的Elasticsearch版本是2.3.3,对应版本插件安装方法是(先切换到Elasticsearch目录下):
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.3.3.0/elasticsearch-sql-2.3.3.0.zip
其实在生产环境中很多服务器是不能直接连接外网进行下载的。这里先将文件下载到本地,然后再上传到生产环境的服务器中,在上传到服务器后,从本地文件安装插件。安装插件时在install后面加"file:",之后加Elasticsearch-sql.zip文件的绝对路径:
[root@ceshi202 elasticsearch-2.3.3]# ./bin/plugin installfile:/opt/elasticsearch-2.3.3/elasticsearch-sql-2.3.3.0.zip-> Installing from file:/opt/elasticsearch-2.3.3/elasticsearch-sql-2.3.3.0.zip...Trying file:/opt/elasticsearch-2.3.3/elasticsearch-sql-2.3.3.0.zip ...Downloading .......................................DONEVerifying file:/opt/elasticsearch-2.3.3/elasticsearch-sql-2.3.3.0.zipchecksums if available ...NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)Installed sql into /opt/elasticsearch-2.3.3/plugins/sql[root@ceshi202 elasticsearch-2.3.3]#
安装结束后,需要重新启动Elasticsearch服务,不然在搜索的时候会有下面的报错:
Invalid index name [sql], must not start with ''];