用于Html的Solr数据导入处理程序

用于Html的Solr数据导入处理程序,solr,dataimporthandler,Solr,Dataimporthandler,TLDR 如何配置solr数据导入处理程序,使其导入类似于solr的“post”实用程序的html 上下文 我们正在做一个小项目,其中代码将从wiki/confluence导出一组页面到“纯html”(为了在DR数据中心中可用,纯html页面将不依赖于数据库等) 我们想在solr中索引html页面 我们使用solr附带的“post实用程序”使其“正常工作” 这很好……但是,我们希望利用数据导入处理程序(DIH),即用对DIH端点(“/dataimport”)的单个http调用替换shell命令

TLDR

如何配置solr数据导入处理程序,使其导入类似于solr的“post”实用程序的html

上下文

我们正在做一个小项目,其中代码将从wiki/confluence导出一组页面到“纯html”(为了在DR数据中心中可用,纯html页面将不依赖于数据库等)

我们想在solr中索引html页面

我们使用solr附带的“post实用程序”使其“正常工作”

这很好……但是,我们希望利用数据导入处理程序(DIH),即用对DIH端点(“/dataimport”)的单个http调用替换shell命令

问题

如何配置tika“数据配置xml”文件以获得与solr“post命令”类似的功能

  • 当我使用data-config.xml进行配置时,solr文档只会以“id”和“version”字段结束(即,id是未加密的文件名)
更正:我最初写的是“id”和“标题”字段

  • 但是,当我使用“bin/post”时,文档具有以下字段,即包括标记化标题:
一些要点

  • 我尝试过RTM'ing,但不了解“字段”如何映射到“html正文”
  • 解析一个满是HTML的目录是一个大约1999年的问题,所以我不期望有很多人
  • 我已经看过SimplePostTool.java(bin/post的实现)…没有真正的答案
数据配置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>


我最后写了几行代码来解析html文件(jsoup),并放弃了solr数据导入处理程序(DIH)

使用Spring、solr和jsoup html解析器非常简单


一个警告:我的java“bean”对象存储solr字段需要一个“文本”字段,开箱即用的默认搜索字段才能工作(即,使用solr docker实例)

您在示例中是否确实获得了标题?您写了这样的内容,但没有包括它-文件名是
id
字段(应该是原始字符串,而不是标记化文本字符串)。您还可以在配置中使用LogTransformer来获取数据导入处理程序的扩展日志。我的错误。我的意思是“id和版本”。。我更新了原始问题。澄清我的java bean需要一个名为下划线文本下划线的字段…(“文本”)“字符串(用下划线包装)以使默认搜索字段正常工作。
        "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},
<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>