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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault query result limit is 100static final intDefault page size of result is 0, which means no pagination -
Method Summary
Modifier and TypeMethodDescription<K,V> LuceneQuery<K, V> Creates a query based on a query string which is parsed by Lucene'sStandardQueryParser.<K,V> LuceneQuery<K, V> create(String indexName, String regionName, LuceneQueryProvider provider) Create a query based on a programmatically constructed LuceneQuery.setLimit(int limit) Set maximum number of results for a query.setPageSize(int pageSize) Set page size for a query result.
-
Field Details
-
DEFAULT_LIMIT
static final int DEFAULT_LIMITDefault query result limit is 100- See Also:
-
DEFAULT_PAGESIZE
static final int DEFAULT_PAGESIZEDefault page size of result is 0, which means no pagination- See Also:
-
-
Method Details
-
setPageSize
Set page size for a query result. The default page size is 0 which means no pagination.- Parameters:
pageSize- the page size for a query result- Returns:
- this factory
- Throws:
IllegalArgumentException- if the value is less than 0
-
setLimit
Set maximum number of results for a query. By default, the limit is set toDEFAULT_LIMITwhich is 100.- Parameters:
limit- the maximum number of results for a query- Returns:
- this factory
- Throws:
IllegalArgumentException- if the value is less than or equal to zero.
-
create
<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'sStandardQueryParser. See the javadocs forStandardQueryParserfor details on the syntax of the query string. The query string and default field as passed as is toStandardQueryParser.parse(String, String)- Type Parameters:
K- the key type in the query resultsV- the value type in the query results- Parameters:
regionName- region nameindexName- index namequeryString- Query string parsed by Lucene's StandardQueryParserdefaultField- default field used by the Lucene's StandardQueryParser- Returns:
- LuceneQuery object
-
create
Create a query based on a programmatically constructed Lucene
Query. This can be used for queries that are not covered byStandardQueryParser, such as range queries.Because Geode may execute the Lucene query on multiple nodes in parallel and
Queryis not serializable, this method requires a serializableLuceneQueryProviderthat can create aQueryon 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 resultsV- the value type in the query results- Parameters:
indexName- index nameregionName- region nameprovider- constructs and provides a LuceneQuery.- Returns:
- LuceneQuery object
-