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
|
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, wait
explain, getFacetManager, getLuceneQuery, getQueryString, luceneQuery, queryDocumentExtractor, queryEntityInfos, queryResultSize
public 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)
HSQuery
afterDeserialise.
afterDeserialise
in interface HSQuery
extendedIntegrator
- a SearchIntegrator
object.public HSQuery setSpatialParameters(Coordinates center, String fieldName)
HSQuery
setSpatialParameters.
setSpatialParameters
in interface HSQuery
center
- center of the spatial searchfieldName
- name ot the spatial fieldthis
to allow for method chainingpublic HSQuery tenantIdentifier(String tenantId)
tenantIdentifier
in interface HSQuery
public final HSQuery targetedEntities(List<Class<?>> classes)
HSQuery
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.
targetedEntities
in interface HSQuery
classes
- the list of classes (indexes) targeted by this querythis
to allow for method chainingpublic final HSQuery targetedTypes(List<CustomTypeMetadata> types)
HSQuery
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.
targetedTypes
in interface HSQuery
types
- 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)
HSQuery
public HSQuery filter(org.apache.lucene.search.Filter filter)
HSQuery
public HSQuery timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)
HSQuery
QueryTimeoutException
timeoutExceptionFactory
in interface HSQuery
exceptionFactory
- 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 HSQuery
fields
- the projected field namesthis
to allow for method chainingpublic HSQuery firstResult(int firstResult)
HSQuery
firstResult
in interface HSQuery
firstResult
- a element number, numbered from 0this
to allow for method chainingpublic HSQuery maxResults(int maxResults)
HSQuery
maxResults
in interface HSQuery
maxResults
- the maximum number of elementsthis
in order to allow method chainingpublic FullTextFilter enableFullTextFilter(String name)
HSQuery
enableFullTextFilter
in interface HSQuery
name
- the name of the filter to enableFullTextFilter
object that allows filter parameter injectionpublic void disableFullTextFilter(String name)
HSQuery
disableFullTextFilter
in interface HSQuery
name
- 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 HSQuery
public Set<Class<?>> getIndexedTargetedEntities()
getIndexedTargetedEntities
in interface HSQuery
public String[] getProjectedFields()
getProjectedFields
in interface HSQuery
public boolean hasThisProjection()
hasThisProjection
in interface HSQuery
true
if the projected field names contain the
ProjectionConstants.THIS
constant.public TimeoutManagerImpl getTimeoutManager()
getTimeoutManager
in interface HSQuery
timeoutManager.start()
and timeoutManager.stop()
.public ExtendedSearchIntegrator getExtendedSearchIntegrator()
HSQuery
getExtendedSearchIntegrator.
getExtendedSearchIntegrator
in interface HSQuery
ExtendedSearchIntegrator
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 abstract void extractFacetResults()
protected abstract void clearCachedResults()
protected abstract TimeoutManagerImpl buildTimeoutManager()
Copyright © 2006–2017 Hibernate. All rights reserved.