Search in sources :

Example 6 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testPlanWithPropertyAndPrimaryTypeRestrictionsEnabled.

@Test
public void testPlanWithPropertyAndPrimaryTypeRestrictionsEnabled() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("propertyRestrictions", true).setProperty("primaryTypes", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
    filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
    filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(1, 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) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 7 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPropertyRestrictionsEnabledButPropertyIgnored.

@Test
public void testNoPlanWithPropertyRestrictionsEnabledButPropertyIgnored() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("ignoredProperties", Collections.singleton("name"), Type.STRINGS).setProperty("propertyRestrictions", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
    filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    // there's no plan matching the filter
    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) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 8 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPathRestrictions.

@Test
public void testNoPlanWithPathRestrictions() throws Exception {
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where isdescendantnode(a, '/test')", new QueryEngineSettings());
    filter.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
    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 9 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoIndexPlanWithNoRestrictions.

@Test
public void testNoIndexPlanWithNoRestrictions() throws Exception {
    SelectorImpl selector = mock(SelectorImpl.class);
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "", 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 10 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testPlanWithPropertyRestrictionsEnabledAndUsedProperty.

@Test
public void testPlanWithPropertyRestrictionsEnabledAndUsedProperty() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS).setProperty("propertyRestrictions", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
    filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(1, 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) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)36 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)30 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)29 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)17 Test (org.junit.Test)17 LinkedList (java.util.LinkedList)14 NodeStateNodeTypeInfoProvider (org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)14 NodeTypeInfo (org.apache.jackrabbit.oak.query.ast.NodeTypeInfo)14 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)14 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 ColumnImpl (org.apache.jackrabbit.oak.query.ast.ColumnImpl)4 DefaultSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration)3 OakSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration)3 OakSolrConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider)3 SolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)1