public interface LuceneQueryFactory
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.
| 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
|
| Modifier and Type | Method and Description |
|---|---|
<K,V> LuceneQuery<K,V> |
create(String indexName,
String regionName,
LuceneQueryProvider provider)
Create a query based on a programmatically constructed Lucene
Query. |
<K,V> LuceneQuery<K,V> |
create(String indexName,
String regionName,
String queryString,
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.
|
static final int DEFAULT_LIMIT
static final int DEFAULT_PAGESIZE
LuceneQueryFactory setPageSize(int pageSize)
pageSize - the page size for a query resultIllegalArgumentException - if the value is less than 0LuceneQueryFactory setLimit(int limit)
DEFAULT_LIMIT which is 100.limit - the maximum number of results for a queryIllegalArgumentException - if the value is less than or equal to zero.<K,V> LuceneQuery<K,V> create(String indexName, String regionName, String queryString, String defaultField)
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)K - the key type in the query resultsV - the value type in the query resultsregionName - region nameindexName - index namequeryString - Query string parsed by Lucene's StandardQueryParserdefaultField - default field used by the Lucene's StandardQueryParser<K,V> LuceneQuery<K,V> create(String indexName, 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))
K - the key type in the query resultsV - the value type in the query resultsindexName - index nameregionName - region nameprovider - constructs and provides a Lucene Query.