Skip to content

Commit

Permalink
Merge branch 'master' into feature/reader-context
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Mar 23, 2020
2 parents b4ffd2e + aa56f91 commit 2bcee88
Show file tree
Hide file tree
Showing 72 changed files with 1,534 additions and 480 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
public class AsyncSearchResponse implements ToXContentObject {
@Nullable
private final String id;
private final int version;
@Nullable
private final SearchResponse searchResponse;
@Nullable
Expand All @@ -55,15 +54,13 @@ public class AsyncSearchResponse implements ToXContentObject {
/**
* Creates an {@link AsyncSearchResponse} with the arguments that are always present in the server response
*/
AsyncSearchResponse(int version,
boolean isPartial,
boolean isRunning,
long startTimeMillis,
long expirationTimeMillis,
@Nullable String id,
@Nullable SearchResponse searchResponse,
@Nullable ElasticsearchException error) {
this.version = version;
AsyncSearchResponse(boolean isPartial,
boolean isRunning,
long startTimeMillis,
long expirationTimeMillis,
@Nullable String id,
@Nullable SearchResponse searchResponse,
@Nullable ElasticsearchException error) {
this.isPartial = isPartial;
this.isRunning = isRunning;
this.startTimeMillis = startTimeMillis;
Expand All @@ -81,13 +78,6 @@ public String getId() {
return id;
}

/**
* Returns the version of this response.
*/
public int getVersion() {
return version;
}

/**
* Returns the current {@link SearchResponse} or <code>null</code> if not available.
*
Expand Down Expand Up @@ -145,7 +135,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (id != null) {
builder.field("id", id);
}
builder.field("version", version);
builder.field("is_partial", isPartial);
builder.field("is_running", isRunning);
builder.field("start_time_in_millis", startTimeMillis);
Expand All @@ -165,7 +154,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}

public static final ParseField ID_FIELD = new ParseField("id");
public static final ParseField VERSION_FIELD = new ParseField("version");
public static final ParseField IS_PARTIAL_FIELD = new ParseField("is_partial");
public static final ParseField IS_RUNNING_FIELD = new ParseField("is_running");
public static final ParseField START_TIME_FIELD = new ParseField("start_time_in_millis");
Expand All @@ -176,16 +164,14 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
public static final ConstructingObjectParser<AsyncSearchResponse, Void> PARSER = new ConstructingObjectParser<>(
"submit_async_search_response", true,
args -> new AsyncSearchResponse(
(int) args[0],
(boolean) args[0],
(boolean) args[1],
(boolean) args[2],
(long) args[2],
(long) args[3],
(long) args[4],
(String) args[5],
(SearchResponse) args[6],
(ElasticsearchException) args[7]));
(String) args[4],
(SearchResponse) args[5],
(ElasticsearchException) args[6]));
static {
PARSER.declareInt(constructorArg(), VERSION_FIELD);
PARSER.declareBoolean(constructorArg(), IS_PARTIAL_FIELD);
PARSER.declareBoolean(constructorArg(), IS_RUNNING_FIELD);
PARSER.declareLong(constructorArg(), START_TIME_FIELD);
Expand All @@ -203,7 +189,7 @@ private static SearchResponse parseSearchResponse(XContentParser p) throws IOExc
return SearchResponse.innerFromXContent(p);
}

public static AsyncSearchResponse fromXContent(XContentParser parser) throws IOException {
public static AsyncSearchResponse fromXContent(XContentParser parser) {
return PARSER.apply(parser, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void testSubmitAsyncSearchRequest() throws IOException {
// 15 sec should be enough to make sure we always complete right away
request.setWaitForCompletion(new TimeValue(15, TimeUnit.SECONDS));
AsyncSearchResponse response = highLevelClient().asyncSearch().submitAsyncSearch(request, RequestOptions.DEFAULT);
assertTrue(response.getVersion() >= 0);
assertFalse(response.isPartial());
assertTrue(response.getStartTime() > 0);
assertTrue(response.getExpirationTime() > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class AsyncSearchResponseTests

@Override
protected org.elasticsearch.xpack.core.search.action.AsyncSearchResponse createServerTestInstance(XContentType xContentType) {
int version = randomIntBetween(0, Integer.MAX_VALUE);
boolean isPartial = randomBoolean();
boolean isRunning = randomBoolean();
long startTimeMillis = randomLongBetween(0, Long.MAX_VALUE);
Expand All @@ -48,7 +47,7 @@ protected org.elasticsearch.xpack.core.search.action.AsyncSearchResponse createS
: new SearchResponse(InternalSearchResponse.empty(), randomAlphaOfLength(10), 1, 1, 0, randomIntBetween(0, 10000),
ShardSearchFailure.EMPTY_ARRAY, Clusters.EMPTY);
org.elasticsearch.xpack.core.search.action.AsyncSearchResponse testResponse =
new org.elasticsearch.xpack.core.search.action.AsyncSearchResponse(id, version, searchResponse, error, isPartial, isRunning,
new org.elasticsearch.xpack.core.search.action.AsyncSearchResponse(id, searchResponse, error, isPartial, isRunning,
startTimeMillis, expirationTimeMillis);
return testResponse;
}
Expand All @@ -62,7 +61,6 @@ protected AsyncSearchResponse doParseToClientInstance(XContentParser parser) thr
protected void assertInstances(org.elasticsearch.xpack.core.search.action.AsyncSearchResponse expected, AsyncSearchResponse parsed) {
assertNotSame(parsed, expected);
assertEquals(expected.getId(), parsed.getId());
assertEquals(expected.getVersion(), parsed.getVersion());
assertEquals(expected.isRunning(), parsed.isRunning());
assertEquals(expected.isPartial(), parsed.isPartial());
assertEquals(expected.getStartTime(), parsed.getStartTime());
Expand Down
45 changes: 24 additions & 21 deletions docs/reference/search/async-search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ POST /sales*/_async_search?size=0
}
}
--------------------------------------------------
// TEST[skip:"AwaitsFix https://github.com/elastic/elasticsearch/issues/53887"]
// TEST[setup:sales]
// TEST[s/size=0/size=0&wait_for_completion=0/]
// TEST[s/size=0/size=0&wait_for_completion=10s&clean_on_completion=false/]

The response contains an identifier of the search being executed.
You can use this ID to later retrieve the search's final results.
Expand All @@ -43,7 +42,6 @@ results are returned as part of the <<search-api-response-body,`response`>> obje
--------------------------------------------------
{
"id" : "FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=", <1>
"version" : 0,
"is_partial" : true, <2>
"is_running" : true, <3>
"start_time_in_millis" : 1583945890986,
Expand All @@ -70,12 +68,17 @@ results are returned as part of the <<search-api-response-body,`response`>> obje
}
--------------------------------------------------
// TESTRESPONSE[s/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=/$body.id/]
// TESTRESPONSE[s/"is_partial" : true/"is_partial": $body.is_partial/]
// TESTRESPONSE[s/"is_running" : true/"is_running": $body.is_running/]
// TESTRESPONSE[s/1583945890986/$body.start_time_in_millis/]
// TESTRESPONSE[s/1584377890986/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/"took" : 1122/"took": $body.response.took/]
// TESTRESPONSE[s/"num_reduce_phases" : 0,//]
// TESTRESPONSE[s/"total" : 562/"total": $body.response._shards.total/]
// TESTRESPONSE[s/"successful" : 3/"successful": $body.response._shards.successful/]
// TESTRESPONSE[s/"value" : 157483/"value": $body.response.hits.total.value/]
// TESTRESPONSE[s/"relation" : "gte"/"relation": $body.response.hits.total.relation/]
// TESTRESPONSE[s/"hits" : \[ \]\n\s\s\s\s\}/"hits" : \[\]},"aggregations": $body.response.aggregations/]

<1> Identifier of the async search that can be used to monitor its progress, retrieve its results, and/or delete it.
<2> Whether the returned search results are partial or final
Expand Down Expand Up @@ -135,17 +138,16 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
--------------------------------------------------
{
"id" : "FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=",
"version" : 2, <1>
"is_partial" : true, <2>
"is_running" : true, <3>
"is_partial" : true, <1>
"is_running" : true, <2>
"start_time_in_millis" : 1583945890986,
"expiration_time_in_millis" : 1584377890986, <4>
"expiration_time_in_millis" : 1584377890986, <3>
"response" : {
"took" : 12144,
"timed_out" : false,
"num_reduce_phases" : 38,
"num_reduce_phases" : 46, <4>
"_shards" : {
"total" : 562,
"total" : 562, <5>
"successful" : 188,
"skipped" : 0,
"failed" : 0
Expand All @@ -158,7 +160,7 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
"max_score" : null,
"hits" : [ ]
},
"aggregations" : { <5>
"aggregations" : { <6>
"sale_date" : {
"buckets" : []
}
Expand All @@ -176,17 +178,18 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
// TESTRESPONSE[s/"successful" : 188/"successful": $body.response._shards.successful/]
// TESTRESPONSE[s/"value" : 456433/"value": $body.response.hits.total.value/]
// TESTRESPONSE[s/"buckets" : \[\]/"buckets": $body.response.aggregations.sale_date.buckets/]
// TESTRESPONSE[s/"num_reduce_phases" : 38,//]

<1> The returned `version` is useful to identify whether the response contains
additional results compared to previously obtained responses. If the version
stays the same, no new results have become available, otherwise a higher version
number indicates that more shards have completed their execution of the query
and their partial results are also included in the response.
<2> Whether the returned search results are partial or final
<3> Whether the search is still being executed or it has completed
<4> When the async search will expire
<5> Partial aggregations results, coming from the shards that have already
// TESTRESPONSE[s/"num_reduce_phases" : 46,//]

<1> Whether the returned search results are partial or final
<2> Whether the search is still being executed or it has completed
<3> When the async search will expire
<4> Indicates how many reduction of the results have been performed. If this
number increases compared to the last retrieved results, you can expect
additional results included in the search response
<5> Indicates how many shards have executed the query. Note that in order for
shard results to be included in the search response, they need to be reduced
first.
<6> Partial aggregations results, coming from the shards that have already
completed the execution of the query.

The `wait_for_completion` parameter, which defaults to `1`, can also be provided
Expand Down
26 changes: 21 additions & 5 deletions docs/reference/sql/functions/date-time.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -500,18 +500,19 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[datePartDateTimeTzOffsetMinus]
--------------------------------------------------
DATE_TRUNC(
string_exp, <1>
datetime_exp) <2>
datetime_exp/interval_exp) <2>
--------------------------------------------------

*Input*:

<1> string expression denoting the unit to which the date/datetime should be truncated to
<2> date/datetime expression
<1> string expression denoting the unit to which the date/datetime/interval should be truncated to
<2> date/datetime/interval expression

*Output*: datetime
*Output*: datetime/interval

*Description*: Truncate the date/datetime to the specified unit by setting all fields that are less significant than the specified
*Description*: Truncate the date/datetime/interval to the specified unit by setting all fields that are less significant than the specified
one to zero (or one, for day, day of week and month). If any of the two arguments is `null` a `null` is returned.
If the first argument is `week` and the second argument is of `interval` type, an error is thrown since the `interval` data type doesn't support a `week` time unit.

[cols="^,^"]
|===
Expand Down Expand Up @@ -563,6 +564,21 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[truncateDateDecades]
include-tagged::{sql-specs}/docs/docs.csv-spec[truncateDateQuarter]
--------------------------------------------------

[source, sql]
--------------------------------------------------
include-tagged::{sql-specs}/docs/docs.csv-spec[truncateIntervalCenturies]
--------------------------------------------------

[source, sql]
--------------------------------------------------
include-tagged::{sql-specs}/docs/docs.csv-spec[truncateIntervalHour]
--------------------------------------------------

[source, sql]
--------------------------------------------------
include-tagged::{sql-specs}/docs/docs.csv-spec[truncateIntervalDay]
--------------------------------------------------

[[sql-functions-datetime-day]]
==== `DAY_OF_MONTH/DOM/DAY`

Expand Down
2 changes: 2 additions & 0 deletions docs/reference/transform/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ your data.
* <<transform-api-quickref>>
* <<ecommerce-transforms>>
* <<transform-examples>>
* <<transform-painless-examples>>
* <<transform-troubleshooting>>
* <<transform-limitations>>

Expand All @@ -26,5 +27,6 @@ include::checkpoints.asciidoc[]
include::api-quickref.asciidoc[]
include::ecommerce-tutorial.asciidoc[]
include::examples.asciidoc[]
include::painless-examples.asciidoc[]
include::troubleshooting.asciidoc[]
include::limitations.asciidoc[]
Loading

0 comments on commit 2bcee88

Please sign in to comment.