Skip to content

Instantly share code, notes, and snippets.

@paul58914080
Created August 27, 2017 18:49
Show Gist options
  • Save paul58914080/b1e31544b85f25a8abaf7b3971eba918 to your computer and use it in GitHub Desktop.
Save paul58914080/b1e31544b85f25a8abaf7b3971eba918 to your computer and use it in GitHub Desktop.
Fix for ff4j elasticstore
public Search queryReadAllFeatures(Integer totalCount) {
return new Search.Builder(new SearchSourceBuilder().size(totalCount).toString()).addIndex(connection.getIndexName())
.addType(ElasticConstants.TYPE_FEATURE).build();
}
@Override
public Map<String, Feature> readAll() {
SearchResult resultTotal = getConnection().search(getBuilder().queryReadAllFeatures(), true);
Map<String, Feature> mapOfFeatures = new HashMap<String, Feature>();
if (null != resultTotal && resultTotal.isSucceeded()) {
Integer total = resultTotal.getTotal();
SearchResult result = getConnection().search(getBuilder().queryReadAllFeatures(total), true);
if (null != result && result.isSucceeded()) {
for (Hit<Feature, Void> feature : result.getHits(Feature.class)) {
mapOfFeatures.put(feature.source.getUid(), feature.source);
}
}
}
return mapOfFeatures;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment