Skip to content

Commit 4f5f53d

Browse files
committed
Merge branch 'master' into primary-promotion-transition
* master: Add a second refresh to concurrent relocation test Add a dummy_index to upgrade tests to ensure we recover fine with replicas (elastic#24937) Rework bwc snapshot projects to build up to two bwc versions (elastic#24870) Move the IndexDeletionPolicy to be engine internal (elastic#24930) [Tests] Harden InternalExtendedStatsTests (elastic#24934) TCorrecting api name (elastic#24924) Add search method to high level REST client (elastic#24796) Add fromXContent method to ClearScrollResponse (elastic#24909) ClearScrollRequest to implement ToXContentObject (elastic#24907) SearchScrollRequest to implement ToXContentObject (elastic#24906) Fix bug in weight computation for query cache
2 parents 73c48fe + b2abdd1 commit 4f5f53d

38 files changed

+1371
-260
lines changed

build.gradle

+16-6
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,22 @@ subprojects {
218218
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
219219
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
220220
]
221-
if (wireCompatVersions[-1].snapshot) {
222-
// if the most previous version is a snapshot, we need to connect that version to the
223-
// bwc project which will checkout and build that snapshot version
224-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc'
225-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc'
226-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc'
221+
if (indexCompatVersions[-1].snapshot) {
222+
/* The last and second to last versions can be snapshots. Rather than use
223+
* snapshots built by CI we connect these versions to projects that build
224+
* those those versions from the HEAD of the appropriate branch. */
225+
if (indexCompatVersions[-1].bugfix == 0) {
226+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
227+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
228+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
229+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
230+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
231+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
232+
} else {
233+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
234+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
235+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
236+
}
227237
}
228238
project.afterEvaluate {
229239
configurations.all {

client/rest-high-level/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ group = 'org.elasticsearch.client'
2626
dependencies {
2727
compile "org.elasticsearch:elasticsearch:${version}"
2828
compile "org.elasticsearch.client:rest:${version}"
29+
compile "org.elasticsearch.plugin:parent-join-client:${version}"
30+
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
2931

3032
testCompile "org.elasticsearch.client:test:${version}"
3133
testCompile "org.elasticsearch.test:framework:${version}"
32-
// for parent/child testing
33-
testCompile "org.elasticsearch.plugin:parent-join-client:${version}"
3434
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
3535
testCompile "junit:junit:${versions.junit}"
3636
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"

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

+60-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import org.elasticsearch.action.delete.DeleteRequest;
3434
import org.elasticsearch.action.get.GetRequest;
3535
import org.elasticsearch.action.index.IndexRequest;
36+
import org.elasticsearch.action.search.SearchRequest;
3637
import org.elasticsearch.action.support.ActiveShardCount;
38+
import org.elasticsearch.action.support.IndicesOptions;
3739
import org.elasticsearch.action.support.WriteRequest;
3840
import org.elasticsearch.action.update.UpdateRequest;
3941
import org.elasticsearch.common.Nullable;
@@ -42,11 +44,13 @@
4244
import org.elasticsearch.common.lucene.uid.Versions;
4345
import org.elasticsearch.common.unit.TimeValue;
4446
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
47+
import org.elasticsearch.common.xcontent.ToXContent;
4548
import org.elasticsearch.common.xcontent.XContentBuilder;
4649
import org.elasticsearch.common.xcontent.XContentHelper;
4750
import org.elasticsearch.common.xcontent.XContentParser;
4851
import org.elasticsearch.common.xcontent.XContentType;
4952
import org.elasticsearch.index.VersionType;
53+
import org.elasticsearch.rest.action.search.RestSearchAction;
5054
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
5155

5256
import java.io.ByteArrayOutputStream;
@@ -59,7 +63,7 @@
5963

6064
final class Request {
6165

62-
private static final String DELIMITER = "/";
66+
private static final XContentType REQUEST_BODY_CONTENT_TYPE = XContentType.JSON;
6367

6468
final String method;
6569
final String endpoint;
@@ -79,6 +83,7 @@ public String toString() {
7983
"method='" + method + '\'' +
8084
", endpoint='" + endpoint + '\'' +
8185
", params=" + params +
86+
", hasBody=" + (entity != null) +
8287
'}';
8388
}
8489

@@ -307,23 +312,48 @@ static Request update(UpdateRequest updateRequest) throws IOException {
307312
xContentType = Requests.INDEX_CONTENT_TYPE;
308313
}
309314

310-
BytesRef source = XContentHelper.toXContent(updateRequest, xContentType, false).toBytesRef();
311-
HttpEntity entity = new ByteArrayEntity(source.bytes, source.offset, source.length, ContentType.create(xContentType.mediaType()));
312-
315+
HttpEntity entity = createEntity(updateRequest, xContentType);
313316
return new Request(HttpPost.METHOD_NAME, endpoint, parameters.getParams(), entity);
314317
}
315318

319+
static Request search(SearchRequest searchRequest) throws IOException {
320+
String endpoint = endpoint(searchRequest.indices(), searchRequest.types(), "_search");
321+
Params params = Params.builder();
322+
params.putParam(RestSearchAction.TYPED_KEYS_PARAM, "true");
323+
params.withRouting(searchRequest.routing());
324+
params.withPreference(searchRequest.preference());
325+
params.withIndicesOptions(searchRequest.indicesOptions());
326+
params.putParam("search_type", searchRequest.searchType().name().toLowerCase(Locale.ROOT));
327+
if (searchRequest.requestCache() != null) {
328+
params.putParam("request_cache", Boolean.toString(searchRequest.requestCache()));
329+
}
330+
params.putParam("batched_reduce_size", Integer.toString(searchRequest.getBatchedReduceSize()));
331+
if (searchRequest.scroll() != null) {
332+
params.putParam("scroll", searchRequest.scroll().keepAlive());
333+
}
334+
HttpEntity entity = null;
335+
if (searchRequest.source() != null) {
336+
entity = createEntity(searchRequest.source(), REQUEST_BODY_CONTENT_TYPE);
337+
}
338+
return new Request(HttpGet.METHOD_NAME, endpoint, params.getParams(), entity);
339+
}
340+
341+
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
342+
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
343+
return new ByteArrayEntity(source.bytes, source.offset, source.length, ContentType.create(xContentType.mediaType()));
344+
}
345+
346+
static String endpoint(String[] indices, String[] types, String endpoint) {
347+
return endpoint(String.join(",", indices), String.join(",", types), endpoint);
348+
}
349+
316350
/**
317351
* Utility method to build request's endpoint.
318352
*/
319353
static String endpoint(String... parts) {
320-
if (parts == null || parts.length == 0) {
321-
return DELIMITER;
322-
}
323-
324-
StringJoiner joiner = new StringJoiner(DELIMITER, DELIMITER, "");
354+
StringJoiner joiner = new StringJoiner("/", "/", "");
325355
for (String part : parts) {
326-
if (part != null) {
356+
if (Strings.hasLength(part)) {
327357
joiner.add(part);
328358
}
329359
}
@@ -453,6 +483,26 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
453483
return this;
454484
}
455485

486+
Params withIndicesOptions (IndicesOptions indicesOptions) {
487+
putParam("ignore_unavailable", Boolean.toString(indicesOptions.ignoreUnavailable()));
488+
putParam("allow_no_indices", Boolean.toString(indicesOptions.allowNoIndices()));
489+
String expandWildcards;
490+
if (indicesOptions.expandWildcardsOpen() == false && indicesOptions.expandWildcardsClosed() == false) {
491+
expandWildcards = "none";
492+
} else {
493+
StringJoiner joiner = new StringJoiner(",");
494+
if (indicesOptions.expandWildcardsOpen()) {
495+
joiner.add("open");
496+
}
497+
if (indicesOptions.expandWildcardsClosed()) {
498+
joiner.add("closed");
499+
}
500+
expandWildcards = joiner.toString();
501+
}
502+
putParam("expand_wildcards", expandWildcards);
503+
return this;
504+
}
505+
456506
Map<String, String> getParams() {
457507
return Collections.unmodifiableMap(params);
458508
}

0 commit comments

Comments
 (0)