Methods Summary |
---|
private static org.apache.lucene.search.Query[] | createQueries(java.util.List qs, org.apache.lucene.analysis.Analyzer a)Parse the strings containing Lucene queries.
QueryParser qp = new QueryParser("body", a);
List queries = new ArrayList();
for (int i = 0; i < qs.size(); i++) {
try {
Object query = qs.get(i);
Query q = null;
if (query instanceof String) {
q = qp.parse((String) query);
} else if (query instanceof Query) {
q = (Query) query;
} else {
System.err.println("Unsupported Query Type: " + query);
}
if (q != null) {
queries.add(q);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return (Query[]) queries.toArray(new Query[0]);
|
private static org.apache.lucene.search.Query[] | getPrebuiltQueries(java.lang.String field)
// be wary of unanalyzed text
return new Query[] {
new SpanFirstQuery(new SpanTermQuery(new Term(field, "ford")), 5),
new SpanNearQuery(new SpanQuery[]{new SpanTermQuery(new Term(field, "night")), new SpanTermQuery(new Term(field, "trading"))}, 4, false),
new SpanNearQuery(new SpanQuery[]{new SpanFirstQuery(new SpanTermQuery(new Term(field, "ford")), 10), new SpanTermQuery(new Term(field, "credit"))}, 10, false),
new WildcardQuery(new Term(field, "fo*")),
};
|
public org.apache.lucene.search.Query | makeQuery()
return queries[nextQnum()];
|
public org.apache.lucene.search.Query | makeQuery(int size)
throw new Exception(this+".makeQuery(int size) is not supported!");
|
private synchronized int | nextQnum()
int res = qnum;
qnum = (qnum+1) % queries.length;
return res;
|
private void | prepareQueries()
// analyzer (default is standard analyzer)
Analyzer anlzr= (Analyzer) Class.forName(config.get("analyzer",
"org.apache.lucene.analysis.StandardAnalyzer")).newInstance();
List queryList = new ArrayList(20);
queryList.addAll(Arrays.asList(STANDARD_QUERIES));
queryList.addAll(Arrays.asList(getPrebuiltQueries("body")));
queries = createQueries(queryList, anlzr);
|
public java.lang.String | printQueries()
String newline = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer();
if (queries != null) {
for (int i = 0; i < queries.length; i++) {
sb.append(i+". "+Format.simpleName(queries[i].getClass())+" - "+queries[i].toString());
sb.append(newline);
}
}
return sb.toString();
|
public void | resetInputs()
qnum = 0;
|
public void | setConfig(org.apache.lucene.benchmark.byTask.utils.Config config)
this.config = config;
prepareQueries();
|