当前位置: 首页>>代码示例>>Java>>正文


Java NIOFSDirectory类代码示例

本文整理汇总了Java中org.apache.lucene.store.NIOFSDirectory的典型用法代码示例。如果您正苦于以下问题:Java NIOFSDirectory类的具体用法?Java NIOFSDirectory怎么用?Java NIOFSDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NIOFSDirectory类属于org.apache.lucene.store包,在下文中一共展示了NIOFSDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LuceneIndexer

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public LuceneIndexer(File sourceDirectory, File indexDirectory, Analyzer analyzer)  throws Exception {
    if (indexDirectory != null) {
        if (!indexDirectory.exists()) {
            indexDirectory.mkdir();
        }   
        this.setNiofsDirectory(new NIOFSDirectory(indexDirectory.toPath()));
    } else {
        this.setNiofsDirectory(new NIOFSDirectory(new File("./indexDirectory").toPath()));
    }

    this.setAnalyzer(analyzer);
    
    if ((sourceDirectory != null) && (!sourceDirectoryIndexed)) {
        this.setSourceDirectory(sourceDirectory);
        add(getSourceDirectory());
        sourceDirectoryIndexed = true;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:LuceneIndexer.java

示例2: EclExpressionHandler

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
/**
 * Instantiates a new ecl expression handler.
 *
 * @param terminology the terminology
 * @param version the version
 * @throws Exception the exception
 */
public EclExpressionHandler(String terminology, String version)
    throws Exception {

  // instantiate the index searcher
  String indexDir =
      ConfigUtility.getExpressionIndexDirectoryName(terminology, version);
  Directory dirFile = new NIOFSDirectory(new File(indexDir));
  indexSearcher = new IndexSearcher(DirectoryReader.open(dirFile));

  // instantiate the modified SQS lucene converter
  converter = new ExpressionConstraintToLuceneConverter();

  // instantiate the query parser
  queryParser =
      new QueryParser(EclConceptFieldNames.ID, new StandardAnalyzer());
  queryParser.setAllowLeadingWildcard(true);

  // compute the internal functions from the modified SQS lucene converter
  // NOTE: Kept out of Converter to minimize SQS code modification
  for (final ExpressionConstraintToLuceneConverter.InternalFunction internalFunction : ExpressionConstraintToLuceneConverter.InternalFunction
      .values()) {
    internalFunctionPatternMap.put(internalFunction,
        Pattern.compile(".*(" + internalFunction + "\\(([^\\)]+)\\)).*"));
  }
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:33,代码来源:EclExpressionHandler.java

示例3: getIndexWriter

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public static IndexWriter getIndexWriter(String indexdirectory, double buffersize)
        throws IOException {
  Directory dir;
  if (OSUtil.isWindows())
    dir = FSDirectory.open(new File(indexdirectory));
  else
    dir = NIOFSDirectory.open(new File(indexdirectory));

  Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_45);
  IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_45, analyzer);

  config.setOpenMode(OpenMode.CREATE_OR_APPEND);
  config.setRAMBufferSizeMB(buffersize);
  LogDocMergePolicy mergePolicy = new LogDocMergePolicy();
  mergePolicy.setMergeFactor(3);
  config.setMergePolicy(mergePolicy);

  IndexWriter writer = new IndexWriter(dir, config);
  return writer;
}
 
开发者ID:weizh,项目名称:geolocator-3.0,代码行数:21,代码来源:GetWriter.java

示例4: getIndexSearcher

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public static IndexSearcher getIndexSearcher(String filename, String diskOrMem) throws Exception {
  IndexReader reader;
  Directory d ;
  if (diskOrMem.equals("disk"))
    d = FSDirectory.open(new File(filename));
  else if (diskOrMem.equals("mmap"))
    d=  MmapDirectory(new File(filename));
  else
    throw new Exception("parameter for directory type not defined.");
  
  if(OSUtil.isWindows())
   reader = IndexReader.open(FSDirectory.open(new File(filename)));
  else
    reader = IndexReader.open(NIOFSDirectory.open(new File(filename))); 
  IndexSearcher searcher = new IndexSearcher(reader);
  return searcher;
}
 
开发者ID:weizh,项目名称:geolocator-3.0,代码行数:18,代码来源:GetReader.java

示例5: newFSDirectory

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
protected Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException {
    final String storeType = indexSettings.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(),
        IndexModule.Type.FS.getSettingsKey());
    if (IndexModule.Type.FS.match(storeType)) {
        return FSDirectory.open(location, lockFactory); // use lucene defaults
    } else if (IndexModule.Type.SIMPLEFS.match(storeType)) {
        return new SimpleFSDirectory(location, lockFactory);
    } else if (IndexModule.Type.NIOFS.match(storeType)) {
        return new NIOFSDirectory(location, lockFactory);
    } else if (IndexModule.Type.MMAPFS.match(storeType)) {
        return new MMapDirectory(location, lockFactory);
    }
    throw new IllegalArgumentException("No directory found for type [" + storeType + "]");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:FsDirectoryService.java

示例6: doTestStoreDirectory

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
private void doTestStoreDirectory(Index index, Path tempDir, String typeSettingValue, IndexModule.Type type) throws IOException {
    Settings.Builder settingsBuilder = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT);
    if (typeSettingValue != null) {
        settingsBuilder.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), typeSettingValue);
    }
    Settings settings = settingsBuilder.build();
    IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings);
    FsDirectoryService service = new FsDirectoryService(indexSettings, null, new ShardPath(false, tempDir, tempDir, new ShardId(index, 0)));
    try (Directory directory = service.newFSDirectory(tempDir, NoLockFactory.INSTANCE)) {
        switch (type) {
            case NIOFS:
                assertTrue(type + " " + directory.toString(), directory instanceof NIOFSDirectory);
                break;
            case MMAPFS:
                assertTrue(type + " " + directory.toString(), directory instanceof MMapDirectory);
                break;
            case SIMPLEFS:
                assertTrue(type + " " + directory.toString(), directory instanceof SimpleFSDirectory);
                break;
            case FS:
                if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
                    assertTrue(directory.toString(), directory instanceof MMapDirectory);
                } else if (Constants.WINDOWS) {
                    assertTrue(directory.toString(), directory instanceof SimpleFSDirectory);
                } else {
                    assertTrue(directory.toString(), directory instanceof NIOFSDirectory);
                }
                break;
            default:
                fail();
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:IndexStoreTests.java

示例7: open

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public void open(File indexDirectory, Analyzer analyzer) throws IOException {
    if (indexDirectory != null) {
        indexReader = DirectoryReader.open(new NIOFSDirectory(indexDirectory.toPath()));
    } else {
        indexReader = DirectoryReader.open(new NIOFSDirectory(new File("./indexDirectory").toPath()));
    }
    indexSearcher = new IndexSearcher(indexReader);
    this.analyzer = analyzer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:LuceneSearcher.java

示例8: LogSearch

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public LogSearch(File file) throws Exception
{
    this.file = file;
    directory = new NIOFSDirectory(file, new NativeFSLockFactory());
    reader = IndexReader.open(directory);
    searcher = new IndexSearcher(reader);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:8,代码来源:LogSearch.java

示例9: open

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public void open() throws Exception
{
    if ( !directory.exists() && !directory.mkdirs() )
    {
        throw new IOException("Could not make: " + directory);
    }

    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, new KeywordAnalyzer()).setOpenMode(IndexWriterConfig.OpenMode.CREATE);

    niofsDirectory = new NIOFSDirectory(directory, new SingleInstanceLockFactory());
    writer = new IndexWriter(niofsDirectory, conf);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:13,代码来源:IndexBuilder.java

示例10: openIndexes

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
private void openIndexes(boolean overwrite) throws IOException {
  if (directory == null) {
    try {
      if (path == null)
        directory = new RAMDirectory();
      else {
        //directory = new MMapDirectory(new File(config.getPath()));
        // as per http://wiki.apache.org/lucene-java/ImproveSearchingSpeed
        // we use NIOFSDirectory, provided we're not on Windows
        if (Utils.isWindowsOS())
          directory = FSDirectory.open(new File(path));
        else
          directory = NIOFSDirectory.open(new File(path));
      }

      IndexWriterConfig cfg =
        new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
      cfg.setOpenMode(overwrite ? IndexWriterConfig.OpenMode.CREATE :
                                  IndexWriterConfig.OpenMode.APPEND);
      iwriter = new IndexWriter(directory, cfg);
      iwriter.commit(); // so that the searcher doesn't fail
    } catch (IndexNotFoundException e) {
      if (!overwrite) {
        // the index was not there, so make a new one
        directory = null; // ensure we really do try again
        openIndexes(true);
      } else
        throw new DukeException(e);
    }
  }
}
 
开发者ID:larsga,项目名称:Duke,代码行数:32,代码来源:LuceneDatabase.java

示例11: create

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
/**
 * Creates a corpus adapter which uses the Lucene index with the given path
 * and searches on the field with the given field name.
 * 
 * @param indexPath
 * @param fieldName
 * @return
 * @throws CorruptIndexException
 * @throws IOException
 */
public static LuceneCorpusAdapter create(String indexPath, String fieldName)
        throws CorruptIndexException, IOException {
    DirectoryReader dirReader = DirectoryReader.open(new NIOFSDirectory(new File(indexPath)));
    List<AtomicReaderContext> leaves = dirReader.leaves();
    AtomicReader reader[] = new AtomicReader[leaves.size()];
    AtomicReaderContext contexts[] = new AtomicReaderContext[leaves.size()];
    for (int i = 0; i < reader.length; i++) {
        contexts[i] = leaves.get(i);
        reader[i] = contexts[i].reader();
    }
    return new LuceneCorpusAdapter(dirReader, reader, contexts, fieldName);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:23,代码来源:LuceneCorpusAdapter.java

示例12: ReadIndex

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public ReadIndex(String indexDirPath) {
	super();
	this.m_indexDir = new File(indexDirPath);
	try {
		this.m_indexReader = DirectoryReader.open(new NIOFSDirectory(m_indexDir));
	} catch (IOException e) {
		System.out.println(e.getMessage());
		System.exit(0);
	}
}
 
开发者ID:satyaavasarala,项目名称:lir,代码行数:11,代码来源:ReadIndex.java

示例13: getTaxDirectory

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
private Directory getTaxDirectory(ODatabaseDocumentInternal database) throws IOException {
  Directory dir = null;
  final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
  if (storageLocalAbstract instanceof OLocalPaginatedStorage) {
    String pathname = getIndexFacetPath((OLocalPaginatedStorage) storageLocalAbstract);
    dir = NIOFSDirectory.open(new File(pathname));
  } else {
    dir = new RAMDirectory();
  }
  return dir;
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:12,代码来源:OLuceneFacetManager.java

示例14: reOpen

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
private void reOpen(final ODocument metadata) throws IOException {
  ODatabaseDocumentInternal database = getDatabase();

  final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
  Directory dir = null;
  if (storageLocalAbstract instanceof OLocalPaginatedStorage) {
    String pathname = getIndexPath((OLocalPaginatedStorage) storageLocalAbstract);

    OLogManager.instance().debug(this, "Opening NIOFS Lucene db=%s, path=%s", database.getName(), pathname);

    dir = NIOFSDirectory.open(new File(pathname));
  } else {

    OLogManager.instance().debug(this, "Opening RAM Lucene index db=%s", database.getName());
    dir = new RAMDirectory();

  }

  final IndexWriter indexWriter = createIndexWriter(dir, metadata);
  mgrWriter = new TrackingIndexWriter(indexWriter);
  searcherManager = new SearcherManager(indexWriter, true, null);
  if (nrt != null) {
    nrt.close();
  }

  nrt = new ControlledRealTimeReopenThread(mgrWriter, searcherManager, 60.00, 0.1);
  nrt.setDaemon(true);
  nrt.start();
  flush();
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:31,代码来源:OLuceneIndexManagerAbstract.java

示例15: IndexDatabase

import org.apache.lucene.store.NIOFSDirectory; //导入依赖的package包/类
public IndexDatabase(Path indexFolder, SongDatabase songDb) throws IOException {
    this.songDb = songDb;

    analyzer = new StandardAnalyzer();
    index = new NIOFSDirectory(indexFolder);
    indexWriter = new IndexWriter(index, new IndexWriterConfig(analyzer));
    if (!DirectoryReader.indexExists(index)) {
        analyzeSongs();
    }
}
 
开发者ID:kawane,项目名称:songbook,代码行数:11,代码来源:IndexDatabase.java


注:本文中的org.apache.lucene.store.NIOFSDirectory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。