Class TextQuery


  • public class TextQuery
    extends ChangableValueQuery
    A query allowing search on a text string. The flexibility provided by this query makes it an ideal wrapper for unstructured query terms (such as come from a user-facing search bar).

    TextQuery supports several options for controlling how this text is used, most prominently which fields should be searched against and if/how proximity searching should be performed. See individual options for more details.

    • Constructor Detail

      • TextQuery

        public TextQuery​(java.util.List<KeyAndBoost> fields,
                         java.util.List<KeyAndBoost> phraseFields,
                         java.lang.Integer phraseSlop,
                         java.lang.String minimumShouldMatch,
                         java.util.List<MinimumMatch> minimumMatch,
                         java.lang.Integer queryPhraseSlop,
                         java.lang.String value)
    • Method Detail

      • getFields

        public java.util.List<KeyAndBoost> getFields()
        Returns:
        the fields to search for the supplied text, along with per-field boosts indicating the relative importance of each field.
      • getPhraseFields

        public java.util.List<KeyAndBoost> getPhraseFields()
        Returns:
        the fields to phrase-search for the supplied text, along with per-field boosts indicating the relative importance of each field.
      • getMinimumShouldMatch

        @Deprecated
        public java.lang.String getMinimumShouldMatch()
        Deprecated.
        Returns:
        an expression signifying how many query terms in getValue() must be present for a document to be considered a match.

        May be specified as a positive integer (indicating the number of terms in absolute terms), a negative integer (indicating the number of terms relative to the total), a positive percentage (indicating the percent of query terms that must be present), or a negative percentage (indicting the percent of query terms that may be absent).

        If not specified, assumed default is "1"

      • getMinimumMatch

        public java.util.List<MinimumMatch> getMinimumMatch()
      • setMinimumMatch

        public void setMinimumMatch​(java.util.List<MinimumMatch> minimumMatch)
      • getPhraseSlop

        public java.lang.Integer getPhraseSlop()
        Returns:
        the "slop" used when detecting phrase matches for the entire value. Slop is a measure of how flexible phrase searches should be in matching documents - each unit of slop represents a movement of one token relative to another that is needed for a phrase query to match text in an underlying document. The higher the number, the more forgiving phrase searches are.
      • getQueryPhraseSlop

        public java.lang.Integer getQueryPhraseSlop()
        Returns:
        the "slop" used when evaluating phrase queries explicitly included in the provided value. (As opposed to phraseSlop which designates the slop used for matching the complete query string).
        See Also:
        getPhraseSlop()
      • getValue

        public java.lang.String getValue()
        Specified by:
        getValue in class ChangableValueQuery
        Returns:
        a text string containing the query terms to search.
      • setFields

        public void setFields​(java.util.List<KeyAndBoost> fields)