Search in sources :

Example 16 with OrderEntry

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());
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) FulltextIndexPlanner(org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner) LuceneIndexDefinitionBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) Test(org.junit.Test)

Example 17 with OrderEntry

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);
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) PropertyIndexResult(org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult) FulltextIndexPlanner(org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) LuceneIndexDefinitionBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) Test(org.junit.Test)

Example 18 with OrderEntry

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);
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) FulltextIndexPlanner(org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) Test(org.junit.Test)

Example 19 with OrderEntry

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());
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) FulltextIndexPlanner(org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner) LuceneIndexDefinitionBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) Test(org.junit.Test)

Aggregations

OrderEntry (org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry)19 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)12 FulltextIndexPlanner (org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner)12 Test (org.junit.Test)12 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)8 LuceneIndexDefinitionBuilder (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder)6 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)6 IndexPlan (org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan)4 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 PropertyDefinition (org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition)2 PropertyIndexResult (org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult)2 DynamicOperandImpl (org.apache.jackrabbit.oak.query.ast.DynamicOperandImpl)2 OrderingImpl (org.apache.jackrabbit.oak.query.ast.OrderingImpl)2 PropertyRestriction (org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction)2 FullTextExpression (org.apache.jackrabbit.oak.spi.query.fulltext.FullTextExpression)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1