Search code examples
lucenehighlighting

Return full field text with Lucene Highlighter


How would I the full text instead of just a snippet when highlighting a field using the Highlighter class? I couldn't find the answer anywhere.


Solution

  • The highlighter's fragmenter governs the generation of snippets (fragments) that are returned. You can use the NullFragmenter to have it use the entire content of the field:

    highlighter.setTextFragmenter(new NullFragmenter());