add getTook method to search result
This commit is contained in:
parent
2701c2b11d
commit
db6d67a91a
4 changed files with 16 additions and 4 deletions
|
@ -6,5 +6,7 @@ public interface SearchResult {
|
|||
|
||||
long getTotal();
|
||||
|
||||
long getTook();
|
||||
|
||||
List<SearchDocument> getDocuments();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<SearchDocument> getDocuments() {
|
||||
List<SearchDocument> list = new ArrayList<>();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue