public class FullTextQueryImpl extends AbstractQueryImpl implements FullTextQuery
FullTextQuery
.parameterMetadata, session
Constructor and Description |
---|
FullTextQueryImpl(org.apache.lucene.search.Query query,
Class<?>[] classes,
SessionImplementor session,
ParameterMetadata parameterMetadata)
Constructs a
FullTextQueryImpl instance. |
Modifier and Type | Method and Description |
---|---|
void |
disableFullTextFilter(String name)
Disable a given filter by its name.
|
org.hibernate.search.filter.FullTextFilter |
enableFullTextFilter(String name)
Enable a given filter by its name.
|
int |
executeUpdate()
Execute the update or delete statement.
|
org.apache.lucene.search.Explanation |
explain(int documentId)
Return the Lucene
Explanation
object describing the score computation for the matching object/document
in the current query |
org.hibernate.search.query.engine.spi.FacetManager |
getFacetManager() |
protected Map |
getLockModes() |
LockOptions |
getLockOptions()
Obtains the LockOptions in effect for this query.
|
int |
getResultSize() |
boolean |
hasPartialResults()
Experimental API, subject to change or removal
|
FullTextQuery |
initializeObjectsWith(org.hibernate.search.query.ObjectLookupMethod lookupMethod,
org.hibernate.search.query.DatabaseRetrievalMethod retrievalMethod)
Refine the strategies used to load entities.
|
Iterator |
iterate()
Return an iterator on the results.
|
FullTextQuery |
limitExecutionTimeTo(long timeout,
TimeUnit timeUnit)
*Experimental* API, subject to change or removal
Limit the time used by Hibernate Search to execute the query.
|
List |
list()
Return the query results as a List.
|
ScrollableResults |
scroll()
Return the query results as ScrollableResults.
|
ScrollableResults |
scroll(ScrollMode scrollMode)
Return the query results as ScrollableResults.
|
FullTextQuery |
setCriteriaQuery(Criteria criteria)
Defines the Database Query used to load the Lucene results.
|
FullTextQuery |
setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.
|
FullTextQuery |
setFilter(org.apache.lucene.search.Filter filter)
Allows to use lucene filters.
|
FullTextQuery |
setFirstResult(int firstResult)
Set the first row to retrieve.
|
Query |
setLockMode(String alias,
LockMode lockMode)
Set the LockMode to use for specific alias (as defined in the query's FROM clause).
|
Query |
setLockOptions(LockOptions lockOptions)
Set the lock options for the query.
|
FullTextQuery |
setMaxResults(int maxResults)
Set the maximum number of rows to retrieve.
|
FullTextQuery |
setProjection(String... fields)
Defines the Lucene field names projected and returned in a query result
Each field is converted back to it's object representation, an Object[] being returned for each "row"
(similar to an HQL or a Criteria API projection).
|
FullTextQuery |
setResultTransformer(ResultTransformer transformer)
Set a strategy for handling the query results.
|
FullTextQuery |
setSort(org.apache.lucene.search.Sort sort)
Allows to let lucene sort the results.
|
FullTextQuery |
setSpatialParameters(org.hibernate.search.spatial.Coordinates center,
String fieldName)
Defines the center of the spatial search for this query to project distance in results
|
FullTextQuery |
setSpatialParameters(double latitude,
double longitude,
String fieldName)
Defines the center of the spatial search for this query to project distance in results
|
FullTextQuery |
setTimeout(int timeout)
Set the query timeout in seconds.
|
FullTextQuery |
setTimeout(long timeout,
TimeUnit timeUnit)
Define a timeout period for a given unit of time.
|
<T> T |
unwrap(Class<T> type) |
addQueryHint, after, applyEntityGraphQueryHint, before, determineType, determineType, determineType, determineType, determineType, expandParameterLists, getCacheMode, getCacheRegion, getComment, getFetchSize, getFirstResult, getFlushMode, getMaxResults, getNamedParameterLists, getNamedParameters, getNamedParams, getParameterMetadata, getQueryParameters, getQueryString, getReturnAliases, getReturnTypes, getRowSelection, getTimeout, getTypes, getValues, guessType, hasNamedParameters, isCacheable, isReadOnly, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCacheable, setCacheMode, setCacheRegion, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setCollectionKey, setComment, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFloat, setFloat, setFlushMode, setInteger, setInteger, setLocale, setLocale, setLong, setLong, setOptionalEntityName, setOptionalId, setOptionalObject, setParameter, setParameter, setParameter, setParameter, setParameterList, setParameterList, setParameterList, setParameterList, setParameters, setProperties, setProperties, setReadOnly, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimestamp, setTimestamp, toString, typeArray, uniqueResult, valueArray, verifyParameters, verifyParameters
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addQueryHint, getComment, getFirstResult, getMaxResults, getNamedParameters, getQueryString, getReturnAliases, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCacheable, setCacheMode, setCacheRegion, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setComment, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFloat, setFloat, setFlushMode, setInteger, setInteger, setLocale, setLocale, setLong, setLong, setParameter, setParameter, setParameter, setParameter, setParameterList, setParameterList, setParameterList, setParameterList, setParameters, setProperties, setProperties, setReadOnly, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimestamp, setTimestamp, uniqueResult
getCacheMode, getCacheRegion, getFetchSize, getFlushMode, getReturnTypes, getTimeout, isCacheable, isReadOnly
public FullTextQueryImpl(org.apache.lucene.search.Query query, Class<?>[] classes, SessionImplementor session, ParameterMetadata parameterMetadata)
FullTextQueryImpl
instance.query
- The Lucene query.classes
- Array of classes (must be immutable) used to filter the results to the given class types.session
- Access to the Hibernate session.parameterMetadata
- Additional query metadata.public FullTextQuery setSort(org.apache.lucene.search.Sort sort)
FullTextQuery
setSort
in interface FullTextQuery
sort
- The lucene sort object.public FullTextQuery setFilter(org.apache.lucene.search.Filter filter)
FullTextQuery
setFilter
in interface FullTextQuery
filter
- The lucene filter.public Iterator iterate()
public ScrollableResults scroll()
Query
scroll
in interface Query
ScrollableResults
public ScrollableResults scroll(ScrollMode scrollMode)
Query
scroll
in interface Query
scrollMode
- The scroll modeScrollableResults
,
ScrollMode
public List list()
Query
public org.apache.lucene.search.Explanation explain(int documentId)
FullTextQuery
Explanation
object describing the score computation for the matching object/document
in the current queryexplain
in interface FullTextQuery
documentId
- Lucene Document id to be explain. This is NOT the object idExplanation
instancepublic int getResultSize()
getResultSize
in interface FullTextQuery
Caution:
The number of results might be slightly different from
list().size()
because list() if the index is
not in sync with the database at the time of query.
public FullTextQuery setCriteriaQuery(Criteria criteria)
FullTextQuery
criteria.setProjection()
) allowed, the root entity must be the only returned typesetCriteriaQuery
in interface FullTextQuery
criteria
- Hibernate criteria query used to load resultsthis
for method chainingpublic FullTextQuery setProjection(String... fields)
FullTextQuery
A projectable field must be stored in the Lucene index and use a TwoWayFieldBridge
Unless notified in their JavaDoc, all built-in bridges are two-way. All @DocumentId fields are projectable by design.
If the projected field is not a projectable field, null is returned in the object[]
setProjection
in interface FullTextQuery
fields
- list of field names to project onthis
for method chainingpublic FullTextQuery setSpatialParameters(org.hibernate.search.spatial.Coordinates center, String fieldName)
FullTextQuery
setSpatialParameters
in interface FullTextQuery
center
- the search centerfieldName
- name of the spatial fieldthis
for method chainingpublic FullTextQuery setSpatialParameters(double latitude, double longitude, String fieldName)
FullTextQuery
setSpatialParameters
in interface FullTextQuery
latitude
- latitude of the search centerlongitude
- longitude of the search centerfieldName
- name of the spatial fieldthis
for method chainingpublic FullTextQuery setFirstResult(int firstResult)
Query
setFirstResult
in interface Query
setFirstResult
in interface FullTextQuery
setFirstResult
in class AbstractQueryImpl
firstResult
- a row number, numbered from 0this
, for method chainingQuery.getFirstResult()
public FullTextQuery setMaxResults(int maxResults)
Query
setMaxResults
in interface Query
setMaxResults
in interface FullTextQuery
setMaxResults
in class AbstractQueryImpl
maxResults
- the maximum number of rowsthis
, for method chainingQuery.getMaxResults()
public FullTextQuery setFetchSize(int fetchSize)
BasicQueryContract
setFetchSize
in interface BasicQueryContract
setFetchSize
in interface Query
setFetchSize
in interface FullTextQuery
setFetchSize
in class AbstractQueryImpl
fetchSize
- the fetch size hintthis
, for method chainingBasicQueryContract.getFetchSize()
public Query setLockOptions(LockOptions lockOptions)
Query
Query.setLockMode(String, LockMode)
.setLockOptions
in interface Query
lockOptions
- The lock options to apply to the query.this
, for method chainingQuery.getLockOptions()
public FullTextQuery setResultTransformer(ResultTransformer transformer)
Query
setResultTransformer
in interface Query
setResultTransformer
in interface FullTextQuery
setResultTransformer
in class AbstractQueryImpl
transformer
- The transformer to applypublic <T> T unwrap(Class<T> type)
unwrap
in interface FullTextQuery
T
- the type of the unwrapped objecttype
- the type to unwrapIllegalArgumentException
is thrown. Supported types are:
public LockOptions getLockOptions()
Query
getLockOptions
in interface Query
getLockOptions
in class AbstractQueryImpl
LockOptions
public int executeUpdate()
Query
executeUpdate
in interface Query
public Query setLockMode(String alias, LockMode lockMode)
Query
LockOptions
.
The effect of these alias-specific LockModes is somewhat dependent on the driver/database in use. Generally
speaking, for maximum portability, this method should only be used to mark that the rows corresponding to
the given alias should be included in pessimistic locking (LockMode.PESSIMISTIC_WRITE
).setLockMode
in interface Query
alias
- a query alias, or "this"
for a collection filterlockMode
- The lock mode to apply.this
, for method chainingQuery.getLockOptions()
protected Map getLockModes()
public org.hibernate.search.filter.FullTextFilter enableFullTextFilter(String name)
FullTextQuery
enableFullTextFilter
in interface FullTextQuery
name
- the name of the filter to enableFullTextFilter
object that allows filter parameter injectionpublic void disableFullTextFilter(String name)
FullTextQuery
disableFullTextFilter
in interface FullTextQuery
name
- the name of the filter to disable.public org.hibernate.search.query.engine.spi.FacetManager getFacetManager()
getFacetManager
in interface FullTextQuery
public FullTextQuery setTimeout(int timeout)
BasicQueryContract
setTimeout
in interface BasicQueryContract
setTimeout
in interface Query
setTimeout
in class AbstractQueryImpl
timeout
- the timeout in secondsthis
, for method chainingBasicQueryContract.getTimeout()
public FullTextQuery setTimeout(long timeout, TimeUnit timeUnit)
FullTextQuery
QueryTimeoutException
is raised.setTimeout
in interface FullTextQuery
timeout
- time out periodtimeUnit
- time out unitthis
to allow method chainingpublic FullTextQuery limitExecutionTimeTo(long timeout, TimeUnit timeUnit)
FullTextQuery
FullTextQuery.hasPartialResults()
returns true.limitExecutionTimeTo
in interface FullTextQuery
timeout
- time out periodtimeUnit
- time out unitthis
to allow method chainingpublic boolean hasPartialResults()
FullTextQuery
hasPartialResults
in interface FullTextQuery
FullTextQuery.limitExecutionTimeTo(long, java.util.concurrent.TimeUnit)
}, returns true
if partial results are returned (ie if the time limit has been reached
and the result fetching process has been terminated.public FullTextQuery initializeObjectsWith(org.hibernate.search.query.ObjectLookupMethod lookupMethod, org.hibernate.search.query.DatabaseRetrievalMethod retrievalMethod)
FullTextQuery
initializeObjectsWith
in interface FullTextQuery
lookupMethod
- the lookuip strategyretrievalMethod
- the retrieval strategythis
to allow method chainingCopyright © 2016 JBoss by Red Hat. All rights reserved.