org.hibernate.search.query.engine.impl

## Class AbstractHSQuery

- java.lang.Object
- - org.hibernate.search.query.engine.impl.AbstractHSQuery

- All Implemented Interfaces:
    Serializable, ProjectionConstants, HSQuery
  Direct Known Subclasses:
    ElasticsearchHSQueryImpl, LuceneHSQuery

      public abstract class AbstractHSQuery
      extends Object
      implements HSQuery, Serializable

  Base class for `HSQuery` implementations, exposing basic state needed by all implementations.
  Author:
    Gunnar Morling
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    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 IndexedTypeSet` | `indexedTargetedEntities`
    `protected Integer` | `maxResults`
    `protected String[]` | `projectedFields`
    `protected Sort` | `sort`
    `protected String` | `spatialFieldName`
    `protected Coordinates` | `spatialSearchCenter`
    `protected IndexedTypeSet` | `targetedEntities`
    `protected String` | `tenantId`
    `protected TimeoutExceptionFactory` | `timeoutExceptionFactory`
    `protected TimeoutManagerImpl` | `timeoutManager`
    `protected Filter` | `userFilter` User specified filters.

    - ### Fields inherited from interface org.hibernate.search.engine.ProjectionConstants

      `DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, SPATIAL_DISTANCE, THIS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator, IndexedTypeMap<CustomTypeMetadata> types)`
    `AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator, IndexedTypeSet types)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterDeserialise(SearchIntegrator extendedIntegrator)` afterDeserialise.
    `protected Map<FacetingRequest,FacetMetadata>` | `buildFacetingRequestsAndMetadata(Collection<FacetingRequest> facetingRequests, Iterable<EntityIndexBinding> targetedEntityBindings)`
    `protected Map<String,EntityIndexBinding>` | `buildTargetedEntityIndexBindingsByName()`
    `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(Filter filter)` Deprecated.
    `HSQuery` | `firstResult(int firstResult)` Set the first element to retrieve.
    `protected Optional<CustomTypeMetadata>` | `getCustomTypeMetadata(IndexedTypeIdentifier target)`
    `ExtendedSearchIntegrator` | `getExtendedSearchIntegrator()` getExtendedSearchIntegrator.
    `IndexedTypeSet` | `getIndexedTargetedEntities()` Set of indexed entities corresponding to the class hierarchy of the targeted entities
    `protected Set<IndexManager>` | `getIndexManagers(EntityIndexBinding binding)`
    `String[]` | `getProjectedFields()`
    `protected abstract Set<String>` | `getSupportedProjectionConstants()`
    `IndexedTypeSet` | `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(Sort sort)` Lets Lucene sort the results.
    `HSQuery` | `tenantIdentifier(String tenantId)`
    `HSQuery` | `timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)` Define the timeout exception factory to customize the exception returned by the user.
    `protected void` | `validateSortFields(Iterable<EntityIndexBinding> targetedBindings)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.hibernate.search.query.engine.spi.HSQuery

      `explain, getFacetManager, getLuceneQuery, getQueryString, luceneQuery, queryDocumentExtractor, queryEntityInfos, queryResultSize`

