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


Java MemoryIndex.search方法代码示例

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


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

示例1: main

import org.apache.lucene.index.memory.MemoryIndex; //导入方法依赖的package包/类
public static void main(String[] args) throws ParseException {
	 Analyzer analyzer = new StandardAnalyzer();
	 MemoryIndex index = new MemoryIndex();
	 Map<String, String> event = new HashMap<String, String>();
	 event.put("content", "Readings about Salmons and other select Alaska fishing Manuals");
	 event.put("author", "Tales of James");
	 
	 for(Entry<String, String> entry : event.entrySet()){
		 index.addField(entry.getKey(), entry.getValue(),analyzer);
	 }
	 
	 QueryParser parser = new QueryParser("content", analyzer);
	 Query query = parser.parse("+author:james +salmon~ +fish* manual~");
	 
	 float score = index.search(query);
	 if (score > 0.0f) {
	     System.out.println("it's a match");
	 } else {
	     System.out.println("no match found");
	 }
	 System.out.println("indexData=" + index.toString());

}
 
开发者ID:atulsm,项目名称:Test_Projects,代码行数:24,代码来源:TestLuceneQueryInMap.java

示例2: search

import org.apache.lucene.index.memory.MemoryIndex; //导入方法依赖的package包/类
protected static void search(MemoryIndex index, Query query) {
	float score = index.search(query);
	if (score > 0.0f) {
		System.out.println("it's a match for " + query);
	} else {
		System.out.println("no match found for " + query);
	}
}
 
开发者ID:atulsm,项目名称:Test_Projects,代码行数:9,代码来源:TestLuceneIndexThenSearchOptions.java

示例3: score

import org.apache.lucene.index.memory.MemoryIndex; //导入方法依赖的package包/类
protected final float score(Client client, LanguageEnum lang,
		MemoryIndex index) throws ParseException, SearchLibException,
		SyntaxError, IOException {
	Query qry = queryMap.get(lang);
	if (qry == null) {
		AbstractSearchRequest searchRequest = getSearchRequest(client, lang);
		qry = searchRequest.getQuery();
		queryMap.put(lang, qry);
	}
	return index.search(qry);
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:12,代码来源:ClassifierItem.java

示例4: searchScore

import org.apache.lucene.index.memory.MemoryIndex; //导入方法依赖的package包/类
public final double searchScore(final String fieldName,
		final CompiledAnalyzer analyzer, final Query query) {
	searchScore = 0;
	if (query == null || analyzer == null)
		return 0;
	MemoryIndex index = new MemoryIndex();
	index.addField(fieldName, originalText, analyzer);
	searchScore = index.search(query);
	return searchScore;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:11,代码来源:Fragment.java


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