2016-05-20 112 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一个新的配置。