簡體   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