org.hibernate.search.jpa

## Interface FullTextQuery

- All Superinterfaces:
    ProjectionConstants, javax.persistence.Query
  All Known Subinterfaces:
    FullTextQuery
  All Known Implementing Classes:
    FullTextQueryImpl

      public interface FullTextQuery
      extends javax.persistence.Query, ProjectionConstants

  The base interface for full-text queries using the JPA API (`Query`).
  Author:
    Hardy Ferentschik, Emmanuel Bernard

- - ### Field Summary

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

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

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `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
    `FacetManager` | `getFacetManager()`
    `int` | `getResultSize()` Returns the number of hits for this search Caution: The number of results might be slightly different from `getResultList().size()` because getResultList() may be not in sync with the database at the time of query.
    `boolean` | `hasPartialResults()`
    `FullTextQuery` | `initializeObjectsWith(ObjectLookupMethod lookupMethod, DatabaseRetrievalMethod retrievalMethod)` Refine the strategies used to load entities.
    `FullTextQuery` | `limitExecutionTimeTo(long timeout, TimeUnit timeUnit)` Limit the time used by Hibernate Search to execute the query.
    `FullTextQuery` | `setCriteriaQuery(Criteria criteria)` Defines the Database Query used to load the Lucene results.
    `FullTextQuery` | `setFilter(Filter filter)` Deprecated.
    `FullTextQuery` | `setFirstResult(int var1)`
    `FullTextQuery` | `setFlushMode(javax.persistence.FlushModeType flushMode)`
    `FullTextQuery` | `setHint(String hintName, Object value)`
    `FullTextQuery` | `setMaxResults(int maxResult)`
    `FullTextQuery` | `setProjection(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).
    `FullTextQuery` | `setResultTransformer(ResultTransformer transformer)` Defines a result transformer used during projection
    `FullTextQuery` | `setSort(Sort sort)` Allows to let lucene sort the results.
    `FullTextQuery` | `setSpatialParameters(Coordinates center, String fieldName)` Defines the center of the spatial search for this query to project distance in results
    `FullTextQuery` | `setSpatialParameters(double latitude, double longitude, String fieldName)` Defines the center of the spatial search for this query to project distance in results
    `FullTextQuery` | `setTimeout(long timeout, TimeUnit timeUnit)` Define a timeout period for a given unit of time.

    - ### Methods inherited from interface javax.persistence.Query

      `executeUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getResultList, getSingleResult, isBound, setLockMode, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, unwrap`

