use of org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexEditor2Test method relativeProperties.
@Test
public void relativeProperties() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("jcr:content/metadata/foo").propertyIndex();
defnb.aggregateRule("nt:base").include("*");
NodeState defnState = defnb.build();
IndexDefinition defn = new IndexDefinition(root, defnState, indexPath);
LuceneIndexEditorContext ctx = newContext(defnState.builder(), defn, true);
ctx.setPropertyUpdateCallback(propCallback);
EditorHook hook = createHook(ctx);
updateBefore(defnb);
// Property added
NodeBuilder builder = before.builder();
builder.child("a").child("jcr:content").child("metadata").setProperty("foo", "bar");
builder.child("a").setProperty("foo2", "bar");
before = hook.processCommit(root, builder.getNodeState(), CommitInfo.EMPTY);
propCallback.state.assertState("/a", "jcr:content/metadata/foo", UpdateState.ADDED);
assertEquals(1, propCallback.invocationCount);
propCallback.reset();
// Property updated
builder = before.builder();
builder.child("a").child("jcr:content").child("metadata").setProperty("foo", "bar2");
builder.child("a").setProperty("foo2", "bar2");
before = hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
propCallback.state.assertState("/a", "jcr:content/metadata/foo", UpdateState.UPDATED);
assertEquals(1, propCallback.invocationCount);
propCallback.reset();
// Property deleted
builder = before.builder();
builder.child("a").child("jcr:content").child("metadata").removeProperty("foo");
builder.child("a").removeProperty("foo2");
before = hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
propCallback.state.assertState("/a", "jcr:content/metadata/foo", UpdateState.DELETED);
assertEquals(1, propCallback.invocationCount);
propCallback.reset();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexDefinitionTest method uniqueIsSync.
@Test
public void uniqueIsSync() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").unique();
IndexDefinition defn = IndexDefinition.newBuilder(root, defnb.build(), "/foo").build();
assertTrue(defn.getApplicableIndexingRule("nt:base").getConfig("foo").sync);
assertTrue(defn.getApplicableIndexingRule("nt:base").getConfig("foo").unique);
assertTrue(defn.getApplicableIndexingRule("nt:base").getConfig("foo").propertyIndex);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexDefinitionTest method syncIsProperty.
@Test
public void syncIsProperty() throws Exception {
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.indexRule("nt:base").property("foo").sync();
IndexDefinition defn = IndexDefinition.newBuilder(root, defnb.build(), "/foo").build();
assertTrue(defn.getApplicableIndexingRule("nt:base").getConfig("foo").sync);
assertTrue(defn.getApplicableIndexingRule("nt:base").getConfig("foo").propertyIndex);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexDefinitionTest method nodeTypeIndex_mixin.
@Test
public void nodeTypeIndex_mixin() throws Exception {
TestUtil.registerNodeType(builder, testNodeTypeDefn);
root = builder.getNodeState();
LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder();
defnb.nodeTypeIndex();
defnb.indexRule("oak:TestMixA");
IndexDefinition defn = IndexDefinition.newBuilder(root, defnb.build(), "/foo").build();
assertFalse(defn.hasSyncPropertyDefinitions());
assertNotNull(getRule(defn, "oak:TestTypeB"));
assertTrue(getRule(defn, "oak:TestTypeB").indexesAllNodesOfMatchingType());
assertNotNull(getRule(defn, "oak:TestMixA"));
assertTrue(getRule(defn, "oak:TestMixA").indexesAllNodesOfMatchingType());
assertNull(getRule(defn, "oak:TestTypeA"));
assertNull(getRule(defn, "oak:TestSuperType"));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexDefinitionTest method regexAllProps.
@Test
public void regexAllProps() {
LuceneIndexDefinitionBuilder builder = new LuceneIndexDefinitionBuilder();
builder.indexRule("nt:base").property("p");
builder.indexRule("nt:base").property("all", FulltextIndexConstants.REGEX_ALL_PROPS, true);
IndexDefinition def = IndexDefinition.newBuilder(root, builder.build(), "/foo").build();
IndexingRule rule = def.getApplicableIndexingRule(root);
assertNotNull(rule);
PropertyDefinition pd = rule.getConfig("p");
assertNotNull(pd);
assertFalse(pd.isRegexp);
assertFalse(pd.relative);
assertEquals(0, pd.ancestors.length);
pd = rule.getConfig("all");
assertNotNull(pd);
assertTrue(pd.isRegexp);
assertFalse(pd.relative);
assertEquals(0, pd.ancestors.length);
assertThat(rule.getAggregate().getIncludes(), is(empty()));
assertFalse(rule.getAggregate().hasNodeAggregates());
List<Aggregate.Matcher> matchers = rule.getAggregate().createMatchers(new TestRoot("/"));
assertThat(matchers, is(empty()));
assertThat(def.getRelativeNodeNames(), is(empty()));
}
Aggregations