Solr从批量更新中丢失记录

时间:2017-11-03 20:05:26

标签: solr apache-zookeeper solr4 solrcloud

我们有一项工作将相同的文件编入SOLR作为批量更新。 SOLR中缺少某些来自更新的文档。例如:如果我们索引

[01,02,03,04]

并按id:02查询。 SOLR不会给我任何回报,而我可以回来 id:01id:03id:04

以下是代码:

private void updateSolrCollection(List<Item> items) throws Exception {
    addToSolr(items);
    commitToSolr();
} 

private void addToSolr(List<Item> items) throws Exception {
    try {
        server.addBeans(items);
    } catch (SolrServerException | IOException e) {
        // try once more
        logger.error("Error while adding to SOLR: " + e.getStackTrace());
        logger.warn("Retrying ADD: retry Unsuccessful Count: " + retryCount);
        try {
            server.addBeans(items);
        } catch (SolrServerException | IOException ex) {

            if (retryEnabled &&  retryCount < maxRetryCount) {
                logger.warn("Retrying ADD Failed, updating lastModifiedDate: " + ex.getStackTrace());
                updateLastModifiedDate(items);
                retryCount++;
            } else {
                throw ex;
            }

        }
}

private void commitToSolr() throws Exception {
    try {
        server.commit();
    } catch (SolrServerException | IOException e) {
        // try Once More
        logger.error("Error while commiting to SOLR: " + e.getStackTrace());
        logger.warn("Retrying Commit: ");
        try {
            server.commit();
        } catch (SolrServerException | IOException ex) {
                throw ex;
        }
    }
}

为什么SOLR没有索引这些记录?这可能是Zookeeper的一个问题吗?

0 个答案:

没有答案