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() |
List<Class<?>> |
getTargetedEntities() |
TimeoutManager |
getTimeoutManager() |
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
EntityInfos 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 |
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)
classes - the list of classes (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)
QueryTimeoutExceptionexceptionFactory - 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()
TimeoutManager getTimeoutManager()
timeoutManager.start() and timeoutManager.stop().FacetManager getFacetManager()
Query getLuceneQuery()
List<EntityInfo> queryEntityInfos()
EntityInfos populated with
metadata and projection. ProjectionConstants.THIS if projected is not populated.
It is the responsibility of the object source integration.EntityInfos 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