use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method propertyIndexCost2.
@Test
public void propertyIndexCost2() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
defn.setProperty(LuceneIndexConstants.COST_PER_ENTRY, 2.0);
defn.setProperty(LuceneIndexConstants.COST_PER_EXECUTION, 3.0);
long numofDocs = IndexDefinition.DEFAULT_ENTRY_COUNT - 100;
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"), numofDocs);
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
QueryIndex.IndexPlan plan = planner.getPlan();
assertEquals(numofDocs, plan.getEstimatedEntryCount());
assertEquals(3.0, plan.getCostPerExecution(), 0);
assertEquals(2.0, plan.getCostPerEntry(), 0);
assertNotNull(plan);
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method purePropertyIndexAndNodeTypeRestriction2.
@Test
public void purePropertyIndexAndNodeTypeRestriction2() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
defn.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true);
defn = IndexDefinition.updateDefinition(defn.getNodeState().builder());
NodeBuilder foob = getNode(defn, "indexRules/nt:base/properties/foo");
foob.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true);
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
FilterImpl filter = createFilter("nt:file");
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
//No plan should be result for a index with just a rule for nt:base
assertNull(planner.getPlan());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled.
@Test
public void testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled() throws Exception {
NodeBuilder builder = nodeState.builder();
builder.child("oak:index").child("solr").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"));
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(0, plans.size());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testNoPlanWithPropertyNotListedInUsedProperties.
@Test
public void testNoPlanWithPropertyNotListedInUsedProperties() 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 foo = 'bar')", new QueryEngineSettings());
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(0, plans.size());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testNoPlanWithPrimaryTypeRestrictions.
@Test
public void testNoPlanWithPrimaryTypeRestrictions() 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 jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(0, plans.size());
}
Aggregations