Search in sources :

Example 1 with HybridPropertyIndexLookup

use of org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexLookup in project jackrabbit-oak by apache.

the class LucenePropertyIndex method mergePropertyIndexResult.

@SuppressWarnings("Guava")
private static Iterator<LuceneResultRow> mergePropertyIndexResult(IndexPlan plan, NodeState rootState, Iterator<LuceneResultRow> 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 = null;
    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<LuceneResultRow> propIndex = paths.transform(path -> new LuceneResultRow(path, 0, null, null, null));
    // Property index itr should come first
    return Iterators.concat(propIndex.iterator(), itr);
}
Also used : PlanResult(org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PlanResult) PropertyIndexResult(org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PropertyIndexResult) Filter(org.apache.jackrabbit.oak.spi.query.Filter) HybridPropertyIndexLookup(org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexLookup)

Aggregations

PlanResult (org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PlanResult)1 PropertyIndexResult (org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PropertyIndexResult)1 HybridPropertyIndexLookup (org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexLookup)1 Filter (org.apache.jackrabbit.oak.spi.query.Filter)1