use of org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult in project jackrabbit-oak by apache.
the class LucenePropertyIndex method mergePropertyIndexResult.
@SuppressWarnings("Guava")
private static Iterator<FulltextResultRow> mergePropertyIndexResult(IndexPlan plan, NodeState rootState, Iterator<FulltextResultRow> itr) {
PlanResult pr = getPlanResult(plan);
HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(pr.indexPath, NodeStateUtils.getNode(rootState, pr.indexPath), plan.getPathPrefix(), false);
PropertyIndexResult pir = pr.getPropertyIndexResult();
FluentIterable<String> paths;
if (pir != null) {
Iterable<String> queryResult = lookup.query(plan.getFilter(), pir.propertyName, pir.pr);
paths = FluentIterable.from(queryResult).transform(path -> pr.isPathTransformed() ? pr.transformPath(path) : path).filter(notNull());
} else {
// Either of property or nodetype should not be null
checkState(pr.evaluateSyncNodeTypeRestriction());
Filter filter = plan.getFilter();
paths = FluentIterable.from(Iterables.concat(lookup.query(filter, JCR_PRIMARYTYPE, newName(filter.getPrimaryTypes())), lookup.query(filter, JCR_MIXINTYPES, newName(filter.getMixinTypes()))));
}
// No need for path restriction evaluation as thats taken care by PropertyIndex impl itself
// via content mirror strategy
FluentIterable<FulltextResultRow> propIndex = paths.transform(path -> new FulltextResultRow(path, 0, null, null, null));
// Property index itr should come first
return Iterators.concat(propIndex.iterator(), itr);
}
use of org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult in project jackrabbit-oak by apache.
the class IndexPlannerTest method syncIndex_NotUsedWithSort.
@Test
public void syncIndex_NotUsedWithSort() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().sync();
defnb.indexRule("nt:base").property("bar").propertyIndex().ordered();
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"));
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.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult 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.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult in project jackrabbit-oak by apache.
the class IndexPlannerTest method syncIndex_uniqueIndex.
// ~------------------------------< sync indexes >
@Test
public void syncIndex_uniqueIndex() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().unique();
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"));
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
QueryIndex.IndexPlan plan = planner.getPlan();
assertNotNull(plan);
assertEquals(1, plan.getEstimatedEntryCount());
PropertyIndexResult hr = pr(plan).getPropertyIndexResult();
assertNotNull(hr);
assertEquals("foo", hr.propertyName);
assertEquals("foo", hr.pr.propertyName);
}
use of org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult in project jackrabbit-oak by apache.
the class IndexPlannerTest method syncIndex_uniqueAndRelative.
@Test
public void syncIndex_uniqueAndRelative() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").propertyIndex().unique();
LuceneIndexDefinition defn = new LuceneIndexDefinition(root, defnb.build(), "/foo");
LuceneIndexNode node = createIndexNode(defn);
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("jcr:content/foo", Operator.EQUAL, PropertyValues.newString("bar"));
FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
QueryIndex.IndexPlan plan = planner.getPlan();
assertNotNull(plan);
assertEquals(1, plan.getEstimatedEntryCount());
PropertyIndexResult hr = pr(plan).getPropertyIndexResult();
assertNotNull(hr);
assertEquals("foo", hr.propertyName);
assertEquals("jcr:content/foo", hr.pr.propertyName);
}
Aggregations