【问题标题】:Solr query in a pdf file, is not returning highlighting contentpdf文件中的Solr查询,不返回突出显示的内容
【发布时间】:2017-10-10 14:11:18
【问题描述】:

我今天在我的 debian 服务器中实现了 solr 6.5.1,但我无法获取 pdf 文本内容。搜索没问题,因为当我查询我的名字时,文档看起来没问题:“juan”。但是,每个 str 结果并没有出现它应该如何做。

这是示例查询:

http://localhost:8983/solr/ex/select?q=juan&fl=title&wt=xml&hl=true&hl.snippets=20&hl.fl=content&hl.usePhraseHighlighter=true

结果如下:

<response>
    <lst name="responseHeader">
        <int name="status">0</int>
        <int name="QTime">1</int>
        <lst name="params">
            <str name="hl.snippets">20</str>
            <str name="q">juan</str>
            <str name="hl">true</str>
            <str name="fl">title</str>
            <str name="hl.usePhraseHighlighter">true</str>
            <str name="hl.fl">content</str>
            <str name="wt">xml</str>
        </lst>
    </lst>
    <result name="response" numFound="1" start="0">
        <doc>
            <arr name="title">
                <str>CV_Juan_Jara_ultimo</str>
            </arr>
        </doc>
    </result>
    <lst name="highlighting">
        <lst name="/solr-6.5.1/mydocs/CV_Juan_Jara_ultimo.pdf"/>
    </lst>
</response>

此外,日志显示所有 pdf 文本,因此我假设它已正确编入索引(我使用以下命令为 pdf 编入索引:bin/post -c ex mydocs/CV_Juan_Jara_ultimo.pdf)。

我使用 curl 将“内容”字段添加到架构中:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field" : {
     "name":"text",
     "type":"text_general",
     "indexed":"true",
     "stored":"false",
     "multiValued":"true"
     }
}' localhost:8983/solr/ex/schema

你知道哪里出了问题吗?

我要做的就是在我的 pdf 中搜索一个主题,然后像这样突出显示所有结果:

http://www.codewrecks.com/blog/index.php/2013/05/27/hilight-matched-text-inside-documents-indexed-with-solr-plus-tika/

【问题讨论】:

    标签: pdf curl text solr highlighting


    【解决方案1】:

    这是一个非常常见且简单的错误:

    对于 'content' 字段,"stored":"false" 应该是 "stored":"true"。

    目前所有的荧光笔都需要存储字段才能使用 [1]。

    [1]https://cwiki.apache.org/confluence/display/solr/Highlighting

    【讨论】:

    • 感谢您的快速回复。我将存储更改为true,但仍然没有。但是我意识到,当我添加参数“hl.method=unified”时,响应突出显示包含 字段,但为空。
    【解决方案2】:

    已解决:最终对我有用的解决方案是用此 curl 命令替换架构中的 _text_ 字段:

    curl -X POST -H 'Content-type:application/json' --data-binary '{
     "replace-field" : {
     "name":"_text_",
     "type":"text_general",
     "indexed":"true",
     "stored":"true",
     "multiValued":"true"
     }
    }' http://localhost:8983/solr/ex/schema
    

    这是因为_text_字段默认带有"stored":"false"。

    注意:如果您在此架构字段替换之前这样做,请记住将所有文件再次索引到您的核心

    【讨论】:

      猜你喜欢
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-18
      • 1970-01-01
      • 2016-04-26
      • 2021-06-01
      • 1970-01-01
      相关资源
      最近更新 更多