use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method noPlanForFulltextQueryAndOnlyAnalyzedProperties.
@Test
public void noPlanForFulltextQueryAndOnlyAnalyzedProperties() 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_ANALYZED, true);
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
FilterImpl filter = createFilter("nt:base");
filter.setFullTextConstraint(FullTextParser.parse(".", "mountain"));
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
QueryIndex.IndexPlan plan = planner.getPlan();
assertNull(plan);
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method noApplicableRule.
@Test
public void noApplicableRule() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
defn.setProperty(createProperty(IndexConstants.DECLARING_NODE_TYPES, of("nt:folder"), STRINGS));
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
FilterImpl filter = createFilter("nt:base");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNull(planner.getPlan());
filter = createFilter("nt:folder");
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNotNull(planner.getPlan());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method getSuggestOrSpellcheckIndexPlan.
private QueryIndex.IndexPlan getSuggestOrSpellcheckIndexPlan(IndexNode indexNode, String nodeType, boolean forSugggestion) throws Exception {
FilterImpl filter = createFilter(nodeType);
filter.restrictProperty(indexNode.getDefinition().getFunctionName(), Operator.EQUAL, PropertyValues.newString((forSugggestion ? "suggest" : "spellcheck") + "?term=foo"));
IndexPlanner planner = new IndexPlanner(indexNode, "/foo", filter, Collections.<OrderEntry>emptyList());
return planner.getPlan();
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method fulltextIndexAndPathRestriction.
@Test
public void fulltextIndexAndPathRestriction() 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:base");
filter.restrictPath("/content", Filter.PathRestriction.ALL_CHILDREN);
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
//For case when a full text property is present then path restriction can be
//evaluated
assertNotNull(planner.getPlan());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexPlannerTest method hasPathRestHasNoExplicitQueryPaths.
@Test
public void hasPathRestHasNoExplicitQueryPaths() throws Exception {
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
FilterImpl filter = createFilter("nt:base");
filter.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
assertNotNull(planner.getPlan());
}
Aggregations