Class LuceneSearchQueryImpl<H>

java.lang.Object
org.hibernate.search.engine.search.query.spi.AbstractSearchQuery<H,LuceneSearchResult<H>>
org.hibernate.search.backend.lucene.search.query.impl.LuceneSearchQueryImpl<H>
All Implemented Interfaces:
LuceneSearchFetchable<H>, LuceneSearchQuery<H>, ExtendedSearchFetchable<H,LuceneSearchResult<H>,LuceneSearchScroll<H>>, ExtendedSearchQuery<H,LuceneSearchResult<H>,LuceneSearchScroll<H>>, SearchFetchable<H>, SearchQuery<H>, SearchQueryImplementor<H>

public class LuceneSearchQueryImpl<H> extends AbstractSearchQuery<H,LuceneSearchResult<H>> implements LuceneSearchQuery<H>
  • Method Details

    • queryString

      public String queryString()
      Specified by:
      queryString in interface SearchQuery<H>
      Returns:
      A textual representation of the query.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractSearchQuery<H,LuceneSearchResult<H>>
    • extension

      public <Q> Q extension(SearchQueryExtension<Q,H> extension)
      Description copied from interface: SearchQuery
      Extend the current query with the given extension, resulting in an extended query offering more options or a more detailed result type.
      Specified by:
      extension in interface SearchQuery<H>
      Type Parameters:
      Q - The type of queries provided by the extension.
      Parameters:
      extension - The extension to the predicate DSL.
      Returns:
      The extended query.
    • fetch

      public LuceneSearchResult<H> fetch(Integer offset, Integer limit)
      Description copied from interface: SearchFetchable
      Execute the query and return the SearchResult, skipping offset hits and limiting to limit hits.
      Specified by:
      fetch in interface ExtendedSearchFetchable<H,LuceneSearchResult<H>,LuceneSearchScroll<H>>
      Specified by:
      fetch in interface SearchFetchable<H>
      Specified by:
      fetch in class AbstractSearchQuery<H,LuceneSearchResult<H>>
      Parameters:
      offset - The number of hits to skip before adding the hits to the SearchResult. null means no offset.
      limit - The maximum number of hits to be included in the SearchResult. null means no limit.
      Returns:
      The SearchResult.
    • fetchHits

      public List<H> fetchHits(Integer offset, Integer limit)
      Description copied from interface: SearchFetchable
      Execute the query and return the hits as a List, skipping offset hits and limiting to limit hits.
      Specified by:
      fetchHits in interface SearchFetchable<H>
      Parameters:
      offset - The number of hits to skip. null means no offset.
      limit - The maximum number of hits to be returned by this method. null means no limit.
      Returns:
      The query hits.
    • fetchTotalHitCount

      public long fetchTotalHitCount()
      Description copied from interface: SearchFetchable
      Execute the query and return the total hit count.
      Specified by:
      fetchTotalHitCount in interface SearchFetchable<H>
      Returns:
      The total number of matching entities, ignoring pagination settings.
    • scroll

      public LuceneSearchScroll<H> scroll(int chunkSize)
      Description copied from interface: SearchFetchable
      Execute the query continuously to deliver results in small chunks through a SearchScroll.

      Useful to process large datasets.

      Specified by:
      scroll in interface ExtendedSearchFetchable<H,LuceneSearchResult<H>,LuceneSearchScroll<H>>
      Specified by:
      scroll in interface SearchFetchable<H>
      Parameters:
      chunkSize - The maximum number of hits to be returned for each call to SearchScroll.next()
      Returns:
      The SearchScroll.
    • explain

      public org.apache.lucene.search.Explanation explain(Object id)
      Description copied from interface: LuceneSearchQuery
      Explain score computation of this query for the document with the given id.

      This is a shorthand for LuceneSearchQuery.explain(String, Object) when the query only targets one mapped type.

      Specified by:
      explain in interface LuceneSearchQuery<H>
      Parameters:
      id - The id of the entity whose score should be explained. This is the entity ID, which may be of any type (long, ...), not the document ID which is always a string.
      Returns:
      An Explanation describing the score computation for the hit.
    • explain

      public org.apache.lucene.search.Explanation explain(String typeName, Object id)
      Description copied from interface: LuceneSearchQuery
      Explain score computation of this query for the document with the given id in the given mapped type.

      This feature is relatively expensive, use it only sparingly and when you need to debug a slow query.

      Specified by:
      explain in interface LuceneSearchQuery<H>
      Parameters:
      typeName - The name of the type of the entity whose score should be explained.
      id - The id of the entity whose score should be explained. This is the entity ID, which may be of any type (long, ...), not the document ID which is always a string.
      Returns:
      An Explanation describing the score computation for the hit.
    • luceneSort

      public org.apache.lucene.search.Sort luceneSort()
      Specified by:
      luceneSort in interface LuceneSearchQuery<H>
      Returns:
      The Lucene Sort this query relies on.
    • failAfter

      public void failAfter(long timeout, TimeUnit timeUnit)
      Specified by:
      failAfter in interface SearchQueryImplementor<H>