use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexWriterTest method writeInitializedUponReindex.
@Test
public void writeInitializedUponReindex() throws Exception {
IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
DefaultIndexWriter writer = new DefaultIndexWriter(defn, builder, new DefaultDirectoryFactory(null, null), INDEX_DATA_CHILD_NAME, SUGGEST_DATA_CHILD_NAME, true);
assertTrue(writer.close(0));
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexReaderFactoryTest method multipleReaders_SingleSuggester.
@Test
public void multipleReaders_SingleSuggester() throws Exception {
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, null);
enabledSuggestorForSomeProp();
defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
//Suggester field is only present for document in default mount
Document doc = newDoc("/content/en");
doc.add(new StringField(FieldNames.SUGGEST, "test", null));
writer.updateDocument("/content/en", doc);
writer.updateDocument("/libs/config", newDoc("/libs/config"));
writer.close(0);
LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
//Suggester should be present for all though it may be empty
for (LuceneIndexReader reader : readers) {
assertNotNull(reader.getReader());
assertNotNull(reader.getSuggestDirectory());
assertNotNull(reader.getLookup());
}
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.
the class DefaultIndexReaderFactoryTest method suggesterDir.
@Test
public void suggesterDir() throws Exception {
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, null);
enabledSuggestorForSomeProp();
defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
Document doc = newDoc("/content/en");
doc.add(new StringField(FieldNames.SUGGEST, "test", null));
writer.updateDocument("/content/en", doc);
writer.close(0);
LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
LuceneIndexReader reader = readers.get(0);
assertNotNull(reader.getReader());
assertNotNull(reader.getSuggestDirectory());
assertNotNull(reader.getLookup());
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.
the class NRTIndexTest method getReaderWithoutWriter.
@Test
public void getReaderWithoutWriter() throws Exception {
IndexDefinition idxDefn = getSyncIndexDefinition("/foo");
NRTIndex idx1 = indexFactory.createIndex(idxDefn);
List<LuceneIndexReader> readers = idx1.getReaders();
assertNotNull(readers);
assertTrue(readers.isEmpty());
idx1.close();
assertTrue(idx1.isClosed());
//Closing multiple times should not raise exception
idx1.close();
}
use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition in project jackrabbit-oak by apache.
the class LuceneIndexDumper method dump.
public void dump() throws IOException {
try (Closer closer = Closer.create()) {
NodeState idx = NodeStateUtils.getNode(rootState, indexPath);
IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx, indexPath).build();
indexDir = DirectoryUtils.createIndexDir(baseDir, indexPath);
DirectoryUtils.writeMeta(indexDir, indexPath);
for (String dirName : idx.getChildNodeNames()) {
if (NodeStateUtils.isHidden(dirName) && (isIndexDirName(dirName) || isSuggestIndexDirName(dirName))) {
copyContent(idx, defn, indexDir, dirName, closer);
}
}
}
}
Aggregations