Package org.apache.jackrabbit.oak.spi.query

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


        root.commit();

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


        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());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

        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", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child1", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child2", cursor.next().getPath());
        assertTrue(cursor.hasNext());
        assertEquals("/somenode/child2/descendant", cursor.next().getPath());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

        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());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

        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

    @Override
    public Cursor query(Filter filter, NodeState root) {
        if (log.isDebugEnabled()) {
            log.debug("converting filter {}", filter);
        }
        Cursor cursor;
        try {
            SolrQuery query = getQuery(filter);
            if (log.isDebugEnabled()) {
                log.debug("sending query {}", query);
            }
View Full Code Here

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictPath("/newnode", Filter.PathRestriction.EXACT);
        filter.restrictProperty("prop", Operator.EQUAL,
                PropertyValues.newString("val"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/newnode", next.getPath());
        assertFalse(cursor.hasNext());
    }
View Full Code Here

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/", next.getPath());
        assertNotNull(next.getValue("foo"));
        assertEquals(PropertyValues.newString("[bar]"), next.getValue("foo"));
        assertFalse(cursor.hasNext());
    }
View Full Code Here

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "");
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        filter.restrictFulltextCondition("bar");
        Cursor cursor = queryIndex.query(filter, indexed);

        Set<String> paths = newHashSet();
        while (cursor.hasNext()) {
            paths.add(cursor.next().getPath());
        }
        assertTrue(paths.remove("/"));
        assertTrue(paths.remove("/a"));
        assertTrue(paths.remove("/a/b"));
        assertTrue(paths.remove("/a/b/c"));
View Full Code Here

        LOG.debug("query() - rootState: {}", root);

        Filter filter = plan.getFilter();
        List<OrderEntry> sortOrder = plan.getSortOrder();
        Iterable<String> paths = null;
        Cursor cursor = null;
        PropertyIndexLookup pil = getLookup(root);
        if (pil instanceof OrderedPropertyIndexLookup) {
            OrderedPropertyIndexLookup lookup = (OrderedPropertyIndexLookup) pil;
            Collection<PropertyRestriction> prs = filter.getPropertyRestrictions();
            int depth = 1;
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.query.Cursor

Copyright © 2018 www.massapicom. 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.