use of org.apache.jackrabbit.oak.query.index.FilterImpl 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());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl 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());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrIndexLookupTest method collectPathOnSubNode.
@Test
public void collectPathOnSubNode() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l1", of("foo"));
index = builder.child("a").child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l2", of("foo"));
index = builder.child("a").child("b").child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l3", of("foo"));
SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
FilterImpl f = FilterImpl.newTestInstance();
f.restrictPath("/a", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/a/oak:index/l2"), lookup.collectIndexNodePaths(f));
f.restrictPath("/a/b", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/a/oak:index/l2", "/a/b/oak:index/l3"), lookup.collectIndexNodePaths(f));
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrIndexLookupTest method collectPathOnRootNode.
@Test
public void collectPathOnRootNode() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l1", of("foo"));
newSolrIndexDefinition(index, "l2", of("foo"));
SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
FilterImpl f = FilterImpl.newTestInstance();
f.restrictPath("/", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/oak:index/l2"), lookup.collectIndexNodePaths(f));
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl 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());
}
Aggregations