Solrj DeleteByQuery不起作用

时间:2016-03-06 09:34:51

标签: java solr solrj solr4 solr4j

我花了3个多小时的时间来解决这个问题,但不幸的是我无法修复它。任何人都可以帮我吗?

这是我在使用solrj运行deletebyQuery时获得的异常,同时添加到solr工作正常。 注意:deletebyQuery无效但添加正常。

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 

这是我的SolrServerHolder代码。

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;
    }

}

以下是我的代码,它将尝试通过查询删除数据并抛出异常:

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

如果我试图将文档添加到solr,它的工作完全正常

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

我已经审问了类似的问题和解决方案,但它对我没有帮助。

Solrj Authentication Fails On Write Operation

0 个答案:

没有答案