use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexDefinitionTest method indexRuleWithPropertyRegEx.
@Test
public void indexRuleWithPropertyRegEx() throws Exception {
NodeBuilder rules = builder.child(INDEX_RULES);
rules.child("nt:folder");
TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.FIELD_BOOST, 3.0);
TestUtil.child(rules, "nt:folder/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo.*").setProperty(LuceneIndexConstants.PROP_IS_REGEX, true).setProperty(LuceneIndexConstants.FIELD_BOOST, 4.0);
IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
IndexingRule rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
assertNotNull(rule1);
assertTrue(rule1.isIndexed("prop1"));
assertFalse(rule1.isIndexed("prop2"));
assertTrue(rule1.isIndexed("fooProp"));
PropertyDefinition pd = rule1.getConfig("fooProp2");
assertEquals(4.0f, pd.boost, 0);
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder 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.spi.state.NodeBuilder 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.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexDefinitionTest method versionPropertyIsV2.
@Test
public void versionPropertyIsV2() throws Exception {
NodeBuilder defnb = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertEquals(IndexFormatVersion.V2, defn.getVersion());
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexDefinitionTest method fulltextEnabledAndAggregate.
@Test
public void fulltextEnabledAndAggregate() throws Exception {
NodeBuilder defnb = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of("foo"), "async");
IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertFalse(defn.isFullTextEnabled());
NodeBuilder aggregates = defnb.child(LuceneIndexConstants.AGGREGATES);
NodeBuilder aggFolder = aggregates.child("nt:base");
aggFolder.child("i1").setProperty(LuceneIndexConstants.AGG_PATH, "*");
defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertTrue(defn.isFullTextEnabled());
}
Aggregations