本文整理汇总了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());
}
示例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);
}
}
示例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);
}
示例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;
}