Interface LuceneQuery<K,​V>


  • public interface LuceneQuery<K,​V>

    A query on a Lucene index. Instances of this interface are created using LuceneQueryFactory.create(java.lang.String, java.lang.String, java.lang.String, java.lang.String). Once this query is constructed, use one of the find methods to find region entries that match this query.

    Instances obtained from LuceneQueryFactory are immutable, so they are safe for reuse and can be shared by multiple threads.

    Because Lucene indexes are maintained asynchronously, results returned from the find methods may not reflect the most recent updates to the region.

    Results are returned in order of their score with respect to this query.

    • Method Detail

      • findKeys

        java.util.Collection<K> findKeys()
                                  throws LuceneQueryException
        Execute the query and return the region keys that match this query, up to the limit specified by getLimit().
        Returns:
        Collection of Apache Geode region keys that satisfy the Lucene query.
        Throws:
        LuceneQueryException - if the query could not be parsed or executed.
        org.apache.geode.cache.CacheClosedException - if the cache was closed while the Lucene query was being executed.
        org.apache.geode.cache.execute.FunctionException - if the function execution mechanism encounters an error while executing the Lucene query.
        org.apache.geode.cache.persistence.PartitionOfflineException - if the node containing the buckets required to execute the Lucene query goes offline.
        org.apache.geode.CancelException - if a cancel is in progress while the Lucene query was being executed.
      • findValues

        java.util.Collection<V> findValues()
                                    throws LuceneQueryException
        Execute the query and return the region values that match this query, up to the limit specified by getLimit()
        Returns:
        a Collection of Apache Geode region values that satisfy the Lucene query.
        Throws:
        LuceneQueryException - if the query could not be parsed or executed.
        org.apache.geode.cache.CacheClosedException - if the cache was closed while the Lucene query was being executed.
        org.apache.geode.cache.execute.FunctionException - if the function execution mechanism encounters an error while executing the Lucene query.
        org.apache.geode.cache.persistence.PartitionOfflineException - if the node containing the buckets required to execute the Lucene query goes offline.
        org.apache.geode.CancelException - if a cancel is in progress while the Lucene query was being executed.
      • findResults

        java.util.List<LuceneResultStruct<K,​V>> findResults()
                                                           throws LuceneQueryException
        Execute the query and return a list of LuceneResultStructs that match this query, up to the limit specified by getLimit() A LuceneResultStruct contains the region key, value, and a score for that entry.
        Returns:
        a List of LuceneResultStruct that match the Lucene query
        Throws:
        LuceneQueryException - if the query could not be parsed or executed.
        org.apache.geode.cache.CacheClosedException - if the cache was closed while the Lucene query was being executed.
        org.apache.geode.cache.execute.FunctionException - if the function execution mechanism encounters an error while executing the Lucene query.
        org.apache.geode.cache.persistence.PartitionOfflineException - if the node containing the buckets required to execute the Lucene query goes offline.
        org.apache.geode.CancelException - if a cancel is in progress while the Lucene query was being executed.
      • findPages

        PageableLuceneQueryResults<K,​V> findPages()
                                                 throws LuceneQueryException
        Execute the query and get a PageableLuceneQueryResults. The PageableLuceneQueryResults provides the ability to fetch a page of results at a time, as specified by getPageSize()
        Returns:
        a PageableLuceneQuery that can be used to fetch one page of result at a time.
        Throws:
        LuceneQueryException - if the query could not be parsed or executed.
        org.apache.geode.cache.CacheClosedException - if the cache was closed while the Lucene query was being executed.
        org.apache.geode.cache.execute.FunctionException - if the function execution mechanism encounters an error while executing the Lucene query.
        org.apache.geode.cache.persistence.PartitionOfflineException - if the node containing the buckets required to execute the Lucene query goes offline.
        org.apache.geode.CancelException - if a cancel is in progress while the Lucene query was being executed.
      • getPageSize

        int getPageSize()
        Gets the page size setting of current query. This page size is set while creating LuceneQueryImpl object
        Returns:
        int value representing the page size of the current query
      • getLimit

        int getLimit()
        Get limit size setting of current query. This value is the maximum number of results that can be returned by the Lucene query. This value is set while creating the LuceneQueryImpl object
        Returns:
        int value representing the limit of the current query