我正在使用cygwin和solr 4.8.0的nutch 1.9。我可以使用下面的代码将爬网数据索引到solr中。
bin/crawl URL/crawlresult/http://localhost:8983/solr/1
但我想在进行索引时添加一些附加字段,如indexed_by、crawled_by、crawl_name等。
我需要这方面的帮助。
提前道谢。
如果附加字段的值没有改变,那么您可以使用Nutch的索引静态插件。它允许您添加多个字段及其内容。首先需要在nutch-site.xml中启用它。然后添加如下所示的字段列表:
<property>
<name>index.static</name>
<value>indexed_by:solr,crawled_by:nutch-1.8,crawl_name:nutch</value>
<description>
Used by plugin index-static to adds fields with static data at indexing time.
You can specify a comma-separated list of fieldname:fieldcontent per Nutch job.
Each fieldcontent can have multiple values separated by space, e.g.,
field1:value1.1 value1.2 value1.3,field2:value2.1 value2.2 ...
It can be useful when collections can't be created by URL patterns,
like in subcollection, but on a job-basis.
</description>
</property>
如果这些字段的值不是静态的,并且独立于索引文档,那么您将需要编写一个IndexingFilter插件来完成此操作。看看索引静态插件,了解如何实现您的插件。