TLDR
我如何配置solr数据导入处理程序,以便它将类似于solr的“ post”实用程序导入html?
上下文
我们正在做一个小项目,其中的代码会将一组页面从Wiki / confluence导出到“纯HTML”(为了在DR数据中心中提供可用性,纯HTML页面将不依赖于数据库等)>
我们要在solr中为html页面建立索引。
我们使用solr-shiped的“ post实用程序”使它“运行”
post -c OPERATIONS -recursive -0 -host solr $(find . -name '*.html')
这很好..... ,我们想利用数据导入处理程序(DIH),即用对DIH端点的单个http调用('/数据导入')
问题
我如何配置tika“数据配置xml”文件以获得与solr“ post命令”类似的功能?
更正:我最初写的是““ id”和“ title”字段...“'
"id":"database_operations_2019.html",
"_version_":1650836000296927232},
"id":"/usr/local/html/OPERATIONS_2019_1119_1500/./database_operations_2019.html",
"stream_size":[54115],
"x_parsed_by":["org.apache.tika.parser.DefaultParser",
"org.apache.tika.parser.html.HtmlParser"],
"stream_content_type":["text/html"],
"dc_title":["Database Operations 2019 Guidebook"],
"content_encoding":["UTF-8"],
"content_type_hint":["text/html; charset=UTF-8"],
"resourcename":["/usr/local/html/OPERATIONS_2019_1119_1500/./database_operations_2019.html"],
"title":["Database Operations 2019 Guidebook"],
"content_type":["text/html; charset=UTF-8"],
"_version_":1650834641083432960},
一些积分
数据配置XML文件
<dataConfig>
<dataSource type="BinFileDataSource"/>
<document>
<entity name="file" processor="FileListEntityProcessor"
dataSource="null"
htmlMapper="true"
format="html"
baseDir="/usr/local/var/www/confluence/OPERATIONS"
fileName=".*html"
rootEntity="false">
<field column="file" name="id"/>
<entity name="html" processor="TikaEntityProcessor"
url="${file.fileAbsolutePath}" format="text">
<field column="title" name="title" meta="true"/>
<field column="dc:format" name="format" meta="true"/>
<field column="text" name="text"/>
</entity>
</entity>
</document>
</dataConfig>
答案 0 :(得分:0)
我最终写了几行代码来解析html文件(jsoup)并放弃了solr数据导入处理程序(DIH)。
使用Spring和solr和jsoup html解析器非常简单。
一个警告:我的用于存储solr字段的java“ bean”对象需要一个“ text ”字段才能使用开箱即用的默认搜索字段(例如,使用Solr docker实例)