lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Harwood (JIRA)" <>
Subject [jira] Commented: (LUCENE-627) highlighter problems with overlapping tokens
Date Thu, 13 Jul 2006 20:22:30 GMT
    [ ] 

Mark Harwood commented on LUCENE-627:

The problem appears to be because the "pod" token advances the start position to 1 while the
next token "ipod" takes a step back (to 0)

I've found if you just arrange the tokens to be emitted in start pos order all is fine - see

	  public void testOverlapAnalyzer2() throws Exception

	    String s = "iPod foo";
	    // the token stream for the string above:
	    TokenStream ts = new TokenStream() {
	      Iterator iter;
	        List lst = new ArrayList();
	        Token t;
                             //moved this token to start
	        t = new Token("ipod",0,4);
	        t = new Token("i",0,1);
	        t = new Token("pod",1,4);
	        t = new Token("foo",5,8);
	        iter = lst.iterator();
	      public Token next() throws IOException {
	        return iter.hasNext() ? (Token) : null;

	    String srchkey = "foo";

	    QueryParser parser=new QueryParser("text",new WhitespaceAnalyzer());
	    Query query = parser.parse(srchkey);

	    Highlighter highlighter = new Highlighter(new QueryScorer(query));

//	 Get 3 best fragments and seperate with a "..."
	    String result = highlighter.getBestFragments(ts, s, 3, "...");
                         //had to upper case the P in the test here
	    String expectedResult="iPod <B>foo</B>";

> highlighter problems with overlapping tokens
> --------------------------------------------
>          Key: LUCENE-627
>          URL:
>      Project: Lucene - Java
>         Type: Bug

>   Components: Other
>     Versions: 2.0.1
>     Reporter: Yonik Seeley

> The lucene highlighter has problems when tokens that overlap are generated.
> For example, if analysis of iPod generates the tokens "i", "pod", "ipod" (with pod and
ipod in the same position),
> then the highlighter will output this as iipod, regardless of if any of those tokens
are highlighted.
> Discovered via

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

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

View raw message