Skip to content

Commit 569841a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 45223-refactor-env-var-handling
2 parents 9061828 + da2b289 commit 569841a

File tree

121 files changed

+2515
-843
lines changed

Some content is hidden

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

121 files changed

+2515
-843
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ We support development in the Eclipse and IntelliJ IDEs.
115115
For Eclipse, the minimum version that we support is [4.13][eclipse].
116116
For IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
117117

118+
[Docker](https://docs.docker.com/install/) is required for building some Elasticsearch artifacts and executing certain test suites. You can run Elasticsearch without building all the artifacts with:
119+
120+
./gradlew :run
121+
118122
### Configuring IDEs And Running Tests
119123

120124
Eclipse users can automatically configure their IDE: `./gradlew eclipse`
@@ -153,6 +157,10 @@ For IntelliJ, go to
153157
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
154158
`VM Arguments`.
155159

160+
Some tests related to locale testing also require the flag
161+
`-Djava.locale.providers` to be set. Set the VM options/VM arguments for
162+
IntelliJ or Eclipse like describe above to use
163+
`-Djava.locale.providers=SPI,COMPAT`.
156164

157165
### Java Language Formatting Guidelines
158166

TESTING.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ If you want to just run the precommit checks:
263263

264264
Some of these checks will require `docker-compose` installed for bringing up
265265
test fixtures. If it's not present those checks will be skipped automatically.
266+
The host running Docker (or VM if you're using Docker Desktop) needs 4GB of
267+
memory or some of the containers will fail to start. You can tell that you
268+
are short of memory if containers are exiting quickly after starting with
269+
code 137 (128 + 9, where 9 means SIGKILL).
266270

267271
== Testing the REST layer
268272

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSource.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.common.xcontent.ToXContentObject;
2727
import org.elasticsearch.common.xcontent.XContentBuilder;
2828
import org.elasticsearch.common.xcontent.XContentParser;
29+
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
2930

3031
import java.io.IOException;
3132
import java.util.Arrays;
@@ -44,20 +45,27 @@ public static Builder builder() {
4445

4546
private static final ParseField INDEX = new ParseField("index");
4647
private static final ParseField QUERY = new ParseField("query");
48+
public static final ParseField _SOURCE = new ParseField("_source");
4749

4850
private static ObjectParser<Builder, Void> PARSER = new ObjectParser<>("data_frame_analytics_source", true, Builder::new);
4951

5052
static {
5153
PARSER.declareStringArray(Builder::setIndex, INDEX);
5254
PARSER.declareObject(Builder::setQueryConfig, (p, c) -> QueryConfig.fromXContent(p), QUERY);
55+
PARSER.declareField(Builder::setSourceFiltering,
56+
(p, c) -> FetchSourceContext.fromXContent(p),
57+
_SOURCE,
58+
ObjectParser.ValueType.OBJECT_ARRAY_BOOLEAN_OR_STRING);
5359
}
5460

5561
private final String[] index;
5662
private final QueryConfig queryConfig;
63+
private final FetchSourceContext sourceFiltering;
5764

58-
private DataFrameAnalyticsSource(String[] index, @Nullable QueryConfig queryConfig) {
65+
private DataFrameAnalyticsSource(String[] index, @Nullable QueryConfig queryConfig, @Nullable FetchSourceContext sourceFiltering) {
5966
this.index = Objects.requireNonNull(index);
6067
this.queryConfig = queryConfig;
68+
this.sourceFiltering = sourceFiltering;
6169
}
6270

6371
public String[] getIndex() {
@@ -68,13 +76,20 @@ public QueryConfig getQueryConfig() {
6876
return queryConfig;
6977
}
7078

79+
public FetchSourceContext getSourceFiltering() {
80+
return sourceFiltering;
81+
}
82+
7183
@Override
7284
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
7385
builder.startObject();
7486
builder.field(INDEX.getPreferredName(), index);
7587
if (queryConfig != null) {
7688
builder.field(QUERY.getPreferredName(), queryConfig.getQuery());
7789
}
90+
if (sourceFiltering != null) {
91+
builder.field(_SOURCE.getPreferredName(), sourceFiltering);
92+
}
7893
builder.endObject();
7994
return builder;
8095
}
@@ -86,12 +101,13 @@ public boolean equals(Object o) {
86101

87102
DataFrameAnalyticsSource other = (DataFrameAnalyticsSource) o;
88103
return Arrays.equals(index, other.index)
89-
&& Objects.equals(queryConfig, other.queryConfig);
104+
&& Objects.equals(queryConfig, other.queryConfig)
105+
&& Objects.equals(sourceFiltering, other.sourceFiltering);
90106
}
91107

92108
@Override
93109
public int hashCode() {
94-
return Objects.hash(Arrays.asList(index), queryConfig);
110+
return Objects.hash(Arrays.asList(index), queryConfig, sourceFiltering);
95111
}
96112

97113
@Override
@@ -103,6 +119,7 @@ public static class Builder {
103119

104120
private String[] index;
105121
private QueryConfig queryConfig;
122+
private FetchSourceContext sourceFiltering;
106123

107124
private Builder() {}
108125

@@ -121,8 +138,13 @@ public Builder setQueryConfig(QueryConfig queryConfig) {
121138
return this;
122139
}
123140

141+
public Builder setSourceFiltering(FetchSourceContext sourceFiltering) {
142+
this.sourceFiltering = sourceFiltering;
143+
return this;
144+
}
145+
124146
public DataFrameAnalyticsSource build() {
125-
return new DataFrameAnalyticsSource(index, queryConfig);
147+
return new DataFrameAnalyticsSource(index, queryConfig, sourceFiltering);
126148
}
127149
}
128150
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
import org.elasticsearch.script.Script;
8484
import org.elasticsearch.script.ScriptType;
8585
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
86-
import org.elasticsearch.search.sort.SortOrder;
8786
import org.elasticsearch.tasks.TaskId;
8887

8988
import java.util.Collections;
@@ -833,10 +832,6 @@ public void testReindex() throws Exception {
833832
// tag::reindex-request-pipeline
834833
request.setDestPipeline("my_pipeline"); // <1>
835834
// end::reindex-request-pipeline
836-
// tag::reindex-request-sort
837-
request.addSortField("field1", SortOrder.DESC); // <1>
838-
request.addSortField("field2", SortOrder.ASC); // <2>
839-
// end::reindex-request-sort
840835
// tag::reindex-request-script
841836
request.setScript(
842837
new Script(

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,9 @@ public void testPutDataFrameAnalytics() throws Exception {
29392939
DataFrameAnalyticsSource sourceConfig = DataFrameAnalyticsSource.builder() // <1>
29402940
.setIndex("put-test-source-index") // <2>
29412941
.setQueryConfig(queryConfig) // <3>
2942+
.setSourceFiltering(new FetchSourceContext(true,
2943+
new String[] { "included_field_1", "included_field_2" },
2944+
new String[] { "excluded_field" })) // <4>
29422945
.build();
29432946
// end::put-data-frame-analytics-source-config
29442947

client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/DataFrameAnalyticsSourceTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
2424
import org.elasticsearch.common.xcontent.XContentParser;
2525
import org.elasticsearch.search.SearchModule;
26+
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
2627
import org.elasticsearch.test.AbstractXContentTestCase;
2728

2829
import java.io.IOException;
@@ -35,9 +36,17 @@
3536
public class DataFrameAnalyticsSourceTests extends AbstractXContentTestCase<DataFrameAnalyticsSource> {
3637

3738
public static DataFrameAnalyticsSource randomSourceConfig() {
39+
FetchSourceContext sourceFiltering = null;
40+
if (randomBoolean()) {
41+
sourceFiltering = new FetchSourceContext(true,
42+
generateRandomStringArray(10, 10, false, false),
43+
generateRandomStringArray(10, 10, false, false));
44+
}
45+
3846
return DataFrameAnalyticsSource.builder()
3947
.setIndex(generateRandomStringArray(10, 10, false, false))
4048
.setQueryConfig(randomBoolean() ? null : randomQueryConfig())
49+
.setSourceFiltering(sourceFiltering)
4150
.build();
4251
}
4352

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Only used for testing the docker images
2-
version: '3'
2+
version: '3.7'
33
services:
44
elasticsearch-default-1:
55
image: elasticsearch:test
6-
environment:
7-
- node.name=elasticsearch-default-1
6+
environment:
7+
- node.name=elasticsearch-default-1
88
- cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2
9-
- discovery.seed_hosts=elasticsearch-default-2:9300
9+
- discovery.seed_hosts=elasticsearch-default-2:9300
1010
- cluster.name=elasticsearch-default
1111
- bootstrap.memory_lock=true
1212
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@@ -16,20 +16,20 @@ services:
1616
- cluster.routing.allocation.disk.watermark.high=1b
1717
- cluster.routing.allocation.disk.watermark.flood_stage=1b
1818
- script.max_compilations_rate=2048/1m
19-
- node.store.allow_mmap=false
19+
- node.store.allow_mmap=false
2020
- xpack.security.enabled=true
2121
- xpack.security.transport.ssl.enabled=true
2222
- xpack.security.http.ssl.enabled=true
2323
- xpack.security.authc.token.enabled=true
2424
- xpack.security.audit.enabled=true
25-
- xpack.security.authc.realms.file.file1.order=0
25+
- xpack.security.authc.realms.file.file1.order=0
2626
- xpack.security.authc.realms.native.native1.order=1
2727
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks
2828
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks
29-
- xpack.http.ssl.verification_mode=certificate
30-
- xpack.security.transport.ssl.verification_mode=certificate
29+
- xpack.http.ssl.verification_mode=certificate
30+
- xpack.security.transport.ssl.verification_mode=certificate
3131
- xpack.license.self_generated.type=trial
32-
volumes:
32+
volumes:
3333
- ./build/repo:/tmp/es-repo
3434
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks
3535
- ./build/logs/default-1:/usr/share/elasticsearch/logs
@@ -42,14 +42,20 @@ services:
4242
hard: -1
4343
nofile:
4444
soft: 65536
45-
hard: 65536
45+
hard: 65536
4646
entrypoint: /docker-test-entrypoint.sh
47+
healthcheck:
48+
start_period: 15s
49+
test: ["CMD", "curl", "-f", "-u", "x_pack_rest_user:x-pack-test-password", "-k", "https://localhost:9200"]
50+
interval: 10s
51+
timeout: 2s
52+
retries: 5
4753
elasticsearch-default-2:
4854
image: elasticsearch:test
49-
environment:
55+
environment:
5056
- node.name=elasticsearch-default-2
5157
- cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2
52-
- discovery.seed_hosts=elasticsearch-default-1:9300
58+
- discovery.seed_hosts=elasticsearch-default-1:9300
5359
- cluster.name=elasticsearch-default
5460
- bootstrap.memory_lock=true
5561
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@@ -59,20 +65,20 @@ services:
5965
- cluster.routing.allocation.disk.watermark.high=1b
6066
- cluster.routing.allocation.disk.watermark.flood_stage=1b
6167
- script.max_compilations_rate=2048/1m
62-
- node.store.allow_mmap=false
68+
- node.store.allow_mmap=false
6369
- xpack.security.enabled=true
6470
- xpack.security.transport.ssl.enabled=true
6571
- xpack.security.http.ssl.enabled=true
6672
- xpack.security.authc.token.enabled=true
6773
- xpack.security.audit.enabled=true
68-
- xpack.security.authc.realms.file.file1.order=0
69-
- xpack.security.authc.realms.native.native1.order=1
74+
- xpack.security.authc.realms.file.file1.order=0
75+
- xpack.security.authc.realms.native.native1.order=1
7076
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks
7177
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks
72-
- xpack.http.ssl.verification_mode=certificate
73-
- xpack.security.transport.ssl.verification_mode=certificate
78+
- xpack.http.ssl.verification_mode=certificate
79+
- xpack.security.transport.ssl.verification_mode=certificate
7480
- xpack.license.self_generated.type=trial
75-
volumes:
81+
volumes:
7682
- ./build/repo:/tmp/es-repo
7783
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks
7884
- ./build/logs/default-2:/usr/share/elasticsearch/logs
@@ -85,14 +91,20 @@ services:
8591
hard: -1
8692
nofile:
8793
soft: 65536
88-
hard: 65536
94+
hard: 65536
8995
entrypoint: /docker-test-entrypoint.sh
96+
healthcheck:
97+
start_period: 15s
98+
test: ["CMD", "curl", "-f", "-u", "x_pack_rest_user:x-pack-test-password", "-k", "https://localhost:9200"]
99+
interval: 10s
100+
timeout: 2s
101+
retries: 5
90102
elasticsearch-oss-1:
91103
image: elasticsearch:test
92-
environment:
93-
- node.name=elasticsearch-oss-1
104+
environment:
105+
- node.name=elasticsearch-oss-1
94106
- cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2
95-
- discovery.seed_hosts=elasticsearch-oss-2:9300
107+
- discovery.seed_hosts=elasticsearch-oss-2:9300
96108
- cluster.name=elasticsearch-oss
97109
- bootstrap.memory_lock=true
98110
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@@ -102,8 +114,8 @@ services:
102114
- cluster.routing.allocation.disk.watermark.high=1b
103115
- cluster.routing.allocation.disk.watermark.flood_stage=1b
104116
- script.max_compilations_rate=2048/1m
105-
- node.store.allow_mmap=false
106-
volumes:
117+
- node.store.allow_mmap=false
118+
volumes:
107119
- ./build/oss-repo:/tmp/es-repo
108120
- ./build/logs/oss-1:/usr/share/elasticsearch/logs
109121
ports:
@@ -114,13 +126,19 @@ services:
114126
hard: -1
115127
nofile:
116128
soft: 65536
117-
hard: 65536
129+
hard: 65536
130+
healthcheck:
131+
start_period: 15s
132+
test: ["CMD", "curl", "-f", "http://localhost:9200"]
133+
interval: 10s
134+
timeout: 2s
135+
retries: 5
118136
elasticsearch-oss-2:
119137
image: elasticsearch:test
120-
environment:
138+
environment:
121139
- node.name=elasticsearch-oss-2
122140
- cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2
123-
- discovery.seed_hosts=elasticsearch-oss-1:9300
141+
- discovery.seed_hosts=elasticsearch-oss-1:9300
124142
- cluster.name=elasticsearch-oss
125143
- bootstrap.memory_lock=true
126144
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@@ -130,8 +148,8 @@ services:
130148
- cluster.routing.allocation.disk.watermark.high=1b
131149
- cluster.routing.allocation.disk.watermark.flood_stage=1b
132150
- script.max_compilations_rate=2048/1m
133-
- node.store.allow_mmap=false
134-
volumes:
151+
- node.store.allow_mmap=false
152+
volumes:
135153
- ./build/oss-repo:/tmp/es-repo
136154
- ./build/logs/oss-2:/usr/share/elasticsearch/logs
137155
ports:
@@ -140,3 +158,9 @@ services:
140158
memlock:
141159
soft: -1
142160
hard: -1
161+
healthcheck:
162+
start_period: 15s
163+
test: ["CMD", "curl", "-f", "http://localhost:9200"]
164+
interval: 10s
165+
timeout: 2s
166+
retries: 5

distribution/docker/src/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN grep ES_DISTRIBUTION_TYPE=tar /usr/share/elasticsearch/bin/elasticsearch-env
3333
RUN mkdir -p config data logs
3434
RUN chmod 0775 config data logs
3535
COPY config/elasticsearch.yml config/log4j2.properties config/
36+
RUN chmod 0660 config/elasticsearch.yml config/log4j2.properties
3637

3738
################################################################################
3839
# Build stage 1 (the actual elasticsearch image):

docs/java-rest/high-level/document/reindex.asciidoc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ include-tagged::{doc-tests-file}[{api}-request-pipeline]
8989
--------------------------------------------------
9090
<1> set pipeline to `my_pipeline`
9191

92-
If you want a particular set of documents from the source index you’ll need to use sort. If possible, prefer a more
93-
selective query to maxDocs and sort.
94-
95-
["source","java",subs="attributes,callouts,macros"]
96-
--------------------------------------------------
97-
include-tagged::{doc-tests-file}[{api}-request-sort]
98-
--------------------------------------------------
99-
<1> add descending sort to`field1`
100-
<2> add ascending sort to `field2`
101-
10292
+{request}+ also supports a `script` that modifies the document. It allows you to
10393
also change the document's metadata. The following example illustrates that.
10494

docs/java-rest/high-level/ml/put-data-frame-analytics.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ include-tagged::{doc-tests-file}[{api}-source-config]
5252
<1> Constructing a new DataFrameAnalyticsSource
5353
<2> The source index
5454
<3> The query from which to gather the data. If query is not set, a `match_all` query is used by default.
55+
<4> Source filtering to select which fields will exist in the destination index.
5556

5657
===== QueryConfig
5758

0 commit comments

Comments
 (0)