use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlannerTest method noPlanForSortOnlyByScore.
@Test
public void noPlanForSortOnlyByScore() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
IndexPlanner planner = new IndexPlanner(node, "/foo", createFilter("nt:file"), ImmutableList.of(new OrderEntry("jcr:score", Type.LONG, OrderEntry.Order.ASCENDING)));
assertNull(planner.getPlan());
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class QueryImpl method getSortOrder.
private List<OrderEntry> getSortOrder(FilterImpl filter) {
if (orderings == null) {
return null;
}
ArrayList<OrderEntry> sortOrder = new ArrayList<OrderEntry>();
for (OrderingImpl o : orderings) {
DynamicOperandImpl op = o.getOperand();
OrderEntry e = op.getOrderEntry(filter.getSelector(), o);
if (e == null) {
continue;
}
sortOrder.add(e);
}
if (sortOrder.size() == 0) {
return null;
}
return sortOrder;
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlanner method createSortOrder.
private List<OrderEntry> createSortOrder(IndexingRule rule) {
if (sortOrder == null) {
return Collections.emptyList();
}
List<OrderEntry> orderEntries = newArrayListWithCapacity(sortOrder.size());
for (OrderEntry o : sortOrder) {
PropertyDefinition pd = rule.getConfig(o.getPropertyName());
if (pd != null && pd.ordered && o.getPropertyType() != null && !o.getPropertyType().isArray()) {
//Lucene can manage any order desc/asc
orderEntries.add(o);
result.sortedProperties.add(pd);
} else if (o.getPropertyName().equals(IndexDefinition.NATIVE_SORT_ORDER.getPropertyName())) {
// Supports jcr:score descending natively
orderEntries.add(IndexDefinition.NATIVE_SORT_ORDER);
}
for (PropertyDefinition functionIndex : rule.getFunctionRestrictions()) {
if (o.getPropertyName().equals(functionIndex.function)) {
// Lucene can manage any order desc/asc
orderEntries.add(o);
result.sortedProperties.add(functionIndex);
}
}
}
//TODO Should we return order entries only when all order clauses are satisfied
return orderEntries;
}
Aggregations