- - ### Method Detail

    - #### setSort

          FullTextQuery setSort(Sort sort)

      Allows to let lucene sort the results. This is useful when you have additional sort requirements on top of the default lucene ranking. Without lucene sorting you would have to retrieve the full result set and order the hibernate objects.
      Parameters:
        `sort` - The lucene sort object.
      Returns:
        this for method chaining

    - #### setFilter

          @Deprecated
          FullTextQuery setFilter(Filter filter)

      Deprecated.
      Allows to set a single Lucene filter.
      Parameters:
        `filter` - The Lucene filter.
      Returns:
        this for method chaining
      See Also:
        `Filter`

    - #### getResultSize

          int getResultSize()

      Returns the number of hits for this search Caution: The number of results might be slightly different from `getResultList().size()` because getResultList() may be not in sync with the database at the time of query.
      Returns:
        the number of hits for this search

    - #### setCriteriaQuery

          FullTextQuery setCriteriaQuery(Criteria criteria)

      Defines the Database Query used to load the Lucene results. Useful to load a given object graph by refining the fetch modes No projection (criteria.setProjection() ) allowed, the root entity must be the only returned type No where restriction can be defined either.
      Parameters:
        `criteria` - a query defined using `Criteria`
      Returns:
        `this` for method chaining

    - #### setProjection

          FullTextQuery setProjection(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). 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[]
      Parameters:
        `fields` - the fields to use for projection
      Returns:
        `this` for method chaining

    - #### setSpatialParameters

          FullTextQuery setSpatialParameters(double latitude,
                                             double longitude,
                                             String fieldName)

      Defines the center of the spatial search for this query to project distance in results
      Parameters:
        `latitude` - latitude of the search center
        `longitude` - longitude of the search center
        `fieldName` - name of the spatial field
      Returns:
        `this` for method chaining

    - #### setSpatialParameters

          FullTextQuery setSpatialParameters(Coordinates center,
                                             String fieldName)

      Defines the center of the spatial search for this query to project distance in results
      Parameters:
        `center` - the search center
        `fieldName` - name of the spatial field
      Returns:
        `this` for method chaining

    - #### enableFullTextFilter

          FullTextFilter enableFullTextFilter(String name)

      Enable a given filter by its name.
      Parameters:
        `name` - the name of the filter
      Returns:
        a `FullTextFilter` object that allows filter parameter injection

    - #### disableFullTextFilter

          void disableFullTextFilter(String name)

      Disable a given filter by its name
      Parameters:
        `name` - the filter nane

    - #### getFacetManager

          FacetManager getFacetManager()

      Returns:
        return the manager for all faceting related operations

    - #### setResultTransformer

          FullTextQuery setResultTransformer(ResultTransformer transformer)

      Defines a result transformer used during projection
      Parameters:
        `transformer` - the `ResultTransformer` to use during projection
      Returns:
        `this` for method chaining

    - #### explain

          Explanation explain(int documentId)

      Return the Lucene `Explanation` object describing the score computation for the matching object/document in the current query
      Parameters:
        `documentId` - Lucene Document id to be explain. This is NOT the object id
      Returns:
        Lucene `Explanation`

    - #### limitExecutionTimeTo

          FullTextQuery limitExecutionTimeTo(long timeout,
                                             TimeUnit timeUnit)

      Limit the time used by Hibernate Search to execute the query. When the limit is reached, results already fetched are returned. This time limit is a best effort. The query will likely run for longer than the provided time. The time limit only applies to the interactions between Hibernate Search and Lucene. In other words, a query to the database will not be limited. If the limit is reached and all results are not yet fetched, `hasPartialResults()` returns true.
      Parameters:
        `timeout` - time out period
        `timeUnit` - time out unit
      Returns:
        `this` for method chaining

    - #### hasPartialResults

          boolean hasPartialResults()

      Returns:
        When using `limitExecutionTimeTo(long, java.util.concurrent.TimeUnit)` }, returns `true` if partial results are returned (ie if the time limit has been reached and the result fetching process has been terminated.

    - #### initializeObjectsWith

          FullTextQuery initializeObjectsWith(ObjectLookupMethod lookupMethod,
                                              DatabaseRetrievalMethod retrievalMethod)

      Refine the strategies used to load entities. The lookup method defines whether or not to lookup first in the second level cache or the persistence context before trying to initialize objects from the database. Defaults to SKIP. The database retrieval method defines how objects are loaded from the database. Defaults to QUERY. Note that Hibernate Search can deviate from these choices when it makes sense.
      Parameters:
        `lookupMethod` - lookup method
        `retrievalMethod` - how to initilize an object
      Returns:
        `this` for method chaining

    - #### setMaxResults

          FullTextQuery setMaxResults(int maxResult)

      Specified by:
        `setMaxResults` in interface `javax.persistence.Query`

    - #### setFirstResult

          FullTextQuery setFirstResult(int var1)

      Specified by:
        `setFirstResult` in interface `javax.persistence.Query`

    - #### setHint

          FullTextQuery setHint(String hintName,
                                Object value)

      Specified by:
        `setHint` in interface `javax.persistence.Query`

    - #### setFlushMode

          FullTextQuery setFlushMode(javax.persistence.FlushModeType flushMode)

      Specified by:
        `setFlushMode` in interface `javax.persistence.Query`

    - #### setTimeout

          FullTextQuery setTimeout(long timeout,
                                   TimeUnit timeUnit)

      Define a timeout period for a given unit of time. Note that this is time out is on a best effort basis. When the query goes beyond the timeout, a `QueryTimeoutException` is raised.
      Parameters:
        `timeout` - time out period
        `timeUnit` - time out unit
      Returns:
        `this` to allow method chaining

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