Query luceneQuery;
List<String> projections;
Class targetEntity;
Descriptors.Descriptor messageDescriptor;
QueryParser queryParser = new QueryParser();
if (cache.getCacheConfiguration().compatibility().enabled()) {
final QueryInterceptor queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache);
EntityNamesResolver entityNamesResolver = new EntityNamesResolver() {
@Override
public Class<?> getClassFromName(String entityName) {
MessageMarshaller messageMarshaller = (MessageMarshaller) serCtx.getMarshaller(entityName);
Class clazz = messageMarshaller.getJavaClass();
Boolean isIndexed = queryInterceptor.getKnownClasses().get(clazz);
return isIndexed != null && isIndexed ? clazz : null;
}
};
LuceneProcessingChain processingChain = new LuceneProcessingChain((SearchFactoryIntegrator) searchManager.getSearchFactory(), entityNamesResolver, null);
LuceneQueryParsingResult parsingResult = queryParser.parseQuery(request.getJpqlString(), processingChain);
MessageMarshaller messageMarshaller = (MessageMarshaller) serCtx.getMarshaller(parsingResult.getTargetEntity());
messageDescriptor = serCtx.getMessageDescriptor(messageMarshaller.getTypeName());
targetEntity = parsingResult.getTargetEntity();
projections = parsingResult.getProjections();
luceneQuery = parsingResult.getQuery();
} else {
EntityNamesResolver entityNamesResolver = new EntityNamesResolver() {
@Override
public Class<?> getClassFromName(String entityName) {
try {
//todo [anistor] this just checks if the type is known
serCtx.getMessageDescriptor(entityName);
} catch (Exception e) {
return null;
}
return ProtobufValueWrapper.class;
}
};
IspnLuceneProcessingChain processingChain = new IspnLuceneProcessingChain(serCtx, (SearchFactoryIntegrator) searchManager.getSearchFactory(), entityNamesResolver, null);
IspnLuceneQueryParsingResult parsingResult = queryParser.parseQuery(request.getJpqlString(), processingChain);
messageDescriptor = parsingResult.getTargetType();
targetEntity = parsingResult.getTargetEntity();
projections = parsingResult.getProjections();
QueryBuilder qb = searchManager.getSearchFactory().buildQueryBuilder().forEntity(targetEntity).get();