您好我的solr客户端中有以下代码。
尝试连接服务器。
System.out.println("Initializing server");
SystemDefaultHttpClient cl = new SystemDefaultHttpClient();
client = new HttpSolrClient("http://localhost:8983/solr/#/prosp_poc_collection",cl);
System.out.println("Completed initializing the server");
client.deleteByQuery( "*:*" );
尝试删除所有数据时,我收到以下错误消息。
solr 6.6.1 http-core 4.4.8和http client 4.5.3。
org/apache/solr/client/solrj/impl/HttpClientUtil.createClient(Lorg/apache/solr/common/params/SolrParams;)Lorg/apache/http/impl/client/CloseableHttpClient; @57: areturn
Reason:
Type 'org/apache/http/impl/client/SystemDefaultHttpClient' (current frame, stack[0]) is not assignable to 'org/apache/http/impl/client/CloseableHttpClient' (from method signature)
Current Frame:
bci: @57
flags: { }
locals: { 'org/apache/solr/common/params/SolrParams', 'org/apache/solr/common/params/ModifiableSolrParams', 'org/apache/http/impl/client/SystemDefaultHttpClient' }
stack: { 'org/apache/http/impl/client/SystemDefaultHttpClient' }
Bytecode:
0x0000000: bb00 0959 2ab7 000a 4cb2 000b b900 0c01
0x0000010: 0099 001e b200 0bbb 000d 59b7 000e 120f
0x0000020: b600 102b b600 11b6 0012 b900 1302 00b8
0x0000030: 0014 4d2c 2bb8 0015 2cb0
Stackmap Table:
append_frame(@47,Object[#172])
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:514)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:160)
at org.apache.solr.client.solrj.SolrClient.deleteByQuery(SolrClient.java:895)
at org.apache.solr.client.solrj.SolrClient.deleteByQuery(SolrClient.java:858)
at org.apache.solr.client.solrj.SolrClient.deleteByQuery(SolrClient.java:873)
答案 0 :(得分:0)
我认为prosp_poc_collection
是您正在使用的集合的名称。
首先尝试指定没有锚#
的网址,这是正确的方法。
同样,您使用的HttpSolrClient constructor已弃用,请尝试以下方式:
String urlString = "http://localhost:8983/solr/prosp_poc_collection";
SolrClient solrClient = new HttpSolrClient(urlString);
另一方面,另一种方法是使用HttpSolrClient.Builder
类
solrClient = new HttpSolrClient.Builder("http://localhost:8983/solr/prosp_poc_collection")
.build();