lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Muir (JIRA)" <>
Subject [jira] [Commented] (LUCENE-4826) PostingsHighlighter doesn't keep the top N best scoring passages
Date Tue, 12 Mar 2013 20:09:13 GMT


Robert Muir commented on LUCENE-4826:


Here is a smaller test: in order to trick it to fail, you must have something like
Great Sentence. Crappy Sentence. Good Sentence.

otherwise they never make it into the PQ to demonstrate the bug...

  public void testPassageRanking() throws Exception {
    Directory dir = newDirectory();
    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random(),
MockTokenizer.SIMPLE, true));
    RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
    FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
    Field body = new Field("body", "", offsetsType);
    Document doc = new Document();
    body.setStringValue("This is a test.  Just highlighting from postings. This is also a
much sillier test.  Feel free to test test test test test test test.");
    IndexReader ir = iw.getReader();
    IndexSearcher searcher = newSearcher(ir);
    PostingsHighlighter highlighter = new PostingsHighlighter();
    Query query = new TermQuery(new Term("body", "test"));
    TopDocs topDocs =, null, 10, Sort.INDEXORDER);
    assertEquals(1, topDocs.totalHits);
    String snippets[] = highlighter.highlight("body", query, searcher, topDocs, 2);
    assertEquals(1, snippets.length);
    assertEquals("This is a <b>test</b>.  ... Feel free to <b>test</b>
<b>test</b> <b>test</b> <b>test</b> <b>test</b>
<b>test</b> <b>test</b>.", snippets[0]);
> PostingsHighlighter doesn't keep the top N best scoring passages
> ----------------------------------------------------------------
>                 Key: LUCENE-4826
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/highlighter
>            Reporter: Michael McCandless
>             Fix For: 5.0, 4.3
>         Attachments: LUCENE-4826.patch
> The comparator we pass to the PQ is just backwards ...

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

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

View raw message