Tika获取存储在数据库中的二进制内容,但不对其进行索引

时间:2013-02-03 10:21:26

标签: solr binaryfiles apache-tika

我正在尝试解析存储在数据库中的二进制内容数据,该文件存放在file_data列的document_attachment表中,并尝试对其进行索引,以便它的内容可用于使用Solr进行搜索。 当我运行索引器时,它会获取数量为两倍的行,这些行是通过在名为“dcs”的实体中运行查询而返回的行,并且不会抛出任何错误或异常。然而,它不会对二进制内容(我与tika关联的字段,尽管从表中提取它)进行索引。

我正在使用apache-solr-3.6.1和Tika 1.0

我的配置文件类似于:

数据-config.xml中

<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
 <dataSource
          driver="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost/espritkm_1?zeroDateTimeBehavior=convertToNull"
          user="root"
          password=""
          autoCommit="true" batchSize="-1"
          convertType="false"
          name="test"
          />

  <dataSource name="fieldReader" type="FieldStreamDataSource" />
  <document name="items">
  <entity name="dcs"
          query="SELECT 222000000000000000+d.id AS common_id_attr,d.id AS id,UNIX_TIMESTAMP(d.created_at)  AS date_added,d.file_name as common1, d.description as common2, d.file_mime_type as common3, 72 as common4,(Select group_concat(trim(tags) ORDER BY trim(tags) SEPARATOR ' | ') from tags t where t.type_id = 72 AND t.feature_id = d.id group by t.feature_id) as common5,d.created_by as common6, df.name as common7,CONCAT(d.file_name,'.',d.file_mime_type) as common8,'' as common9,(Select da.file_data from document_attachment da where da.document_id = d.id) as text  FROM document d LEFT JOIN document_folder df ON df.id = d.document_folder_id  WHERE d.is_deleted = 0 and d.parent_id = 0 " dataSource="test" transformer="TemplateTransformer">

<field column="common_id_attr" name="common_id_attr" />
    <field column="id" name="id" />
        <entity dataSource="fieldReader" processor="TikaEntityProcessor" dataField="dcs.text" format="text" pk="dcs.id" >  

    <field column="text" name="text" />
   </entity>
 </entity>

schema.xml中

   <schema>
    <fields> 
     <field name="common_id_attr" type="string" indexed="true" stored="true" multiValued="false"/>
     <field name="id" type="string" indexed="true" stored="true"/>
     <field name="text" type="text" indexed="true" stored="true" multiValued="true"/>
   </fields> 
  <uniqueKey>common_id_attr</uniqueKey>
  <solrQueryParser defaultOperator="OR"/>
  <defaultSearchField>text</defaultSearchField>
 </schema>

虽然它获取的行数是将tika行计为单独的文档数量的两倍(我不明白为什么?)。它不会对二进制内容编制索引。

我长期陷入这个问题。有人可以帮忙吗

1 个答案:

答案 0 :(得分:1)

我能够使用Apache Solr版本3.6.2索引文档。我已经描述了这里的步骤:

http://tuxdna.wordpress.com/2013/02/04/indexing-the-documents-stored-in-a-database-using-apache-solr-and-apache-tika/

我认为它也应该在3.6.1中可行。我只是急于搜索版本3.6.1的tarball,当官方网站只有3.6.2可用时。

我希望有所帮助。