知识点
相关文章
更多最近更新
更多elasticsearch-mocksolrplugin编译测试
2019-03-27 01:21|来源: 网路
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
转自:http://my.oschina.net/s21109/blog/100605
相关问答
更多-
由于您的ES在HTTPS上运行,因此您需要将ssl => true添加到elasticsearch输入配置中 input { elasticsearch { hosts => ["hostname" ] index => 'indexname' type => 'type' user => 'username' password => 'password' docinfo => true ...
-
如何强制Camel Elasticsearch在测试中不启动本地节点?(How force Camel Elasticsearch to not start local node in test?)[2022-05-13]
camel-elasticsearch组件检查configuration.getIp()== null以确定它是否创建了Elasticsearch节点。 因此,您必须在URI中指定IP和端口以禁用此功能,如下所示: .to("elasticsearch://clusterName?ip="+ elasticHostIp + "&port=" + elasticHostPort + "&operation=INDEX&indexName=" + elasticIndex + "&indexType=" + e ... -
InMemoryConnection实际上并不发送任何请求或从Elasticsearch接收任何响应 ; 与连接设置上的.SetConnectionStatusHandler()一起使用(或NEST 2.x +中的.OnRequestCompleted() ),这是查看序列化请求形式的便捷方式。 当不使用InMemoryConnection但仍然设置.SetConnectionStatusHandler()或.OnRequestCompleted() ,根据NEST版本,当NEST 1.x或.Disable ...
-
将以下依赖项添加到您的build.gradle文件中 configurations { elasticDist } ... dependencies { elasticDist group: 'org.elasticsearch.distribution.zip', name: 'elasticsearch', version: '6.1.2', ext: 'zip' } 添加任务解压缩和清理,设置依赖关系 task unzip(type: Copy) { // to download di ...
-
我已经修改了bin/crawl以删除bin/nutch solrdedup命令,并用elasticindex替换了solrindex所有提及。 I've modified bin/crawl to remove the bin/nutch solrdedup command, and replaced all mentions of solrindex with elasticindex.
-
InMemoryConnection用于单元测试Elasticsearch项目(InMemoryConnection for unit-testing Elasticsearch projects)[2022-04-11]
是。 如果你看一下InMemoryConnection的实现,你会发现它覆盖了DoSynchronousRequest和DoAsyncRequest (负责实际执行HTTP请求的HttpConnection ),并且只返回一个假的ElasticsearchResponse 。 没有HTTP连接打开且没有请求,因此您可以安全地在单元测试中使用它。 Yes. If you look at the implementation of InMemoryConnection, you'll see that it o ... -
您可能希望切换到本地节点进行测试。 这样就可以禁用zen发现,只有在同一个jvm中运行的其他节点才能加入同一个集群。 此外,节点之间没有tcp传输(如果你有多个,似乎不是这种情况),因为它们在同一个jvm中。 您的节点仍然会打开http传输(默认情况下为9200端口),但如果您不需要它,可能需要禁用它。 无论如何,不要忘记设置群集名称! 当您开始测试时,您的节点正在查看是否有其他节点使用相同的群集名称运行。 如果是这种情况,它将加入现有集群并开始与其他节点共享数据,从而导致奇怪的测试行为。 Node nod ...
-
您不能使用.NET在嵌入式模式下运行,您必须在某处使用elasticsearch服务器。 使用嵌套,您可以轻松地与不同的索引进行通信,专门用于测试 var uri = new Uri("http://localhost:9200"); var connectionSettings = new ConnectionSettings(uri, "my-test-index"); var client = new ElasticClient(connectionSettings); my-test-index现 ...
-
没有setTimeout,使用elasticsearch的后端测试失败(Back-end tests with elasticsearch fails without setTimeout)[2022-04-20]
找到一个解决方案,也许对某人有用。 根据Elasticsearch文档 : 默认情况下,文档可立即用于get()操作,但只能在索引刷新后进行搜索(可以自动或手动进行)。 因此,在这种情况下,应该在另一个回调函数中调用done() : before((done) => { elasticClient.index(elasticMockData, function() { elasticClient.indices.refresh(function (err: any, res: any) { ... -
原因是刷新索引需要时间。 你可以做的是手动刷新(在代码中)而不是睡眠。 POST /_refresh POST /
/_refresh 如果它与代码在同一台机器上,那么使用: import requests requests.post('localhost:9200/ /_refresh') The reason is it take time to refresh the index. What you can do is refresh it manually (in t ...