이 콘텐츠는 선택한 언어로 제공되지 않습니다.
15.8. Querying Example
15.8.1. The Query Module Example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following provides an example of how to set up and run a query in JBoss Data Grid.
In this example, the "Person" object has been annotated using the following:
Assuming several of these "Person" objects have been stored in JBoss Data Grid, they can be searched using querying. The following code creates a
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
SearchManager and QueryBuilder instance:
The
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
SearchManager and QueryBuilder are used to construct a Lucene query. The Lucene query is then passed to the SearchManager to obtain a CacheQuery instance:
CacheQuery query = manager.getQuery(luceneQuery);
for (Object result: query) {
System.out.println("Found " + result);
}
CacheQuery query = manager.getQuery(luceneQuery);
for (Object result: query) {
System.out.println("Found " + result);
}
This
CacheQuery instance contains the results of the query, and can be used to produce a list or it can be used for repeat queries.
Important
The Query Module is currently only available as a Technical Preview for JBoss Data Grid 6.1.