Examples of QueryIndex


Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        child2.addChild("descendant");
        Tree someothernode = tree.addChild("someothernode");
        someothernode.addChild("someotherchild");
        root.commit();

        QueryIndex index = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictPath("/somenode", Filter.PathRestriction.DIRECT_CHILDREN);
        Cursor cursor = index.query(filter, store.getRoot());
        assertNotNull(cursor);
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child1", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child2", cursor.next().getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        child2.addChild("descendant");
        Tree someothernode = tree.addChild("someothernode");
        someothernode.addChild("someotherchild");
        root.commit();

        QueryIndex index = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictPath("/somenode", Filter.PathRestriction.ALL_CHILDREN);
        Cursor cursor = index.query(filter, store.getRoot());
        assertNotNull(cursor);
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child1", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child2/descendant", cursor.next().getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        tree.addChild("somenode").setProperty("foo", "bar");
        tree.addChild("someothernode").setProperty("foo", "bard");
        tree.addChild("anotherone").setProperty("foo", "a fool's bar");
        root.commit();

        QueryIndex index = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
        Cursor cursor = index.query(filter, store.getRoot());
        assertNotNull(cursor);
        assertTrue(cursor.hasNext());
        assertEquals("/somenode", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/anotherone", cursor.next().getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        tree.addChild("asamplenode").setProperty("jcr:primaryType", "nt:unstructured");
        tree.addChild("afoldernode").setProperty("jcr:primaryType", "nt:folder");
        tree.addChild("anothersamplenode").setProperty("jcr:primaryType", "nt:unstructured");
        root.commit();

        QueryIndex index = new SolrQueryIndex("solr", server, configuration);
        SelectorImpl selector = mock(SelectorImpl.class);
        Set<String> primaryTypes = new HashSet<String>();
        primaryTypes.add("nt:folder");
        when(selector.getPrimaryTypes()).thenReturn(primaryTypes);
        FilterImpl filter = new FilterImpl(selector, "select * from [nt:folder]");
        Cursor cursor = index.query(filter, store.getRoot());
        assertNotNull(cursor);
        assertTrue(cursor.hasNext());
        assertEquals("/afoldernode", cursor.next().getPath());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

    }

    private static SelectorExecutionPlan getBestSelectorExecutionPlan(
            NodeState rootState, FilterImpl filter,
            QueryIndexProvider indexProvider, boolean traversalEnabled) {
        QueryIndex best = null;
        if (LOG.isDebugEnabled()) {
            LOG.debug("cost using filter " + filter);
        }

        double bestCost = Double.POSITIVE_INFINITY;
        for (QueryIndex index : indexProvider.getQueryIndexes(rootState)) {
            double cost = index.getCost(filter, rootState);
            if (LOG.isDebugEnabled()) {
                LOG.debug("cost for " + index.getIndexName() + " is " + cost);
            }
            if (cost < bestCost) {
                bestCost = cost;
                best = index;
            }
        }

        if (traversalEnabled) {
            QueryIndex traversal = new TraversingIndex();
            double cost = traversal.getCost(filter, rootState);
            if (cost < bestCost || bestCost == Double.POSITIVE_INFINITY) {
                bestCost = cost;
                best = traversal;
            }
        }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        NodeState after = builder.getNodeState();

        EditorDiff.process(new LuceneIndexEditor(builder), before, after);
        NodeState indexed = builder.getNodeState();

        QueryIndex queryIndex = new LuceneIndex();
        FilterImpl filter = createFilter(NT_BASE);
        filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertTrue(cursor.hasNext());
        assertEquals("/", cursor.next().getPath());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        NodeState after = builder.getNodeState();

        EditorDiff.process(new LuceneIndexEditor(builder), before, after);
        NodeState indexed = builder.getNodeState();

        QueryIndex queryIndex = new LuceneIndex();
        FilterImpl filter = createFilter(NT_BASE);
        // filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);

        assertTrue(cursor.hasNext());
        assertEquals("/", cursor.next().getPath());
        assertEquals("/a", cursor.next().getPath());
        assertEquals("/a/b", cursor.next().getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        NodeState after = builder.getNodeState();

        EditorDiff.process(new LuceneIndexEditor(builder), before, after);
        NodeState indexed = builder.getNodeState();

        QueryIndex queryIndex = new LuceneIndex();
        FilterImpl filter = createFilter(NT_BASE);
        // filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);

        assertTrue(cursor.hasNext());
        assertEquals("/", cursor.next().getPath());
        assertEquals("/a", cursor.next().getPath());
        assertFalse(cursor.hasNext());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

    protected void setTravesalFallback(boolean traversal) {
        this.traversalFallback = traversal;
    }

    public QueryIndex getBestIndex(Query query, NodeState rootState, Filter filter) {
        QueryIndex best = null;
        if (LOG.isDebugEnabled()) {
            LOG.debug("cost using filter " + filter);
        }
        List<QueryIndex> indexes = new ArrayList<QueryIndex>(
                indexProvider.getQueryIndexes(rootState));
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        Tree tree = root.getTree("/");

        tree.addChild("somenode").setProperty("foo", "bar");
        root.commit();

        QueryIndex index = new SolrQueryIndex(testID, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictPath("somenode", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
        Cursor cursor = index.query(filter, store.getRoot());
        assertNotNull(cursor);
        assertTrue(cursor.hasNext());
        assertEquals("somenode", cursor.next().getPath());
        assertFalse(cursor.hasNext());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.