ReadOnlyIndexPartition( File partitionFolder, Directory directory ) throws IOException { super( partitionFolder, directory ); this.searcherManager = new SearcherManager( directory, new SearcherFactory() ); }
private static SearcherManager instantiateSearcherManager( IndexWriter writer ) { try { return new SearcherManager( writer, true, new SearcherFactory() ); } catch ( IOException e ) { throw new RuntimeException( e ); } }
public WritableIndexPartition( File partitionFolder, Directory directory, IndexWriterConfig writerConfig ) throws IOException { super( partitionFolder, directory ); this.indexWriter = new IndexWriter( directory, writerConfig ); this.searcherManager = new SearcherManager( indexWriter, new SearcherFactory() ); }
/** * Creates and returns a new SearcherManager from the given {@link Directory}. * @param dir the directory to open the DirectoryReader on. * @param searcherFactory An optional {@link SearcherFactory}. Pass * <code>null</code> if you don't require the searcher to be warmed * before going live or other custom behavior. * * @throws IOException if there is a low-level I/O error */ public SearcherManager(Directory dir, SearcherFactory searcherFactory) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; current = getSearcher(searcherFactory, DirectoryReader.open(dir), null); }
/** * Creates and returns a new SearcherManager from an existing {@link DirectoryReader}. Note that * this steals the incoming reference. * * @param reader the DirectoryReader. * @param searcherFactory An optional {@link SearcherFactory}. Pass * <code>null</code> if you don't require the searcher to be warmed * before going live or other custom behavior. * * @throws IOException if there is a low-level I/O error */ public SearcherManager(DirectoryReader reader, SearcherFactory searcherFactory) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; this.current = getSearcher(searcherFactory, reader, null); }
searcherFactory = new SearcherFactory();
public static List<Long> getAllNodes( Directory directory, Value propertyValue ) throws IOException { try ( SearcherManager manager = new SearcherManager( directory, new SearcherFactory() ) ) { IndexSearcher searcher = manager.acquire(); Query query = LuceneDocumentStructure.newSeekQuery( propertyValue ); AllNodesCollector collector = new AllNodesCollector(); searcher.search( query, collector ); return collector.nodeIds; } }
@BeforeEach void initLuceneResources() throws Exception { dirFactory = new DirectoryFactory.InMemoryDirectoryFactory(); Directory dir = dirFactory.open( testDir.directory( "test" ) ); writer = new IndexWriter( dir, IndexWriterConfigs.standard() ); searcherManager = new SearcherManager( writer, true, new SearcherFactory() ); }
TrackingIndexWriter writer; // your writer SearcherFactory factory = new SearcherFactory(); NRTManager mgr = new NRTManager(writer, factory);
private void updateSearcherManager() { Log.d(TAG, "updateSearcherManager"); try { if (mSearcherManager != null) { mSearcherManager.close(); } File indexDirFile = new File(mLucenePath); Directory dir = FSDirectory.open(indexDirFile); mSearcherManager = new SearcherManager(dir, new SearcherFactory()); } catch (IOException e) { Log.e(TAG, "updateSearcherManager - " + e.getClass() + ": " + e.getLocalizedMessage()); } }
private void init(Analyzer analyzer, String keyspaceName, String cfName, String indexName, String vNodeName) throws IOException { this.indexName = indexName; this.keyspaceName = keyspaceName; this.cfName = cfName; this.analyzer = analyzer; this.vNodeName = vNodeName; if (logger.isDebugEnabled()) { logger.debug(indexName + " Lucene analyzer -" + analyzer); logger.debug(indexName + " Lucene version -" + Properties.luceneVersion); } indexWriter = getIndexWriter(Properties.luceneVersion); searcherManager = new SearcherManager(indexWriter, true, new SearcherFactory()); }
protected SearcherManager createSearcherManager() throws IOException { return new SearcherManager(indexWriterProvider.getIndexWriter(), new SearcherFactory()); }
/** * Creates and returns a new SearcherManager from the given {@link Directory}. * @param dir the directory to open the DirectoryReader on. * @param searcherFactory An optional {@link SearcherFactory}. Pass * <code>null</code> if you don't require the searcher to be warmed * before going live or other custom behavior. * * @throws IOException if there is a low-level I/O error */ public SearcherManager(Directory dir, SearcherFactory searcherFactory) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; current = getSearcher(searcherFactory, DirectoryReader.open(dir), null); }
/** * Creates and returns a new SearcherManager from the given {@link Directory}. * @param dir the directory to open the DirectoryReader on. * @param searcherFactory An optional {@link SearcherFactory}. Pass * <code>null</code> if you don't require the searcher to be warmed * before going live or other custom behavior. * * @throws IOException if there is a low-level I/O error */ public SearcherManager(Directory dir, SearcherFactory searcherFactory) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; current = getSearcher(searcherFactory, DirectoryReader.open(dir), null); }
public void open() throws IOException { if (fileSystemDirectory == null) { directory = new RAMDirectory(); } else { directory = FSDirectory.open(fileSystemDirectory); } IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_45, analyzer); config.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND); indexWriter = new IndexWriter(directory, config); searcherManager = new SearcherManager(indexWriter, true, new SearcherFactory()); open = true; }
@Override public IndexSearcher nrtSearcher() { try { return new SearcherFactory().newSearcher( nrtReader() ); } catch ( IOException e ) { throw new RuntimeException( e ); } }
@Override public IndexSearcher nrtSearcher() { try { return new SearcherFactory().newSearcher(nrtReader(), null); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Creates this from already opened {@link IndexReader} and {@link DirectoryTaxonomyReader} instances. Note that * the incoming readers will be closed when you call {@link #close}. */ public SearcherTaxonomyManager(IndexReader reader, DirectoryTaxonomyReader taxoReader, SearcherFactory searcherFactory) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; current = new SearcherAndTaxonomy(SearcherManager.getSearcher(searcherFactory, reader, null), taxoReader); this.taxoWriter = null; taxoEpoch = -1; }
/** Expert: creates near-real-time searcher and taxonomy reader * from the corresponding writers, controlling whether deletes should be applied. */ public SearcherTaxonomyManager(IndexWriter writer, boolean applyAllDeletes, SearcherFactory searcherFactory, DirectoryTaxonomyWriter taxoWriter) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; this.taxoWriter = taxoWriter; DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter); current = new SearcherAndTaxonomy(SearcherManager.getSearcher(searcherFactory, DirectoryReader.open(writer, applyAllDeletes, false), null), taxoReader); this.taxoEpoch = taxoWriter.getTaxonomyEpoch(); }
/** Expert: creates near-real-time searcher and taxonomy reader * from the corresponding writers, controlling whether deletes should be applied. */ public SearcherTaxonomyManager(IndexWriter writer, boolean applyAllDeletes, SearcherFactory searcherFactory, DirectoryTaxonomyWriter taxoWriter) throws IOException { if (searcherFactory == null) { searcherFactory = new SearcherFactory(); } this.searcherFactory = searcherFactory; this.taxoWriter = taxoWriter; DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter); current = new SearcherAndTaxonomy(SearcherManager.getSearcher(searcherFactory, DirectoryReader.open(writer, applyAllDeletes), null), taxoReader); this.taxoEpoch = taxoWriter.getTaxonomyEpoch(); }