Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6200

Highlighter sometime went wrong

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.10.2
    • Fix Version/s: None
    • Component/s: modules/highlighter
    • Labels:
    • Lucene Fields:
      New

      Description

      I have write a test case for this. I expect "<B>游戏</B>是<B>游戏</B>", but get "<B>游戏是游戏</B>"

      	public static void main(String[] args) throws IOException,
      			InvalidTokenOffsetsException {
      		String text = "游戏是游戏";
      		String query = "游戏";
      
      		CJKAnalyzer analyzer = new CJKAnalyzer();
      		Scorer fragmentScorer = new QueryScorer(new TermQuery(new Term("field",
      				query)));
      		Highlighter highlighter = new Highlighter(fragmentScorer);
      		String fragment = highlighter.getBestFragment(
      				analyzer.tokenStream("field", text), text);
      		analyzer.close();
      		System.out.println(fragment); // println: <B>游戏是游戏</B>
      	}
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                thihy thihy
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: