當前位置: 首頁>>代碼示例>>Java>>正文


Java Version.LUCENE_36屬性代碼示例

本文整理匯總了Java中org.apache.lucene.util.Version.LUCENE_36屬性的典型用法代碼示例。如果您正苦於以下問題:Java Version.LUCENE_36屬性的具體用法?Java Version.LUCENE_36怎麽用?Java Version.LUCENE_36使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.lucene.util.Version的用法示例。


在下文中一共展示了Version.LUCENE_36屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	try (KeywordAnalyzer kwa = new KeywordAnalyzer()) {
		IndexWriterConfig writerConfig = new IndexWriterConfig(Version.LUCENE_36, kwa);
		writerConfig.setOpenMode(append ? OpenMode.CREATE_OR_APPEND : OpenMode.CREATE);
		try (Directory dir = FSDirectory.open(indexDir)) {
			try (IndexWriter writer = new IndexWriter(dir, writerConfig)) {
				AlvisDBIndexerResolvedObjects resObj = getResolvedObjects();
				Logger logger = getLogger(ctx);
				EvaluationContext evalCtx = new EvaluationContext(logger);
				for (ADBElements.Resolved ent : resObj.elements) {
					ent.indexElements(logger, writer, evalCtx, corpus);
				}
			}
		}
		catch (IOException e) {
			rethrow(e);
		}
	}
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:20,代碼來源:AlvisDBIndexer.java

示例2: search

public Map<String, Integer> search(String word, String field, int maxSearch) {
    if (indexSearcher == null) {
        initialize(index);
    }
    Map<String, Integer> verbFreqs = new HashMap<>();
    QueryParser queryParser = new QueryParser(Version.LUCENE_36, field, analyzer);
    try {
        Query query = queryParser.parse(word);
        TopDocs topDocs = indexSearcher.search(query, maxSearch);
        ScoreDoc[] doc = topDocs.scoreDocs;
        for (int i = 0; i < maxSearch && i < doc.length; ++i) {
            int documentId = doc[i].doc;
            Document document = indexSearcher.doc(documentId);
            String verb = document.get(VERB);
            String frequency = document.get(FREQ);
            verbFreqs.put(verb, Integer.parseInt(frequency));
        }
    } catch (ParseException | IOException e) {
        log.warn("Error searching Lucene index.", e);
    }
    return verbFreqs;
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:22,代碼來源:LuceneWrapper.java

示例3: initialize

private void initialize(File indexDir) {
    try {
        Stopwatch stopwatch = Stopwatch.createStarted();
        indexSearcher = new IndexSearcher(IndexReader.open(FSDirectory.open(indexDir)));
        analyzer = new StandardAnalyzer(Version.LUCENE_36);
        log.info("Initialized lucene index at {} ({})", indexDir.getPath(), stopwatch.stop());
    } catch (IOException e) {
        throw new RuntimeException("Unable to locate Lucene index.", e);
    }
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:10,代碼來源:LuceneWrapper.java


注:本文中的org.apache.lucene.util.Version.LUCENE_36屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。