use of org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LuceneIndexInfoProviderTest method info.
@Test
public void info() throws Exception {
IndexDefinitionBuilder defnBuilder = new IndexDefinitionBuilder();
NodeBuilder builder = store.getRoot().builder();
builder.child("oak:index").setChildNode("fooIndex", defnBuilder.build());
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
when(asyncService.getInfo("async")).thenReturn(new AsyncIndexInfo("async", 0, 0, false, null));
IndexInfo info = provider.getInfo("/oak:index/fooIndex");
assertNotNull(info);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder in project jackrabbit-oak by apache.
the class HybridIndexTest method createIndex.
private static Tree createIndex(Tree index, String name, Set<String> propNames) {
IndexDefinitionBuilder idx = new IndexDefinitionBuilder();
IndexRule rule = idx.indexRule("nt:base");
for (String propName : propNames) {
rule.property(propName).propertyIndex();
}
Tree idxTree = index.getChild("oak:index").addChild(name);
idx.build(idxTree);
return idxTree;
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder in project jackrabbit-oak by apache.
the class HybridIndexTest method createFulltextIndex.
private static Tree createFulltextIndex(Tree index, String name) {
IndexDefinitionBuilder idx = new IndexDefinitionBuilder();
idx.evaluatePathRestrictions();
idx.indexRule("nt:base").property(LuceneIndexConstants.REGEX_ALL_PROPS, true).analyzed().nodeScopeIndex().useInExcerpt();
Tree idxTree = index.getChild("oak:index").addChild(name);
idx.build(idxTree);
return idxTree;
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder in project jackrabbit-oak by apache.
the class HybridIndexTest method newNodeTypesFoundLater2.
@Test
public void newNodeTypesFoundLater2() throws Exception {
String idxName = "hybridtest";
IndexDefinitionBuilder idx = new IndexDefinitionBuilder();
idx.indexRule("oak:TestNode").property(JcrConstants.JCR_PRIMARYTYPE).propertyIndex();
idx.indexRule("nt:base").property("foo").propertyIndex().property("bar").propertyIndex();
idx.async("async", "sync");
idx.build(root.getTree("/").getChild("oak:index").addChild(idxName));
//By default nodetype index indexes every nodetype. Declare a specific list
//such that it does not indexes test nodetype
Tree nodeType = root.getTree("/oak:index/nodetype");
if (!nodeType.hasProperty(IndexConstants.DECLARING_NODE_TYPES)) {
nodeType.setProperty(IndexConstants.DECLARING_NODE_TYPES, ImmutableList.of("nt:file"), Type.NAMES);
nodeType.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true);
}
root.commit();
setTraversalEnabled(false);
createPath("/a").setProperty("foo", "bar");
root.commit();
assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a"));
optionalEditorProvider.delegate = new TypeEditorProvider(false);
NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType");
root.refresh();
Tree b = createPath("/b");
b.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:TestNode", Type.NAME);
b.setProperty("bar", "foo");
Tree c = createPath("/c");
c.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:TestNode", Type.NAME);
root.commit();
String query = "select [jcr:path] from [oak:TestNode] ";
assertThat(explain(query), containsString("/oak:index/hybridtest"));
assertQuery(query, of("/b", "/c"));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder in project jackrabbit-oak by apache.
the class LocalIndexWriterFactoryTest method createIndexDefinition.
private void createIndexDefinition(String idxName, IndexingMode indexingMode) {
IndexDefinitionBuilder idx = new IndexDefinitionBuilder();
TestUtil.enableIndexingMode(idx.getBuilderTree(), indexingMode);
idx.indexRule("nt:base").property("foo").propertyIndex();
builder.child("oak:index").setChildNode(idxName, idx.build());
}
Aggregations