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 class
BooleanQuery.Builder
-
Field Summary
Fields Modifier and Type Field Description static String
KEY
-
Fields inherited from interface com.atlassian.confluence.search.v2.SearchQuery
DEFAULT_BOOST
-
-
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.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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
equals(Object o)
SearchQuery
expand()
Expands this query into a composite query (that composes other queries).float
getBoost()
Return boost factor of this query.Set<SearchQuery>
getFilters()
String
getKey()
Set<SearchQuery>
getMustNotQueries()
Set<SearchQuery>
getMustQueries()
List
getParameters()
List of parameters asString
s orSearchQuery
s.Set<SearchQuery>
getShouldQueries()
Stream<SubClause<SearchQuery>>
getSubClauses()
Returns a stream of nested queries.int
hashCode()
boolean
isCoordDisabled()
static SearchQuery
orQuery(SearchQuery... queries)
Create a query that is the OR of the provided sub-queriesString
toString()
-
-
-
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
-
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 Detail
-
getKey
public String getKey()
- Specified by:
getKey
in 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 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
public static SearchQuery andQuery(SearchQuery... queries)
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
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 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
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: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
public Stream<SubClause<SearchQuery>> getSubClauses()
Description copied from interface:SearchQuery
Returns a stream of nested queries.- Specified by:
getSubClauses
in interfaceSearchQuery
-
getParameters
public List 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
-
builder
public static BooleanQuery.Builder builder()
-
-