我可以使用solr 4.3.0中的数据导入处理程序成功地索引pdf、doc、ppt等文件。
我的data-config.xml看起来像这样-
<dataConfig>
<dataSource name="bin" type="BinFileDataSource" />
<document>
<entity name="f" dataSource="null" rootEntity="false"
processor="FileListEntityProcessor"
baseDir="C:\Users\aroraarc\Desktop\Impdo"
fileName=".*\.(DOC)|(PDF)|(pdf)|(doc)|(docx)|(ppt)|(pptx)|(xls)|(xlsx)|(txt)" onError="skip"
recursive="true">
<field column="fileAbsolutePath" name="path" />
<field column="fileSize" name="size" />
<field column="fileLastModified" name="lastmodified" />
<field column="file" name="fileName"/>
<entity name="tika-test" dataSource="bin" processor="TikaEntityProcessor"
url="${f.fileAbsolutePath}" format="text" onError="skip">
<field column="Author" name="author" meta="true"/>
<field column="title" name="title" meta="true"/>
<field column="text" name="content"/>
</entity>
</entity>
</document>
</dataConfig>但是,在fileName字段中,我想插入不带扩展名的纯文件名。例如,我只想在fileName字段中插入'HelloWorld‘,而不是’fileName‘。我该如何实现这一点?
提前感谢!
发布于 2013-07-03 13:07:13
选中ScriptTransformer可在索引之前替换或更改该值。
示例:
数据配置-添加自定义字段-
<script><![CDATA[
function changeFileName(row){
var fileName= row.get('fileName');
// Replace or remove the extension .. e.g. from last index of .
file_name_new = file_name.replace ......
row.put(fileName, row.get('file_name_new'));
return row;
}
]]></script>实体映射-
<entity name="f" transformer="script:changeFileName" ....>
......
</entity>https://stackoverflow.com/questions/17439874
复制相似问题