Search in sources :

Example 1 with LuceneIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory in project jackrabbit-oak by apache.

the class HybridIndexClusterIT method customize.

@Override
protected Jcr customize(Jcr jcr) {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
    DocumentQueue queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    ExternalIndexObserver externalIndexObserver = new ExternalIndexObserver(queue, tracker, StatisticsProvider.NOOP);
    QueryEngineSettings qs = new QueryEngineSettings();
    qs.setFailTraversal(true);
    jcr.with((QueryIndexProvider) provider).with((Observer) provider).with(localIndexObserver).with(externalIndexObserver).with(editorProvider).with(qs).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    return jcr;
}
Also used : IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 2 with LuceneIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory in project jackrabbit-oak by apache.

the class SynchronousPropertyIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    nrtIndexFactory = new NRTIndexFactory(copier, Clock.SIMPLE, 1000, StatisticsProvider.NOOP);
    MountInfoProvider mip = defaultMountInfoProvider();
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, Mounts.defaultMountInfoProvider());
    editorProvider.setIndexingQueue(queue);
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) luceneIndexProvider).with((Observer) luceneIndexProvider).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(new NodeCounterEditorProvider()).with(delayingEditorProvider).with(optionalEditorProvider).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) InitialContent(org.apache.jackrabbit.oak.InitialContent) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) Oak(org.apache.jackrabbit.oak.Oak) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 3 with LuceneIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory in project jackrabbit-oak by apache.

the class HybridIndexTest method prepareLuceneIndexer.

private void prepareLuceneIndexer(File workDir) {
    try {
        indexCopierDir = createTemporaryFolderIn(workDir);
        copier = new IndexCopier(executorService, indexCopierDir, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    nrtIndexFactory = new NRTIndexFactory(copier, Clock.SIMPLE, TimeUnit.MILLISECONDS.toSeconds(refreshDeltaMillis), StatisticsProvider.NOOP);
    MountInfoProvider mip = Mounts.defaultMountInfoProvider();
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    luceneEditorProvider = new LuceneIndexEditorProvider(copier, tracker, //extractedTextCache
    null, //augmentorFactory
    null, mip);
    queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
    localIndexObserver = new LocalIndexObserver(queue, statsProvider);
    luceneEditorProvider.setIndexingQueue(queue);
}
Also used : LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) LocalIndexObserver(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver) NRTIndexFactory(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)

Example 4 with LuceneIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory in project jackrabbit-oak by apache.

the class HybridIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    nrtIndexFactory.setAssertAllResourcesClosed(true);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) luceneIndexProvider).with((Observer) luceneIndexProvider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) InitialContent(org.apache.jackrabbit.oak.InitialContent) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 5 with LuceneIndexReaderFactory

use of org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory in project jackrabbit-oak by apache.

the class MultiplexingLucenePropertyIndexTest method numDocsIsSumOfAllReaders.

@Test
public void numDocsIsSumOfAllReaders() throws Exception {
    NodeBuilder defnBuilder = newLucenePropertyIndexDefinition(builder, "test", ImmutableSet.of("foo"), "async");
    IndexDefinition defn = new IndexDefinition(initialContent, defnBuilder.getNodeState(), "/foo");
    // 1. Have 2 reader created by writes in 2 diff mounts
    DirectoryFactory directoryFactory = new DefaultDirectoryFactory(null, null);
    LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, directoryFactory, new LuceneIndexWriterConfig());
    LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
    Document doc = newDoc("/content/en");
    doc.add(new StringField("foo", "bar", Field.Store.NO));
    writer.updateDocument("/content/en", doc);
    doc = newDoc("/libs/config");
    doc.add(new StringField("foo", "baz", Field.Store.NO));
    writer.updateDocument("/libs/config", doc);
    writer.close(0);
    // 2. Construct the readers
    LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
    List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
    IndexNodeManager node = new IndexNodeManager("foo", defn, readers, null);
    // 3 Obtain the plan
    FilterImpl filter = createFilter("nt:base");
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    IndexPlanner planner = new IndexPlanner(node.acquire(), "/foo", filter, Collections.<QueryIndex.OrderEntry>emptyList());
    QueryIndex.IndexPlan plan = planner.getPlan();
    // Count should be sum of both readers
    assertEquals(IndexPlannerTest.documentsPerValue(2), plan.getEstimatedEntryCount());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) LuceneIndexWriter(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter) LuceneIndexWriterFactory(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriterFactory) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Document(org.apache.lucene.document.Document) LuceneIndexWriterConfig(org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriterConfig) LuceneIndexReader(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReader) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) DirectoryFactory(org.apache.jackrabbit.oak.plugins.index.lucene.directory.DirectoryFactory) DefaultDirectoryFactory(org.apache.jackrabbit.oak.plugins.index.lucene.directory.DefaultDirectoryFactory) StringField(org.apache.lucene.document.StringField) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) DefaultIndexWriterFactory(org.apache.jackrabbit.oak.plugins.index.lucene.writer.DefaultIndexWriterFactory) DefaultDirectoryFactory(org.apache.jackrabbit.oak.plugins.index.lucene.directory.DefaultDirectoryFactory) Test(org.junit.Test) AbstractQueryTest(org.apache.jackrabbit.oak.query.AbstractQueryTest)

Aggregations

DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)6 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)6 IOException (java.io.IOException)5 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)5 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)5 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)5 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)5 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)5 NRTIndexFactory (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory)3 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)3 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)3 InitialContent (org.apache.jackrabbit.oak.InitialContent)2 Oak (org.apache.jackrabbit.oak.Oak)2 NodeCounterEditorProvider (org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)2 DocumentQueue (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue)2 LocalIndexObserver (org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver)2 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)2 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)2 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)2 AsyncIndexInfoService (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService)1