我希望使用SolR DataImport Handler来索引存储在数据库中的候选人以及链接到这些候选人的文件的内容。
我有一个数据库表包含候选人列表,另一个表包含链接到候选人的文件路径列表。
我需要的是:
这就是我被困在这里的地方!我尝试了各种选项,但系统只是索引第一个文件的内容。我试过使用javascript全局变量,尽管这种工作似乎不是最好的解决方案.
下面查找我的dih.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<script><![CDATA[
var globalContent = '';
function processFile(row) {
var text = row.get('text');
if (text == null) text = '';
else globalContent += ' ' + text;
row.remove('text');
row.remove('content');
row.put('content', globalContent);
return row;
}
]]></script>
<dataSource type="JdbcDataSource" name="dbs" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/dbname" user="login" password="password" />
<dataSource type="BinFileDataSource" name="fds" />
<document name="ListOfCandidates">
<entity name="candidats" datasource="dbs" query="select * from candidates">
<field column="id_candidat" name="id_candidat" />
<field column="name" name="lastname" />
<field column="first_name" name="firstname" />
<entity name="ListOfFiles"
query="SELECT distinct cd.id_document, cd.filepath
FROM candidat_document cd
WHERE cd.id_candidat = '${candidats.id_candidat}'">
<entity name="file"
processor="TikaEntityProcessor"
url="/some/folder/${ListOfFiles.filepath}"
dataSource="fds"
format="text"
onError="skip"
transformer="script:processFile">
<field column="text" name="text" />
</entity>
</entity>
</entity>
</document>任何帮助都将不胜感激!
发布于 2013-07-14 14:43:33
行对象包含通过候选人的单个条目积累的所有信息。您是否尝试过在积累文本的行中填充一个特殊字段。
所以,这正是您要做的,但是要将其存储在行中而不是全局变量中。
https://stackoverflow.com/questions/17616529
复制相似问题