use of org.infinispan.search.mapper.mapping.SearchMapping 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));
}
use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.
the class JBMARRemoteQueryDslConditionsTest method testIndexPresence.
@Override
public void testIndexPresence() {
SearchMapping searchMapping = TestingUtil.extractComponent(cache, SearchMapping.class);
verifyClassIsIndexed(searchMapping, getModelFactory().getUserImplClass());
verifyClassIsIndexed(searchMapping, getModelFactory().getAccountImplClass());
verifyClassIsIndexed(searchMapping, getModelFactory().getTransactionImplClass());
verifyClassIsNotIndexed(searchMapping, getModelFactory().getAddressImplClass());
}
use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.
the class RemoteQueryDslConditionsTest method testIndexPresence.
@Override
public void testIndexPresence() {
SearchMapping searchMapping = TestingUtil.extractComponent(cache, SearchMapping.class);
// we have indexing for remote query!
assertNotNull(searchMapping.indexedEntity("sample_bank_account.User"));
assertNotNull(searchMapping.indexedEntity("sample_bank_account.Account"));
assertNotNull(searchMapping.indexedEntity("sample_bank_account.Transaction"));
// we have some indexes for this cache
assertEquals(3, searchMapping.allIndexedEntities().size());
}
use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.
the class QueryDslConditionsTest method testIndexPresence.
public void testIndexPresence() {
SearchMapping searchMapping = TestingUtil.extractComponent((Cache<?, ?>) getCacheForQuery(), SearchMapping.class);
verifyClassIsIndexed(searchMapping, getModelFactory().getUserImplClass());
verifyClassIsIndexed(searchMapping, getModelFactory().getAccountImplClass());
verifyClassIsIndexed(searchMapping, getModelFactory().getTransactionImplClass());
verifyClassIsNotIndexed(searchMapping, getModelFactory().getAddressImplClass());
}
use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.
the class LifecycleManager method createSearchMapping.
private SearchMapping createSearchMapping(LocalQueryStatistics queryStatistics, IndexingConfiguration indexingConfiguration, Map<String, Class<?>> indexedClasses, ComponentRegistry cr, AdvancedCache<?, ?> cache, KeyTransformationHandler keyTransformationHandler, ClassLoader aggregatedClassLoader) {
SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
if (searchMapping != null && !searchMapping.isClose()) {
// a paranoid check against an unlikely failure
throw new IllegalStateException("SearchIntegrator already initialized!");
}
GlobalConfiguration globalConfiguration = cr.getGlobalComponentRegistry().getGlobalConfiguration();
// load ProgrammaticSearchMappingProviders from classpath
Collection<ProgrammaticSearchMappingProvider> mappingProviders = ServiceFinder.load(ProgrammaticSearchMappingProvider.class, aggregatedClassLoader);
SearchMappingCommonBuilding commonBuilding = new SearchMappingCommonBuilding(KeyTransformationHandlerIdentifierBridge.createReference(keyTransformationHandler), extractProperties(globalConfiguration, indexingConfiguration, aggregatedClassLoader), aggregatedClassLoader, mappingProviders);
Set<Class<?>> types = new HashSet<>(indexedClasses.values());
if (!types.isEmpty()) {
// use the common builder to create the mapping now
SearchMappingBuilder builder = commonBuilding.builder(SearchMappingBuilder.introspector(MethodHandles.lookup()));
builder.setEntityLoader(new EntityLoader<>(queryStatistics, cache, keyTransformationHandler));
builder.addEntityTypes(types);
searchMapping = builder.build();
cr.registerComponent(searchMapping, SearchMapping.class);
}
if (searchMapping == null) {
// register the common builder to create the mapping at a later time
cr.registerComponent(commonBuilding, SearchMappingCommonBuilding.class);
}
return searchMapping;
}
Aggregations