Class QueryDefinition
- java.lang.Object
-
- com.lucidworks.search.dsl.DslBase
-
- com.lucidworks.search.dsl.request.DslCloneable
-
- com.lucidworks.search.dsl.request.query.QueryDefinition
-
public class QueryDefinition extends DslCloneable
A container object for all queries in DSL request. There are following assumptions betweengetUserQuery()
andgetMain()
:If
getUserQuery()
is set andgetMain()
is not,getMain()
will be set toTextQuery
withgetUserQuery()
as a value.If
getUserQuery()
is set andgetMain()
is set, assumption is thatgetMain()
query contains someTextQuery
(s) without a value which will default togetUserQuery()
as a value.Expectation is for at least one of
getUserQuery()
andgetMain()
fields to be populatedgetGroupedQuery()
andgetGroupedFilters()
are used in relation withResults.getGroup()
. Expectation is forResults.getGroup()
to be set if any of these queries are set.Note: keep in mind that not all of the queries that could be specified in
DslRequest
located here. Some are specific to a particular part of request and located there (for example "sort by" queries)
-
-
Constructor Summary
Constructors Constructor Description QueryDefinition(Query main, java.util.List<BoostByValue> boostsByValues, java.util.List<BoostQuery> boostsByQuery, java.util.List<FunctionQuery> boostsByFunction, java.util.List<java.lang.String> boostsByDocId, java.lang.String userQuery, java.util.List<Query> filters, java.util.List<NamedFilter> namedFilters, Query groupedQuery, java.util.List<Query> groupedFilters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBoostByDocId(java.lang.String docId)
void
addBoostByQuery(BoostQuery boostQuery)
void
addBoostByValues(BoostByValue boostByValues)
void
addFilter(Query filter)
QueryDefinition
clone()
java.util.List<java.lang.String>
getBoostsByDocId()
java.util.List<FunctionQuery>
getBoostsByFunction()
java.util.List<BoostQuery>
getBoostsByQuery()
java.util.List<BoostByValue>
getBoostsByValues()
java.util.List<Query>
getFilters()
java.util.List<Query>
getGroupedFilters()
Query
getGroupedQuery()
Query
getMain()
java.util.List<NamedFilter>
getNamedFilters()
Filters with associated names.java.lang.String
getUserQuery()
void
setBoostsByDocId(java.util.List<java.lang.String> boostsByDocId)
void
setBoostsByQuery(java.util.List<BoostQuery> boostsByQuery)
void
setBoostsByValues(java.util.List<BoostByValue> boostsByValues)
void
setFilters(java.util.List<Query> filters)
void
setMain(Query main)
-
Methods inherited from class com.lucidworks.search.dsl.request.DslCloneable
clone, deepClone
-
-
-
-
Constructor Detail
-
QueryDefinition
public QueryDefinition(Query main, java.util.List<BoostByValue> boostsByValues, java.util.List<BoostQuery> boostsByQuery, java.util.List<FunctionQuery> boostsByFunction, java.util.List<java.lang.String> boostsByDocId, java.lang.String userQuery, java.util.List<Query> filters, java.util.List<NamedFilter> namedFilters, Query groupedQuery, java.util.List<Query> groupedFilters)
-
-
Method Detail
-
getMain
public Query getMain()
- Returns:
- main query that defines the base result set and document scores for this request. If null, defaults to
TextQuery
withgetUserQuery()
value
-
setMain
public void setMain(Query main)
-
getBoostsByValues
public java.util.List<BoostByValue> getBoostsByValues()
- Returns:
- a list of fields and boost values that will be used in combination
with
getBoostsByQuery()
and will be added togetMain()
to influence the score. Boosts by query and value have no impact on the result set.
-
getBoostsByQuery
public java.util.List<BoostQuery> getBoostsByQuery()
- Returns:
- a list of additional queries that that will be used in combination
with
getBoostsByValues()
and will be added togetMain()
to influence the score. Boosts by query and value have no impact on the result set.
-
getBoostsByFunction
public java.util.List<FunctionQuery> getBoostsByFunction()
-
getUserQuery
public java.lang.String getUserQuery()
- Returns:
- actual user query that is used in combination with
getMain()
-
getFilters
public java.util.List<Query> getFilters()
- Returns:
- a list of filter queries used to narrow the base result set. Filters have no impact on document scoring.
-
getNamedFilters
public java.util.List<NamedFilter> getNamedFilters()
Filters with associated names. These filters are treated identically to the values ingetFilters()
- they are used to narrow the base result set and have no impact on scoring. Additionally however, filters in this list are paired with names that allow them to be manipulated by other features. SeeFacetDomain.getExcludedFiltersByName()
for an example.
-
setFilters
public void setFilters(java.util.List<Query> filters)
-
addFilter
public void addFilter(Query filter)
-
setBoostsByValues
public void setBoostsByValues(java.util.List<BoostByValue> boostsByValues)
-
addBoostByValues
public void addBoostByValues(BoostByValue boostByValues)
-
getGroupedQuery
public Query getGroupedQuery()
- Returns:
- overrides
getMain()
for group details.Results.getGroup()
has to be setThis field is ignored with "hint.grouping.method=group".
-
getGroupedFilters
public java.util.List<Query> getGroupedFilters()
- Returns:
- overrides
getFilters()
for group details.Results.getGroup()
has to be setThis field is ignored with "hint.grouping.method=group".
-
setBoostsByQuery
public void setBoostsByQuery(java.util.List<BoostQuery> boostsByQuery)
-
addBoostByQuery
public void addBoostByQuery(BoostQuery boostQuery)
-
getBoostsByDocId
public java.util.List<java.lang.String> getBoostsByDocId()
- Returns:
- A list of Solr document IDs which will be boosted to the top of the query results, if they match, using the Query Elevation Component in Solr
-
setBoostsByDocId
public void setBoostsByDocId(java.util.List<java.lang.String> boostsByDocId)
-
addBoostByDocId
public void addBoostByDocId(java.lang.String docId)
-
clone
public QueryDefinition clone()
- Specified by:
clone
in classDslCloneable
-
-