Skip to content

Commit 63a9238

Browse files
committed
Merge remote-tracking branch 'elastic/master' into reduce-metadata-writes-master
2 parents 1a9f88f + cf933b1 commit 63a9238

File tree

183 files changed

+2181
-1015
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+2181
-1015
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java

+7
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ private static boolean shouldRunDockerTests(Project project) {
498498
return true;
499499

500500
case LINUX:
501+
// We don't attempt to check the current flavor and version of Linux unless we're
502+
// running in CI, because we don't want to stop people running the Docker tests in
503+
// their own environments if they really want to.
504+
if (BuildParams.isCi() == false) {
505+
return true;
506+
}
507+
501508
// Only some hosts in CI are configured with Docker. We attempt to work out the OS
502509
// and version, so that we know whether to expect to find Docker. We don't attempt
503510
// to probe for whether Docker is available, because that doesn't tell us whether

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ public void keystore(String key, FileSupplier valueSupplier) {
179179
nodes.all(each -> each.keystore(key, valueSupplier));
180180
}
181181

182+
@Override
183+
public void cliSetup(String binTool, CharSequence... args) {
184+
nodes.all(each -> each.cliSetup(binTool, args));
185+
}
186+
182187
@Override
183188
public void setting(String key, String value) {
184189
nodes.all(each -> each.setting(key, value));

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

+44-5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
124124
private final LazyPropertyMap<String, CharSequence> settings = new LazyPropertyMap<>("Settings", this);
125125
private final LazyPropertyMap<String, CharSequence> keystoreSettings = new LazyPropertyMap<>("Keystore", this);
126126
private final LazyPropertyMap<String, File> keystoreFiles = new LazyPropertyMap<>("Keystore files", this, FileEntry::new);
127+
private final LazyPropertyList<CliEntry> cliSetup = new LazyPropertyList<>("CLI setup commands", this);
127128
private final LazyPropertyMap<String, CharSequence> systemProperties = new LazyPropertyMap<>("System properties", this);
128129
private final LazyPropertyMap<String, CharSequence> environment = new LazyPropertyMap<>("Environment", this);
129130
private final LazyPropertyList<CharSequence> jvmArgs = new LazyPropertyList<>("JVM arguments", this);
@@ -301,6 +302,11 @@ public void keystore(String key, FileSupplier valueSupplier) {
301302
keystoreFiles.put(key, valueSupplier);
302303
}
303304

305+
@Override
306+
public void cliSetup(String binTool, CharSequence... args) {
307+
cliSetup.add(new CliEntry(binTool, args));
308+
}
309+
304310
@Override
305311
public void setting(String key, String value) {
306312
settings.put(key, value);
@@ -475,6 +481,14 @@ public synchronized void start() {
475481
));
476482
}
477483

484+
if (cliSetup.isEmpty() == false) {
485+
logToProcessStdout("Running " + cliSetup.size() + " setup commands");
486+
487+
for (CliEntry entry : cliSetup) {
488+
runElasticsearchBinScript(entry.executable, entry.args);
489+
}
490+
}
491+
478492
logToProcessStdout("Starting Elasticsearch process");
479493
startElasticsearchProcess();
480494
}
@@ -623,7 +637,7 @@ public void user(Map<String, String> userSpec) {
623637
credentials.add(cred);
624638
}
625639

