public abstract class AbstractHSQuery extends Object implements HSQuery, Serializable
HSQuery implementations, exposing basic state needed by all implementations.| Modifier and Type | Field and Description |
|---|---|
protected ExtendedSearchIntegrator |
extendedIntegrator |
protected Map<String,FullTextFilterImpl> |
filterDefinitions
The map of currently active/enabled filters.
|
protected int |
firstResult |
protected boolean |
hasThisProjection |
static String |
HSEARCH_PROJECTION_FIELD_PREFIX
Common prefix shared by all defined projection constants.
|
protected Set<Class<?>> |
indexedTargetedEntities |
protected Integer |
maxResults |
protected String[] |
projectedFields |
protected org.apache.lucene.search.Sort |
sort |
protected String |
spatialFieldName |
protected Coordinates |
spatialSearchCenter |
protected List<Class<?>> |
targetedEntities |
protected String |
tenantId |
protected TimeoutExceptionFactory |
timeoutExceptionFactory |
protected TimeoutManagerImpl |
timeoutManager |
protected org.apache.lucene.search.Filter |
userFilter
User specified filters.
|
DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, SPATIAL_DISTANCE, THIS| Constructor and Description |
|---|
AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterDeserialise(SearchIntegrator extendedIntegrator)
afterDeserialise.
|
protected abstract TimeoutManagerImpl |
buildTimeoutManager() |
protected abstract void |
clearCachedResults() |
protected Object |
createFilterInstance(FullTextFilterImpl fullTextFilter,
FilterDef def) |
void |
disableFullTextFilter(String name)
Disable a given filter by its name.
|
FullTextFilter |
enableFullTextFilter(String name)
Enable a given filter by its name.
|
protected abstract void |
extractFacetResults() |
HSQuery |
filter(org.apache.lucene.search.Filter filter)
Allows to use lucene filters.
|
HSQuery |
firstResult(int firstResult)
Set the first element to retrieve.
|
protected Optional<CustomTypeMetadata> |
getCustomTypeMetadata(Class<?> clazz) |
ExtendedSearchIntegrator |
getExtendedSearchIntegrator()
getExtendedSearchIntegrator.
|
Set<Class<?>> |
getIndexedTargetedEntities()
Set of indexed entities corresponding to the class hierarchy of the targeted entities
|
protected List<IndexManager> |
getIndexManagers(EntityIndexBinding binding) |
String[] |
getProjectedFields() |
protected abstract Set<String> |
getSupportedProjectionConstants()
Returns the names of the projection constants supported by a specific implementation in addition to projecting
actual field values.
|
List<Class<?>> |
getTargetedEntities()
List of targeted entities as described by the user
|
TimeoutManagerImpl |
getTimeoutManager() |
boolean |
hasThisProjection() |
protected boolean |
isPreQueryFilterOnly(FilterDef def) |
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).
|
HSQuery |
setSpatialParameters(Coordinates center,
String fieldName)
setSpatialParameters.
|
HSQuery |
sort(org.apache.lucene.search.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.
|
protected void |
validateSortFields(ExtendedSearchIntegrator extendedIntegrator,
Iterable<Class<?>> targetedEntities) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexplain, getFacetManager, getLuceneQuery, getQueryString, luceneQuery, queryDocumentExtractor, queryEntityInfos, queryResultSizepublic static final String HSEARCH_PROJECTION_FIELD_PREFIX
protected transient ExtendedSearchIntegrator extendedIntegrator
protected transient TimeoutExceptionFactory timeoutExceptionFactory
protected transient TimeoutManagerImpl timeoutManager
protected org.apache.lucene.search.Sort sort
protected String tenantId
protected String[] projectedFields
protected boolean hasThisProjection
protected int firstResult
protected Integer maxResults
protected Coordinates spatialSearchCenter
protected String spatialFieldName
protected org.apache.lucene.search.Filter userFilter
filter(org.apache.lucene.search.Filter).protected final Map<String,FullTextFilterImpl> filterDefinitions
public AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator)
public void afterDeserialise(SearchIntegrator extendedIntegrator)
HSQueryafterDeserialise.
afterDeserialise in interface HSQueryextendedIntegrator - a SearchIntegrator object.public HSQuery setSpatialParameters(Coordinates center, String fieldName)
HSQuerysetSpatialParameters.
setSpatialParameters in interface HSQuerycenter - center of the spatial searchfieldName - name ot the spatial fieldthis to allow for method chainingpublic HSQuery tenantIdentifier(String tenantId)
tenantIdentifier in interface HSQuerypublic final HSQuery targetedEntities(List<Class<?>> classes)
HSQueryNote: calling this method is not necessary if you obtained the HSQuery through
SearchIntegrator.createHSQuery(Query, Class...), unless you want to change the targeted
entities.
targetedEntities in interface HSQueryclasses - the list of classes (indexes) targeted by this querythis to allow for method chainingpublic final HSQuery targetedTypes(List<CustomTypeMetadata> types)
HSQueryNote: calling this method is not necessary if you obtained the HSQuery through
SearchIntegrator.createHSQuery(Query, CustomTypeMetadata...), unless you want to change the
targeted types.
targetedTypes in interface HSQuerytypes - the list of types (indexes) targeted by this querythis to allow for method chainingprotected final Optional<CustomTypeMetadata> getCustomTypeMetadata(Class<?> clazz)
public HSQuery sort(org.apache.lucene.search.Sort sort)
HSQuerypublic HSQuery filter(org.apache.lucene.search.Filter filter)
HSQuerypublic HSQuery timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)
HSQueryQueryTimeoutExceptiontimeoutExceptionFactory in interface HSQueryexceptionFactory - the timeout exception factory to usethis to allow for method chainingpublic HSQuery projection(String... fields)
HSQuery
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[]
projection in interface HSQueryfields - the projected field namesthis to allow for method chainingpublic HSQuery firstResult(int firstResult)
HSQueryfirstResult in interface HSQueryfirstResult - a element number, numbered from 0this to allow for method chainingpublic HSQuery maxResults(int maxResults)
HSQuerymaxResults in interface HSQuerymaxResults - the maximum number of elementsthis in order to allow method chainingpublic FullTextFilter enableFullTextFilter(String name)
HSQueryenableFullTextFilter in interface HSQueryname - the name of the filter to enableFullTextFilter object that allows filter parameter injectionpublic void disableFullTextFilter(String name)
HSQuerydisableFullTextFilter in interface HSQueryname - the name of the filter to disable.protected Object createFilterInstance(FullTextFilterImpl fullTextFilter, FilterDef def)
protected boolean isPreQueryFilterOnly(FilterDef def)
public List<Class<?>> getTargetedEntities()
getTargetedEntities in interface HSQuerypublic Set<Class<?>> getIndexedTargetedEntities()
getIndexedTargetedEntities in interface HSQuerypublic String[] getProjectedFields()
getProjectedFields in interface HSQuerypublic boolean hasThisProjection()
hasThisProjection in interface HSQuerytrue if the projected field names contain the
ProjectionConstants.THIS constant.public TimeoutManagerImpl getTimeoutManager()
getTimeoutManager in interface HSQuerytimeoutManager.start() and timeoutManager.stop().public ExtendedSearchIntegrator getExtendedSearchIntegrator()
HSQuerygetExtendedSearchIntegrator.
getExtendedSearchIntegrator in interface HSQueryExtendedSearchIntegrator instanceprotected abstract Set<String> getSupportedProjectionConstants()
HSEARCH_PROJECTION_FIELD_PREFIX and is not
part of the set of constants returned by an implementation, an exception will be raised.protected void validateSortFields(ExtendedSearchIntegrator extendedIntegrator, Iterable<Class<?>> targetedEntities)
protected List<IndexManager> getIndexManagers(EntityIndexBinding binding)
protected abstract void extractFacetResults()
protected abstract void clearCachedResults()
protected abstract TimeoutManagerImpl buildTimeoutManager()
Copyright © 2006–2017 Hibernate. All rights reserved.