【问题标题】:apache nutch to index to solr via RESTapache nutch 通过 REST 索引到 solr
【发布时间】:2023-03-27 08:07:01
【问题描述】:

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)

实施了吗?传递给 solr 插件的参数?

【问题讨论】:

    标签: apache solr nutch


    【解决方案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 中一切正常,您应该会看到带有所需值 https://gist.github.com/jorgelbg/689b1d66d116fa55a1ee14d7193d71b4#file-nutch-solr-config-json-L464solr.server.url 选项。

    在此之后只需点击/job/create 端点以创建一个新的INDEX 作业,有效负载应该类似于:

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

    这个想法是需要你传递你创建的 configId 以及 crawlId 和其他参数指定的 solr.server.url。这应该返回类似于:

    {
      "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 键指定它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 2018-07-01
      • 2021-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多