diff --git a/elx-api/src/main/java/org/xbib/elx/api/SearchResult.java b/elx-api/src/main/java/org/xbib/elx/api/SearchResult.java index ba846c6..e240d50 100644 --- a/elx-api/src/main/java/org/xbib/elx/api/SearchResult.java +++ b/elx-api/src/main/java/org/xbib/elx/api/SearchResult.java @@ -1,5 +1,7 @@ package org.xbib.elx.api; +import org.elasticsearch.search.aggregations.Aggregations; + import java.util.List; public interface SearchResult { @@ -9,4 +11,6 @@ public interface SearchResult { long getTook(); List getDocuments(); + + Aggregations getAggregations(); } diff --git a/elx-common/src/main/java/org/xbib/elx/common/AbstractSearchClient.java b/elx-common/src/main/java/org/xbib/elx/common/AbstractSearchClient.java index 47078f8..ee9086e 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/AbstractSearchClient.java +++ b/elx-common/src/main/java/org/xbib/elx/common/AbstractSearchClient.java @@ -165,7 +165,9 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement } return isempty ? Optional.empty() : - Optional.of(new DefaultSearchResult(searchResponse.getHits(), searchResponse.getTook().getMillis())); + Optional.of(new DefaultSearchResult(searchResponse.getHits(), + searchResponse.getAggregations(), + searchResponse.getTook().getMillis())); } @Override @@ -249,7 +251,9 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement condition, lastAction), false) .onClose(responseStream::close) .flatMap(searchResponse -> - new DefaultSearchResult(searchResponse.getHits(), searchResponse.getTook().getMillis()).getDocuments().stream()); + new DefaultSearchResult(searchResponse.getHits(), + searchResponse.getAggregations(), + searchResponse.getTook().getMillis()).getDocuments().stream()); } @Override diff --git a/elx-common/src/main/java/org/xbib/elx/common/DefaultSearchResult.java b/elx-common/src/main/java/org/xbib/elx/common/DefaultSearchResult.java index 0578d50..44d808e 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/DefaultSearchResult.java +++ b/elx-common/src/main/java/org/xbib/elx/common/DefaultSearchResult.java @@ -2,6 +2,7 @@ package org.xbib.elx.common; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; +import org.elasticsearch.search.aggregations.Aggregations; import org.xbib.elx.api.SearchDocument; import org.xbib.elx.api.SearchResult; @@ -12,13 +13,31 @@ public class DefaultSearchResult implements SearchResult { private final SearchHits searchHits; + private final Aggregations aggregations; + private final long took; - public DefaultSearchResult(SearchHits searchHits, long took) { + public DefaultSearchResult(SearchHits searchHits, + Aggregations aggregations, + long took) { this.searchHits = searchHits; + this.aggregations = aggregations; this.took = took; } + @Override + public List getDocuments() { + List list = new ArrayList<>(); + for (SearchHit searchHit : searchHits.getHits()) { + list.add(new DefaultSearchDocument(searchHit)); + } + return list; + } + + public Aggregations getAggregations() { + return aggregations; + } + @Override public long getTotal() { return searchHits.getTotalHits().value; @@ -29,12 +48,4 @@ public class DefaultSearchResult implements SearchResult { return took; } - @Override - public List getDocuments() { - List list = new ArrayList<>(); - for (SearchHit searchHit : searchHits.getHits()) { - list.add(new DefaultSearchDocument(searchHit)); - } - return list; - } } diff --git a/gradle.properties b/gradle.properties index 312001d..bdd799a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = elx -version = 7.10.2.14 +version = 7.10.2.15 gradle.wrapper.version = 6.6.1 xbib-metrics.version = 2.2.0