use of org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory in project jackrabbit-oak by apache.
the class AggregateTest method propOneLevelNamedDirect.
@Test
public void propOneLevelNamedDirect() throws Exception {
IndexDefinitionBuilder builder = new IndexDefinitionBuilder();
builder.indexRule("nt:folder").property("jcr:content/a").ordered(PropertyType.TYPENAME_LONG).propertyIndex().property("jcr:content/b").ordered(PropertyType.TYPENAME_LONG).propertyIndex();
IndexDefinition defn = new IndexDefinition(root, builder.build(), "/foo");
Aggregate ag = defn.getApplicableIndexingRule("nt:folder").getAggregate();
NodeBuilder nb = newNode("nt:folder");
nb.child("jcr:content").setProperty("a", 1);
nb.child("jcr:content").setProperty("b", 1);
LuceneDocumentMaker maker = new LuceneDocumentMaker(defn, defn.getApplicableIndexingRule("nt:folder"), "/bar");
Document doc = maker.makeDocument(nb.getNodeState());
DefaultIndexWriterFactory writerFactory = new DefaultIndexWriterFactory(Mounts.defaultMountInfoProvider(), null, null);
LuceneIndexWriter writer = writerFactory.newInstance(defn, EMPTY_NODE.builder(), false);
writer.updateDocument("/bar", doc);
writer.close(100);
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory in project jackrabbit-oak by apache.
the class DefaultIndexReaderFactoryTest method indexDir.
@Test
public void indexDir() throws Exception {
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, null);
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
writer.updateDocument("/content/en", newDoc("/content/en"));
writer.close(0);
LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
assertEquals(1, readers.size());
LuceneIndexReader reader = readers.get(0);
assertNotNull(reader.getReader());
assertNull(reader.getSuggestDirectory());
assertNull(reader.getLookup());
assertEquals(1, reader.getReader().numDocs());
final AtomicBoolean closed = new AtomicBoolean();
reader.getReader().addReaderClosedListener(new IndexReader.ReaderClosedListener() {
@Override
public void onClose(IndexReader reader) {
closed.set(true);
}
});
reader.close();
assertTrue(closed.get());
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory in project jackrabbit-oak by apache.
the class DefaultIndexReaderFactoryTest method indexDirWithBlobStore.
@Test
public void indexDirWithBlobStore() throws Exception {
/* Register a blob store */
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(folder.newFolder().getAbsolutePath(), folder.newFolder().getAbsolutePath());
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, new DataStoreBlobStore(ds));
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
writer.updateDocument("/content/en", newDoc("/content/en"));
writer.close(0);
LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
assertEquals(1, readers.size());
LuceneIndexReader reader = readers.get(0);
assertNotNull(reader.getReader());
assertNull(reader.getSuggestDirectory());
assertNull(reader.getLookup());
assertEquals(1, reader.getReader().numDocs());
final AtomicBoolean closed = new AtomicBoolean();
reader.getReader().addReaderClosedListener(new IndexReader.ReaderClosedListener() {
@Override
public void onClose(IndexReader reader) {
closed.set(true);
}
});
reader.close();
assertTrue(closed.get());
}
Aggregations