Class HSQueryImpl

java.lang.Object
org.hibernate.search.query.engine.impl.HSQueryImpl
All Implemented Interfaces:
ProjectionConstants, HSQuery

public class HSQueryImpl extends Object implements HSQuery
  • Constructor Details

  • Method Details

    • luceneQuery

      public HSQuery luceneQuery(Query query)
      Description copied from interface: HSQuery
      Defines the underlying Lucene query
      Specified by:
      luceneQuery in interface HSQuery
      Parameters:
      query - the Lucene query
      Returns:
      this to allow method chaining
    • targetedEntities

      public HSQuery targetedEntities(List<Class<?>> classes)
      Description copied from interface: HSQuery
      Defines the targeted entities. This helps to reduce the number of targeted indexes.
      Specified by:
      targetedEntities in interface HSQuery
      Parameters:
      classes - the list of classes (indexes) targeted by this query
      Returns:
      this to allow for method chaining
    • 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

      public HSQuery filter(Filter filter)
      Description copied from interface: HSQuery
      Allows to use lucene filters. Semi-deprecated? a preferred way is to use the @FullTextFilterDef approach
      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(Integer 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
    • getTargetedEntities

      public List<Class<?>> getTargetedEntities()
      List of targeted entities as described by the user
      Specified by:
      getTargetedEntities in interface HSQuery
      Returns:
      the targeted entity types
    • getIndexedTargetedEntities

      public Set<Class<?>> getIndexedTargetedEntities()
      Set of indexed entities corresponding to the class hierarchy of the targeted entities
      Specified by:
      getIndexedTargetedEntities in interface HSQuery
    • getProjectedFields

      public String[] getProjectedFields()
      Specified by:
      getProjectedFields in interface HSQuery
      Returns:
      the projected field names
    • getTimeoutManager

      public TimeoutManager 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().
    • getFacetManager

      public FacetManagerImpl getFacetManager()
      Specified by:
      getFacetManager in interface HSQuery
      Returns:
      return the manager for all faceting related operations
    • getLuceneQuery

      public Query getLuceneQuery()
      Specified by:
      getLuceneQuery in interface HSQuery
      Returns:
      the underlying Lucene query
    • queryEntityInfos

      public List<EntityInfo> queryEntityInfos()
      Description copied from interface: HSQuery
      Execute the Lucene query and return the list of EntityInfos populated with metadata and projection. ProjectionConstants.THIS if projected is
      not
      populated. It is the responsibility of the object source integration.
      Specified by:
      queryEntityInfos in interface HSQuery
      Returns:
      list of EntityInfos populated with metadata and projection
    • queryDocumentExtractor

      public DocumentExtractor queryDocumentExtractor()
      DocumentExtractor returns a traverser over the full-text results (EntityInfo) This operation is lazy bound: - the query is executed - results are not retrieved until actually requested DocumentExtractor objects *must* be closed when the results are no longer traversed.
      Specified by:
      queryDocumentExtractor in interface HSQuery
      Returns:
      the DocumentExtractor instance
    • queryResultSize

      public int queryResultSize()
      Specified by:
      queryResultSize in interface HSQuery
      Returns:
      the number of hits for this search

      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.

    • explain

      public Explanation explain(int documentId)
      Description copied from interface: HSQuery
      Return the Lucene Explanation object describing the score computation for the matching object/document in the current query
      Specified by:
      explain in interface HSQuery
      Parameters:
      documentId - Lucene Document id to be explain. This is NOT the object id
      Returns:
      Lucene Explanation
    • 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.
    • getSearchFactoryImplementor

      public SearchFactoryImplementor getSearchFactoryImplementor()
      Specified by:
      getSearchFactoryImplementor in interface HSQuery
      Returns:
      the SearchFactoryImplementor instance