2012-03-27 116 views
1

我使用DIH來索引本地文件系統。但沒有存儲文件路徑,大小和上次修改的字段。在schema.xml中,我定義:如何在使用TikaEntityProcessor時在Solr中存儲文件路徑

<fields> 
    <field name="title" type="string" indexed="true" stored="true"/> 
    <field name="author" type="string" indexed="true" stored="true" /> 
    <!--<field name="text" type="text" indexed="true" stored="true" /> 
    liang added--> 
    <field name="path" type="string" indexed="true" stored="true" /> 
    <field name="size" type="long" indexed="true" stored="true" /> 
    <field name="lastmodified" type="date" indexed="true" stored="true" /> 
</fields> 

而且還定義蒂卡數據-config.xml中:

<dataConfig> 
    <dataSource name="bin" type="BinFileDataSource" /> 
    <document> 
     <entity name="f" dataSource="null" rootEntity="false" 
      processor="FileListEntityProcessor" 
      baseDir="E:/my_project/ecmkit/infotouch" 
      fileName=".*\.(DOC)|(PDF)|(pdf)|(doc)|(docx)|(ppt)" onError="skip" 
      recursive="true"> 
      <entity name="tika-test" dataSource="bin" processor="TikaEntityProcessor" 
      url="${f.fileAbsolutePath}" format="text" onError="skip"> 
       <field column="Author" name="author" meta="true"/> 
       <field column="title" name="title" meta="true"/> 
       <!-- 
       <field column="text" name="text"/> --> 
       <field column="fileAbsolutePath" name="path" /> 
       <field column="fileSize" name="size" /> 
       <field column="fileLastModified" name="lastmodified" /> 
      </entity> 
     </entity> 
    </document> 
</dataConfig> 

Solr的版本是3.5。任何想法?

在此先感謝。

+0

在solr郵件列表上提問:http://www.mail-archive.com/[email protected]/msg64225.html。我也在那裏回答。 – javanna 2012-03-28 15:12:35

回答

2

這些數據並不來自蒂卡元數據,所以你應該將它們移到FileListEntityProcessor實體是這樣的:

<dataConfig> 
    <dataSource name="bin" type="BinFileDataSource" /> 
    <document> 
     <entity name="f" dataSource="null" rootEntity="false" 
      processor="FileListEntityProcessor" 
      baseDir="/home/luca/Documents" 
      fileName=".*\.(DOC)|(PDF)|(pdf)|(doc)|(docx)|(ppt)" onError="skip" 
      recursive="true"> 

      <field column="fileAbsolutePath" name="path" /> 
      <field column="fileSize" name="size" /> 
      <field column="fileLastModified" name="lastmodified" /> 

      <entity name="tika-test" dataSource="bin" processor="TikaEntityProcessor" 
      url="${f.fileAbsolutePath}" format="text" onError="skip"> 
       <field column="Author" name="author" meta="true"/> 
       <field column="title" name="title" meta="true"/> 
       <!--<field column="text" />-->   
      </entity> 
     </entity> 
    </document> 
</dataConfig> 
1

你並不需要聲明在DIH配置這個領域,只是將它們定義schema.xml中:

<field name="fileAbsolutePath" type="string" indexed="true" stored="true" multiValued="false" /> 
<field name="file"    type="string" indexed="true" stored="true" multiValued="false" /> 
<field name="fileLastModified" type="string" indexed="true" stored="true" multiValued="false" /> 

他們會自動填入基於FileListEntityProcessor(Solr中4.6測試)。

相關問題