简体   繁体   English

Solrj完全导入无法正常工作

[英]Solrj full-import not working

I configured solr server on my Glassfish and everything works well. 我在Glassfish上配置了solr服务器,一切正常。 The problem is when I try to make reindex call using Solrj in my Java application. 问题是当我尝试在我的Java应用程序中使用Solrj进行reindex调用时。

I'm using delta import via full import but it works well outside Solrj so I suppose there isn't problem 我通过完全导入使用delta导入,但它在Solrj之外运行良好,所以我认为没有问题

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

When I call 我打电话的时候

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

then reindex is correct and I see my new results. 然后reindex是正确的,我看到了我的新结果。 The problems starts when I do it using Solrj 当我使用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);

The resposne seems ok 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.}

All the info there are correct - it should made 4 requests to database and proceed all 5 rows to index. 所有信息都是正确的 - 它应该向数据库发出4个请求并继续进行所有5行索引。 But when I look at my indexed data (using URL or Solrj) 但是当我查看我的索引数据时(使用URL或Solrj)

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

I see there is still old index. 我看到还有旧索引。 For example I changed one row in database, called reindex using Solrj and I see no changes in index. 例如,我在数据库中更改了一行,使用Solrj调用了reindex,我看到索引没有变化。 When I call URL command 当我调用URL命令时

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

the reindex runs correctly and I see changed values in Solr (using URL or Solrj). reindex正确运行,我在Solr中看到更改的值(使用URL或Solrj)。 I tried to add solr.commit() to my code but it didn't help. 我试图将solr.commit()添加到我的代码中,但它没有帮助。 What am I doing wrong? 我究竟做错了什么? Why I see no changes using Solrj but everything is fine using URL? 为什么我看到没有使用Solrj的更改,但使用URL一切正常?

Few things you can check for - 你可以检查几件事 -

  • command only full-import params.set("command", "full-import"); 命令only full-import params.set("command", "full-import");
  • you can add clean=true as seperate param 你可以添加clean=true作为单独的param
  • Also, check if you need to pass commit=true as a param to have the documents committed. 另外,检查是否需要将commit=true作为参数传递以commit=true文档。
  • Also, DIH calls are async to you would get a response back fast, however the process might still be running in the backend. 此外,DIH调用是异步的,您可以快速获得响应,但是该过程可能仍在后端运行。

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

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