Class BooleanQueryFactory


  • public final class BooleanQueryFactory
    extends Object
    Container class for the results of a SearchQueryParser operation, providing a mutable version of the BooleanQuery.
    Since:
    2.9
    • Constructor Detail

      • BooleanQueryFactory

        public BooleanQueryFactory()
        Constructs an empty BooleanQueryFactory.
      • BooleanQueryFactory

        public BooleanQueryFactory​(Set<SearchQuery> must,
                                   Set<SearchQuery> should,
                                   Set<SearchQuery> mustNot)
        Constructs a BooleanQueryFactory with the specified SearchQueries as initial values.
        Parameters:
        must - queries that must match
        should - queries that should match
        mustNot - queries that must not match
    • Method Detail

      • toBooleanQuery

        public BooleanQuery toBooleanQuery()
        Returns a BooleanQuery instance using the current state of this BooleanQueryFactory.
        Returns:
        a BooleanQuery instance reflecting the current state
      • addMust

        public void addMust​(SearchQuery query)
        Adds the specified SearchQuery to the "must match" criteria.
        Parameters:
        query - the SearchQuery to add
      • addMust

        public void addMust​(Collection<? extends SearchQuery> queries)
        Adds the specified Collection<SearchQuery> to the "must match" criteria.
        Parameters:
        queries - the SearchQueries to add
      • addMust

        public void addMust​(BooleanQueryFactory factory)
        Adds the specified BooleanQueryFactory to the "must match" criteria after calling toBooleanQuery() on it. Empty or null factories are silently ignored.
        Parameters:
        factory - the BooleanQueryFactory to add
        Since:
        2.10
      • addShould

        public void addShould​(SearchQuery query)
        Adds the specified SearchQuery to the "should match" criteria.
        Parameters:
        query - the SearchQuery to add
      • addShould

        public void addShould​(Collection<? extends SearchQuery> queries)
        Adds the specified Collection<SearchQuery> to the "should match" criteria.
        Parameters:
        queries - the SearchQueries to add
      • addShould

        public void addShould​(BooleanQueryFactory factory)
        Adds the specified BooleanQueryFactory to the "should match" criteria after calling toBooleanQuery() on it. Empty or null factories are silently ignored.
        Parameters:
        factory - the BooleanQueryFactory to add
        Since:
        2.10
      • addMustNot

        public void addMustNot​(SearchQuery query)
        Adds the specified SearchQuery to the "must not match" criteria.
        Parameters:
        query - the SearchQuery to add
      • addMustNot

        public void addMustNot​(Collection<? extends SearchQuery> queries)
        Adds the specified Collection<SearchQuery> to the "must not match" criteria.
        Parameters:
        queries - the SearchQueries to add
      • addMustNot

        public void addMustNot​(BooleanQueryFactory factory)
        Adds the specified BooleanQueryFactory to the "must not match" criteria after calling toBooleanQuery() on it. Empty or null factories are silently ignored.
        Parameters:
        factory - the BooleanQueryFactory to add
        Since:
        2.10
      • merge

        public void merge​(BooleanQueryFactory result)
        Merges the specified BooleanQueryFactory with the current one.
        Parameters:
        result - the BooleanQueryFactory to merge
        Throws:
        IllegalArgumentException - if result is null
      • isEmpty

        public boolean isEmpty()
        Returns true if the current BooleanQueryFactory is empty; that is, if no SearchQueries have been added to it.
        Returns:
        true if the current BooleanQueryFactory is empty.
        Since:
        2.10