Search in sources :

Example 6 with OrderEntry

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());
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 7 with OrderEntry

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;
}
Also used : DynamicOperandImpl(org.apache.jackrabbit.oak.query.ast.DynamicOperandImpl) OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) OrderingImpl(org.apache.jackrabbit.oak.query.ast.OrderingImpl) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList)

Example 8 with OrderEntry

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;
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry)

Aggregations

OrderEntry (org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry)8 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)3 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)3 IndexPlan (org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 Test (org.junit.Test)3 DynamicOperandImpl (org.apache.jackrabbit.oak.query.ast.DynamicOperandImpl)2 OrderingImpl (org.apache.jackrabbit.oak.query.ast.OrderingImpl)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 IndexingRule (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule)1 PropertyValueImpl (org.apache.jackrabbit.oak.query.ast.PropertyValueImpl)1 FullTextExpression (org.apache.jackrabbit.oak.query.fulltext.FullTextExpression)1 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)1 TraversingIndex (org.apache.jackrabbit.oak.query.index.TraversingIndex)1 SelectorExecutionPlan (org.apache.jackrabbit.oak.query.plan.SelectorExecutionPlan)1 PropertyRestriction (org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction)1 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)1 AdvancedQueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex)1