Class Feature

  • All Implemented Interfaces:
    Direct Known Subclasses:
    FieldLengthFeature, FieldValueFeature, OriginalScoreFeature, SolrFeature, ValueFeature

    public abstract class Feature
    implements org.apache.lucene.util.Accountable
    A recipe for computing a feature. Subclass this for specialized feature calculations.

    A feature consists of

    • a name as the identifier
    • parameters to represent the specific feature

    Example configuration (snippet):

       "class" : "...",
       "name" : "myFeature",
       "params" : {

    Feature is an abstract class and concrete classes should implement the validate() function, and must implement the paramsToMap() and createWeight() methods.

    • Field Detail

      • name

        protected final String name
    • Method Detail

      • validate

        protected abstract void validate()
                                  throws FeatureException
        As part of creation of a feature instance, this function confirms that the feature parameters are valid.
        FeatureException - Feature Exception
      • toString

        public String toString​(String field)
        Specified by:
        toString in class
      • getDefaultValue

        public float getDefaultValue()
      • setDefaultValue

        public void setDefaultValue​(Object obj)
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class
      • equals

        public boolean equals​(Object o)
        Specified by:
        equals in class
      • ramBytesUsed

        public long ramBytesUsed()
        Specified by:
        ramBytesUsed in interface org.apache.lucene.util.Accountable
      • visit

        public void visit​( visitor)
        Specified by:
        visit in class
      • getName

        public String getName()
        the name
      • getIndex

        public int getIndex()
        the id
      • setIndex

        public void setIndex​(int index)
        index - Unique ID for this feature. Similar to feature name, except it can be used to directly access the feature in the global list of features.