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 7ea0dd1..ba846c6 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 @@ -6,5 +6,7 @@ public interface SearchResult { long getTotal(); + long getTook(); + List getDocuments(); } 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 fa57cee..47078f8 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,7 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement } return isempty ? Optional.empty() : - Optional.of(new DefaultSearchResult(searchResponse.getHits())); + Optional.of(new DefaultSearchResult(searchResponse.getHits(), searchResponse.getTook().getMillis())); } @Override @@ -248,7 +248,8 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement return StreamSupport.stream(TakeWhileSpliterator.over(responseStream.spliterator(), condition, lastAction), false) .onClose(responseStream::close) - .flatMap(searchResponse -> new DefaultSearchResult(searchResponse.getHits()).getDocuments().stream()); + .flatMap(searchResponse -> + new DefaultSearchResult(searchResponse.getHits(), 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 4ab88ff..0578d50 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 @@ -12,14 +12,23 @@ public class DefaultSearchResult implements SearchResult { private final SearchHits searchHits; - public DefaultSearchResult(SearchHits searchHits) { + private final long took; + + public DefaultSearchResult(SearchHits searchHits, long took) { this.searchHits = searchHits; + this.took = took; } + @Override public long getTotal() { return searchHits.getTotalHits().value; } + @Override + public long getTook() { + return took; + } + @Override public List getDocuments() { List list = new ArrayList<>(); diff --git a/gradle.properties b/gradle.properties index 56c5814..312001d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = elx -version = 7.10.2.13 +version = 7.10.2.14 gradle.wrapper.version = 6.6.1 xbib-metrics.version = 2.2.0