0

I have spent more than 3 hours of time to fix this issue, but unfortunately i am not able to fix it. Can anyone help me on this ?

Here is the exception i am getting while running deletebyQuery using solrj while adding to solr is working. Note : deletebyQuery is not working but add is working.

org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: http://localhost:8090/solr/abc
    at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:589)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:241)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:230)
    at org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.request(ConcurrentUpdateSolrClient.java:351)
    at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:150)
    at org.apache.solr.client.solrj.SolrClient.deleteByQuery(SolrClient.java:896)
    at org.apache.solr.client.solrj.SolrClient.deleteByQuery(SolrClient.java:914)
    at net.merger.prune.Merger.run(Merger.java:19)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:886)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:480)
    ... 14 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity.
    at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:663)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:487)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
    ... 18 more 

and here is my SolrServerHolder code.

public class SolrServerHolder {
    private static SolrClient concurrentSolrServer = null;
    private static HttpSolrClient solrServer = null;
    @SuppressWarnings("deprecation")
    private static HttpSolrServer httpServer = null;
    private static DefaultHttpClient client = null;

    private static synchronized void initHttpClient() {
        try {
            PoolingClientConnectionManager connManager = new PoolingClientConnectionManager();
            connManager.setDefaultMaxPerRoute(20); // Allow upto 20 connections for solr server
            connManager.setMaxTotal(1000);
            client = new DefaultHttpClient(connManager);
        } catch (Error e) {
            e.getMessage();
        }
    }

    private static synchronized void initConcurrentSolrServer() throws Exception {      
        if(client == null)
            initHttpClient();       

        UsernamePasswordCredentials defaultcreds = new UsernamePasswordCredentials("XXXX", "YYYY");
        client.getCredentialsProvider().setCredentials(
                new AuthScope("localhost", 
                        "8090", AuthScope.ANY_REALM),defaultcreds);

        concurrentSolrServer = new ConcurrentUpdateSolrClient("http://localhost:8090/solr/abc", client, 5000, 2);

    }

public static  SolrClient getConcurrentSolrServer() throws Exception {
        if(concurrentSolrServer == null)
            initConcurrentSolrServer();
        return concurrentSolrServer;
    }

}

and Here is my code which will trying to delete the data by query and throwing exception :

SolrClient server =SolrServerHolder.getConcurrentSolrServer();
server.deleteByQuery("id:65657575", 12000);
server.commit();

if i am trying to add docs to solr it is working perfectly Fine

SolrInputDocument docs = getDocs();
SolrClient server =SolrServerHolder.getConcurrentSolrServer();
server.add(abc);
server.commit();

I have refereed similar issues and solutions but it didn't help me.

Solrj Authentication Fails On Write Operation

Community
  • 1
  • 1
Sthita
  • 1,750
  • 2
  • 19
  • 38
  • Don't have the answer, but I have encountered multiple of issues (bugs ?) when trying to use deleteByQuery. Ended up using custom http call just for that. However, for your case, did you try using deleteById method? Or your query is just an example? – taleodor Mar 07 '16 at 03:07
  • @talyyweb yes i have tried deletebyid also, its same problem :( custom http call , so did ti work for you ? Can you help me on that. – Sthita Mar 07 '16 at 08:11
  • 1
    First, try doing this using curl (or using your browser) and issuing a GET request to `http://yourlogin:yourpassword@localhost:8090/solr/abc/update?stream.body= id:65657575&commit=true` If that works for you, the workaround is basically to script it using an http client, such as Apache HttpClient. But check if it works with curl first. – taleodor Mar 07 '16 at 16:40
  • @talyyweb yes that helped. Thanks. – Sthita Mar 12 '16 at 03:48

0 Answers0