如何在Solr的单个代码段中突出显示所有匹配的单词 [英] How to highlight all matched word in single snippet in solr

查看:70
本文介绍了如何在Solr的单个代码段中突出显示所有匹配的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部:

现在,我正在使用SOLR高光功能,但我想问的一件事是:

Right now, I am using SOLR highlight feature, but one thing I want to ask is:

假设我要搜索关键字基金和价值:

Suppose I want to search keyword fund and value:

fund AND value

返回高亮部分如下:

"highlighting": {
    "blk_0019": {
      "content": [
        "philosophy of the <em>fund</em> – <em>value</em> and turning point. \n \n MUSA was an orphaned"
      ]
    },
    "blk_0006": {
      "content": [
        "Global Equities <em>Fund</em> Ltd. \n \n CONFIDENTIAL enclosed"
      ]
    }
}

问题是我确定blk_0019和blk_0006都具有资金和价值(显然我使用的是资金AND报告),因为我设置hl.fragsize = 100,如果资金和价值在一个文档中的距离不够近,它们不能在同一代码段中同时显示.在blk_0019中,solr突出显示了资金和价值,但在blk_0006中,仅显示了资金.

The problem is I am sure blk_0019 and blk_0006 have both fund and value(obviously I use fund AND report), because the I set hl.fragsize=100, if the fund and value located not close enough in one document, they can not be shown both in same snippet. In blk_0019, solr highlights both fund and value, but in blk_0006, only fund shown.

如何在单个代码段中显示匹配的内容,而又像在Google中一样忽略它们之间的文本...

还有一些小问题:

[1]如何指定仅搜索大写单词,例如Hello HELLO 在Solr中?

[1] How to specify to search capitalized only word like Hello HELLO in Solr?

[2]如何搜索全大写AND(全大写"AND"将被视为逻辑运算符)

[2] How to search All-capital AND(All-capital "AND" will be consider as logical operator)

谢谢

推荐答案

这取决于您使用的荧光笔.对于标准荧光笔,您可以设置例如hl.snippets=5(默认为1).然后,您将获得5个片段/片段(最多),每个片段/片段的最大长度为hl.fragsize.

It depends on the highlighter you are using. For the Standard Highlighter you can set hl.snippets=5 for instance (default is 1). Then you'll get 5 snippets/fragments (at most), each with a maximum length of hl.fragsize.

它们作为多个值返回,因此您需要自己加入它们(例如,使用"...").

They're returned as multiple values, so you'll need to join them yourself (using "..." for instance).

这篇关于如何在Solr的单个代码段中突出显示所有匹配的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