use of org.infinispan.search.mapper.scope.SearchScope in project infinispan by infinispan.
the class ProtobufValueWrapperIndexingTest method testIndexingWithWrapper.
public void testIndexingWithWrapper() {
SearchMapping searchMapping = ComponentRegistryUtils.getSearchMapping(cache);
assertNotNull(searchMapping);
// Store some test data:
cache.put(new byte[] { 1, 2, 3 }, createUser("Adrian", "Nistor"));
cache.put(new byte[] { 4, 5, 6 }, createUser("John", "Batman"));
SearchSession session = searchMapping.getMappingSession();
SearchScope<byte[]> scope = session.scope(byte[].class, "sample_bank_account.User");
SearchQuery<Object> query = session.search(scope).select(f -> f.field("surname")).where(f -> f.match().field("name").matching("Adrian")).toQuery();
List<Object> result = query.fetchAllHits();
assertEquals(1, result.size());
assertEquals("Nistor", result.get(0));
}
Aggregations