apache nutch 通过 REST 索引到 solr
apache nutch to index to solr via REST
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 插件的参数?
您需要 create/update 使用 /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 for an example/default output. If everything worked fine in the returned JSON you should see the solr.server.url
option with the desired value 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
创建的 configId
以及 crawlId
和其他参数。这应该 return 类似于:
{
"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
键指定它。
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 插件的参数?
您需要 create/update 使用 /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 for an example/default output. If everything worked fine in the returned JSON you should see the solr.server.url
option with the desired value 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
创建的 configId
以及 crawlId
和其他参数。这应该 return 类似于:
{
"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
键指定它。