Class BooleanQuery
- All Implemented Interfaces:
Expandable<SearchQuery>
,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 -
Field Summary
FieldsFields inherited from interface com.atlassian.confluence.search.v2.SearchQuery
DEFAULT_BOOST
-
Constructor Summary
ConstructorsConstructorDescriptionBooleanQuery
(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.BooleanQuery
(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters, float boost, boolean disableCoord) Construct a new BooleanQuery encapsulating the supplied sub queries. -
Method Summary
Modifier and TypeMethodDescriptionstatic SearchQuery
andQuery
(SearchQuery... queries) Build an AND query from one or more subqueries.static BooleanQuery.Builder
builder()
static SearchQuery
composeAndQuery
(Set<? extends SearchQuery> subqueries) Return a query that "ANDs" together a list of queries.static SearchQuery
composeOrQuery
(Set<? extends SearchQuery> subqueries) Return a query that "ORs" together a list of queries.boolean
expand()
Expands this query into a composite query (that composes other queries).float
getBoost()
Return boost factor of this query.getKey()
List of parameters asString
s orSearchQuery
s.Returns a stream of nested queries.int
hashCode()
boolean
static SearchQuery
orQuery
(SearchQuery... queries) Create a query that is the OR of the provided sub-queriestoString()
-
Field Details
-
KEY
- See Also:
-
-
Constructor Details
-
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
-
BooleanQuery
public BooleanQuery(Collection<? extends SearchQuery> must, Collection<? extends SearchQuery> should, Collection<? extends SearchQuery> mustNot, Collection<? extends SearchQuery> filters, float boost, boolean disableCoord) 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.disableCoord
- disable similarity coord in scoring.- Throws:
IllegalArgumentException
- if the parameters are not correct.- Since:
- 8.7
-
-
Method Details
-
getKey
- Specified by:
getKey
in interfaceSearchQuery
- Returns:
- the plugin key
-
composeAndQuery
Return a query that "ANDs" together a list of queries. If the list contains no entries then anAllQuery
is 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 ofSearchQuery
s to combine. Must have size >= 1.- Returns:
- a
SearchQuery
combining thesubqueries
. - Throws:
IllegalArgumentException
- if the list of subqueries is empty.
-
andQuery
Build an AND query from one or more subqueries.- Parameters:
queries
- theSearchQuery
s to combine. Must be >= 1.- Returns:
- a
SearchQuery
combining thesubqueries
. - Throws:
IllegalArgumentException
- if the list of subqueries is empty.
-
composeOrQuery
Return a query that "ORs" together a list of queries. If the list contains no entries then anAllQuery
is 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 ofSearchQuery
s to combine. Must have size >= 1.- Returns:
- a
SearchQuery
combining thesubqueries
. - Throws:
IllegalArgumentException
- if the list of subqueries is empty.
-
orQuery
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
-
getShouldQueries
-
getMustNotQueries
-
getFilters
-
expand
Description copied from interface:SearchQuery
Expands 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:
expand
in interfaceExpandable<SearchQuery>
- Specified by:
expand
in interfaceSearchQuery
- Returns:
- a query
-
getSubClauses
Description copied from interface:SearchQuery
Returns a stream of nested queries.- Specified by:
getSubClauses
in interfaceSearchQuery
-
getParameters
Description copied from interface:SearchQuery
List of parameters asString
s orSearchQuery
s.- Specified by:
getParameters
in 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:SearchQuery
Return boost factor of this query. It will take effect when the query is used in combination with others e.g. inBooleanQuery
.- Specified by:
getBoost
in interfaceSearchQuery
- Returns:
- boost factor
-
isCoordDisabled
public boolean isCoordDisabled()- Returns:
- true if similarity-coord is disabled
- Since:
- 8.7
-
equals
-
hashCode
public int hashCode() -
toString
-
builder
-