Class FastVectorHighlighter


  • public class FastVectorHighlighter
    extends Object
    Another highlighter implementation.
    • Field Detail

      • DEFAULT_PHRASE_HIGHLIGHT

        public static final boolean DEFAULT_PHRASE_HIGHLIGHT
        See Also:
        Constant Field Values
    • Constructor Detail

      • FastVectorHighlighter

        public FastVectorHighlighter()
        the default constructor.
      • FastVectorHighlighter

        public FastVectorHighlighter​(boolean phraseHighlight,
                                     boolean fieldMatch)
        Parameters:
        phraseHighlight - true or false for phrase highlighting
        fieldMatch - true of false for field matching
      • FastVectorHighlighter

        public FastVectorHighlighter​(boolean phraseHighlight,
                                     boolean fieldMatch,
                                     FragListBuilder fragListBuilder,
                                     FragmentsBuilder fragmentsBuilder)
        a constructor. A FragListBuilder and a FragmentsBuilder can be specified (plugins).
        Parameters:
        phraseHighlight - true of false for phrase highlighting
        fieldMatch - true of false for field matching
        fragListBuilder - an instance of FragListBuilder
        fragmentsBuilder - an instance of FragmentsBuilder
    • Method Detail

      • getFieldQuery

        public FieldQuery getFieldQuery​(org.apache.lucene.search.Query query)
        create a FieldQuery object.
        Parameters:
        query - a query
        Returns:
        the created FieldQuery object
      • getFieldQuery

        public FieldQuery getFieldQuery​(org.apache.lucene.search.Query query,
                                        org.apache.lucene.index.IndexReader reader)
                                 throws IOException
        create a FieldQuery object.
        Parameters:
        query - a query
        Returns:
        the created FieldQuery object
        Throws:
        IOException
      • getBestFragment

        public final String getBestFragment​(FieldQuery fieldQuery,
                                            org.apache.lucene.index.IndexReader reader,
                                            int docId,
                                            String fieldName,
                                            int fragCharSize)
                                     throws IOException
        return the best fragment.
        Parameters:
        fieldQuery - FieldQuery object
        reader - IndexReader of the index
        docId - document id to be highlighted
        fieldName - field of the document to be highlighted
        fragCharSize - the length (number of chars) of a fragment
        Returns:
        the best fragment (snippet) string
        Throws:
        IOException
      • getBestFragments

        public final String[] getBestFragments​(FieldQuery fieldQuery,
                                               org.apache.lucene.index.IndexReader reader,
                                               int docId,
                                               String fieldName,
                                               int fragCharSize,
                                               int maxNumFragments)
                                        throws IOException
        return the best fragments.
        Parameters:
        fieldQuery - FieldQuery object
        reader - IndexReader of the index
        docId - document id to be highlighted
        fieldName - field of the document to be highlighted
        fragCharSize - the length (number of chars) of a fragment
        maxNumFragments - maximum number of fragments
        Returns:
        created fragments or null when no fragments created. size of the array can be less than maxNumFragments
        Throws:
        IOException
      • getBestFragment

        public final String getBestFragment​(FieldQuery fieldQuery,
                                            org.apache.lucene.index.IndexReader reader,
                                            int docId,
                                            String fieldName,
                                            int fragCharSize,
                                            FragListBuilder fragListBuilder,
                                            FragmentsBuilder fragmentsBuilder,
                                            String[] preTags,
                                            String[] postTags,
                                            Encoder encoder)
                                     throws IOException
        return the best fragment.
        Parameters:
        fieldQuery - FieldQuery object
        reader - IndexReader of the index
        docId - document id to be highlighted
        fieldName - field of the document to be highlighted
        fragCharSize - the length (number of chars) of a fragment
        fragListBuilder - FragListBuilder object
        fragmentsBuilder - FragmentsBuilder object
        preTags - pre-tags to be used to highlight terms
        postTags - post-tags to be used to highlight terms
        encoder - an encoder that generates encoded text
        Returns:
        the best fragment (snippet) string
        Throws:
        IOException
      • getBestFragments

        public final String[] getBestFragments​(FieldQuery fieldQuery,
                                               org.apache.lucene.index.IndexReader reader,
                                               int docId,
                                               String fieldName,
                                               int fragCharSize,
                                               int maxNumFragments,
                                               FragListBuilder fragListBuilder,
                                               FragmentsBuilder fragmentsBuilder,
                                               String[] preTags,
                                               String[] postTags,
                                               Encoder encoder)
                                        throws IOException
        return the best fragments.
        Parameters:
        fieldQuery - FieldQuery object
        reader - IndexReader of the index
        docId - document id to be highlighted
        fieldName - field of the document to be highlighted
        fragCharSize - the length (number of chars) of a fragment
        maxNumFragments - maximum number of fragments
        fragListBuilder - FragListBuilder object
        fragmentsBuilder - FragmentsBuilder object
        preTags - pre-tags to be used to highlight terms
        postTags - post-tags to be used to highlight terms
        encoder - an encoder that generates encoded text
        Returns:
        created fragments or null when no fragments created. size of the array can be less than maxNumFragments
        Throws:
        IOException
      • isPhraseHighlight

        public boolean isPhraseHighlight()
        return whether phraseHighlight or not.
        Returns:
        whether phraseHighlight or not
      • isFieldMatch

        public boolean isFieldMatch()
        return whether fieldMatch or not.
        Returns:
        whether fieldMatch or not
      • getPhraseLimit

        public int getPhraseLimit()
        Returns:
        the maximum number of phrases to analyze when searching for the highest-scoring phrase.
      • setPhraseLimit

        public void setPhraseLimit​(int phraseLimit)
        set the maximum number of phrases to analyze when searching for the highest-scoring phrase. The default is unlimited (Integer.MAX_VALUE).