add timeout to SearchResult API

This commit is contained in:
Jörg Prante 2021-08-31 10:33:51 +02:00
parent 7f8edfab0f
commit 1f436a5bbf
4 changed files with 17 additions and 5 deletions

View file

@ -13,4 +13,6 @@ public interface SearchResult {
List<SearchDocument> getDocuments(); List<SearchDocument> getDocuments();
Aggregations getAggregations(); Aggregations getAggregations();
boolean isTimedOut();
} }

View file

@ -167,7 +167,8 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement
Optional.empty() : Optional.empty() :
Optional.of(new DefaultSearchResult(searchResponse.getHits(), Optional.of(new DefaultSearchResult(searchResponse.getHits(),
searchResponse.getAggregations(), searchResponse.getAggregations(),
searchResponse.getTook().getMillis())); searchResponse.getTook().getMillis(),
searchResponse.isTimedOut()));
} }
@Override @Override
@ -253,7 +254,8 @@ public abstract class AbstractSearchClient extends AbstractBasicClient implement
.flatMap(searchResponse -> .flatMap(searchResponse ->
new DefaultSearchResult(searchResponse.getHits(), new DefaultSearchResult(searchResponse.getHits(),
searchResponse.getAggregations(), searchResponse.getAggregations(),
searchResponse.getTook().getMillis()).getDocuments().stream()); searchResponse.getTook().getMillis(),
searchResponse.isTimedOut()).getDocuments().stream());
} }
@Override @Override

View file

@ -17,12 +17,16 @@ public class DefaultSearchResult implements SearchResult {
private final long took; private final long took;
private final boolean timedout;
public DefaultSearchResult(SearchHits searchHits, public DefaultSearchResult(SearchHits searchHits,
Aggregations aggregations, Aggregations aggregations,
long took) { long took,
boolean timedout) {
this.searchHits = searchHits; this.searchHits = searchHits;
this.aggregations = aggregations; this.aggregations = aggregations;
this.took = took; this.took = took;
this.timedout = timedout;
} }
@Override @Override
@ -48,4 +52,8 @@ public class DefaultSearchResult implements SearchResult {
return took; return took;
} }
@Override
public boolean isTimedOut() {
return timedout;
}
} }

View file

@ -1,6 +1,6 @@
group = org.xbib group = org.xbib
name = elx name = elx
version = 7.10.2.15 version = 7.10.2.16
gradle.wrapper.version = 6.6.1 gradle.wrapper.version = 6.6.1
xbib-metrics.version = 2.2.0 xbib-metrics.version = 2.2.0
@ -9,7 +9,7 @@ elasticsearch.version = 7.10.2
# ES 7.10.2 uses Jackson 2.10.4 # ES 7.10.2 uses Jackson 2.10.4
jackson.version = 2.12.3 jackson.version = 2.12.3
# ES 7.10.2. uses Netty 4.1.49 # ES 7.10.2. uses Netty 4.1.49
xbib-netty-http.version = 4.1.65.0 xbib-netty-http.version = 4.1.66.0
# ES 7.10.2 uses log4j2 2.11.1 # ES 7.10.2 uses log4j2 2.11.1
log4j.version = 2.14.1 log4j.version = 2.14.1
junit.version = 5.7.1 junit.version = 5.7.1