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


Java FSDirectory.getDirectory方法代码示例

本文整理汇总了Java中org.apache.lucene.store.FSDirectory.getDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FSDirectory.getDirectory方法的具体用法?Java FSDirectory.getDirectory怎么用?Java FSDirectory.getDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.store.FSDirectory的用法示例。


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

示例1: main

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
      Directory directory = FSDirectory.getDirectory("demo index", false);
      IndexReader reader = IndexReader.open(directory);

//       Term term = new Term("path", "pizza");
//       int deleted = reader.delete(term);

//       System.out.println("deleted " + deleted +
// 			 " documents containing " + term);

      for (int i = 0; i < reader.maxDoc(); i++)
	reader.delete(i);

      reader.close();
      directory.close();

    } catch (Exception e) {
      System.out.println(" caught a " + e.getClass() +
			 "\n with message: " + e.getMessage());
    }
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:DeleteFiles.java

示例2: MixedDirectory

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
public MixedDirectory(FileSystem readFs, Path readPath, FileSystem writeFs,
    Path writePath, Configuration conf) throws IOException {

  try {
    readDir = new FileSystemDirectory(readFs, readPath, false, conf);
    // check writeFS is a local FS?
    writeDir = FSDirectory.getDirectory(writePath.toString());

  } catch (IOException e) {
    try {
      close();
    } catch (IOException e1) {
      // ignore this one, throw the original one
    }
    throw e;
  }

  lockFactory = new NoLockFactory();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:20,代码来源:MixedDirectory.java

示例3: getId

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
private String getId(IndexCommit commit) {
  StringBuilder sb = new StringBuilder();
  Directory dir = commit.getDirectory();

  // For anything persistent, make something that will
  // be the same, regardless of the Directory instance.
  if (dir instanceof FSDirectory) {
    FSDirectory fsd = (FSDirectory) dir;
    File fdir = fsd.getDirectory();
    sb.append(fdir.getPath());
  } else {
    sb.append(dir);
  }

  sb.append('/');
  sb.append(commit.getGeneration());
  return sb.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:SolrDeletionPolicy.java

示例4: spellChecker

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
/**
 * 拼写错误的提示修正
 * 
 * @param keyword
 * @return
 */
@Override
public List<String> spellChecker(Integer typeId, String sword) {
    try {
        List<String> strList = new ArrayList<String>();
        SpellChecker sp = new SpellChecker(FSDirectory.getDirectory(typeId == appConfig.getGameTypeId() ? appConfig
                .getGameSpellIndexDir() : appConfig.getSoftSpellIndexDir()), new JaroWinklerDistance());
        String[] suggestions = sp.suggestSimilar(sword, appConfig.getSuggestNum());
        for (int i = 0; i < suggestions.length; i++)
            strList.add(suggestions[i]);
        return strList;
    } catch (IOException e) {
        logger.error("Exception", e);

        return null;
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:23,代码来源:SearchServiceImpl.java

示例5: initSpellIndex

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
/**
 * 初始化SpellIndex
 * 
 * @throws IOException
 */
public void initSpellIndex(boolean isGame) throws IOException {
    FileOPHelper.del(isGame ? appConfig.getGameSpellIndexDir() : appConfig.getSoftSpellIndexDir());
    Directory spellIndexDir = FSDirectory.getDirectory(new File(isGame ? appConfig.getGameSpellIndexDir()
            : appConfig.getSoftSpellIndexDir()));
    SpellChecker spellChecker = new SpellChecker(spellIndexDir);
    spellChecker.indexDictionary(new PlainTextDictionary(new File(isGame ? appConfig.getGameSuggestDict()
            : appConfig.getSoftSuggestDict())));
    spellIndexDir.close();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:15,代码来源:SearchServiceImpl.java

示例6: indexSpellCheck

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
private void indexSpellCheck(String id) throws SearchException  {
   	if(!spellcheck) return;
   	
   	IndexReader reader=null;
   	FSDirectory spellDir=null;
   	
   	Resource dir = _createSpellDirectory(id);
	try {
   		File spellFile = FileWrapper.toFile(dir);
   		spellDir = FSDirectory.getDirectory(spellFile);
    	reader = _getReader(id,false);
    	Dictionary dictionary = new LuceneDictionary(reader,"contents");
		
    	SpellChecker spellChecker = new SpellChecker(spellDir);
    	spellChecker.indexDictionary(dictionary);
		
   	}
   	catch(IOException ioe) {
   		throw new SearchException(ioe);
   	}
   	finally {
   		flushEL(reader);
		closeEL(reader);
   	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:26,代码来源:LuceneSearchCollection.java

示例7: setup

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
/**
 * Sets up any Lucene Indexer classes
 *
 * @param context
 * @return
 * @throws Exception
 */
public boolean setup(IndexerContext context) throws Exception {
  // Make sure the complex queries can use more than the default clause count
  BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);

  // Setup the Indexes so they are in a state in which they can immediately
  // be accessed
  ApplicationPrefs prefs = context.getApplicationPrefs();
  {
    // Establish the full directory
    LOG.info("Starting Lucene disk index");
    File path = new File(prefs.get("FILELIBRARY") + Constants.FULL_INDEX);
    boolean create = !path.exists();
    fullIndex = FSDirectory.getDirectory(prefs.get("FILELIBRARY") + Constants.FULL_INDEX);
    if (create) {
      LOG.warn("Lucene index not found, creating new index: " + path.getPath());
      Analyzer fullAnalyzer = new StandardAnalyzer();
      fullWriter = new IndexWriter(fullIndex, fullAnalyzer, true);
      fullWriter.close();
    }
  }

  {
    // Load up the ram directory
    LOG.info("Creating Lucene RAM index...");
    // Create the Ram Directory
    directoryIndex = new RAMDirectory();
    Analyzer directoryAnalyzer = new SnowballAnalyzer("English");
    directoryWriter = new IndexWriter(directoryIndex, directoryAnalyzer, true);
    directoryWriter.close();
    LOG.info("Initialization of RAM index complete...");
  }
  // Search using the updated index
  resetSearchers();
  return true;
}
 
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:43,代码来源:LuceneIndexer.java

示例8: getSpellChecker

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
private SpellChecker getSpellChecker(String id) throws IOException {
	FSDirectory siDir = FSDirectory.getDirectory(FileWrapper.toFile(_getSpellDirectory(id)));
    SpellChecker spellChecker = new SpellChecker(siDir);
    return spellChecker;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:6,代码来源:LuceneSearchCollection.java

示例9: getSpellCheckerDirectory

import org.apache.lucene.store.FSDirectory; //导入方法依赖的package包/类
/**
 * @param language
 * @return the Lucene Directory object for indexedClass and Entity. it is constructed as
 * "${base-spellchecker-directory}/${indexed-class-name}/${indexedField}" so each field indexes are stored in it's
 * own file-directory inside owning-class directory
 * @throws IOException
 */
private Directory getSpellCheckerDirectory(String language) throws IOException {
    String path = "./spellchecker/lucene/" + language;
    return FSDirectory.getDirectory(path);
}
 
开发者ID:andreymoser,项目名称:jspellchecker,代码行数:12,代码来源:LuceneSpellCheckerServlet.java


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