apache nutch通过REST索引到solr

时间:2016-05-20 11:28:04

标签: apache solr nutch

apache nutch中的新手 - 写一个客户端通过REST使用它。 在所有步骤(INJECT,FETCH ...)中成功 - 在最后一步 - 尝试索引到solr时 - 它无法传递参数。 请求(我在一些网站上格式化)

{
  "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)

实施了吗? param传递给solr插件?

1 个答案:

答案 0 :(得分: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-config的GET请求(solr-config是先前指定的configId),输出应包含所有默认参数,请参阅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": {}
}

我们的想法是,您需要传递使用configId创建的solr.server.url以及crawlId和其他参数。这应该返回类似于:

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

您需要创建一个设置solr.server.url的新配置,而不是通过JSON有效内容中的args键指定它。