use of org.swordapp.server.SwordServerException in project mycore by MyCoRe-Org.
the class MCRSwordSolrObjectIDSupplier method getCount.
@Override
public long getCount() throws SwordServerException {
try {
// make a copy to prevent multi threading issues
final SolrQuery queryCopy = this.solrQuery.getCopy();
// only need the numFound
queryCopy.setStart(0);
queryCopy.setRows(0);
final QueryResponse queryResponse = MCRSolrClientFactory.getSolrClient().query(queryCopy);
return queryResponse.getResults().getNumFound();
} catch (SolrServerException | IOException e) {
throw new SwordServerException("Error while getting count with MCRSword2SolrObjectIDSupplier and Query: " + this.solrQuery, e);
}
}
use of org.swordapp.server.SwordServerException in project mycore by MyCoRe-Org.
the class MCRSwordSolrObjectIDSupplier method get.
@Override
public List<MCRObjectID> get(int from, int count) throws SwordServerException {
final SolrQuery queryCopy = this.solrQuery.getCopy();
queryCopy.setStart(from);
queryCopy.setRows(count);
try {
final QueryResponse queryResponse = MCRSolrClientFactory.getSolrClient().query(queryCopy);
return queryResponse.getResults().stream().map(r -> (String) r.getFieldValue("id")).map(MCRObjectID::getInstance).collect(Collectors.toList());
} catch (SolrServerException | IOException e) {
throw new SwordServerException("Error while getting id list with MCRSword2SolrObjectIDSupplier and Query: " + this.solrQuery, e);
}
}
Aggregations