Solrj full-import not working

做~自己de王妃 提交于 2019-12-11 21:10:08

问题


I configured solr server on my Glassfish and everything works well. The problem is when I try to make reindex call using Solrj in my Java application.

I'm using delta import via full import but it works well outside Solrj so I suppose there isn't problem

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. The problems starts when I do it using 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

{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. But when I look at my indexed data (using URL or 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. When I call URL command

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). I tried to add solr.commit() to my code but it didn't help. What am I doing wrong? Why I see no changes using Solrj but everything is fine using URL?


回答1:


Few things you can check for -

  • command only full-import params.set("command", "full-import");
  • you can add clean=true as seperate param
  • Also, check if you need to pass commit=true as a param to have the documents committed.
  • Also, DIH calls are async to you would get a response back fast, however the process might still be running in the backend.


来源:https://stackoverflow.com/questions/17543302/solrj-full-import-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!