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 getTotal();
|
||||||
|
|
||||||
|
long getTook();
|
||||||
|
|
||||||
List<SearchDocument> getDocuments();
|
List<SearchDocument> getDocuments();
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement
|
||||||
}
|
}
|
||||||
return isempty ?
|
return isempty ?
|
||||||
Optional.empty() :
|
Optional.empty() :
|
||||||
Optional.of(new DefaultSearchResult(searchResponse.getHits()));
|
Optional.of(new DefaultSearchResult(searchResponse.getHits(), searchResponse.getTook().getMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -248,7 +248,8 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement
|
||||||
return StreamSupport.stream(TakeWhileSpliterator.over(responseStream.spliterator(),
|
return StreamSupport.stream(TakeWhileSpliterator.over(responseStream.spliterator(),
|
||||||
condition, lastAction), false)
|
condition, lastAction), false)
|
||||||
.onClose(responseStream::close)
|
.onClose(responseStream::close)
|
||||||
.flatMap(searchResponse -> new DefaultSearchResult(searchResponse.getHits()).getDocuments().stream());
|
.flatMap(searchResponse ->
|
||||||
|
new DefaultSearchResult(searchResponse.getHits(), searchResponse.getTook().getMillis()).getDocuments().stream());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,14 +12,23 @@ public class DefaultSearchResult implements SearchResult {
|
||||||
|
|
||||||
private final SearchHits searchHits;
|
private final SearchHits searchHits;
|
||||||
|
|
||||||
public DefaultSearchResult(SearchHits searchHits) {
|
private final long took;
|
||||||
|
|
||||||
|
public DefaultSearchResult(SearchHits searchHits, long took) {
|
||||||
this.searchHits = searchHits;
|
this.searchHits = searchHits;
|
||||||
|
this.took = took;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTotal() {
|
public long getTotal() {
|
||||||
return searchHits.getTotalHits().value;
|
return searchHits.getTotalHits().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getTook() {
|
||||||
|
return took;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SearchDocument> getDocuments() {
|
public List<SearchDocument> getDocuments() {
|
||||||
List<SearchDocument> list = new ArrayList<>();
|
List<SearchDocument> list = new ArrayList<>();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = elx
|
name = elx
|
||||||
version = 7.10.2.13
|
version = 7.10.2.14
|
||||||
|
|
||||||
gradle.wrapper.version = 6.6.1
|
gradle.wrapper.version = 6.6.1
|
||||||
xbib-metrics.version = 2.2.0
|
xbib-metrics.version = 2.2.0
|
||||||
|
|
Loading…
Reference in a new issue