How to highlight all matched word in single snippe

2019-08-29 06:47发布

问题:

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