lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: svn commit: r829128 - /lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
Date Fri, 23 Oct 2009 17:09:17 GMT
This probably warrants a CHANGES entry?

-Yonik
http://www.lucidimagination.com



On Fri, Oct 23, 2009 at 1:07 PM,  <markrmiller@apache.org> wrote:
> Author: markrmiller
> Date: Fri Oct 23 17:07:22 2009
> New Revision: 829128
>
> URL: http://svn.apache.org/viewvc?rev=829128&view=rev
> Log:
> LUCENE-2003: Highlighter doesn't respect position increments other than 1 with PhraseQuerys
>
> Modified:
>    lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
>
> Modified: lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
> URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java?rev=829128&r1=829127&r2=829128&view=diff
> ==============================================================================
> --- lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
(original)
> +++ lucene/java/branches/lucene_2_9/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
Fri Oct 23 17:07:22 2009
> @@ -109,13 +109,32 @@
>         }
>       }
>     } else if (query instanceof PhraseQuery) {
> -      Term[] phraseQueryTerms = ((PhraseQuery) query).getTerms();
> +      PhraseQuery phraseQuery = ((PhraseQuery) query);
> +      Term[] phraseQueryTerms = phraseQuery.getTerms();
>       SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.length];
>       for (int i = 0; i < phraseQueryTerms.length; i++) {
>         clauses[i] = new SpanTermQuery(phraseQueryTerms[i]);
>       }
> +      int slop = phraseQuery.getSlop();
> +      int[] positions = phraseQuery.getPositions();
> +      // add largest position increment to slop
> +      if (positions.length > 0) {
> +        int lastPos = positions[0];
> +        int largestInc = 0;
> +        int sz = positions.length;
> +        for (int i = 1; i < sz; i++) {
> +          int pos = positions[i];
> +          int inc = pos - lastPos;
> +          if (inc > largestInc) {
> +            largestInc = inc;
> +          }
> +          lastPos = pos;
> +        }
> +        if(largestInc > 1) {
> +          slop += largestInc;
> +        }
> +      }
>
> -      int slop = ((PhraseQuery) query).getSlop();
>       boolean inorder = false;
>
>       if (slop == 0) {
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message