protected QueryResults search( String workspaceName,
String searchExpression,
int maxResults,
int offset ) {
RequestProcessor processor = searchEngine.createProcessor(context, null, true);
try {
FullTextSearchRequest request = new FullTextSearchRequest(searchExpression, workspaceName, maxResults, offset);
processor.process(request);
if (request.hasError()) {
fail(request.getError().getMessage());
return null;
}
assertThat(request.getResultColumns().getColumnCount(), is(0));
assertThat(request.getResultColumns().getLocationCount(), is(1));
assertThat(request.getResultColumns().hasFullTextSearchScores(), is(true));
// Convert the results to a List<Location>
List<Object[]> tuples = request.getTuples();
List<Location> results = new ArrayList<Location>(tuples.size());
for (Object[] tuple : tuples) {
results.add((Location)tuple[0]);
Float score = (Float)tuple[1];
assertThat(score, is(notNullValue()));
}
return new org.jboss.dna.graph.query.process.QueryResults(request.getResultColumns(), request.getStatistics(),
request.getTuples());
} finally {
processor.close();
}
}