Package org.apache.lucene.search

Examples of org.apache.lucene.search.SearcherManager


    private final FullTextIndexShared index;
    private final SearcherManager searcherManager;

    public Searcher(FullTextIndexShared index, Analyzer analyzer) throws IOException {
        this.index = index;
        this.searcherManager = new SearcherManager(index.open(), new SearcherFactory());
    }
View Full Code Here


         /* Acquire order here is store -> manager since we need
          * to make sure that the store is not closed before
          * the searcher is acquired. */
        store.incRef();
        try {
            SearcherManager manager = this.searcherManager;
            if (manager == null) {
                ensureOpen();
                try (InternalLock _ = this.readLock.acquire()) {
                    // we might start up right now and the searcherManager is not initialized
                    // we take the read lock and retry again since write lock is taken
                    // while start() is called and otherwise the ensureOpen() call will
                    // barf.
                    manager = this.searcherManager;
                    assert manager != null : "SearcherManager is null but shouldn't";
                }
            }
            /* This might throw NPE but that's fine we will run ensureOpen()
            *  in the catch block and throw the right exception */
            final IndexSearcher searcher = manager.acquire();
            try {
                final Searcher retVal = newSearcher(source, searcher, manager);
                success = true;
                return retVal;
            } finally {
                if (!success) {
                    manager.release(searcher);
                }
            }
        } catch (EngineClosedException ex) {
            throw ex;
        } catch (Throwable ex) {
View Full Code Here

                            indexWriter.setCommitData(Collections.singletonMap(Translog.TRANSLOG_ID_KEY, Long.toString(translogId)));
                            indexWriter.commit();
                            translog.newTranslog(translogId);
                        }

                        SearcherManager current = this.searcherManager;
                        this.searcherManager = buildSearchManager(indexWriter);
                        versionMap.setManager(searcherManager);

                        try {
                            IOUtils.close(current);
View Full Code Here

            }
        }
    }

    private SearcherManager buildSearchManager(IndexWriter indexWriter) throws IOException {
        return new SearcherManager(indexWriter, true, searcherFactory);
    }
View Full Code Here

    Preconditions.checkNotNull(user);

    Multimap<WaveId, WaveletId> userWavesViewMap = HashMultimap.create();
    BooleanQuery participantQuery = new BooleanQuery();
    participantQuery.add(new TermQuery(new Term(WITH.toString(), user.getAddress())), Occur.SHOULD);
    SearcherManager searcherManager = nrtManager.getSearcherManager(true);
    IndexSearcher indexSearcher = searcherManager.acquire();
    try {
      TopDocs hints = indexSearcher.search(participantQuery, MAX_WAVES, LMT_ASC_SORT);
      for (ScoreDoc hint : hints.scoreDocs) {
        Document document = indexSearcher.doc(hint.doc);
        WaveId waveId = WaveId.deserialise(document.get(WAVEID.toString()));
        WaveletId waveletId = WaveletId.deserialise(document.get(WAVELETID.toString()));
        userWavesViewMap.put(waveId, waveletId);
      }
    } catch (IOException e) {
      LOG.log(Level.WARNING, "Search failed: " + user, e);
    } finally {
      try {
        searcherManager.release(indexSearcher);
      } catch (IOException e) {
        LOG.log(Level.WARNING, "Failed to close searcher. " + user, e);
      }
      indexSearcher = null;
    }
View Full Code Here

            // The index needs to exist before creating the searcher manager so do a quick commit
            // of nothing in case the index doesn't exist already.
            this.indexWriter.commit();
        }

        this.searcherManager = new SearcherManager(FSDirectory.open(indexDir), new SearcherFactory());
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.SearcherManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.