Class BooleanQuery

    • Field Detail

      • minNrShouldMatch

        protected int minNrShouldMatch
    • Constructor Detail

      • BooleanQuery

        public BooleanQuery()
        Constructs an empty boolean query.
      • BooleanQuery

        public BooleanQuery​(boolean disableCoord)
        Constructs an empty boolean query. Similarity.coord(int,int) may be disabled in scoring, as appropriate. For example, this score factor does not make sense for most automatically generated queries, like WildcardQuery and FuzzyQuery.
        Parameters:
        disableCoord - disables Similarity.coord(int,int) in scoring.
    • Method Detail

      • getMaxClauseCount

        public static int getMaxClauseCount()
        Return the maximum number of clauses permitted, 1024 by default. Attempts to add more than the permitted number of clauses cause BooleanQuery.TooManyClauses to be thrown.
        See Also:
        setMaxClauseCount(int)
      • setMaxClauseCount

        public static void setMaxClauseCount​(int maxClauseCount)
        Set the maximum number of clauses permitted per BooleanQuery. Default value is 1024.
      • setMinimumNumberShouldMatch

        public void setMinimumNumberShouldMatch​(int min)
        Specifies a minimum number of the optional BooleanClauses which must be satisfied.

        By default no optional clauses are necessary for a match (unless there are no required clauses). If this method is used, then the specified number of clauses is required.

        Use of this method is totally independent of specifying that any specific clauses are required (or prohibited). This number will only be compared against the number of matching optional clauses.

        Parameters:
        min - the number of optional clauses that must match
      • getMinimumNumberShouldMatch

        public int getMinimumNumberShouldMatch()
        Gets the minimum number of the optional BooleanClauses which must be satisfied.
      • getClauses

        public BooleanClause[] getClauses()
        Returns the set of clauses in this query.
      • clauses

        public List<BooleanClause> clauses()
        Returns the list of clauses in this query.
      • createWeight

        public Weight createWeight​(IndexSearcher searcher)
                            throws IOException
        Description copied from class: Query
        Expert: Constructs an appropriate Weight implementation for this query.

        Only implemented by primitive queries, which re-write to themselves.

        Overrides:
        createWeight in class Query
        Throws:
        IOException
      • rewrite

        public Query rewrite​(IndexReader reader)
                      throws IOException
        Description copied from class: Query
        Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
        Overrides:
        rewrite in class Query
        Throws:
        IOException
      • extractTerms

        public void extractTerms​(Set<Term> terms)
        Description copied from class: Query
        Expert: adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten form.
        Overrides:
        extractTerms in class Query
      • clone

        public BooleanQuery clone()
        Description copied from class: Query
        Returns a clone of this query.
        Overrides:
        clone in class Query
      • toString

        public String toString​(String field)
        Prints a user-readable version of this query.
        Specified by:
        toString in class Query
      • equals

        public boolean equals​(Object o)
        Returns true iff o is equal to this.
        Overrides:
        equals in class Query
      • hashCode

        public int hashCode()
        Returns a hash code value for this object.
        Overrides:
        hashCode in class Query