dev2110
dev2110

Reputation: 3

Solr version 6.6.1 and http core and client versions

Hello I have the following code in my solr client.

Trying to connect to the server.

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( "*:*" );

I get the error below when it tries to delete all data.
Version of solr 6.6.1 http-core 4.4.8 and 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)

Upvotes: 0

Views: 325

Answers (1)

freedev
freedev

Reputation: 30167

I assume that prosp_poc_collection is the name of the collection you're using.

First try specifying the Url without the anchor #, this the correct way.

And again, the HttpSolrClient constructor you're using has been deprecated, try in this way:

String urlString = "http://localhost:8983/solr/prosp_poc_collection";
SolrClient solrClient = new HttpSolrClient(urlString);

https://lucene.apache.org/solr/6_6_1/solr-solrj/org/apache/solr/client/solrj/impl/HttpSolrClient.html

On the other hand, another way is use HttpSolrClient.Builder class

solrClient = new HttpSolrClient.Builder("http://localhost:8983/solr/prosp_poc_collection")
                             .build();

Upvotes: 0

Related Questions