【问题标题】:Indexing PDF documents in Solr with no UniqueKey在没有 UniqueKey 的情况下在 Solr 中索引 PDF 文档
【发布时间】:2011-07-15 20:43:50
【问题描述】:

我想索引 PDF(和其他丰富的)文档。我正在使用 DataImportHandler。

这是我的 schema.xml 的外观:

.........
.........
 <field name="title" type="text" indexed="true" stored="true" multiValued="false"/>
   <field name="description" type="text" indexed="true" stored="true" multiValued="false"/>
   <field name="date_published" type="string" indexed="false" stored="true" multiValued="false"/>
   <field name="link" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
   <dynamicField name="attr_*" type="textgen" indexed="true" stored="true" multiValued="false"/>
........
........
<uniqueKey>link</uniqueKey>

如您所见,我已将链接设置为唯一键,以便在发生索引时不会再次复制文档。现在我将文件路径存储在数据库中,并且设置了 DataImportHandler 以获取所有文件路径的列表并索引每个文档。为了测试它,我使用了 Solr 中示例文档附带的 tutorial.pdf 文件。问题当然是这个 pdf 文档没有“链接”字段。我正在考虑如何在索引这些文档时手动将文件路径设置为链接。我尝试了如下数据配置设置,

 <entity name="fileItems"  rootEntity="false" dataSource="dbSource" query="select path from file_paths">
   <entity name="tika-test" processor="TikaEntityProcessor" url="${fileItems.path}" dataSource="fileSource">
     <field column="title" name="title" meta="true"/>
     <field column="Creation-Date" name="date_published" meta="true"/>
     <entity name="filePath" dataSource="dbSource" query="SELECT path FROM file_paths as link where path = '${fileItems.path}'">
       <field column="link" name="link"/>
     </entity>
   </entity>
  </entity>

我创建了一个子实体,它查询路径名并使其在标题为“链接”的列中返回结果。但我仍然看到这个错误:

WARNING: Error creating document : SolrInputDocument[{date_published=date_published(1.0)={2011-06-23T12:47:45Z}, title=title(1.0)={Solr tutorial}}]
org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: link

我是否可以为 pdf 文档创建一个名为链接的字段?

之前已经问过here,但提供的解决方案使用的是 ExtractRequestHandler,但我想通过 DataImportHandler 使用它。

【问题讨论】:

    标签: lucene solr


    【解决方案1】:

    试试这个:

    <entity name="fileItems"  rootEntity="false" dataSource="dbSource" query="select path from file_paths">
      <field column="path" name="link"/>
      <entity name="tika-test" processor="TikaEntityProcessor" url="${fileItems.path}" dataSource="fileSource">
        <field column="title" name="title" meta="true"/>
        <field column="Creation-Date" name="date_published" meta="true"/>
      </entity>
    </entity>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      • 2012-03-27
      • 1970-01-01
      • 2011-02-17
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      相关资源
      最近更新 更多