本文整理汇总了Java中org.apache.lucene.search.payloads.AveragePayloadFunction类的典型用法代码示例。如果您正苦于以下问题:Java AveragePayloadFunction类的具体用法?Java AveragePayloadFunction怎么用?Java AveragePayloadFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AveragePayloadFunction类属于org.apache.lucene.search.payloads包,在下文中一共展示了AveragePayloadFunction类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: search
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
public void search(String queryString) {
try {
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File("D:/data/indices/sandbox")));
IndexSearcher searcher = new IndexSearcher(reader);
searcher.setSimilarity(new MyPayloadSimilarity());
PayloadTermQuery query = new PayloadTermQuery(new Term("concept", queryString),
new AveragePayloadFunction());
System.out.println("Query: " + query.toString());
TopDocs topDocs = searcher.search(query, 999);
ScoreDoc[] hits = topDocs.scoreDocs;
System.out.println("Number of results:" + hits.length);
// output
for (int i = 0; i < hits.length; i++) {
Document doc = searcher.doc(hits[i].doc);
System.out.println("-> docid: " + doc.get("path") + " score: " + hits[i].score);
}
reader.close();
} catch (Exception e) {
System.out.println("Exception while searching: " + e.getMessage());
}
}
开发者ID:mucke,项目名称:mucke,代码行数:25,代码来源:PayloadShowcase.java
示例2: getSpanQuery
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
@Override
public SpanQuery getSpanQuery(Element e) throws ParserException {
String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
String value = DOMUtils.getNonBlankTextOrFail(e);
PayloadTermQuery btq = new PayloadTermQuery(new Term(fieldName, value), new AveragePayloadFunction());
btq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
return btq;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:BoostingTermBuilder.java
示例3: getMathQueries
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
private List<Query> getMathQueries(Map<String, Float> queryForms, MathTokenizer.MathMLType type) {
String field = (type == MathTokenizer.MathMLType.PRESENTATION ? "p" : "c") + "math";
List<Query> result = new ArrayList<>();
Iterator<Map.Entry<String, Float>> it = queryForms.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Float> entry = it.next();
Float boost = entry.getValue();
PayloadTermQuery ptq = new PayloadTermQuery(new Term(field, entry.getKey()), new AveragePayloadFunction());
ptq.setBoost(boost);
result.add(ptq);
}
return result;
}
开发者ID:martinliska,项目名称:MIaS,代码行数:15,代码来源:Searching.java
示例4: matchSequence
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
private void matchSequence(IndexReader reader, String sequence, int docs, int continuations) throws IOException {
ContinuationCollector collector = new ContinuationCollector();
ContinuationSimilarity similarity = new ContinuationSimilarity(collector);
IndexSearcher searcher = new IndexSearcher(reader);
searcher.setSimilarity(similarity);
Query query = new PayloadTermQuery(new Term(FIELD_NAME, sequence), new AveragePayloadFunction());
searcher.search(query, collector);
TopDocs results = collector.getTopDocs();
assertEquals(docs, results.scoreDocs.length);
assertEquals(continuations, collector.getContinuationsCount());
}
开发者ID:Elegie,项目名称:luchess,代码行数:13,代码来源:ProofOfConcept.java
示例5: testPayloadTermQuery
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
public void testPayloadTermQuery() throws Throwable {
addDoc("Hurricane warning",
"Bulletin: A hurricane warning was issued at " +
"6 AM for the outer great banks");
addDoc("Warning label maker",
"The warning label maker is a delightful toy for " +
"your precocious seven year old's warning needs");
addDoc("Tornado warning",
"Bulletin: There is a tornado warning for " +
"Worcester county until 6 PM today");
IndexReader r = writer.getReader();
writer.close();
IndexSearcher searcher = new IndexSearcher(r);
searcher.setSimilarity(new BoostingSimilarity());
Term warning = new Term("contents", "warning");
Query query1 = new TermQuery(warning);
LOGGER.info("\nTermQuery results:");
TopDocs hits = searcher.search(query1, 10);
TestUtil.dumpHits(searcher, hits);
assertEquals("Warning label maker", // #B
searcher.doc(hits.scoreDocs[0].doc).get("title")); // #B
Query query2 = new PayloadTermQuery(warning,
new AveragePayloadFunction());
LOGGER.info("\nPayloadTermQuery results:");
hits = searcher.search(query2, 10);
TestUtil.dumpHits(searcher, hits);
assertEquals("Warning label maker", // #C
searcher.doc(hits.scoreDocs[2].doc).get("title")); // #C
r.close();
searcher.close();
}
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:40,代码来源:PayloadsTest.java
示例6: search
import org.apache.lucene.search.payloads.AveragePayloadFunction; //导入依赖的package包/类
/**
* Searches for documents based on a text query.
* @param queryString The query that is used to search
*/
public List<Result> search(String queryString) {
// for results
List<Result> results = new ArrayList<>();
String conceptIndexfolder = configManager.getProperty("conceptindexer.indexfolder");
try {
// access the index and create a searcher
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(conceptIndexfolder)));
IndexSearcher searcher = new IndexSearcher(reader);
searcher.setSimilarity(new PayloadSimilarity());
// create query
PayloadTermQuery query = new PayloadTermQuery(new Term("concept", queryString),
new AveragePayloadFunction());
logger.info("Query: " + query.toString());
// searching...
TopDocs topDocs = searcher.search(query,999);
ScoreDoc[] hits = topDocs.scoreDocs;
// transform into Results objects
for (int i = 0; i < hits.length; i++) {
// get document from index
Document doc = searcher.doc(hits[i].doc);
// store docIDs (filename) and score
Result result = new Result(doc.get("path"), doc.get("path"), hits[i].score, "NO_USER");
results.add(result);
}
reader.close();
} catch (Exception e) {
logger.error("Exception while searching for '" + queryString + "': " + e.getMessage());
e.printStackTrace();
}
return results;
}
开发者ID:mucke,项目名称:mucke,代码行数:47,代码来源:PayloadSearcher.java
注:本文中的org.apache.lucene.search.payloads.AveragePayloadFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论