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 Jamie Johnson <je...@gmail.com> on 2011/06/18 15:59:55 UTC

merging highlights

I have a setup where I have a title and a phonetic_title, I'm using the
edismax query parser and doing a weighted search across the two fields,
there are cases where phonetic_title matches part of the string and title
matches another, i.e. if my query was foo AND subject:bar and the fields had

title: phoo bar
phonetic_title: foo br (obviously making this up)

I'd get back in the highlights the following

phonetic_title: <em>foo</em> bar
title: foo <em>bar</em>

Is there any utility to merge these results so that the title looks like

title: <em>foo</em> <em>bar</em>

Re: merging highlights

Posted by Jamie Johnson <je...@gmail.com>.
Perhaps a better question is this.  Looking at DefaultSolrHighlighter I'd
like to make modifications so that when doing highlighting on a specific
field it automatically checks to see if there is another _phonetic field
available to also pull tokens from.  It looks like I could do this extending
the DefaultSolrHighlighter by overridding making my own
doHighlightingByHighlighter which does the following:
Around Line 431:
TokenStream tvStream =
TokenSources.getTokenStream(searcher.getIndexReader(), docId, fieldName);
                TokenStream tvStream_phonetic =
TokenSources.getTokenStream(searcher.getIndexReader(), docId, fieldName +
"_phonetic");
                tvStream_phonetic.copyTo(tvStream);

and further down doing
Around Line 446
// fall back to analyzer
                tstream = createAnalyzerTStream(schema, fieldName,
docTexts[j]);
                TokenStream tstream_phonetic = createAnalyzerTStream(schema,
fieldName + "_phonetic", docTexts[j]);
                tstream_phonetic.copyTo(tstream);

now I'd obviously need a way to see if fieldName + "_phonetic" existed
before making the calls to get the token streams for them (anyone have an
idea how to do that?).

Only problem is this would only work for the default highlighter, using fast
vector highlighter I don't see a clear way to do this.

Am I the only person looking to do something along these lines?

On Sat, Jun 18, 2011 at 9:59 AM, Jamie Johnson <je...@gmail.com> wrote:

> I have a setup where I have a title and a phonetic_title, I'm using the
> edismax query parser and doing a weighted search across the two fields,
> there are cases where phonetic_title matches part of the string and title
> matches another, i.e. if my query was foo AND subject:bar and the fields had
>
> title: phoo bar
> phonetic_title: foo br (obviously making this up)
>
> I'd get back in the highlights the following
>
> phonetic_title: <em>foo</em> bar
> title: foo <em>bar</em>
>
> Is there any utility to merge these results so that the title looks like
>
> title: <em>foo</em> <em>bar</em>
>
>
>