Class TermInFieldModifier

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Model, IndexConfigurable

    public class TermInFieldModifier
    extends WeightingModel
    implements IndexConfigurable
    Resets the scores of documents according to whether a term appears in a given set of fields. This class implements the TermScoreModifier interface.
    Author:
    Vassilis Plachouras
    See Also:
    Serialized Form
    • Field Detail

      • index

        protected transient Index index
      • field

        protected java.lang.String field
        The fields that a query term should appear in.
      • requirement

        protected boolean requirement
        The requirement. By default it is true.
    • Constructor Detail

      • TermInFieldModifier

        public TermInFieldModifier​(java.lang.String _field)
        Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.
        Parameters:
        _field - String a field
      • TermInFieldModifier

        public TermInFieldModifier​(java.lang.String _field,
                                   boolean req)
        Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.
        Parameters:
        _field - String a field
        req - boolean the requirement for this field. If req is true, then the term is required to appear in the field (this is the default behaviour), otherwise the term should not appear in the field.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of the class and whether the query term is required.
      • getInfo

        public java.lang.String getInfo()
        Description copied from class: WeightingModel
        Returns the name of the model.
        Specified by:
        getInfo in interface Model
        Specified by:
        getInfo in class WeightingModel
        Returns:
        java.lang.String
      • score

        public double score​(double tf,
                            double docLength)
        Description copied from class: WeightingModel
        This method provides the contract for implementing weighting models.
        Specified by:
        score in class WeightingModel
        Parameters:
        tf - The term frequency in the document
        docLength - the document's length
        Returns:
        the score assigned to a document with the given tf and docLength, and other preset parameters
      • setIndex

        public void setIndex​(Index i)
        Tell the implementer which Index object it is associated with.
        Specified by:
        setIndex in interface IndexConfigurable
        Parameters:
        i - Index object to use