本文整理匯總了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);
}
}
}
示例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;
}
示例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);
}
}