BigMemory 4.3.7 | Product Documentation | BigMemory Max Developer Guide | Searching a Cache | About Searching
 
About Searching
The Search API allows you to execute arbitrarily complex queries against caches. The development of alternative indexes on values provides the ability for data to be looked up based on multiple criteria instead of just keys.
Searchable attributes can be extracted from both keys and values. Keys, values, or summary values (Aggregators) can all be returned. Here is a simple example: Search for 32-year-old males and return the cache values.
Results results = cache.createQuery().includeValues()
.addCriteria(age.eq(32).and(gender.eq("male"))).execute();
You can formulate queries using the Search API or using BigMemory SQL.
// BigMemory Search API:
Attribute<Integer> age = cache.getSearchAttribute("age");
Person.createQuery().addCriteria(age.gt(30)).includeValues().execute();
// BigMemory SQL:
QueryManager queryManager =
QueryManagerBuilder
.newQueryManagerBuilder()
.addCache(Person)
.addCache(Address)
.build();
Query personQuery = queryManager.createQuery(
"select * from Person where age > 30");
Before creating a query, the cache configuration must be prepared as described in Making a Cache Searchable.
*For more information about creating queries using the Search API, see Creating a Query.
*For more information about creating queries using BigMemory SQL, see Searching with BigMemory SQL.
What is Searchable?
Searches can be performed against Element keys and values, but they must be treated as attributes. Some Element keys and values are directly searchable and can simply be added to the search index as attributes. Some Element keys and values must be made searchable by extracting attributes with supported search types out of the keys and values. It is the attributes themselves that are searchable.