I’m trying to create indexes in Jackrabbit Oak (1.1.3) with MongoDB. I was
following http://jackrabbit.apache.org/oak/docs/query/query.html to create
indexes.
The problem is that I’m not sure what to do with the NodeBuilder after it is
generated... It feels like I need to commit/merge the “indexNodeBuilder”, but
that hasn’t worked for me yet. If I try to do an “ns.merge(builder,
commitHook, info)” it fails because the NodeBuilder generated by the IndexUtils
is not a DocumentRootBuilder as required by DocumentNodeStore (that I am using
with MongoDB).
Any Suggestions on how to load the indexes created in Java to the JCR? I have
fullTextSearch running, but it requires me to setFullTextComparisonWithoutIndex
to true, which means my indexing isn’t working. Otherwise if it is false it
won’t return any results in my search. The purpose of this is to prototype
what it would look like to switch from Jackrabbit 2.8 to Oak for speeding up
searches.
Code:
------------------------------------------------------------------------------------------------------------------------
import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
DB db = new MongoClient("127.0.0.1", 27017).getDB("test2");
DocumentNodeStore ns = new DocumentMK.Builder().setMongoDB(db).getNodeStore();
Oak oak = new Oak(ns);
oak.with(new RepositoryInitializer() {
@Override
public void initialize(NodeBuilder builder) {
NodeBuilder root = builder.getBaseState().builder();
NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
ImmutableList fields = ImmutableList.builder().add(
"attributes", "on", "nodes", "like",
"jcr:createdBy", "jcr:lastModifiedBy").build();
NodeBuilder indexNodebuilder = IndexUtils.createIndexDefinition(index,
"fullSearchText", true, false, fields, null);
}
});
------------------------------------------------------------------------------------------------------------------------