Interface HSQuery

  • All Superinterfaces:
    ProjectionConstants

    @Deprecated
    public interface HSQuery
    extends ProjectionConstants
    Deprecated.
    This class will be removed without replacement. Use actual API instead.
    Defines and executes an Hibernate Search query (wrapping a Lucene query). Uses fluent APIs to define the query and offer a few alternatives on how to execute the query. This object is not meant to be thread safe. The typical usage is as follow
      //get query object
     HSQuery query = searchIntegrator.createHSQuery();
     //configure query object
     query
     .luceneQuery( luceneQuery )
     .timeoutExceptionFactory( exceptionFactory )
     .targetedEntities( Arrays.asList( classes ) );
    
     [...]
    
     //start timeout counting
     query.getTimeoutManager().start();
    
     //query execution and use
     List<EntityInfo> entityInfos = query.getEntityInfos();
     [...]
    
     //done with the core of the query
     query.getTimeoutManager().stop();
     
     
    Author:
    Emmanuel Bernard
    • Method Detail

      • sort

        HSQuery sort​(Sort sort)
        Deprecated.
        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.
        Parameters:
        sort - The Lucene sort object.
        Returns:
        this to allow for method chaining
      • projection

        HSQuery projection​(String... fields)
        Deprecated.
        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 two-way field bridge 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 projected field names
        Returns:
        this to allow for method chaining
      • firstResult

        HSQuery firstResult​(int firstResult)
        Deprecated.
        Set the first element to retrieve. If not set, elements will be retrieved beginning from element 0.
        Parameters:
        firstResult - a element number, numbered from 0
        Returns:
        this to allow for method chaining
      • maxResults

        HSQuery maxResults​(Integer maxResults)
        Deprecated.
        Set the maximum number of elements to retrieve. If not set, there is no limit to the number of elements retrieved.
        Parameters:
        maxResults - the maximum number of elements
        Returns:
        this in order to allow method chaining
      • getTargetedEntities

        Set<Class<?>> getTargetedEntities()
        Deprecated.
        Returns:
        the targeted entity types
      • getProjectedFields

        String[] getProjectedFields()
        Deprecated.
        Returns:
        the projected field names
      • getFacetManager

        FacetManager getFacetManager()
        Deprecated.
        Returns:
        return the manager for all faceting related operations
      • getLuceneQuery

        Query getLuceneQuery()
        Deprecated.
        Returns:
        the underlying Lucene query (if any)
      • getQueryString

        String getQueryString()
        Deprecated.
        Returns:
        a String representation of the underlying query
      • fetch

        List<?> fetch()
        Deprecated.
        Execute the Lucene query and return the hits.
        Returns:
        list of hits.
      • hasPartialResults

        boolean hasPartialResults()
        Deprecated.
        Returns:
        true if the last call to fetch() returned a truncated list of hits, false otherwise.
      • getResultSize

        int getResultSize()
        Deprecated.
        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.

      • scroll

        SearchScroll<?> scroll​(int chunkSize)
        Deprecated.
        Execute the Lucene query continuously, as a SearchScroll.
        Parameters:
        chunkSize - The size of chunks.
        Returns:
        the scroll (must eventually be closed).
      • explain

        Explanation explain​(Object entityId)
        Deprecated.
        Return the Lucene Explanation object describing the score computation for the matching object/document in the current query
        Parameters:
        entityId - The identifier of the entity whose match should be explained.
        Returns:
        Lucene Explanation
      • setSpatialParameters

        HSQuery setSpatialParameters​(Coordinates center,
                                     String fieldName)
        Deprecated.

        setSpatialParameters.

        Parameters:
        center - center of the spatial search
        fieldName - name ot the spatial field
        Returns:
        this to allow for method chaining