Class HitHighlighterImpl

  • All Implemented Interfaces:
    HitHighlighter

    @NotThreadSafe
    public class HitHighlighterImpl
    extends Object
    implements HitHighlighter
    Finds search hits in content based on a given Lucene query. Highlights those hits with a formatter.
    • Constructor Summary

      Constructors 
      Constructor Description
      HitHighlighterImpl​(org.apache.lucene.search.Query query, org.apache.lucene.analysis.Analyzer analyzer)
      Create a new highlighter that uses the default formatter, and HTML encoding.
      HitHighlighterImpl​(org.apache.lucene.search.Query query, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.highlight.Formatter formatter)
      Create a new highlighter with specified formatter with HTML encoding.
      HitHighlighterImpl​(org.apache.lucene.search.Query query, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.highlight.Formatter formatter, org.apache.lucene.search.highlight.Encoder encoder)
      Create a new highlighter
    • Constructor Detail

      • HitHighlighterImpl

        public HitHighlighterImpl​(org.apache.lucene.search.Query query,
                                  org.apache.lucene.analysis.Analyzer analyzer)
        Create a new highlighter that uses the default formatter, and HTML encoding.

        The output format for hit highlights is: Lorem ipsum <span class="search-highlight>dolor</span> sit amet

      • HitHighlighterImpl

        public HitHighlighterImpl​(org.apache.lucene.search.Query query,
                                  org.apache.lucene.analysis.Analyzer analyzer,
                                  org.apache.lucene.search.highlight.Formatter formatter)
        Create a new highlighter with specified formatter with HTML encoding.
      • HitHighlighterImpl

        public HitHighlighterImpl​(org.apache.lucene.search.Query query,
                                  org.apache.lucene.analysis.Analyzer analyzer,
                                  org.apache.lucene.search.highlight.Formatter formatter,
                                  org.apache.lucene.search.highlight.Encoder encoder)
        Create a new highlighter
    • Method Detail

      • getSummary

        public String getSummary​(String text)
        Get a summary, suitable for displaying excerpts of search results.
        Specified by:
        getSummary in interface HitHighlighter
        Returns:
        a summary, or an empty string if the summary is null or empty.