T
- projection typeQ
- concrete subtype of querypublic abstract class AbstractLuceneQuery<T,Q extends AbstractLuceneQuery<T,Q>> extends java.lang.Object implements SimpleQuery<Q>, Fetchable<T>
Constructor and Description |
---|
AbstractLuceneQuery(org.apache.lucene.search.IndexSearcher searcher,
java.util.function.Function<org.apache.lucene.document.Document,T> transformer) |
AbstractLuceneQuery(LuceneSerializer serializer,
org.apache.lucene.search.IndexSearcher searcher,
java.util.function.Function<org.apache.lucene.document.Document,T> transformer) |
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.search.Filter |
asFilter()
Create a filter for constraints defined in this query
|
protected org.apache.lucene.search.Query |
createQuery() |
Q |
distinct()
Set the Query to return distinct results
|
Q |
distinct(Path<?> property)
Add a DuplicateFilter for the field of the given property path
|
java.util.List<T> |
fetch()
Get the projection as a typed List
|
long |
fetchCount()
Get the count of matched elements
Note: not all QueryDSL modules might optimize fetchCount using a count query.
|
T |
fetchFirst()
Get the first result of Get the projection or null if no result is found
|
T |
fetchOne()
Get the projection as a unique result or null if no result is found
|
QueryResults<T> |
fetchResults()
Get the projection in
QueryResults form. |
Q |
filter(org.apache.lucene.search.Filter filter)
Apply the given Lucene filter to the search results
|
com.mysema.commons.lang.CloseableIterator<T> |
iterate()
Get the projection as a typed closeable Iterator
|
Q |
limit(long limit)
Set the limit / max results for the query results
|
Q |
load(FieldSelector fieldSelector)
Set the given FieldSelector to the query
|
Q |
load(Path<?>... paths)
Load only the fields of the given paths
|
Q |
offset(long offset)
Set the offset for the query results
|
Q |
orderBy(OrderSpecifier<?>... o)
Add order expressions
|
Q |
orderBy(OrderSpecifier<?> o) |
Q |
restrict(QueryModifiers modifiers)
Set both limit and offset of the query results
|
<P> Q |
set(ParamExpression<P> param,
P value)
Set the given parameter to the given value
|
Q |
sort(org.apache.lucene.search.Sort sort) |
java.lang.String |
toString() |
Q |
where(Predicate... e)
Adds the given filter conditions
|
Q |
where(Predicate e) |
public AbstractLuceneQuery(LuceneSerializer serializer, org.apache.lucene.search.IndexSearcher searcher, java.util.function.Function<org.apache.lucene.document.Document,T> transformer)
public AbstractLuceneQuery(org.apache.lucene.search.IndexSearcher searcher, java.util.function.Function<org.apache.lucene.document.Document,T> transformer)
public long fetchCount()
Fetchable
fetch().size()
.fetchCount
in interface Fetchable<T>
protected org.apache.lucene.search.Query createQuery()
public org.apache.lucene.search.Filter asFilter()
public Q distinct()
SimpleQuery
distinct
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
public Q distinct(Path<?> property)
property
- distinct propertypublic Q filter(org.apache.lucene.search.Filter filter)
filter
- filterpublic Q limit(long limit)
SimpleQuery
limit
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
limit
- max rowspublic com.mysema.commons.lang.CloseableIterator<T> iterate()
Fetchable
public java.util.List<T> fetch()
Fetchable
public Q load(FieldSelector fieldSelector)
fieldSelector
- field selectorpublic Q load(Path<?>... paths)
paths
- fields to loadpublic QueryResults<T> fetchResults()
Fetchable
QueryResults
form.
Make sure to use Fetchable.fetch()
instead if you do not rely on the QueryResults.getOffset()
or
QueryResults.getLimit()
, because it will be more performant. Also, count queries cannot be
properly generated for all dialects. For example: in JPA count queries can't be generated for queries
that have multiple group by expressions or a having clause.
Get the projection in QueryResults
form.
Use Fetchable.fetch()
instead if you do not need the total count of rows in the query result.fetchResults
in interface Fetchable<T>
Fetchable.fetch()
public Q offset(long offset)
SimpleQuery
offset
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
offset
- row offsetpublic Q orderBy(OrderSpecifier<?> o)
public Q orderBy(OrderSpecifier<?>... o)
SimpleQuery
orderBy
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
o
- orderpublic Q restrict(QueryModifiers modifiers)
SimpleQuery
restrict
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
modifiers
- query modifierspublic <P> Q set(ParamExpression<P> param, P value)
SimpleQuery
set
in interface SimpleQuery<Q extends AbstractLuceneQuery<T,Q>>
param
- paramvalue
- bindingpublic Q sort(org.apache.lucene.search.Sort sort)
public T fetchFirst()
Fetchable
fetchFirst
in interface Fetchable<T>
public T fetchOne() throws NonUniqueResultException
Fetchable
fetchOne
in interface Fetchable<T>
NonUniqueResultException
- if there is more than one matching resultpublic Q where(Predicate... e)
FilteredClause
Skips null arguments
where
in interface FilteredClause<Q extends AbstractLuceneQuery<T,Q>>
e
- filter conditions to be addedpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2007–2021 Querydsl. All rights reserved.