626-
private void runElasticsearchBinScriptWithInput(String input, String tool, String... args) {
640+
private void runElasticsearchBinScriptWithInput(String input, String tool, CharSequence... args) {
627641
if (
628642
Files.exists(getDistroDir().resolve("bin").resolve(tool)) == false &&
629643
Files.exists(getDistroDir().resolve("bin").resolve(tool + ".bat")) == false
@@ -642,12 +656,12 @@ private void runElasticsearchBinScriptWithInput(String input, String tool, Strin
642656
.supply()
643657
);
644658
spec.args(
645-
OS.<List<String>>conditional()
659+
OS.<List<CharSequence>>conditional()
646660
.onWindows(() -> {
647-
ArrayList<String> result = new ArrayList<>();
661+
ArrayList<CharSequence> result = new ArrayList<>();
648662
result.add("/c");
649663
result.add("bin\\" + tool + ".bat");
650-
for (String arg : args) {
664+
for (CharSequence arg : args) {
651665
result.add(arg);
652666
}
653667
return result;
@@ -663,7 +677,7 @@ private void runElasticsearchBinScriptWithInput(String input, String tool, Strin
663677
}
664678
}
665679

666-
private void runElasticsearchBinScript(String tool, String... args) {
680+
private void runElasticsearchBinScript(String tool, CharSequence... args) {
667681
runElasticsearchBinScriptWithInput("", tool, args);
668682
}
669683

@@ -1205,6 +1219,11 @@ public List<?> getKeystoreFiles() {
12051219
return keystoreFiles.getNormalizedCollection();
12061220
}
12071221

1222+
@Nested
1223+
public List<?> getCliSetup() {
1224+
return cliSetup.getNormalizedCollection();
1225+
}
1226+
12081227
@Nested
12091228
public List<?> getSettings() {
12101229
return settings.getNormalizedCollection();
@@ -1376,4 +1395,24 @@ public File getFile() {
13761395
return file;
13771396
}
13781397
}
1398+
1399+
private static class CliEntry {
1400+
private String executable;
1401+
private CharSequence[] args;
1402+
1403+
CliEntry(String executable, CharSequence[] args) {
1404+
this.executable = executable;
1405+
this.args = args;
1406+
}
1407+
1408+
@Input
1409+
public String getExecutable() {
1410+
return executable;
1411+
}
1412+
1413+
@Input
1414+
public CharSequence[] getArgs() {
1415+
return args;
1416+
}
1417+
}
13791418
}

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterConfiguration.java

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public interface TestClusterConfiguration {
5858

5959
void keystore(String key, FileSupplier valueSupplier);
6060

61+
void cliSetup(String binTool, CharSequence... args);
62+
6163
void setting(String key, String value);
6264

6365
void setting(String key, String value, PropertyNormalization normalization);

client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -2168,8 +2168,8 @@ public void testGetTrainedModels() throws Exception {
21682168
GetTrainedModelsResponse getTrainedModelsResponse = execute(
21692169
GetTrainedModelsRequest.getAllTrainedModelConfigsRequest(),
21702170
machineLearningClient::getTrainedModels, machineLearningClient::getTrainedModelsAsync);
2171-
assertThat(getTrainedModelsResponse.getTrainedModels(), hasSize(numberOfModels));
2172-
assertThat(getTrainedModelsResponse.getCount(), equalTo(5L));
2171+
assertThat(getTrainedModelsResponse.getTrainedModels(), hasSize(numberOfModels + 1));
2172+
assertThat(getTrainedModelsResponse.getCount(), equalTo(5L + 1));
21732173
}
21742174
{
21752175
GetTrainedModelsResponse getTrainedModelsResponse = execute(
@@ -2192,7 +2192,7 @@ public void testGetTrainedModels() throws Exception {
21922192

21932193
public void testGetTrainedModelsStats() throws Exception {
21942194
MachineLearningClient machineLearningClient = highLevelClient().machineLearning();
2195-
String modelIdPrefix = "get-trained-model-stats-";
2195+
String modelIdPrefix = "a-get-trained-model-stats-";
21962196
int numberOfModels = 5;
21972197
for (int i = 0; i < numberOfModels; ++i) {
21982198
String modelId = modelIdPrefix + i;
@@ -2224,8 +2224,8 @@ public void testGetTrainedModelsStats() throws Exception {
22242224
GetTrainedModelsStatsResponse getTrainedModelsStatsResponse = execute(
22252225
GetTrainedModelsStatsRequest.getAllTrainedModelStatsRequest(),
22262226
machineLearningClient::getTrainedModelsStats, machineLearningClient::getTrainedModelsStatsAsync);
2227-
assertThat(getTrainedModelsStatsResponse.getTrainedModelStats(), hasSize(numberOfModels));
2228-
assertThat(getTrainedModelsStatsResponse.getCount(), equalTo(5L));
2227+
assertThat(getTrainedModelsStatsResponse.getTrainedModelStats(), hasSize(numberOfModels + 1));
2228+
assertThat(getTrainedModelsStatsResponse.getCount(), equalTo(5L + 1));
22292229
assertThat(getTrainedModelsStatsResponse.getTrainedModelStats().get(0).getPipelineCount(), equalTo(1));
22302230
assertThat(getTrainedModelsStatsResponse.getTrainedModelStats().get(1).getPipelineCount(), equalTo(0));
22312231
}

docs/reference/aggregations/bucket/composite-aggregation.asciidoc

+66
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,72 @@ Time zones may either be specified as an ISO 8601 UTC offset (e.g. `+01:00` or
287287
`-08:00`) or as a timezone id, an identifier used in the TZ database like
288288
`America/Los_Angeles`.
289289

290+
*Offset*
291+
292+
include::datehistogram-aggregation.asciidoc[tag=offset-explanation]
293+
294+
[source,console,id=composite-aggregation-datehistogram-offset-example]
295+
----
296+
PUT my_index/_doc/1?refresh
297+
{
298+
"date": "2015-10-01T05:30:00Z"
299+
}
300+
301+
PUT my_index/_doc/2?refresh
302+
{
303+
"date": "2015-10-01T06:30:00Z"
304+
}
305+
306+
GET my_index/_search?size=0
307+
{
308+
"aggs": {
309+
"my_buckets": {
310+
"composite" : {
311+
"sources" : [
312+
{
313+
"date": {
314+
"date_histogram" : {
315+
"field": "date",
316+
"calendar_interval": "day",
317+
"offset": "+6h",
318+
"format": "iso8601"
319+
}
320+
}
321+
}
322+
]
323+
}
324+
}
325+
}
326+
}
327+
----
328+
329+
include::datehistogram-aggregation.asciidoc[tag=offset-result-intro]
330+
331+
[source,console-result]
332+
----
333+
{
334+
...
335+
"aggregations": {
336+
"my_buckets": {
337+
"after_key": { "date": "2015-10-01T06:00:00.000Z" },
338+
"buckets": [
339+
{
340+
"key": { "date": "2015-09-30T06:00:00.000Z" },
341+
"doc_count": 1
342+
},
343+
{
344+
"key": { "date": "2015-10-01T06:00:00.000Z" },
345+
"doc_count": 1
346+
}
347+
]
348+
}
349+
}
350+
}
351+
----
352+
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
353+
354+
include::datehistogram-aggregation.asciidoc[tag=offset-note]
355+
290356
===== Mixing different values source
291357

292358
The `sources` parameter accepts an array of values source.

docs/reference/aggregations/bucket/datehistogram-aggregation.asciidoc

+8-1
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,19 @@ the bucket covering that day will only hold data for 23 hours instead of the usu
461461
where you'll have only a 11h bucket on the morning of 27 March when the DST shift
462462
happens.
463463

464+
[[search-aggregations-bucket-datehistogram-offset]]
464465
===== Offset
465466

467+
// tag::offset-explanation[]
466468
Use the `offset` parameter to change the start value of each bucket by the
467469
specified positive (`+`) or negative offset (`-`) duration, such as `1h` for
468470
an hour, or `1d` for a day. See <<time-units>> for more possible time
469471
duration options.
470472

471473
For example, when using an interval of `day`, each bucket runs from midnight
472-
to midnight. Setting the `offset` parameter to `+6h` changes each bucket
474+
to midnight. Setting the `offset` parameter to `+6h` changes each bucket
473475
to run from 6am to 6am:
476+
// end::offset-explanation[]
474477

475478
[source,console,id=datehistogram-aggregation-offset-example]
476479
-----------------------------
@@ -498,8 +501,10 @@ GET my_index/_search?size=0
498501
}
499502
-----------------------------
500503

504+
// tag::offset-result-intro[]
501505
Instead of a single bucket starting at midnight, the above request groups the
502506
documents into buckets starting at 6am:
507+
// end::offset-result-intro[]
503508

504509
[source,console-result]
505510
-----------------------------
@@ -525,8 +530,10 @@ documents into buckets starting at 6am:
525530
-----------------------------
526531
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
527532

533+
// tag::offset-note[]
528534
NOTE: The start `offset` of each bucket is calculated after `time_zone`
529535
adjustments have been made.
536+
// end::offset-note[]
530537

531538
===== Keyed Response
532539

docs/reference/analysis/tokenfilters/reverse-tokenfilter.asciidoc

+87-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,90 @@
44
<titleabbrev>Reverse</titleabbrev>
55
++++
66

7-
A token filter of type `reverse` that simply reverses each token.
7+
Reverses each token in a stream. For example, you can use the `reverse` filter
8+
to change `cat` to `tac`.
9+
10+
Reversed tokens are useful for suffix-based searches,
11+
such as finding words that end in `-ion` or searching file names by their
12+
extension.
13+
14+
This filter uses Lucene's
15+
https://lucene.apache.org/core/{lucene_version_path}/analyzers-common/org/apache/lucene/analysis/reverse/ReverseStringFilter.html[ReverseStringFilter].
16+
17+
[[analysis-reverse-tokenfilter-analyze-ex]]
18+
==== Example
19+
20+
The following <<indices-analyze,analyze API>> request uses the `reverse`
21+
filter to reverse each token in `quick fox jumps`:
22+
23+
[source,console]
24+
--------------------------------------------------
25+
GET _analyze
26+
{
27+
"tokenizer" : "standard",
28+
"filter" : ["reverse"],
29+
"text" : "quick fox jumps"
30+
}
31+
--------------------------------------------------
32+
33+
The filter produces the following tokens:
34+
35+
[source,text]
36+
--------------------------------------------------
37+
[ kciuq, xof, spmuj ]
38+
--------------------------------------------------
39+
40+
/////////////////////
41+
[source,console-result]
42+
--------------------------------------------------
43+
{
44+
"tokens" : [
45+
{
46+
"token" : "kciuq",
47+
"start_offset" : 0,
48+
"end_offset" : 5,
49+
"type" : "<ALPHANUM>",
50+
"position" : 0
51+
},
52+
{
53+
"token" : "xof",
54+
"start_offset" : 6,
55+
"end_offset" : 9,
56+
"type" : "<ALPHANUM>",
57+
"position" : 1
58+
},
59+
{
60+
"token" : "spmuj",
61+
"start_offset" : 10,
62+
"end_offset" : 15,
63+
"type" : "<ALPHANUM>",
64+
"position" : 2
65+
}
66+
]
67+
}
68+
--------------------------------------------------
69+
/////////////////////
70+
71+
[[analysis-reverse-tokenfilter-analyzer-ex]]
72+
==== Add to an analyzer
73+
74+
The following <<indices-create-index,create index API>> request uses the
75+
`reverse` filter to configure a new
76+
<<analysis-custom-analyzer,custom analyzer>>.
77+
78+
[source,console]
79+
--------------------------------------------------
80+
PUT reverse_example
81+
{
82+
"settings" : {
83+
"analysis" : {
84+
"analyzer" : {
85+
"whitespace_reverse" : {
86+
"tokenizer" : "whitespace",
87+
"filter" : ["reverse"]
88+
}
89+
}
90+
}
91+
}
92+
}
93+
--------------------------------------------------

0 commit comments

Comments
 (0)