use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlannerTest method valuePattern_StartsWith.
@Test
public void valuePattern_StartsWith() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().valueExcludedPrefixes("/jobs");
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, defnb.build(), "/foo");
LuceneIndexNode node = createIndexNode(defn);
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.GREATER_OR_EQUAL, PropertyValues.newString("/bar"));
filter.restrictProperty("foo", Operator.LESS_OR_EQUAL, PropertyValues.newString("/bar0"));
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNotNull(planner.getPlan());
filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.GREATER_OR_EQUAL, PropertyValues.newString("/jobs"));
filter.restrictProperty("foo", Operator.LESS_OR_EQUAL, PropertyValues.newString("/jobs0"));
planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNull(planner.getPlan());
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlannerTest method syncIndex_NotUsedWithFulltext.
@Test
public void syncIndex_NotUsedWithFulltext() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().sync();
defnb.indexRule("nt:base").property("bar").analyzed();
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, defnb.build(), "/foo");
LuceneIndexNode node = createIndexNode(defn, 100);
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
filter.setFullTextConstraint(FullTextParser.parse("bar", "mountain"));
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, ImmutableList.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING)));
QueryIndex.IndexPlan plan = planner.getPlan();
assertNotNull(plan);
assertEquals(documentsPerValue(100), plan.getEstimatedEntryCount());
PropertyIndexResult hr = pr(plan).getPropertyIndexResult();
assertNull(hr);
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlannerTest method noRestrictionWithTwoSortableFields.
@Test
public void noRestrictionWithTwoSortableFields() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo", "bar"), "async");
defn.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo", "bar"), STRINGS));
LuceneIndexDefinition definition = new LuceneIndexDefinition(root, defn.getNodeState(), "/test");
LuceneIndexNode node = createIndexNode(definition);
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/test", createFilter("nt:base"), ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING)));
assertNotNull(planner.getPlan());
assertEquals(1, planner.getPlan().getEstimatedEntryCount());
assertEquals(definition.getCostPerEntry() / 3, planner.getPlan().getCostPerEntry(), 0.0001);
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry in project jackrabbit-oak by apache.
the class IndexPlannerTest method valuePattern_Equals.
@Test
public void valuePattern_Equals() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().valueExcludedPrefixes("/jobs");
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, defnb.build(), "/foo");
LuceneIndexNode node = createIndexNode(defn);
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("/bar"));
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNotNull(planner.getPlan());
filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("/jobs/a"));
planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNull(planner.getPlan());
}
Aggregations