lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sebastian L. (Commented) (JIRA)" <>
Subject [jira] [Commented] (LUCENE-3440) FastVectorHighlighter: IDF-weighted terms for ordered fragments
Date Tue, 04 Oct 2011 13:09:34 GMT


sebastian L. commented on LUCENE-3440:

Another patch for 4.0. This one makes FieldFragList "plugable".  

This patch contains:
- Introduction of interface FieldFragList
- Introduction of abstract class BaseFieldFragList which contains SubInfo and FieldFragInfo
(I renamed WeightedFragInfo)
- Introduction of class SimpleFieldFragList (default)
- Introduction of class WeightedFieldFragList
- Introduction of abstract class BaseFragListBuilder
- Introduction of class SimpleFragListBuilder (default)
- Introduction of class WeightedFragListBuilder 

The weighting-formula now depends on the implementation of 
FieldFragList.add(int startOffset, int endOffset, List<FieldPhraseInfo> phraseInfoList):

  /* (non-Javadoc)
   * @see
  public void add( int startOffset, int endOffset, List<FieldPhraseInfo> phraseInfoList
) {
    float score = 0;
    List<SubInfo> subInfos = new ArrayList<SubInfo>();
    for( FieldPhraseInfo phraseInfo : phraseInfoList ){
      subInfos.add( new SubInfo( phraseInfo.getText(), phraseInfo.getTermsOffset(), phraseInfo.getSeqnum()
) );
      score += phraseInfo.getBoost();
    getFragInfos().add( new FieldFragInfo( startOffset, endOffset, subInfos, score ) );

The choosen FieldFragList depends on FragListBuilder.createFieldFragList( FieldPhraseList
fieldPhraseList, int fragCharSize ):

  /* (non-Javadoc)
   * @see
fieldPhraseList, int fragCharSize)
  public FieldFragList createFieldFragList( FieldPhraseList fieldPhraseList, int fragCharSize
    return createFieldFragList( fieldPhraseList, new SimpleFieldFragList( fragCharSize ),
fragCharSize );

Of course, Solr-config could look like this:

 <fragListBuilder name="simple" class="org.apache.solr.highlight.SimpleFragListBuilder"/>
 <fragListBuilder name="weighted" class="org.apache.solr.highlight.WeightedFragListBuilder"
 <fragmentsBuilder name="ordered" class="org.apache.solr.highlight.ScoreOrderFragmentsBuilder"

I think, this is the best possible approach, because it maintains backwards-compatibility,
but do also some refactoring which would/could/should/can make it easier to plug-in different
approaches in future. 

But, after a few weeks of banging my head against the wall I have to admit: I have no idea.

> FastVectorHighlighter: IDF-weighted terms for ordered fragments 
> ----------------------------------------------------------------
>                 Key: LUCENE-3440
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: modules/highlighter
>    Affects Versions: 3.5, 4.0
>            Reporter: sebastian L.
>            Priority: Minor
>              Labels: FastVectorHighlighter
>             Fix For: 3.5, 4.0
>         Attachments:, LUCENE-3.5-SNAPSHOT-3440-6.patch,
LUCENE-4.0-SNAPSHOT-3440-6.patch, WeightOrderFragmentsBuilder_table01.html, WeightOrderFragmentsBuilder_table02.html
> The FastVectorHighlighter uses for every term found in a fragment an equal weight, which
causes a higher ranking for fragments with a high number of words or, in the worst case, a
high number of very common words than fragments that contains *all* of the terms used in the
original query. 
> This patch provides ordered fragments with IDF-weighted terms: 
> total weight = total weight + IDF for unique term per fragment * boost of query; 
> The ranking-formula should be the same, or at least similar, to that one used in
> The patch is simple, but it works for us. 
> Some ideas:
> - A better approach would be moving the whole fragments-scoring into a separate class.
> - Switch scoring via parameter 
> - Exact phrases should be given a even better score, regardless if a phrase-query was
executed or not
> - edismax/dismax-parameters pf, ps and pf^boost should be observed and corresponding
fragments should be ranked higher 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message