2017-09-24 7 views
0

DIHを使用して、MySQLとテキストフォルダからデータをインデックスできますか?私は2つの異なるデータソースからのデータインポートハンドラを介して、単一のコアにインデックスデータにしたい単一のdata_configファイル内の2つの異なるデータソースのデータを単一のDIHでインデックスできますか?

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

:私は、次のdata-configファイルを使用しています。

  1. 最初のデータソースは、テキストファイルのメタデータを含むMysqlです。

  2. 第2のデータソースには何千ものテキストファイルが含まれています。

これらの異なるデータソースをDIHを使用して1つのコアにインデックスしたいと思います。 コードは機能していますが、TikaEntityProcessorは機能していませんか? コードの間違いはどこですか?

答えて

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

おかげ@MatsLindhを、私データソースは異なります。 1つはフォルダ内のテキストファイルで、2つ目はmysqlデータベースです。私は、テキストファイルフィールドのいずれかに基づいてmysqlデータベースからデータを取得できますか?情報のコードを参照してください –

+0

<エンティティ名= "ファイル" のdataSource = "ヌル" rootEntity = "false" を プロセッサ= "FileListEntityProcessor" トランス= "RegexTransformer" BASEDIR = "/ホーム/シャー/ ResearchTestData/TestScore3 recursive = "true">

+0

<エンティティ name = "documentImport" プロセッサ= "TikaEntityProcessor" URL = "$ {files.fileAbsolutePath}" 形式= "テキスト"> <フィールド列= "テキスト" 名前= "テキスト" /> <データソースドライバ= "com.mysql .jdbc.Driver "url =" jdbc:mysql:// localhost:3306/ACL "user =" root " パスワード=" "/> –

関連する問題