Java Code Examples for org.apache.lucene.index.SlowCompositeReaderWrapper#wrap()

The following examples show how to use org.apache.lucene.index.SlowCompositeReaderWrapper#wrap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuceneUtils.java    From semanticvectors with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param flagConfig Contains all information necessary for configuring LuceneUtils.
 *        {@link FlagConfig#luceneindexpath()} must be non-empty. 
 */
public LuceneUtils(FlagConfig flagConfig) throws IOException {
  if (flagConfig.luceneindexpath().isEmpty()) {
    throw new IllegalArgumentException(
        "-luceneindexpath is a required argument for initializing LuceneUtils instance.");
  }

  this.compositeReader = DirectoryReader.open(
      FSDirectory.open(FileSystems.getDefault().getPath(flagConfig.luceneindexpath())));
  this.leafReader = SlowCompositeReaderWrapper.wrap(compositeReader);
  MultiFields.getFields(compositeReader);
  this.flagConfig = flagConfig;
  if (!flagConfig.stoplistfile().isEmpty())
    loadStopWords(flagConfig.stoplistfile());

  if (!flagConfig.startlistfile().isEmpty())
    loadStartWords(flagConfig.startlistfile());

  VerbatimLogger.info("Initialized LuceneUtils from Lucene index in directory: " + flagConfig.luceneindexpath() + "\n");
  VerbatimLogger.info("Fields in index are: " + String.join(", ", this.getFieldNames()) + "\n");
}
 
Example 2
Source File: TermDocIterableTest.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
private AtomicReader createIndexReader() throws IOException {
  RAMDirectory directory = new RAMDirectory();
  IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(LUCENE_VERSION, new StandardAnalyzer(LUCENE_VERSION)));
  for (int i = 0; i < BLOCKS; i++) {
    addDocumentBlock(i, COUNT_PER_BLOCK, writer);
  }
  writer.close();
  return SlowCompositeReaderWrapper.wrap(DirectoryReader.open(directory));
}
 
Example 3
Source File: BlurUtil.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
public static AtomicReader getAtomicReader(IndexReader reader) throws IOException {
  return SlowCompositeReaderWrapper.wrap(reader);
}