2016-05-20 113 views
0

apache nutch的新手 - 編寫客戶端通過REST使用它。 成功完成所有步驟(INJECT,FETCH ...) - 最後一步 - 試圖索引solr時 - 它無法傳遞參數。 的請求(我格式化它在一些網站)apache nutch通過REST索引到索引

{ 
    "args": { 
    "batch": "1463743197862", 
    "crawlId": "sample-crawl-01", 
    "solr.server.url": "http:\/\/x.x.x.x:8081\/solr\/" 
    }, 
    "confId": "default", 
    "type": "INDEX", 
    "crawlId": "sample-crawl-01" 
} 

的Nutch的日誌:

java.lang.Exception: java.lang.RuntimeException: Missing SOLR URL. Should be set via -D solr.server.url 
SOLRIndexWriter 
     solr.server.url : URL of the SOLR instance (mandatory) 
     solr.commit.size : buffer size when sending to SOLR (default 1000) 
     solr.mapping.file : name of the mapping file for fields (default solrindex-mapping.xml) 
     solr.auth : use authentication (default false) 
     solr.auth.username : username for authentication 
     solr.auth.password : password for authentication 
     at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462) 
     at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522) 

是實施?傳遞給solr插件的參數?

回答

1

您需要創建/使用/config/create/端點更新配置,用POST請求,類似於有效載荷:

{ 
    "configId":"solr-config", 
    "force":"true", 
    "params":{"solr.server.url":"http://127.0.0.1:8983/solr/"} 
} 

在這種情況下,我創建一個新的配置並指定solr.server.url參數。您可以驗證這是否正在使用到/config/solr-configsolr-config是之前指定的configId)的GET請求,輸出應包含所有默認參數,請參閱https://gist.github.com/jorgelbg/689b1d66d116fa55a1ee14d7193d71b4以獲取示例/默認輸出。如果返回的JSON中一切正常,您應該看到solr.server.url選項,並且所需的值爲https://gist.github.com/jorgelbg/689b1d66d116fa55a1ee14d7193d71b4#file-nutch-solr-config-json-L464

之後正好砸在/job/create端點創建一個新的INDEX工作,有效載荷應該是這樣的:

{ 
    "type":"INDEX", 
    "confId":"solr-config", 
    "crawlId":"crawl01", 
    "args": {} 
} 

的想法是,需要你通過,你沿着指定的solr.server.url創建configIdcrawlId和其他參數。這應返回類似於:

{ 
    "id": "crawl01-solr-config-INDEX-1252914231", 
    "type": "INDEX", 
    "confId": "solr-config", 
    "args": {}, 
    "result": null, 
    "state": "RUNNING", 
    "msg": "OK", 
    "crawlId": "crawl01" 
} 

底線,你需要創建一個設置好的,而不是通過在JSON有效載荷的args密鑰的指定它的solr.server.url一個新的配置。