IndexAccess(IndexWriter writer) throws IOException { this.writer = writer; IndexReader reader = IndexReader.open(writer, true); searcher = new IndexSearcher(reader); }
/** * Commit the changes. */ public synchronized void commit() throws IOException { writer.commit(); if (counter != 0) { counters.put(searcher, counter); counter = 0; } else { closeSearcher(searcher); } // recreate Searcher with the IndexWriter's reader. searcher = new IndexSearcher(IndexReader.open(writer, true)); }
public LogSearch(File file) throws Exception { this.file = file; directory = new NIOFSDirectory(file, new NativeFSLockFactory()); reader = IndexReader.open(directory); searcher = new IndexSearcher(reader); }
public IndexReader newReader(Directory indexDir, boolean readOnly) throws IOException { return IndexReader.open(indexDir, null, readOnly, termInfosIndexDivisor); } }
/** Returns a read/write IndexReader reading the index in * the given Directory. <b>NOTE</b>: starting in 3.0 this * will return a readOnly IndexReader. * @param directory the index directory * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public static IndexReader open(final Directory directory) throws CorruptIndexException, IOException { return open(directory, false, null, null, READ_ONLY_DEFAULT); }
private IndexSearcher getSearcher() throws IOException { IndexReader reader = IndexReader.open(FSDirectory.open(this._indexDir), true); IndexSearcher searcher = new IndexSearcher(reader); return searcher; }
/** Returns an IndexReader reading the index in an FSDirectory in the named path. */ public static IndexReader open(String path) throws IOException { return open(FSDirectory.getDirectory(path, false), true); }
/** Returns a read/write IndexReader reading the index in an FSDirectory in the named path. <b>NOTE</b>: starting in 3.0 this will return a readOnly IndexReader. * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error * @param path the path to the index directory */ public static IndexReader open(String path) throws CorruptIndexException, IOException { return open(FSDirectory.getDirectory(path), true, null, null, READ_ONLY_DEFAULT); }
private TermFreqVector getTermFreqVector() throws IOException { if( termFreqVector == null ) { IndexReader reader = IndexReader.open(indexDir, true); createFreqVect(reader); reader.close(); } return termFreqVector; }
public Indexer(BlockingQueue<Collection<Document>> queue, IndexWriter writer) throws CorruptIndexException, IOException { _queue = queue; _writer = writer; _reader = IndexReader.open(_writer, true); }
/** Expert: returns a read/write IndexReader reading the index in the given * {@link IndexCommit}. <b>NOTE</b>: starting in 3.0 this * will return a readOnly IndexReader. * @param commit the commit point to open * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public static IndexReader open(final IndexCommit commit) throws CorruptIndexException, IOException { return open(commit.getDirectory(), false, null, commit, READ_ONLY_DEFAULT); }
private void initSourceReader() { if (sourceLocation != null) { try { FSDirectory luceneIndexDir = FSDirectory.getDirectory(sourceLocation); this.reader = IndexReader.open(luceneIndexDir); } catch (IOException e) { throw new RuntimeException(e); } } }
private void openIndex() { try { this.reader = IndexReader.open(this.index); } catch (CorruptIndexException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** Returns a read/write IndexReader reading the index in an FSDirectory in the named * path. <b>NOTE</b>: starting in 3.0 this will return a readOnly IndexReader. * @param path the path to the index directory * @throws CorruptIndexException if the index is corrupt * @throws IOException if there is a low-level IO error */ public static IndexReader open(File path) throws CorruptIndexException, IOException { return open(FSDirectory.getDirectory(path), true, null, null, READ_ONLY_DEFAULT); }
@PostConstruct @Refreshable(dependsOn = RefreshableResources.ROUTE_COLLECTION_SEARCH_DATA) public void initialize() throws IOException { File path = _bundle.getRouteSearchIndexPath(); if (path.exists()) { IndexReader reader = IndexReader.open(path); _searcher = new IndexSearcher(reader); } else { _searcher = null; } }
public void initialize() throws CorruptIndexException, IOException { indexReader = IndexReader.open(FSDirectory.open(new File(indexPath))); numDocs = indexReader.numDocs(); indexSearcher = new IndexSearcher(indexReader); standardAnalyzer = new StandardAnalyzer(Version.LUCENE_40); queryParser = new QueryParser(Version.LUCENE_40, searchField, standardAnalyzer); lastQuery = new Cache(); }
private void newEmpty() throws IOException { lastManaged = false; lastDirectory = EmptyDirectory.get(); lastSequence = Long.MIN_VALUE; reader = IndexReader.open(lastDirectory); watch.reset(); }
protected IndexReader getIndexReader() { // Always return a new reader. Write may have changed. try { flushWriter() ; return IndexReader.open(dir) ; } catch (Exception e) { throw new ARQLuceneException("getIndexReader", e) ; } }
public void deleteStorage(IStorage storage) throws Exception { IndexReader reader = IndexReader.open(getIndexDir(), false); String filePath = storage.getFullPath().toString(); Term term = Field.FILE.createTerm(filePath); reader.deleteDocuments(term); reader.close(); }
private IndexReader openIndexReader() throws IOException { if (useNRT()) { return IndexReader.open(writerReference.get(Index.UpdateMode.INTERACTIVE).getLuceneWriter(), true); } // Ensure all writes have been committed writerReference.get(Index.UpdateMode.INTERACTIVE).getLuceneWriter().commit(); return IndexReader.open(configuration.getDirectory(), true); }