[ 
http://issues.apache.org/jira/browse/LUCENE-645?page=comments#action_12425643 ] 
            
Erik Hatcher commented on LUCENE-645:
-------------------------------------

There is some commented out code in Highlighter.java:

                        if (lastEndOffset < text.length())
                                
newText.append(encoder.encodeText(text.substring(lastEndOffset)));

uncommenting that code fixes this issue.

I've added this test to HighlighterTest.java:

  public void testOffByOne() throws IOException {
    TermQuery query= new TermQuery( new Term( "data", "help" ));
    Highlighter hg = new Highlighter(new SimpleHTMLFormatter(), new 
QueryScorer( query ));
    hg.setTextFragmenter( new NullFragmenter() );

    String match = null;
    match = hg.getBestFragment( new StandardAnalyzer(), "data", "help me 
[54-65]");
    assertEquals("<B>help</B> me [54-65]", match);
  }

all tests pass even with that code uncommented.   I'll commit if there are no 
objections.

> Highligter fails to include non-token at end of string to be highlighted
> ------------------------------------------------------------------------
>
>                 Key: LUCENE-645
>                 URL: http://issues.apache.org/jira/browse/LUCENE-645
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 1.9
>         Environment: Red Hat Linux, Java 1.5
> Windows Java 1.5
>            Reporter: Andrew Palmer
>            Priority: Minor
>
> The following code extract show the problem
>               TermQuery query= new TermQuery( new Term( "data", "help" )); 
>               Highlighter hg = new Highlighter(new SimpleHTMLFormatter(), new 
> QueryScorer( query ));
>               hg.setTextFragmenter( new NullFragmenter() );
>               
>               String match = null;
>               try {
>                       match = hg.getBestFragment( new StandardAnalyzer(), 
> "data", "help me [54-65]" );
>               } catch (IOException e) {
>                       e.printStackTrace();
>               }
>               System.out.println( match );
> The sytsem outputs 
> <B>help</B> me [54-65
> would expect 
> <B>help</B> me [54-65]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to