use of org.infinispan.search.mapper.session.SearchSession in project infinispan by infinispan.
the class SearchQueryMaker method transform.
public SearchQueryParsingResult transform(IckleParsingResult<TypeMetadata> parsingResult, Map<String, Object> namedParameters, Class<?> targetedType, String targetedTypeName) {
if (searchMapping == null) {
throw log.noTypeIsIndexed(parsingResult.getQueryString());
}
this.namedParameters = namedParameters;
SearchSession querySession = searchMapping.getMappingSession();
SearchScope<?> scope = targetedTypeName == null ? querySession.scope(targetedType) : querySession.scope(targetedType, targetedTypeName);
predicateFactory = scope.predicate().extension(LuceneExtension.get());
indexedEntity = targetedTypeName == null ? searchMapping.indexedEntity(targetedType) : searchMapping.indexedEntity(targetedTypeName);
SearchPredicate predicate = makePredicate(parsingResult.getWhereClause()).toPredicate();
SearchProjectionInfo projection = makeProjection(parsingResult.getTargetEntityMetadata(), scope.projection(), parsingResult.getProjections(), parsingResult.getProjectedTypes());
SearchSort sort = makeSort(scope.sort(), parsingResult.getSortFields());
return new SearchQueryParsingResult(targetedType, targetedTypeName, projection, predicate, sort);
}
use of org.infinispan.search.mapper.session.SearchSession 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.session.SearchSession in project infinispan by infinispan.
the class LocalIndexStatistics method indexInfos.
private CompletionStage<IndexInfo> indexInfos(SearchIndexedEntity indexedEntity) {
SearchSession session = searchMapping.getMappingSession();
SearchScope<?> scope = session.scope(indexedEntity.javaClass(), indexedEntity.name());
CompletionStage<Long> countStage = blockingManager.supplyBlocking(() -> session.search(scope).where(SearchPredicateFactory::matchAll).fetchTotalHitCount(), this);
CompletionStage<Long> sizeStage = indexedEntity.indexManager().unwrap(LuceneIndexManager.class).computeSizeInBytesAsync();
return countStage.thenCombine(sizeStage, IndexInfo::new);
}
Aggregations