@Override
  public <T> PaginatedResult<T> readPartial(Query<T> query, long offset, int limit) {
    Client client = openConnection();

    try {
      Set<UUID> typeIds = query.getConcreteTypeIds(this);
      String[] typeIdStrings =
          typeIds.size() == 0
              ? new String[] {"_all"}
              : typeIds.stream().map(UUID::toString).toArray(String[]::new);

      SearchResponse response =
          client
              .prepareSearch(getIndexName())
              .setFetchSource(!query.isReferenceOnly())
              .setTypes(typeIdStrings)
              .setQuery(predicateToQueryBuilder(query.getPredicate()))
              .setFrom((int) offset)
              .setSize(limit)
              .execute()
              .actionGet();

      SearchHits hits = response.getHits();
      List<T> items = new ArrayList<>();

      for (SearchHit hit : hits.getHits()) {
        items.add(createSavedObjectWithHit(hit, query));
      }

      return new PaginatedResult<>(offset, limit, hits.getTotalHits(), items);

    } finally {
      closeConnection(client);
    }
  }