You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Teague James <te...@insystechinc.com> on 2014/07/17 20:19:48 UTC

Contiguous Phrase Highlighting Example

Hi everyone!

Does anyone have any good examples of generating a contiguous highlight for
a phrase? Here's what I have done:

curl http://localhost/solr/collection1/update?commit=true -H "Content-Type:
text/xml" --data-binary '<add><doc><field name="id">100</field><field
name="content">blah blah blah knowledge of science blah blah
blah</field></doc></add>'

Then, using a browser:

http://localhost/solr/collection1/select?q="knowledge+of+science"&fq=id:100

What I get back in highlighting is:
<str>blah blah blah <b>knowledge</b> <b>of</b> <b>science</b> blah blah
blah</str>

What I want to get back is:
<str>blah blah blah <b>knowledge of science</b> blah blah blah</str>

I have the following highlighting configurations in my requestHandler in
addition to hl, hl.fl, etc.:
<str name="hl.mergeContiguous">false</str>
<str name="usePhraseHighlighter">true</str>
<str name-"highlightMultiTerm">true</str>
None of the last two seemed to have any impact on the output. I've tried
every permutation of those three, but the output is the same. Any
suggestions or examples of getting highlights to come back this way? I'd
appreciate any advice on this! Thanks!

-Teague




Re: Contiguous Phrase Highlighting Example

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
Hi Teague,

If you want phrase-unit tagging for highlighter, you need to use
FastVectorHighlighter instead of the ordinary Highlighter.

To turn on FVH, set hl.useFastVectorHighlighter=on when querying.
In addition, when indexing, you need to set termVectors=on, termPositions=on
and termOffsets=on on content field in your schema.xml.

http://wiki.apache.org/solr/HighlightingParameters#hl.useFastVectorHighlighter

Koji
-- 
http://soleami.com/blog/comparing-document-classification-functions-of-lucene-and-mahout.html

(2014/07/18 3:19), Teague James wrote:
> Hi everyone!
>
> Does anyone have any good examples of generating a contiguous highlight for
> a phrase? Here's what I have done:
>
> curl http://localhost/solr/collection1/update?commit=true -H "Content-Type:
> text/xml" --data-binary '<add><doc><field name="id">100</field><field
> name="content">blah blah blah knowledge of science blah blah
> blah</field></doc></add>'
>
> Then, using a browser:
>
> http://localhost/solr/collection1/select?q="knowledge+of+science"&fq=id:100
>
> What I get back in highlighting is:
> <str>blah blah blah <b>knowledge</b> <b>of</b> <b>science</b> blah blah
> blah</str>
>
> What I want to get back is:
> <str>blah blah blah <b>knowledge of science</b> blah blah blah</str>
>
> I have the following highlighting configurations in my requestHandler in
> addition to hl, hl.fl, etc.:
> <str name="hl.mergeContiguous">false</str>
> <str name="usePhraseHighlighter">true</str>
> <str name-"highlightMultiTerm">true</str>
> None of the last two seemed to have any impact on the output. I've tried
> every permutation of those three, but the output is the same. Any
> suggestions or examples of getting highlights to come back this way? I'd
> appreciate any advice on this! Thanks!
>
> -Teague
>
>
>
>