2
私はDIHとTikaを使用して、異なる言語のドキュメントをインデックスしています。ファイルパスに基づく動的フィールドの追加
言語ごとにフォルダがあります(例:/de/file001.pdf)。パスから言語を抽出し、言語固有のソルフィールド(例:text_de)を動的に追加したいとします。
は、ここに私の未遂ソリューションです:
<dataConfig>
<script><![CDATA[
function addField(row) {
row.put('text_' + row.get('lang'), row.get('text'));
return row;
}
]]></script>
<dataSource type="BinFileDataSource" />
<document>
<entity name="files" dataSource="null" rootEntity="false"
processor="FileListEntityProcessor"
baseDir="/tmp/documents" fileName=".*\.(doc)|(pdf)|(docx)"
onError="skip"
recursive="true"
transformer="RegexTransformer" query="select * from files">
<field column="fileAbsolutePath" name="id" />
<field column="lang" regex=".*/(\w*)/.*" sourceColName="fileAbsolutePath"/>
<entity name="documentImport"
processor="TikaEntityProcessor"
url="${files.fileAbsolutePath}"
format="text"
transformer="script:addField">
<field column="date" name="date" meta="true"/>
<field column="title" name="title" meta="true"/>
</entity>
</entity>
</document>
行が「テキスト」フィールドではなく、「LANG」フィールドが含まれているので、これは動作しません。