Class BooleanQuery
- java.lang.Object
-
- com.atlassian.confluence.search.v2.query.BooleanQuery
-
- All Implemented Interfaces:
Expandable<SearchQuery>,SearchQuery
@SearchPrimitive public class BooleanQuery extends Object implements SearchQuery
A boolean query that allows and/or and not combinations of sub queries.
TODO: This SearchQuery implementation does not work with the QuerySerializer (or parser) since that mechanism relies on all parameters returned by getParameters having the same meaning; this is not currently true in this implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBooleanQuery.Builder
-
Constructor Summary
Constructors Constructor Description BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot)Construct a new BooleanQuery encapsulating the supplied sub queries with a default boost value.BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, float boost)Construct a new BooleanQuery encapsulating the supplied sub queries without any filters.BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters)Construct a new BooleanQuery encapsulating the supplied sub queries with the default boost.BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters, float boost)Construct a new BooleanQuery encapsulating the supplied sub queries.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SearchQueryandQuery(SearchQuery... queries)Build an AND query from one or more subqueries.static BooleanQuery.Builderbuilder()static SearchQuerycomposeAndQuery(Set<? extends SearchQuery> subqueries)Return a query that "ANDs" together a list of queries.static SearchQuerycomposeOrQuery(Set<? extends SearchQuery> subqueries)Return a query that "ORs" together a list of queries.booleanequals(Object o)SearchQueryexpand()Expands this query into a composite query (that composes other queries).floatgetBoost()Return boost factor of this query.Set<SearchQuery>getFilters()StringgetKey()Set<SearchQuery>getMustNotQueries()Set<SearchQuery>getMustQueries()ListgetParameters()List of parameters asStrings orSearchQuerys.Set<SearchQuery>getShouldQueries()Stream<SubClause<SearchQuery>>getSubClauses()Returns a stream of nested queries.inthashCode()static SearchQueryorQuery(SearchQuery... queries)Create a query that is the OR of the provided sub-queriesStringtoString()
-
-
-
Field Detail
-
KEY
public static final String KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BooleanQuery
public BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot)
Construct a new BooleanQuery encapsulating the supplied sub queries with a default boost value.At least one of must, should or mustNot subquery must contain value. Neither of them can contain a null value.
- Parameters:
must- the queries that must match.should- the queries that may match.mustNot- the queries that must not match.- Throws:
IllegalArgumentException- if the parameters are not correct.
-
BooleanQuery
public BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, float boost)
Construct a new BooleanQuery encapsulating the supplied sub queries without any filters.At least one of must, should or mustNot bquery must contain value. Neither of them can contain a null value.
- Parameters:
must- the queries that must match.should- the queries that may match.mustNot- the queries that must not match.boost- the boost factor.- Throws:
IllegalArgumentException- if the parameters are not correct.
-
BooleanQuery
public BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters)
Construct a new BooleanQuery encapsulating the supplied sub queries with the default boost.- Parameters:
must- the queries that must match.should- the queries that may match.mustNot- the queries that must not match.filters- the filters that must match.- Since:
- 7.20
-
BooleanQuery
public BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters, float boost)
Construct a new BooleanQuery encapsulating the supplied sub queries.At least one of must, should or mustNot or filter subquery must contain value. Neither of them can contain a null value.
- Parameters:
must- the queries that must match.should- the queries that may match.mustNot- the queries that must not match.filters- the filters that must match.boost- the boost factor.- Throws:
IllegalArgumentException- if the parameters are not correct.- Since:
- 7.20
-
-
Method Detail
-
getKey
public String getKey()
- Specified by:
getKeyin interfaceSearchQuery- Returns:
- the plugin key
-
composeAndQuery
public static SearchQuery composeAndQuery(Set<? extends SearchQuery> subqueries)
Return a query that "ANDs" together a list of queries. If the list contains no entries then anAllQueryis installed. If it contains only a single entry, then that entry is returned. Otherwise a BooleanQuery combining the full list is returned.- Parameters:
subqueries- a list ofSearchQuerys to combine. Must have size >= 1.- Returns:
- a
SearchQuerycombining thesubqueries. - Throws:
IllegalArgumentException- if the list of subqueries is empty.
-
andQuery
public static SearchQuery andQuery(SearchQuery... queries)
Build an AND query from one or more subqueries.- Parameters:
queries- theSearchQuerys to combine. Must be >= 1.- Returns:
- a
SearchQuerycombining thesubqueries. - Throws:
IllegalArgumentException- if the list of subqueries is empty.
-
composeOrQuery
public static SearchQuery composeOrQuery(Set<? extends SearchQuery> subqueries)
Return a query that "ORs" together a list of queries. If the list contains no entries then anAllQueryis installed. If it contains only a single entry, then that entry is returned. Otherwise a BooleanQuery combining the full list is returned.- Parameters:
subqueries- a list ofSearchQuerys to combine. Must have size >= 1.- Returns:
- a
SearchQuerycombining thesubqueries. - Throws:
IllegalArgumentException- if the list of subqueries is empty.
-
orQuery
public static SearchQuery orQuery(SearchQuery... queries)
Create a query that is the OR of the provided sub-queries- Parameters:
queries- the queries to OR- Returns:
- the OR of the provided queries
-
getMustQueries
public Set<SearchQuery> getMustQueries()
-
getShouldQueries
public Set<SearchQuery> getShouldQueries()
-
getMustNotQueries
public Set<SearchQuery> getMustNotQueries()
-
getFilters
public Set<SearchQuery> getFilters()
-
expand
public SearchQuery expand()
Description copied from interface:SearchQueryExpands this query into a composite query (that composes other queries). By overriding this method, one can specify a new query that is composition of the behaviour of the composed queries.- Specified by:
expandin interfaceExpandable<SearchQuery>- Specified by:
expandin interfaceSearchQuery- Returns:
- a query
-
getSubClauses
public Stream<SubClause<SearchQuery>> getSubClauses()
Description copied from interface:SearchQueryReturns a stream of nested queries.- Specified by:
getSubClausesin interfaceSearchQuery
-
getParameters
public List getParameters()
Description copied from interface:SearchQueryList of parameters asStrings orSearchQuerys.- Specified by:
getParametersin interfaceSearchQuery- Returns:
- a List containing all the sub queries combined. I'm not sure if this is ever useful to anyone.
-
getBoost
public float getBoost()
Description copied from interface:SearchQueryReturn boost factor of this query. It will take effect when the query is used in combination with others e.g. inBooleanQuery.- Specified by:
getBoostin interfaceSearchQuery- Returns:
- boost factor
-
builder
public static BooleanQuery.Builder builder()
-
-