當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。