Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public Time build() {
return new Time(this);
}

public ObjectBuilder<Time> time(Integer t, TimeUnit u) {
this._kind = Kind.Time;
this._value = String.valueOf(t).concat(u.jsonValue());
return this;
}
}

private static JsonpDeserializer<Time> buildTimeDeserializer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import co.elastic.clients.elasticsearch._types.FieldSort;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.ScriptSource;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch._types.TimeUnit;
import co.elastic.clients.elasticsearch._types.aggregations.TopMetrics;
import co.elastic.clients.elasticsearch._types.query_dsl.MatchAllQuery;
import co.elastic.clients.elasticsearch.core.MsearchRequest;
import co.elastic.clients.elasticsearch.core.OpenPointInTimeRequest;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.testkit.ModelTestCase;
Expand Down Expand Up @@ -89,12 +92,12 @@ public void voidClassTDocumentOverload() throws IOException {
// nor testing anything, just checking that this compiles
ElasticsearchClient client = ElasticsearchClient.of(e -> e.host("http://localhost:9200"));

SearchResponse<Void> resp = client.search(s -> s,Void.class);
SearchResponse<Void> resp = client.search(s -> s, Void.class);
SearchResponse<Void> respDefault = client.search(s -> s);
}

@Test
public void searchRequestBodyOverloads() throws IOException {
public void searchRequestBodyOverloads() {

// Normal search request
SearchRequest searchRequest = SearchRequest.of(b -> b
Expand Down Expand Up @@ -147,4 +150,22 @@ public void searchRequestBodyOverloads() throws IOException {
// Assert both variants result in the same serialization
assertEquals(scriptSourceStandard.toString(), scriptSourceOverload.toString());
}

@Test
public void timeOverload() {
OpenPointInTimeRequest opr = OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(k -> k.time(
"5s")));
OpenPointInTimeRequest opr1 =
OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(k -> k.time(5, TimeUnit.Seconds)));
OpenPointInTimeRequest opr2 =
OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(Time.of(t -> t.time("5s"))));
OpenPointInTimeRequest opr3 =
OpenPointInTimeRequest.of(o -> o.index("test").keepAlive(Time.of(t -> t.time(5,
TimeUnit.Seconds))));

// Assert all variants result in the same serialization
assertEquals(opr.toString(), opr1.toString());
assertEquals(opr.toString(), opr2.toString());
assertEquals(opr.toString(), opr3.toString());
}
}