我们可以通过单个DIH索引来自单个data_config文件中两个不同数据源的数据吗?

问题描述 投票:0回答:2

是否可以使用DIH索引来自MySQL和文本文件夹的数据?我使用以下data-config文件:

<dataConfig>
    <dataSource name="test1" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/ACL"  user="root"
                password="" />
    <dataSource type="BinFileDataSource" />
    <document>
        <entity name="files" dataSource="null" rootEntity="false"
                processor="FileListEntityProcessor" transformer="RegexTransformer"
                baseDir="/home/shah/ResearchTestData/TestScore3" fileName="\.(txt)|(pdf)|(docx)"
                onError="skip"
                recursive="true">
            <field column="fileSize" name="size" />
            <field column="fileLastModified" name="lastModified" />
            <field column="file" name="fileName" regex="(.txt)" replaceWith=""/>
            <entity name="documentImport"
                    processor="TikaEntityProcessor"
                    url="${files.fileAbsolutePath}"
                    format="text">
                <field column="text" name="Text" />         
            </entity>   
            <entity name="item" dataSource="test1" query="select PaperID,PID, Author  from ACL.Test where PaperID='${files.file}'">   
                <field column="PaperID" name="PaperID" />
                <field column="Author" name="Author" />
                <field column="PID" name="id" />               
            </entity>           
        </entity>
    </document>
</dataConfig>

我想通过来自两个不同数据源的数据导入处理程序将数据索引到单个核心。

  1. 第一个数据源是包含文本文件的元数据的Mysql。
  2. 第二个数据源包含数千个文本文件。

我想使用DIH在单个核心中索引这些不同的数据源。代码正常,但TikaEntityProcessor不工作?请问代码中的错误在哪里?

solr solrj
2个回答
0
投票

您可以configure multiple data sources in a single configuration file并指定实体描述的数据源:

<dataSource type="JdbcDataSource" name="ds-1" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://db1-host/dbname" user="db_username" password="db_password"/>
<dataSource type="JdbcDataSource" name="ds-2" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://db2-host/dbname" user="db_username" password="db_password"/>

然后引用实体中的数据源:

<entity name="one" dataSource="ds-1" ...>
   ..
</entity>
<entity name="two" dataSource="ds-2" ...>
   ..
</entity>

我的猜测是,即使对于嵌套实体也是如此。


0
投票

是的,您可以通过以特定的所需逻辑顺序定义实体,从单个核心中的多个异构数据源索引数据。有关信息和代码,请参阅:why the tikaEntityProcesor does not index the Text field in the following data-config file?

© www.soinside.com 2019 - 2024. All rights reserved.