amit-jain commented on code in PR #2817: URL: https://github.com/apache/jackrabbit-oak/pull/2817#discussion_r3860842644
########## oak-search-lucene-ng/src/main/java/org/apache/jackrabbit/oak/plugins/index/luceneNg/internal/IndexSearcherHolder.java: ########## @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.plugins.index.luceneNg.internal; + +import org.apache.jackrabbit.oak.plugins.index.luceneNg.LuceneNgIndexStorage; +import org.apache.jackrabbit.oak.plugins.index.luceneNg.directory.OakDirectory; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.search.IndexSearcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * Manages IndexSearcher lifecycle for a Lucene 9 index. + * Opens the index from the {@link LuceneNgIndexStorage} node state passed in (typically the + * {@link LuceneNgIndexStorage#STORAGE_NODE_NAME} child under the index definition). + */ +public class IndexSearcherHolder implements Closeable { + + private static final Logger LOG = LoggerFactory.getLogger(IndexSearcherHolder.class); + + private final String indexName; + private DirectoryReader reader; + private IndexSearcher searcher; + private OakDirectory directory; + private final ConcurrentMap<String, DefaultSortedSetDocValuesReaderState> facetStateCache = + new ConcurrentHashMap<>(); + + /** + * @param storageState {@link LuceneNgIndexStorage#storageState(NodeState)} for the index definition + * @param indexName the index name, used only for logging/error messages + */ + + public IndexSearcherHolder(NodeState storageState, String indexName) throws IOException { + this.indexName = indexName; + this.directory = new OakDirectory(storageState.builder(), indexName, true); Review Comment: > Let's keep this like this for now. I would really like to test this first "core" implementation on indices where it already has sufficient features and then extend the features to cover the other cases. This functionality was added afair as users complained adding a doc and not being able to search on it. > Some users put nrt just because they can, not because they need it. And does it create a problem? But for users requiring it, not having this it creates a problem Also, adding this with the extended common oak-search extension might have some quirks (new overloaded methods etc) which might be cleaner in a new impl as this. BTW i am just looking at this from a parity pov and do not have a personal view on it. @thomasmueller can best suggest if we are ok not adding it initially. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
