繁体   English   中英

Solrj完全导入无法正常工作

[英]Solrj full-import not working

我在Glassfish上配置了solr服务器,一切正常。 问题是当我尝试在我的Java应用程序中使用Solrj进行reindex调用时。

我通过完全导入使用delta导入,但它在Solrj之外运行良好,所以我认为没有问题

http://wiki.apache.org/solr/DataImportHandlerDeltaQueryViaFullImport

我打电话的时候

http://localhost:8787/solr-4.2.1/db/dataimport?command=full-import&clean=true

然后reindex是正确的,我看到了我的新结果。 当我使用Solrj时,问题就开始了

    SolrServer solr = new HttpSolrServer("http://localhost:8787/solr-4.2.1/db");

    ModifiableSolrParams params = new ModifiableSolrParams();

    params.set("qt", "/dataimport");
    params.set("command", "full-import&clean=true");

    QueryResponse response = null;

    try {
        response = solr.query(params);
    } catch (SolrServerException e1) {
        e1.printStackTrace();
    } 
    System.out.println(response);

resposne似乎没问题

{responseHeader={status=0,QTime=0},initArgs={defaults={config=db-data-config.xml}},command=full-import&clean=true,status=idle,importResponse=,statusMessages={Total Requests made to DataSource=4, Total Rows Fetched=5, Total Documents Skipped=0, Full Dump Started=2013-07-09 09:42:34, =Indexing completed. Added/Updated: 5 documents. Deleted 0 documents., Committed=2013-07-09 09:42:35, Total Documents Processed=5, Time taken=0:0:0.390},WARNING=This response format is experimental.  It is likely to change in the future.}

所有信息都是正确的 - 它应该向数据库发出4个请求并继续进行所有5行索引。 但是当我查看我的索引数据时(使用URL或Solrj)

http://localhost:8787/solr-4.2.1/db/search/?q=*:*

我看到还有旧索引。 例如,我在数据库中更改了一行,使用Solrj调用了reindex,我看到索引没有变化。 当我调用URL命令时

http://localhost:8787/solr-4.2.1/db/dataimport?command=full-import&clean=true

reindex正确运行,我在Solr中看到更改的值(使用URL或Solrj)。 我试图将solr.commit()添加到我的代码中,但它没有帮助。 我究竟做错了什么? 为什么我看到没有使用Solrj的更改,但使用URL一切正常?

你可以检查几件事 -

  • 命令only full-import params.set("command", "full-import");
  • 你可以添加clean=true作为单独的param
  • 另外,检查是否需要将commit=true作为参数传递以commit=true文档。
  • 此外,DIH调用是异步的,您可以快速获得响应,但是该过程可能仍在后端运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM