LuceneQueryFactory (Apache Geode 1.7.0)
Date: 2018-09-27

org.apache.geode.cache.lucene

## Interface LuceneQueryFactory

-     public interface LuceneQueryFactory

  Factory for configuring a Lucene query. Use this factory to set parameters of the query such as page size, result limit, and query expression. To get an instance of this factory call `LuceneService.createLuceneQueryFactory()`.

  To use this factory configure it with the `set` methods and then call one of the create methods on this class. `create(String, String, String, String)` creates a query by parsing a query string. `create(String, String, LuceneQueryProvider)` creates a query based on a custom Lucene `Query` object.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_LIMIT` Default query result limit is 100
    `static int` | `DEFAULT_PAGESIZE` Default page size of result is 0, which means no pagination

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> LuceneQuery<K,V>` | `create(java.lang.String indexName, java.lang.String regionName, LuceneQueryProvider provider)` Create a query based on a programmatically constructed Lucene `Query`.
    `<K,V> LuceneQuery<K,V>` | `create(java.lang.String indexName, java.lang.String regionName, java.lang.String queryString, java.lang.String defaultField)` Creates a query based on a query string which is parsed by Lucene's `StandardQueryParser`.
    `LuceneQueryFactory` | `setLimit(int limit)` Set maximum number of results for a query.
    `LuceneQueryFactory` | `setPageSize(int pageSize)` Set page size for a query result.

- - ### Field Detail

    - #### DEFAULT_LIMIT

          static final int DEFAULT_LIMIT

      Default query result limit is 100
      See Also:
        Constant Field Values

    - #### DEFAULT_PAGESIZE

          static final int DEFAULT_PAGESIZE

      Default page size of result is 0, which means no pagination
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### setPageSize

          LuceneQueryFactory setPageSize(int pageSize)

      Set page size for a query result. The default page size is 0 which means no pagination.
      Throws:
        `java.lang.IllegalArgumentException` - if the value is less than 0

    - #### setLimit

          LuceneQueryFactory setLimit(int limit)

      Set maximum number of results for a query. By default, the limit is set to `DEFAULT_LIMIT` which is 100.
      Throws:
        `java.lang.IllegalArgumentException` - if the value is less than or equal to zero.

    - #### create

          <K,V> LuceneQuery<K,V> create(java.lang.String indexName,
                                        java.lang.String regionName,
                                        java.lang.String queryString,
                                        java.lang.String defaultField)

      Creates a query based on a query string which is parsed by Lucene's `StandardQueryParser`. See the javadocs for `StandardQueryParser` for details on the syntax of the query string. The query string and default field as passed as is to `StandardQueryParser.parse(String, String)`
      Type Parameters:
        `K` - the key type in the query results
        `V` - the value type in the query results
      Parameters:
        `regionName` - region name
        `indexName` - index name
        `queryString` - Query string parsed by Lucene's StandardQueryParser
        `defaultField` - default field used by the Lucene's StandardQueryParser
      Returns:
        LuceneQuery object

    - #### create

          <K,V> LuceneQuery<K,V> create(java.lang.String indexName,
                                        java.lang.String regionName,
                                        LuceneQueryProvider provider)

      Create a query based on a programmatically constructed Lucene `Query`. This can be used for queries that are not covered by `StandardQueryParser`, such as range queries.

      Because Geode may execute the Lucene query on multiple nodes in parallel and `Query` is not serializable, this method requires a serializable `LuceneQueryProvider` that can create a `Query` on the nodes hosting the Lucene index.

      Here's an example of using this method to create a range query on an integer field called "age."

             LuceneQuery query = factory.create("index", "region", index -> IntPoint.newRangeQuery("age", 20, 30))

      Type Parameters:
        `K` - the key type in the query results
        `V` - the value type in the query results
      Parameters:
        `indexName` - index name
        `regionName` - region name
        `provider` - constructs and provides a Lucene `Query`.
      Returns:
        LuceneQuery object