Class RegexFragmenter

  • All Implemented Interfaces:
    AutoCloseable, SolrInfoBean, SolrFragmenter, SolrMetricProducer, NamedListInitializedPlugin

    public class RegexFragmenter
    extends HighlightingPluginBase
    implements SolrFragmenter
    Fragmenter that tries to produce snippets that "look" like a regular expression. solrconfig.xml parameters:
    • hl.regex.pattern: regular expression corresponding to "nice" fragments.
    • hl.regex.slop: how far the fragmenter can stray from the ideal fragment size. A slop of 0.2 means that the fragmenter can go over or under by 20%.
    • hl.regex.maxAnalyzedChars: how many characters to apply the regular expression to (independent from the global highlighter setting).
    NOTE: the default for maxAnalyzedChars is much lower for this fragmenter. After this limit is exhausted, fragments are produced in the same way as GapFragmenter
    • Field Detail

      • defaultPatternRaw

        protected String defaultPatternRaw
      • defaultPattern

        protected Pattern defaultPattern
    • Constructor Detail

      • RegexFragmenter

        public RegexFragmenter()
    • Method Detail

      • init

        public void init​(org.apache.solr.common.util.NamedList<?> args)
        Description copied from interface: NamedListInitializedPlugin
        init will be called just once, immediately after creation.

        Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself

        Specified by:
        init in interface NamedListInitializedPlugin
        Overrides:
        init in class HighlightingPluginBase
        Parameters:
        args - non-null list of initialization parameters (may be empty)
      • getFragmenter

        public org.apache.lucene.search.highlight.Fragmenter getFragmenter​(String fieldName,
                                                                           org.apache.solr.common.params.SolrParams params)
        Description copied from interface: SolrFragmenter
        Return a Fragmenter appropriate for this field.
        Specified by:
        getFragmenter in interface SolrFragmenter
        Parameters:
        fieldName - The name of the field
        params - The params controlling Highlighting
        Returns:
        An appropriate Fragmenter.