public interface HSQuery extends ProjectionConstants
//get query object
HSQuery query = searchIntegrator.createHSQuery();
//configure query object
query
.luceneQuery( luceneQuery )
.timeoutExceptionFactory( exceptionFactory )
.targetedEntities( Arrays.asList( classes ) );
[...]
//start timeout counting
query.getTimeoutManager().start();
//query execution and use
List<EntityInfo> entityInfos = query.getEntityInfos();
[...]
//done with the core of the query
query.getTimeoutManager().stop();
DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, SPATIAL_DISTANCE, THIS
Modifier and Type | Method and Description |
---|---|
void |
afterDeserialise(SearchIntegrator integrator)
afterDeserialise.
|
void |
disableFullTextFilter(String name)
Disable a given filter by its name.
|
FullTextFilter |
enableFullTextFilter(String name)
Enable a given filter by its name.
|
Explanation |
explain(int documentId)
Return the Lucene
Explanation
object describing the score computation for the matching object/document
in the current query |
HSQuery |
filter(Filter filter)
Allows to use lucene filters.
|
HSQuery |
firstResult(int firstResult)
Set the first element to retrieve.
|
ExtendedSearchIntegrator |
getExtendedSearchIntegrator()
Deprecated.
should be at most SearchIntegrator, preferably removed altogether
|
FacetManager |
getFacetManager() |
Set<Class<?>> |
getIndexedTargetedEntities() |
Query |
getLuceneQuery() |
String[] |
getProjectedFields() |
String |
getQueryString() |
List<Class<?>> |
getTargetedEntities() |
TimeoutManager |
getTimeoutManager() |
boolean |
hasThisProjection() |
HSQuery |
luceneQuery(Query query)
Defines the underlying Lucene query
|
HSQuery |
maxResults(int maxResults)
Set the maximum number of elements to retrieve.
|
HSQuery |
projection(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).
|
DocumentExtractor |
queryDocumentExtractor()
Execute the Lucene query and return a traversable object over the results.
|
List<EntityInfo> |
queryEntityInfos()
Execute the Lucene query and return the list of
EntityInfo s populated with
metadata and projection. |
int |
queryResultSize() |
HSQuery |
setSpatialParameters(Coordinates center,
String fieldName)
setSpatialParameters.
|
HSQuery |
sort(Sort sort)
Lets Lucene sort the results.
|
HSQuery |
targetedEntities(List<Class<?>> classes)
Defines the targeted entities.
|
HSQuery |
targetedTypes(List<CustomTypeMetadata> types)
Defines the targeted types, which may carry custom metadata which should override the supporting entity type's metadata.
|
HSQuery |
tenantIdentifier(String tenantId) |
HSQuery |
timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)
Define the timeout exception factory to customize the exception returned by the user.
|
HSQuery luceneQuery(Query query)
query
- the Lucene querythis
to allow method chainingHSQuery targetedEntities(List<Class<?>> classes)
Note: calling this method is not necessary if you obtained the HSQuery through
SearchIntegrator.createHSQuery(Query, Class...)
, unless you want to change the targeted
entities.
classes
- the list of classes (indexes) targeted by this querythis
to allow for method chainingHSQuery targetedTypes(List<CustomTypeMetadata> types)
Note: calling this method is not necessary if you obtained the HSQuery through
SearchIntegrator.createHSQuery(Query, CustomTypeMetadata...)
, unless you want to change the
targeted types.
types
- the list of types (indexes) targeted by this querythis
to allow for method chainingHSQuery sort(Sort sort)
sort
- The Lucene sort object.this
to allow for method chainingHSQuery filter(Filter filter)
filter
- The Lucene filter.this
to allow for method chainingHSQuery timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)
QueryTimeoutException
exceptionFactory
- the timeout exception factory to usethis
to allow for method chainingHSQuery projection(String... fields)
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[]
fields
- the projected field namesthis
to allow for method chainingHSQuery firstResult(int firstResult)
firstResult
- a element number, numbered from 0this
to allow for method chainingHSQuery maxResults(int maxResults)
maxResults
- the maximum number of elementsthis
in order to allow method chainingSet<Class<?>> getIndexedTargetedEntities()
String[] getProjectedFields()
boolean hasThisProjection()
true
if the projected field names contain the
ProjectionConstants.THIS
constant.TimeoutManager getTimeoutManager()
timeoutManager.start()
and timeoutManager.stop()
.FacetManager getFacetManager()
Query getLuceneQuery()
String getQueryString()
List<EntityInfo> queryEntityInfos()
EntityInfo
s populated with
metadata and projection. ProjectionConstants.THIS
if projected is not populated.
It is the responsibility of the object source integration.EntityInfo
s populated with metadata and projectionDocumentExtractor queryDocumentExtractor()
ProjectionConstants.THIS
if projected is not populated. It is the responsibility
of the object source integration.
The returned DocumentExtractor
must be closed by the caller to release Lucene resources.DocumentExtractor
instanceint queryResultSize()
Caution: The number of results might be slightly different from what the object source returns if the index is not in sync with the store at the time of query.
Explanation explain(int documentId)
Explanation
object describing the score computation for the matching object/document
in the current querydocumentId
- Lucene Document id to be explain. This is NOT the object idFullTextFilter enableFullTextFilter(String name)
name
- the name of the filter to enableFullTextFilter
object that allows filter parameter injectionvoid disableFullTextFilter(String name)
name
- the name of the filter to disable.@Deprecated ExtendedSearchIntegrator getExtendedSearchIntegrator()
getExtendedSearchIntegrator.
ExtendedSearchIntegrator
instancevoid afterDeserialise(SearchIntegrator integrator)
afterDeserialise.
integrator
- a SearchIntegrator
object.HSQuery setSpatialParameters(Coordinates center, String fieldName)
setSpatialParameters.
center
- center of the spatial searchfieldName
- name ot the spatial fieldthis
to allow for method chainingCopyright © 2006-2017 Red Hat, Inc. All Rights Reserved