Search in sources :

Example 96 with FilterImpl

use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testUnion.

@Test
public void testUnion() throws Exception {
    SelectorImpl selector = mock(SelectorImpl.class);
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    String sqlQuery = "select [jcr:path], [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where" + " isdescendantnode(a, '/content') and contains([jcr:content/*], 'founded') union select [jcr:path]," + " [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:title], 'founded') union select [jcr:path], [jcr:score], [rep:excerpt]" + " from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:description], 'founded') order by [jcr:score] desc";
    FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 97 with FilterImpl

use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.

the class LuceneIndexTest method testLuceneLazyCursor.

@Test
public void testLuceneLazyCursor() throws Exception {
    NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
    newLucenePropertyIndexDefinition(index, "lucene", ImmutableSet.of("foo"), null);
    NodeState before = builder.getNodeState();
    builder.setProperty("foo", "bar");
    for (int i = 0; i < LuceneIndex.LUCENE_QUERY_BATCH_SIZE; i++) {
        builder.child("parent").child("child" + i).setProperty("foo", "bar");
    }
    NodeState after = builder.getNodeState();
    NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
    tracker = new IndexTracker();
    tracker.update(indexed);
    AdvancedQueryIndex queryIndex = new LucenePropertyIndex(tracker);
    FilterImpl filter = createFilter(NT_BASE);
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed);
    Cursor cursor = queryIndex.query(plans.get(0), indexed);
    List<String> paths = copyOf(transform(cursor, new Function<IndexRow, String>() {

        public String apply(IndexRow input) {
            return input.getPath();
        }
    }));
    assertTrue(!paths.isEmpty());
    assertEquals(LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 1, paths.size());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) IndexRow(org.apache.jackrabbit.oak.spi.query.IndexRow) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Cursor(org.apache.jackrabbit.oak.spi.query.Cursor) AdvancedQueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex) Function(com.google.common.base.Function) IndexPlan(org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan) Test(org.junit.Test)

Example 98 with FilterImpl

use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.

the class LuceneIndexTest method createTestFilter.

private FilterImpl createTestFilter() {
    FilterImpl filter = createFilter(NT_BASE);
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    return filter;
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl)

Aggregations

FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)98 Test (org.junit.Test)81 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)74 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)39 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)28 SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)27 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)26 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)26 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)25 AdvancedQueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex)15 LinkedList (java.util.LinkedList)14 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 NodeStateNodeTypeInfoProvider (org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)10 NodeTypeInfo (org.apache.jackrabbit.oak.query.ast.NodeTypeInfo)10 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)10 Cursor (org.apache.jackrabbit.oak.spi.query.Cursor)9 IndexPlan (org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan)8 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)4 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)4 DefaultSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration)3