mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-30 16:52:11 +00:00
DATAES-1003 - Polishing.
This commit is contained in:
parent
e950752e79
commit
6fd35b56da
@ -1174,7 +1174,7 @@ class RequestFactory {
|
||||
}
|
||||
|
||||
TimeValue timeout = query.getTimeout();
|
||||
if (timeout !=null) {
|
||||
if (timeout != null) {
|
||||
sourceBuilder.timeout(timeout);
|
||||
}
|
||||
|
||||
@ -1254,7 +1254,7 @@ class RequestFactory {
|
||||
}
|
||||
|
||||
TimeValue timeout = query.getTimeout();
|
||||
if (timeout !=null) {
|
||||
if (timeout != null) {
|
||||
searchRequestBuilder.setTimeout(timeout);
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,13 @@ abstract class AbstractQuery implements Query {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(TimeValue timeout) {
|
||||
/**
|
||||
* set the query timeout
|
||||
*
|
||||
* @param timeout
|
||||
* @since 4.2
|
||||
*/
|
||||
public void setTimeout(@Nullable TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
@ -278,9 +278,10 @@ public interface Query {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get timeout
|
||||
* Get the query timeout.
|
||||
*
|
||||
* @return null if not set
|
||||
* @since 4.2
|
||||
*/
|
||||
@Nullable
|
||||
TimeValue getTimeout();
|
||||
|
@ -483,21 +483,23 @@ class RequestFactoryTests {
|
||||
assertThat(indexRequest.opType()).isEqualTo(DocWriteRequest.OpType.INDEX);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAES-1003
|
||||
@DisplayName("should set timeout to request")
|
||||
void shouldSetTimeoutToRequest() {
|
||||
Query query = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTimeout(TimeValue.timeValueSeconds(1)).build();
|
||||
Query query = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTimeout(TimeValue.timeValueSeconds(1))
|
||||
.build();
|
||||
|
||||
SearchRequest searchRequest = requestFactory.searchRequest(query, Person.class, IndexCoordinates.of("persons"));
|
||||
|
||||
assertThat(searchRequest.source().timeout()).isEqualTo(TimeValue.timeValueSeconds(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAES-1003
|
||||
@DisplayName("should set timeout to requestbuilder")
|
||||
void shouldSetTimeoutToRequestBuilder() {
|
||||
when(client.prepareSearch(any())).thenReturn(new SearchRequestBuilder(client, SearchAction.INSTANCE));
|
||||
Query query = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTimeout(TimeValue.timeValueSeconds(1)).build();
|
||||
Query query = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTimeout(TimeValue.timeValueSeconds(1))
|
||||
.build();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = requestFactory.searchRequestBuilder(client, query, Person.class,
|
||||
IndexCoordinates.of("persons"));
|
||||
@ -505,7 +507,6 @@ class RequestFactoryTests {
|
||||
assertThat(searchRequestBuilder.request().source().timeout()).isEqualTo(TimeValue.timeValueSeconds(1));
|
||||
}
|
||||
|
||||
|
||||
private String requestToString(ToXContent request) throws IOException {
|
||||
return XContentHelper.toXContent(request, XContentType.JSON, true).utf8ToString();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user