当前位置: 首页>>代码示例>>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;未经允许,请勿转载。