- - ### Field Detail

    - #### HSEARCH_PROJECTION_FIELD_PREFIX

          public static final String HSEARCH_PROJECTION_FIELD_PREFIX

      Common prefix shared by all defined projection constants.
      See Also:
        Constant Field Values

    - #### extendedIntegrator

          protected transient ExtendedSearchIntegrator extendedIntegrator

    - #### timeoutExceptionFactory

          protected transient TimeoutExceptionFactory timeoutExceptionFactory

    - #### timeoutManager

          protected transient TimeoutManagerImpl timeoutManager

    - #### targetedEntities

          protected final IndexedTypeSet targetedEntities

    - #### indexedTargetedEntities

          protected final IndexedTypeSet indexedTargetedEntities

    - #### sort

          protected Sort sort

    - #### tenantId

          protected String tenantId

    - #### projectedFields

          protected String[] projectedFields

    - #### hasThisProjection

          protected boolean hasThisProjection

    - #### firstResult

          protected int firstResult

    - #### maxResults

          protected Integer maxResults

    - #### spatialSearchCenter

          protected Coordinates spatialSearchCenter

    - #### spatialFieldName

          protected String spatialFieldName

    - #### userFilter

          protected Filter userFilter

      User specified filters. Will be combined into a single chained filter `filter(org.apache.lucene.search.Filter)`.

    - #### filterDefinitions

          protected final Map<String,FullTextFilterImpl> filterDefinitions

      The map of currently active/enabled filters.

  - ### Constructor Detail

    - #### AbstractHSQuery

          public AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator,
                                 IndexedTypeSet types)

    - #### AbstractHSQuery

          public AbstractHSQuery(ExtendedSearchIntegrator extendedIntegrator,
                                 IndexedTypeMap<CustomTypeMetadata> types)

  - ### Method Detail

    - #### afterDeserialise

          public void afterDeserialise(SearchIntegrator extendedIntegrator)

      Description copied from interface: `HSQuery`

      afterDeserialise.

      Specified by:
        `afterDeserialise` in interface `HSQuery`
      Parameters:
        `extendedIntegrator` - a `SearchIntegrator` object.

    - #### setSpatialParameters

          public HSQuery setSpatialParameters(Coordinates center,
                                              String fieldName)

      Description copied from interface: `HSQuery`

      setSpatialParameters.

      Specified by:
        `setSpatialParameters` in interface `HSQuery`
      Parameters:
        `center` - center of the spatial search
        `fieldName` - name ot the spatial field
      Returns:
        `this` to allow for method chaining

    - #### tenantIdentifier

          public HSQuery tenantIdentifier(String tenantId)

      Specified by:
        `tenantIdentifier` in interface `HSQuery`

    - #### getCustomTypeMetadata

          protected final Optional<CustomTypeMetadata> getCustomTypeMetadata(IndexedTypeIdentifier target)

    - #### sort

          public HSQuery sort(Sort sort)

      Description copied from interface: `HSQuery`
      Lets Lucene sort the results. This is useful when you have different sort requirements than the default Lucene ranking. Without Lucene sorting you would have to retrieve the full result set and order the Hibernate objects.
      Specified by:
        `sort` in interface `HSQuery`
      Parameters:
        `sort` - The Lucene sort object.
      Returns:
        `this` to allow for method chaining

    - #### filter

          @Deprecated
          public HSQuery filter(Filter filter)

      Deprecated.
      Description copied from interface: `HSQuery`
      Allows to use lucene filters.
      Specified by:
        `filter` in interface `HSQuery`
      Parameters:
        `filter` - The Lucene filter.
      Returns:
        `this` to allow for method chaining

    - #### timeoutExceptionFactory

          public HSQuery timeoutExceptionFactory(TimeoutExceptionFactory exceptionFactory)

      Description copied from interface: `HSQuery`
      Define the timeout exception factory to customize the exception returned by the user. Defaults to returning `QueryTimeoutException`
      Specified by:
        `timeoutExceptionFactory` in interface `HSQuery`
      Parameters:
        `exceptionFactory` - the timeout exception factory to use
      Returns:
        `this` to allow for method chaining

    - #### projection

          public HSQuery projection(String... fields)

      Description copied from interface: `HSQuery`
      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).

      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[]

      Specified by:
        `projection` in interface `HSQuery`
      Parameters:
        `fields` - the projected field names
      Returns:
        `this` to allow for method chaining

    - #### firstResult

          public HSQuery firstResult(int firstResult)

      Description copied from interface: `HSQuery`
      Set the first element to retrieve. If not set, elements will be retrieved beginning from element `0`.
      Specified by:
        `firstResult` in interface `HSQuery`
      Parameters:
        `firstResult` - a element number, numbered from `0`
      Returns:
        `this` to allow for method chaining

    - #### maxResults

          public HSQuery maxResults(int maxResults)

      Description copied from interface: `HSQuery`
      Set the maximum number of elements to retrieve. If not set, there is no limit to the number of elements retrieved.
      Specified by:
        `maxResults` in interface `HSQuery`
      Parameters:
        `maxResults` - the maximum number of elements
      Returns:
        `this` in order to allow method chaining

    - #### enableFullTextFilter

          public FullTextFilter enableFullTextFilter(String name)

      Description copied from interface: `HSQuery`
      Enable a given filter by its name.
      Specified by:
        `enableFullTextFilter` in interface `HSQuery`
      Parameters:
        `name` - the name of the filter to enable
      Returns:
        Returns a `FullTextFilter` object that allows filter parameter injection

    - #### disableFullTextFilter

          public void disableFullTextFilter(String name)

      Description copied from interface: `HSQuery`
      Disable a given filter by its name.
      Specified by:
        `disableFullTextFilter` in interface `HSQuery`
      Parameters:
        `name` - the name of the filter to disable.

    - #### createFilterInstance

          protected Object createFilterInstance(FullTextFilterImpl fullTextFilter,
                                                FilterDef def)

    - #### isPreQueryFilterOnly

          protected boolean isPreQueryFilterOnly(FilterDef def)

    - #### getTargetedEntities

          public IndexedTypeSet getTargetedEntities()

      List of targeted entities as described by the user
      Specified by:
        `getTargetedEntities` in interface `HSQuery`
      Returns:
        the targeted entity types

    - #### getIndexedTargetedEntities

          public IndexedTypeSet getIndexedTargetedEntities()

      Set of indexed entities corresponding to the class hierarchy of the targeted entities
      Specified by:
        `getIndexedTargetedEntities` in interface `HSQuery`
      Returns:
        a set of indexed entities corresponding to the class hierarchy of the targeted entities

    - #### getProjectedFields

          public String[] getProjectedFields()

      Specified by:
        `getProjectedFields` in interface `HSQuery`
      Returns:
        the projected field names

    - #### hasThisProjection

          public boolean hasThisProjection()

      Specified by:
        `hasThisProjection` in interface `HSQuery`
      Returns:
        `true` if the projected field names contain the `ProjectionConstants.THIS` constant.

    - #### getTimeoutManager

          public TimeoutManagerImpl getTimeoutManager()

      Specified by:
        `getTimeoutManager` in interface `HSQuery`
      Returns:
        the timeout manager. Make sure to wrap your HSQuery usage around a `timeoutManager.start()` and `timeoutManager.stop()`.

    - #### getExtendedSearchIntegrator

          public ExtendedSearchIntegrator getExtendedSearchIntegrator()

      Description copied from interface: `HSQuery`

      getExtendedSearchIntegrator.

      Specified by:
        `getExtendedSearchIntegrator` in interface `HSQuery`
      Returns:
        the `ExtendedSearchIntegrator` instance

    - #### getSupportedProjectionConstants

          protected abstract Set<String> getSupportedProjectionConstants()

      Returns:
        the names of the projection constants supported by a specific implementation in addition to projecting actual field values. If a given projection name begins with `HSEARCH_PROJECTION_FIELD_PREFIX` and is not part of the set of constants returned by an implementation, an exception will be raised.

    - #### validateSortFields

          protected void validateSortFields(Iterable<EntityIndexBinding> targetedBindings)

    - #### buildTargetedEntityIndexBindingsByName

          protected final Map<String,EntityIndexBinding> buildTargetedEntityIndexBindingsByName()

    - #### buildFacetingRequestsAndMetadata

          protected final Map<FacetingRequest,FacetMetadata> buildFacetingRequestsAndMetadata(Collection<FacetingRequest> facetingRequests,
                                                                                              Iterable<EntityIndexBinding> targetedEntityBindings)

    - #### getIndexManagers

          protected Set<IndexManager> getIndexManagers(EntityIndexBinding binding)

    - #### extractFacetResults

          protected abstract void extractFacetResults()

    - #### clearCachedResults

          protected abstract void clearCachedResults()

    - #### buildTimeoutManager

          protected abstract TimeoutManagerImpl buildTimeoutManager()

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved