@Override public Iterable<Document> getAllLatest(List<GetRequest> getRequests) throws IOException { Map<String, Collection<String>> collectionIdMap = new HashMap<>(); for (GetRequest getRequest : getRequests) { Optional<String> index = SolrUtilities .getIndex(config.getIndexSupplier(), getRequest.getSensorType(), getRequest.getIndex()); if (index.isPresent()) { Collection<String> ids = collectionIdMap.getOrDefault(index.get(), new HashSet<>()); ids.add(getRequest.getGuid()); collectionIdMap.put(index.get(), ids); } else { LOG.debug("Unable to find index for sensorType {}", getRequest.getSensorType()); } } try { List<Document> documents = new ArrayList<>(); for (String collection : collectionIdMap.keySet()) { SolrDocumentList solrDocumentList = client.getById(collectionIdMap.get(collection), new SolrQuery().set("collection", collection)); documents.addAll( solrDocumentList.stream().map(SolrUtilities::toDocument).collect(Collectors.toList())); } return documents; } catch (SolrServerException e) { throw new IOException(e); } } }