How to highlight all matched word in single snippet in solr

拥有回忆 提交于 2019-12-12 02:03:09

问题


All:

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

And the return highlight part is like:

"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"
      ]
    }
}

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.

How can I show both matched in single snippet and just ignore text between them as ..... like in Google

Also some small questions are:

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

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

Thanks


回答1:


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).



来源:https://stackoverflow.com/questions/27849659/how-to-highlight-all-matched-word-in-single-snippet-in-solr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!