https://github.com/mattweber/elasticsearch-mocksolrplugin 下载源码,通过eclipse导入maven工程。maven库更新后 co.diji.rest.SolrUpdateHandlerRestAction 类有错误,可能是rtf版本没有正确更新,手动修正
86行 String qstr = request.contentAsString();
替换为 String qstr = request.content().toUtf8();
118行 XMLStreamReader parser =
inputFactory.createXMLStreamReader(new StringReader(request.contentAsString()));
替换为
XMLStreamReader parser =
inputFactory.createXMLStreamReader(new StringReader(request.content().toUtf8()));
主要是这2个方法调用有错误,其他行错误参照修改
编译elasticsearch-mocksolrplugin
修改pom.xml的elasticsearch、solr版本
<elasticsearch.version>0.20.2</elasticsearch.version>
<solr.version>3.5.0</solr.version>
打包插件
mvn package
输出路径 elasticsearch-mocksolrplugin-master\target\releases\elasticsearch-mocksolrplugin-1.1.4-SNAPSHOT.zip
上传到服务器端分发到集群节点
#停集群服务
./pssh.sh ./clients "service elasticsearch stop;"
#授权
./pssh.sh ./clients "cd /opt/elasticsearch/bin;chmod +x plugin;"
#分发到节点的根路径
./pscp.sh ./clients /root/elasticsearch-mocksolrplugin-1.1.4-SNAPSHOT.zip /root/
#安装插件
./pssh.sh ./clients "/opt/elasticsearch/bin/plugin -url
file:/root/elasticsearch-mocksolrplugin-1.1.4-SNAPSHOT.zip
-install mocksolrplugin"
#启动集群,等待建立关系 ./pssh.sh ./clients "service elasticsearch start;"
测试URL
http://ipaddress:port/index/type/_solr/select
http://ip地址:端口/索引/类型(mapping) /_solr/select
elasticsearch-mocksolrplugin接口
SolrSearchHandlerRestAction 接口
- ipaddress:port/_solr/select
- ipaddress:port/{index}/_solr/select
- ipaddress:port/{index}/{type}/_solr/select
SolrUpdateHandlerRestAction 接口
- ipaddress:port/_solr/update
- ipaddress:port/_solr/update/{handler}
- ipaddress:port/{index}/_solr/update
- ipaddress:port/{index}/_solr/update/{handler}
- ipaddress:port/{index}/{type}/_solr/update
- ipaddress:port/{index}/{type}/_solr/update/{handler}
关于pssh
http://code.google.com/p/parallel-ssh/
PSSH provides parallel versions of OpenSSH and related tools. Included are pssh, pscp, prsync, pnuke, and pslurp. The project includes psshlib which can be used within custom applications.
中文乱码
后续测试遇到了中文乱码的问题解决办法如下
找到co.diji.solr.SolrResponseWriter类的writeXmlResponse方法修改,此处是UTF8编码格式以此类推
// send the response
channel.sendResponse(new BytesRestResponse(
writer.toString().getBytes(Charset.forName("UTF-8")), contentTypeXml));
重新打包测试。
ES社区推荐
http://www.elasticsearch.org
http://es-bbs.medcl.net
http://es-cn.medcl.net
本文es-bbs地址 http://es-bbs.medcl.net/discussion/94/elasticsearch-mocksolrplugin%E7%BC%96%E8%AF%91%E6%B5%8B%E8%AF%95#Item_1