1

我正在使用 DIH 来索引本地文件系统。但是没有存储文件路径、大小和 lastmodified 字段。在我定义的 schema.xml 中:

 <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>

并且还定义了 tika-data-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。任何的想法?

提前致谢。

4

2 回答 2

2

这些数据并非来自 Tika 元数据,因此您应该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>
于 2012-03-28T15:11:54.573 回答
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.

于 2014-03-06T08:32:37.037 回答