Skip to content

Commit 127799e

Browse files
committed
Merge remote-tracking branch 'elastic/master' into pr/31343
* elastic/master: (92 commits) Reduce number of raw types warnings (elastic#31523) Migrate scripted metric aggregation scripts to ScriptContext design (elastic#30111) turn GetFieldMappingsResponse to ToXContentObject (elastic#31544) Close xcontent parsers (partial) (elastic#31513) Ingest Attachment: Upgrade Tika to 1.18 (elastic#31252) TEST: Correct the assertion arguments order (elastic#31540) Add get field mappings to High Level REST API Client (elastic#31423) [DOCS] Updates Watcher examples for code testing (elastic#31152) TEST: Add bwc recovery tests with synced-flush index [DOCS] Move sql to docs (elastic#31474) [DOCS] Move monitoring to docs folder (elastic#31477) Core: Combine doExecute methods in TransportAction (elastic#31517) IndexShard should not return null stats (elastic#31528) fix repository update with the same settings but different type (elastic#31458) Fix Mockito trying to mock IOException that isn't thrown by method (elastic#31433) (elastic#31527) Node selector per client rather than per request (elastic#31471) Core: Combine messageRecieved methods in TransportRequestHandler (elastic#31519) Upgrade to Lucene 7.4.0. (elastic#31529) [ML] Add ML filter update API (elastic#31437) Allow multiple unicast host providers (elastic#31509) ...
2 parents a1a1e2c + 86ab3a2 commit 127799e

File tree

1,152 files changed

+17522
-7784
lines changed

Some content is hidden

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

1,152 files changed

+17522
-7784
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class DocsTestPlugin extends RestTestPlugin {
3232
public void apply(Project project) {
3333
project.pluginManager.apply('elasticsearch.standalone-rest-test')
3434
super.apply(project)
35+
// The distribution can be configured with -Dtests.distribution on the command line
36+
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
3537
// Docs are published separately so no need to assemble
3638
project.tasks.remove(project.assemble)
3739
project.build.dependsOn.remove('assemble')
@@ -43,6 +45,8 @@ public class DocsTestPlugin extends RestTestPlugin {
4345
'\\{version\\}':
4446
VersionProperties.elasticsearch.toString().replace('-SNAPSHOT', ''),
4547
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
48+
'\\{build_flavor\\}' :
49+
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
4650
]
4751
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
4852
listSnippets.group 'Docs'

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

+12-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.gradle.api.tasks.OutputDirectory
2727

2828
import java.nio.file.Files
2929
import java.nio.file.Path
30-
import java.util.regex.Matcher
3130

3231
/**
3332
* Generates REST tests for each snippet marked // TEST.
@@ -100,6 +99,14 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
10099
return snippet.language == 'js' || snippet.curl
101100
}
102101

102+
/**
103+
* Certain requests should not have the shard failure check because the
104+
* format of the response is incompatible i.e. it is not a JSON object.
105+
*/
106+
static shouldAddShardFailureCheck(String path) {
107+
return path.startsWith('_cat') == false && path.startsWith('_xpack/ml/datafeeds/') == false
108+
}
109+
103110
/**
104111
* Converts Kibana's block quoted strings into standard JSON. These
105112
* {@code """} delimited strings can be embedded in CONSOLE and can
@@ -309,13 +316,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
309316
* no shard succeeds. But we need to fail the tests on all of these
310317
* because they mean invalid syntax or broken queries or something
311318
* else that we don't want to teach people to do. The REST test
312-
* framework doesn't allow us to has assertions in the setup
313-
* section so we have to skip it there. We also have to skip _cat
314-
* actions because they don't return json so we can't is_false
315-
* them. That is ok because they don't have this
316-
* partial-success-is-success thing.
319+
* framework doesn't allow us to have assertions in the setup
320+
* section so we have to skip it there. We also omit the assertion
321+
* from APIs that don't return a JSON object
317322
*/
318-
if (false == inSetup && false == path.startsWith('_cat')) {
323+
if (false == inSetup && shouldAddShardFailureCheck(path)) {
319324
current.println(" - is_false: _shards.failures")
320325
}
321326
}

buildSrc/src/test/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTaskTest.groovy

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
package org.elasticsearch.gradle.doc
2121

22-
import org.elasticsearch.gradle.doc.SnippetsTask.Snippet
23-
import org.gradle.api.InvalidUserDataException
24-
22+
import static org.elasticsearch.gradle.doc.RestTestsFromSnippetsTask.shouldAddShardFailureCheck
2523
import static org.elasticsearch.gradle.doc.RestTestsFromSnippetsTask.replaceBlockQuote
2624

2725
class RestTestFromSnippetsTaskTest extends GroovyTestCase {
@@ -47,4 +45,10 @@ class RestTestFromSnippetsTaskTest extends GroovyTestCase {
4745
assertEquals("\"foo\": \"bort\\n baz\"",
4846
replaceBlockQuote("\"foo\": \"\"\"bort\n baz\"\"\""));
4947
}
48+
49+
void testIsDocWriteRequest() {
50+
assertTrue(shouldAddShardFailureCheck("doc-index/_search"));
51+
assertFalse(shouldAddShardFailureCheck("_cat"))
52+
assertFalse(shouldAddShardFailureCheck("_xpack/ml/datafeeds/datafeed-id/_preview"));
53+
}
5054
}

buildSrc/version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 7.0.0-alpha1
2-
lucene = 7.4.0-snapshot-518d303506
2+
lucene = 7.4.0
33

44
# optional dependencies
55
spatial4j = 0.7

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/NoopBulkAction.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
package org.elasticsearch.plugin.noop.action.bulk;
2020

2121
import org.elasticsearch.action.Action;
22-
import org.elasticsearch.action.bulk.BulkRequest;
2322
import org.elasticsearch.action.bulk.BulkResponse;
2423

25-
public class NoopBulkAction extends Action<BulkRequest, BulkResponse> {
24+
public class NoopBulkAction extends Action<BulkResponse> {
2625
public static final String NAME = "mock:data/write/bulk";
2726

2827
public static final NoopBulkAction INSTANCE = new NoopBulkAction();

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,31 @@
1919
package org.elasticsearch.plugin.noop.action.bulk;
2020

2121
import org.elasticsearch.action.ActionListener;
22-
import org.elasticsearch.action.DocWriteResponse;
2322
import org.elasticsearch.action.DocWriteRequest;
23+
import org.elasticsearch.action.DocWriteResponse;
2424
import org.elasticsearch.action.bulk.BulkItemResponse;
2525
import org.elasticsearch.action.bulk.BulkRequest;
2626
import org.elasticsearch.action.bulk.BulkResponse;
2727
import org.elasticsearch.action.support.ActionFilters;
2828
import org.elasticsearch.action.support.HandledTransportAction;
2929
import org.elasticsearch.action.update.UpdateResponse;
30-
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
3130
import org.elasticsearch.common.inject.Inject;
3231
import org.elasticsearch.common.settings.Settings;
3332
import org.elasticsearch.index.shard.ShardId;
34-
import org.elasticsearch.threadpool.ThreadPool;
33+
import org.elasticsearch.tasks.Task;
3534
import org.elasticsearch.transport.TransportService;
3635

3736
public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
3837
private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE,
3938
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 1L, DocWriteResponse.Result.CREATED));
4039

4140
@Inject
42-
public TransportNoopBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService,
43-
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
44-
super(settings, NoopBulkAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, BulkRequest::new);
41+
public TransportNoopBulkAction(Settings settings, TransportService transportService, ActionFilters actionFilters) {
42+
super(settings, NoopBulkAction.NAME, transportService, actionFilters, BulkRequest::new);
4543
}
4644

4745
@Override
48-
protected void doExecute(BulkRequest request, ActionListener<BulkResponse> listener) {
46+
protected void doExecute(Task task, BulkRequest request, ActionListener<BulkResponse> listener) {
4947
final int itemCount = request.requests().size();
5048
// simulate at least a realistic amount of data that gets serialized
5149
BulkItemResponse[] bulkItemResponses = new BulkItemResponse[itemCount];

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/NoopSearchAction.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
package org.elasticsearch.plugin.noop.action.search;
2020

2121
import org.elasticsearch.action.Action;
22-
import org.elasticsearch.action.search.SearchRequest;
2322
import org.elasticsearch.action.search.SearchResponse;
2423

25-
public class NoopSearchAction extends Action<SearchRequest, SearchResponse> {
24+
public class NoopSearchAction extends Action<SearchResponse> {
2625
public static final NoopSearchAction INSTANCE = new NoopSearchAction();
2726
public static final String NAME = "mock:data/read/search";
2827

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/NoopSearchRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public NoopSearchRequestBuilder addSort(String field, SortOrder order) {
329329
*
330330
* @see org.elasticsearch.search.sort.SortBuilders
331331
*/
332-
public NoopSearchRequestBuilder addSort(SortBuilder sort) {
332+
public NoopSearchRequestBuilder addSort(SortBuilder<?> sort) {
333333
sourceBuilder().sort(sort);
334334
return this;
335335
}
@@ -415,7 +415,7 @@ public NoopSearchRequestBuilder setRescorer(RescorerBuilder<?> rescorer) {
415415
* @param window rescore window
416416
* @return this for chaining
417417
*/
418-
public NoopSearchRequestBuilder setRescorer(RescorerBuilder rescorer, int window) {
418+
public NoopSearchRequestBuilder setRescorer(RescorerBuilder<?> rescorer, int window) {
419419
sourceBuilder().clearRescorers();
420420
return addRescorer(rescorer.windowSize(window));
421421
}

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/TransportNoopSearchAction.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,28 @@
2424
import org.elasticsearch.action.search.ShardSearchFailure;
2525
import org.elasticsearch.action.support.ActionFilters;
2626
import org.elasticsearch.action.support.HandledTransportAction;
27-
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2827
import org.elasticsearch.common.inject.Inject;
28+
import org.elasticsearch.common.io.stream.Writeable;
2929
import org.elasticsearch.common.settings.Settings;
30-
import org.elasticsearch.search.aggregations.InternalAggregations;
3130
import org.elasticsearch.search.SearchHit;
3231
import org.elasticsearch.search.SearchHits;
32+
import org.elasticsearch.search.aggregations.InternalAggregations;
3333
import org.elasticsearch.search.internal.InternalSearchResponse;
3434
import org.elasticsearch.search.profile.SearchProfileShardResults;
3535
import org.elasticsearch.search.suggest.Suggest;
36-
import org.elasticsearch.threadpool.ThreadPool;
36+
import org.elasticsearch.tasks.Task;
3737
import org.elasticsearch.transport.TransportService;
3838

3939
import java.util.Collections;
4040

4141
public class TransportNoopSearchAction extends HandledTransportAction<SearchRequest, SearchResponse> {
4242
@Inject
43-
public TransportNoopSearchAction(Settings settings, ThreadPool threadPool, TransportService transportService, ActionFilters
44-
actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
45-
super(settings, NoopSearchAction.NAME, threadPool, transportService, actionFilters, SearchRequest::new,
46-
indexNameExpressionResolver);
43+
public TransportNoopSearchAction(Settings settings, TransportService transportService, ActionFilters actionFilters) {
44+
super(settings, NoopSearchAction.NAME, transportService, actionFilters, (Writeable.Reader<SearchRequest>) SearchRequest::new);
4745
}
4846

4947
@Override
50-
protected void doExecute(SearchRequest request, ActionListener<SearchResponse> listener) {
48+
protected void doExecute(Task task, SearchRequest request, ActionListener<SearchResponse> listener) {
5149
listener.onResponse(new SearchResponse(new InternalSearchResponse(
5250
new SearchHits(
5351
new SearchHit[0], 0L, 0.0f),

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java

+63
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
3838
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
3939
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
40+
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
41+
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
4042
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
4143
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
4244
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
@@ -57,6 +59,8 @@
5759
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
5860
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
5961
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
62+
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
63+
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
6064
import org.elasticsearch.rest.RestStatus;
6165

6266
import java.io.IOException;
@@ -186,6 +190,35 @@ public void getMappingsAsync(GetMappingsRequest getMappingsRequest, RequestOptio
186190
GetMappingsResponse::fromXContent, listener, emptySet());
187191
}
188192

193+
/**
194+
* Retrieves the field mappings on an index or indices using the Get Field Mapping API.
195+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html">
196+
* Get Field Mapping API on elastic.co</a>
197+
* @param getFieldMappingsRequest the request
198+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
199+
* @return the response
200+
* @throws IOException in case there is a problem sending the request or parsing back the response
201+
*/
202+
public GetFieldMappingsResponse getFieldMapping(GetFieldMappingsRequest getFieldMappingsRequest,
203+
RequestOptions options) throws IOException {
204+
return restHighLevelClient.performRequestAndParseEntity(getFieldMappingsRequest, RequestConverters::getFieldMapping, options,
205+
GetFieldMappingsResponse::fromXContent, emptySet());
206+
}
207+
208+
/**
209+
* Asynchronously retrieves the field mappings on an index on indices using the Get Field Mapping API.
210+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html">
211+
* Get Field Mapping API on elastic.co</a>
212+
* @param getFieldMappingsRequest the request
213+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
214+
* @param listener the listener to be notified upon request completion
215+
*/
216+
public void getFieldMappingAsync(GetFieldMappingsRequest getFieldMappingsRequest, RequestOptions options,
217+
ActionListener<GetFieldMappingsResponse> listener) {
218+
restHighLevelClient.performRequestAsyncAndParseEntity(getFieldMappingsRequest, RequestConverters::getFieldMapping, options,
219+
GetFieldMappingsResponse::fromXContent, listener, emptySet());
220+
}
221+
189222
/**
190223
* Updates aliases using the Index Aliases API.
191224
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
@@ -661,6 +694,36 @@ public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, Re
661694
PutIndexTemplateResponse::fromXContent, listener, emptySet());
662695
}
663696

697+
/**
698+
* Validate a potentially expensive query without executing it.
699+
* <p>
700+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html"> Validate Query API
701+
* on elastic.co</a>
702+
* @param validateQueryRequest the request
703+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
704+
* @return the response
705+
* @throws IOException in case there is a problem sending the request or parsing back the response
706+
*/
707+
public ValidateQueryResponse validateQuery(ValidateQueryRequest validateQueryRequest, RequestOptions options) throws IOException {
708+
return restHighLevelClient.performRequestAndParseEntity(validateQueryRequest, RequestConverters::validateQuery, options,
709+
ValidateQueryResponse::fromXContent, emptySet());
710+
}
711+
712+
/**
713+
* Asynchronously validate a potentially expensive query without executing it.
714+
* <p>
715+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html"> Validate Query API
716+
* on elastic.co</a>
717+
* @param validateQueryRequest the request
718+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
719+
* @param listener the listener to be notified upon request completion
720+
*/
721+
public void validateQueryAsync(ValidateQueryRequest validateQueryRequest, RequestOptions options,
722+
ActionListener<ValidateQueryResponse> listener) {
723+
restHighLevelClient.performRequestAsyncAndParseEntity(validateQueryRequest, RequestConverters::validateQuery, options,
724+
ValidateQueryResponse::fromXContent, listener, emptySet());
725+
}
726+
664727
/**
665728
* Gets index templates using the Index Templates API
666729
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API

client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.java

+35
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.elasticsearch.action.ingest.GetPipelineRequest;
2525
import org.elasticsearch.action.ingest.GetPipelineResponse;
2626
import org.elasticsearch.action.ingest.PutPipelineRequest;
27+
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
28+
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
2729
import org.elasticsearch.action.ingest.WritePipelineResponse;
2830

2931
import java.io.IOException;
@@ -125,4 +127,37 @@ public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions op
125127
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, options,
126128
WritePipelineResponse::fromXContent, listener, emptySet());
127129
}
130+
131+
/**
132+
* Simulate a pipeline on a set of documents provided in the request
133+
* <p>
134+
* See
135+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html">
136+
* Simulate Pipeline API on elastic.co</a>
137+
* @param request the request
138+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
139+
* @return the response
140+
* @throws IOException in case there is a problem sending the request or parsing back the response
141+
*/
142+
public SimulatePipelineResponse simulatePipeline(SimulatePipelineRequest request, RequestOptions options) throws IOException {
143+
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::simulatePipeline, options,
144+
SimulatePipelineResponse::fromXContent, emptySet());
145+
}
146+
147+
/**
148+
* Asynchronously simulate a pipeline on a set of documents provided in the request
149+
* <p>
150+
* See
151+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html">
152+
* Simulate Pipeline API on elastic.co</a>
153+
* @param request the request
154+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
155+
* @param listener the listener to be notified upon request completion
156+
*/
157+
public void simulatePipelineAsync(SimulatePipelineRequest request,
158+
RequestOptions options,
159+
ActionListener<SimulatePipelineResponse> listener) {
160+
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::simulatePipeline, options,
161+
SimulatePipelineResponse::fromXContent, listener, emptySet());
162+
}
128163
}

0 commit comments

Comments
 (0)