.must(qb.keyword().onField(TYPE_FIELD_NAME).ignoreFieldBridge().matching(messageDescriptor.getFullName()).createQuery())
.must(parsingResult.getQuery())
.createQuery();
}
CacheQuery cacheQuery = searchManager.getQuery(luceneQuery, targetEntity);
if (request.getSortCriteria() != null && !request.getSortCriteria().isEmpty()) {
SortField[] sortField = new SortField[request.getSortCriteria().size()];
int i = 0;
for (QueryRequest.SortCriteria sc : request.getSortCriteria()) {
//TODO [anistor] sort type is not properly handled right now
Descriptors.FieldDescriptor field = getFieldDescriptor(messageDescriptor, sc.getAttributePath());
int sortType = SortField.STRING;
if (field != null) {
switch (field.getJavaType()) {
case INT:
case BOOLEAN:
case ENUM:
sortType = SortField.INT;
break;
case LONG:
sortType = SortField.LONG;
break;
case FLOAT:
sortType = SortField.FLOAT;
break;
case DOUBLE:
sortType = SortField.DOUBLE;
break;
}
}
sortField[i++] = new SortField(sc.getAttributePath(), sortType, !sc.isAscending());
}
cacheQuery = cacheQuery.sort(new Sort(sortField));
}
int projSize = 0;
if (projections != null && !projections.isEmpty()) {
projSize = projections.size();
cacheQuery = cacheQuery.projection(projections.toArray(new String[projSize]));
}
if (request.getStartOffset() > 0) {
cacheQuery = cacheQuery.firstResult((int) request.getStartOffset());
}
if (request.getMaxResults() > 0) {
cacheQuery = cacheQuery.maxResults(request.getMaxResults());
}
List list = cacheQuery.list();
List<WrappedMessage> results = new ArrayList<WrappedMessage>(projSize == 0 ? list.size() : list.size() * projSize);
for (Object o : list) {
if (projSize == 0) {
results.add(new WrappedMessage(o));
} else {