Hi, We are going to implement faceted search (for both string & numeric) based on DocValuesField. For better performance, we decided to put the SortedSetDocValuesReaderState in cache ie
*During first faceted search - new DocValuesReaderState will be opened and "$facets" values will be loaded from index and then we put that state in cache using ConcurrentHashMap *For next faceted search - instead of opening new DocValuesReaderState, we served the DocValuesReaderState from the ConcurrentHashMap. we will maintain the DocValuesReaderState in concurrentHashMap till 5 minutes. After 5 minutes, an Old DocValuesReaderState will be removed from the ConcurrentHashMap. And for every search calls, DocValuesReaderState will be taken from cache like SortedSetDocValuesReaderStatereaderState oldReaderState = new DefaultSortedSetDocValuesReaderState(oldIndexSearcher.getIndexReader()); readerStateCacheMap.put(key, oldReaderState); DocValuesReaderState will be maintained in readerStateCacheMap till 5 minutes **** TopDocs will be computed using new IndexSearcher as FacetsCollector.search(newIndexSearcher, drillDownQuery, boolFilter, noofdocs, facetsCollector); ****After computing TopDocs, facets will be estimated from using old SortedSetDocValuesReaderState ad SortedSetDocValuesFacetCounts facetCount = new SortedSetDocValuesFacetCounts(oldReaderState, facetsCollector); 1. So, is there any chance to get conflicts during topDocs search or facets estimation (because of old indexSearcher in DocValuesReaderState and newIndexSearcher in topDocs computation)? 2. How can we maintain SortedSetDocValuesReaderState in cache? Kindly post your suggestions. Thanks & Regards, Chitra