【问题标题】:How to add some additional fields into solr when indexing from nutch?从 nutch 索引时如何在 solr 中添加一些附加字段?
【发布时间】:2014-09-20 06:30:06
【问题描述】:

我正在使用 nutch 1.9,使用 cygwin 和 solr 4.8.0。我可以使用下面的代码将爬取的数据索引到 solr 中。

bin/crawl urls/ crawlresult/ http://localhost:8983/solr/ 1

但我想在索引时添加一些额外的字段,例如 indexed_by、crawled_by、crawl_name 等。
我需要这方面的帮助。

提前致谢。

【问题讨论】:

    标签: solr cygwin web-crawler nutch


    【解决方案1】:

    如果附加字段的值没有改变,那么您可以使用 Nutch 的 index-static 插件。它允许您添加许多字段及其内容。您首先需要在 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 插件来执行此操作。查看 index-static 插件以了解如何实现您的。

    【讨论】:

    • 感谢它的工作。我添加了 index.static 属性,然后在 schema.xml 中添加了字段定义,并在 plugin.includes 中启用了索引。
    猜你喜欢
    • 2023-03-05
    • 2016-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多