Skip to content

Commit e3f1886

Browse files
committed
Merge branch 'master' into primary-context
* master: Upgrade icu4j for the ICU analysis plugin to 59.1 (#25243) move assertBusy to use CheckException (#25246) Use SPI in High Level Rest Client to load XContent parsers (#25098) [TEST] test that low level REST client leaves path untouched (#25193) Speed up PK lookups at index time. (#19856) [Docs] Fix documentation for percentiles bucket aggregation (#25229) Upgrade to lucene-7.0.0-snapshot-92b1783. (#25222) Build: Add master flag for disabling bwc tests (#25230) Scripting: Rename SearchScript.needsScores to needs_score (#25235) Support script context stateful factory in Painless. (#25233) FastVectorHighlighter should not cache the field query globally (#25197) Remove QUERY_AND_FETCH BWC for pre-5.3.0 nodes (#25223) Add more missing AggregationBuilder getters (#25198) Extract the snapshot/restore full cluster restart tests from the translog full cluster restart tests (#25204)
2 parents 51ad65b + 0036f28 commit e3f1886

File tree

130 files changed

+1254
-788
lines changed

Some content is hidden

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

130 files changed

+1254
-788
lines changed

build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,28 @@ task verifyVersions {
152152
}
153153
}
154154

155+
/*
156+
* When adding backcompat behavior that spans major versions, temporarily
157+
* disabling the backcompat tests is necessary. This flag controls
158+
* the enabled state of every bwc task. It should be set back to true
159+
* after the backport of the backcompat code is complete.
160+
*/
161+
allprojects {
162+
ext.bwc_tests_enabled = true
163+
}
164+
165+
task verifyBwcTestsEnabled {
166+
doLast {
167+
if (project.bwc_tests_enabled == false) {
168+
throw new GradleException('Bwc tests are disabled. They must be re-enabled after completing backcompat behavior backporting.')
169+
}
170+
}
171+
}
172+
155173
task branchConsistency {
156174
description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.'
157175
group 'Verification'
158-
dependsOn verifyVersions
176+
dependsOn verifyVersions, verifyBwcTestsEnabled
159177
}
160178

161179
subprojects {

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# When updating elasticsearch, please update 'rest' version in core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
22
elasticsearch = 6.0.0-alpha3
3-
lucene = 7.0.0-snapshot-a0aef2f
3+
lucene = 7.0.0-snapshot-92b1783
44

55
# optional dependencies
66
spatial4j = 0.6

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
5050
import org.elasticsearch.common.xcontent.XContentParser;
5151
import org.elasticsearch.common.xcontent.XContentType;
52-
import org.elasticsearch.join.aggregations.ChildrenAggregationBuilder;
53-
import org.elasticsearch.join.aggregations.ParsedChildren;
52+
import org.elasticsearch.plugins.spi.NamedXContentProvider;
5453
import org.elasticsearch.rest.BytesRestResponse;
5554
import org.elasticsearch.rest.RestStatus;
5655
import org.elasticsearch.search.aggregations.Aggregation;
@@ -92,8 +91,6 @@
9291
import org.elasticsearch.search.aggregations.bucket.terms.ParsedLongTerms;
9392
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
9493
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
95-
import org.elasticsearch.search.aggregations.matrix.stats.MatrixStatsAggregationBuilder;
96-
import org.elasticsearch.search.aggregations.matrix.stats.ParsedMatrixStats;
9794
import org.elasticsearch.search.aggregations.metrics.avg.AvgAggregationBuilder;
9895
import org.elasticsearch.search.aggregations.metrics.avg.ParsedAvg;
9996
import org.elasticsearch.search.aggregations.metrics.cardinality.CardinalityAggregationBuilder;
@@ -142,11 +139,13 @@
142139
import org.elasticsearch.search.suggest.term.TermSuggestion;
143140

144141
import java.io.IOException;
142+
import java.util.ArrayList;
145143
import java.util.Collections;
146144
import java.util.HashMap;
147145
import java.util.List;
148146
import java.util.Map;
149147
import java.util.Objects;
148+
import java.util.ServiceLoader;
150149
import java.util.Set;
151150
import java.util.function.Function;
152151
import java.util.stream.Collectors;
@@ -180,8 +179,9 @@ public RestHighLevelClient(RestClient restClient) {
180179
*/
181180
protected RestHighLevelClient(RestClient restClient, List<NamedXContentRegistry.Entry> namedXContentEntries) {
182181
this.client = Objects.requireNonNull(restClient);
183-
this.registry = new NamedXContentRegistry(Stream.of(getDefaultNamedXContents().stream(), namedXContentEntries.stream())
184-
.flatMap(Function.identity()).collect(toList()));
182+
this.registry = new NamedXContentRegistry(
183+
Stream.of(getDefaultNamedXContents().stream(), getProvidedNamedXContents().stream(), namedXContentEntries.stream())
184+
.flatMap(Function.identity()).collect(toList()));
185185
}
186186

187187
/**
@@ -566,8 +566,6 @@ static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
566566
map.put(SignificantLongTerms.NAME, (p, c) -> ParsedSignificantLongTerms.fromXContent(p, (String) c));
567567
map.put(SignificantStringTerms.NAME, (p, c) -> ParsedSignificantStringTerms.fromXContent(p, (String) c));
568568
map.put(ScriptedMetricAggregationBuilder.NAME, (p, c) -> ParsedScriptedMetric.fromXContent(p, (String) c));
569-
map.put(ChildrenAggregationBuilder.NAME, (p, c) -> ParsedChildren.fromXContent(p, (String) c));
570-
map.put(MatrixStatsAggregationBuilder.NAME, (p, c) -> ParsedMatrixStats.fromXContent(p, (String) c));
571569
List<NamedXContentRegistry.Entry> entries = map.entrySet().stream()
572570
.map(entry -> new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(entry.getKey()), entry.getValue()))
573571
.collect(Collectors.toList());
@@ -579,4 +577,15 @@ static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
579577
(parser, context) -> CompletionSuggestion.fromXContent(parser, (String)context)));
580578
return entries;
581579
}
580+
581+
/**
582+
* Loads and returns the {@link NamedXContentRegistry.Entry} parsers provided by plugins.
583+
*/
584+
static List<NamedXContentRegistry.Entry> getProvidedNamedXContents() {
585+
List<NamedXContentRegistry.Entry> entries = new ArrayList<>();
586+
for (NamedXContentProvider service : ServiceLoader.load(NamedXContentProvider.class)) {
587+
entries.addAll(service.getNamedXContentParsers());
588+
}
589+
return entries;
590+
}
582591
}

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@
5656
import org.elasticsearch.common.xcontent.XContentParser;
5757
import org.elasticsearch.common.xcontent.cbor.CborXContent;
5858
import org.elasticsearch.common.xcontent.smile.SmileXContent;
59+
import org.elasticsearch.join.aggregations.ChildrenAggregationBuilder;
5960
import org.elasticsearch.rest.RestStatus;
6061
import org.elasticsearch.search.SearchHits;
6162
import org.elasticsearch.search.aggregations.Aggregation;
6263
import org.elasticsearch.search.aggregations.InternalAggregations;
64+
import org.elasticsearch.search.aggregations.matrix.stats.MatrixStatsAggregationBuilder;
6365
import org.elasticsearch.search.suggest.Suggest;
6466
import org.elasticsearch.test.ESTestCase;
6567
import org.junit.Before;
@@ -69,6 +71,7 @@
6971

7072
import java.io.IOException;
7173
import java.net.SocketTimeoutException;
74+
import java.util.ArrayList;
7275
import java.util.Collections;
7376
import java.util.HashMap;
7477
import java.util.List;
@@ -613,9 +616,9 @@ public void testWrapResponseListenerOnResponseExceptionWithIgnoresErrorValidBody
613616
assertEquals("Elasticsearch exception [type=exception, reason=test error message]", elasticsearchException.getMessage());
614617
}
615618

616-
public void testNamedXContents() {
619+
public void testDefaultNamedXContents() {
617620
List<NamedXContentRegistry.Entry> namedXContents = RestHighLevelClient.getDefaultNamedXContents();
618-
assertEquals(45, namedXContents.size());
621+
assertEquals(43, namedXContents.size());
619622
Map<Class<?>, Integer> categories = new HashMap<>();
620623
for (NamedXContentRegistry.Entry namedXContent : namedXContents) {
621624
Integer counter = categories.putIfAbsent(namedXContent.categoryClass, 1);
@@ -624,10 +627,28 @@ public void testNamedXContents() {
624627
}
625628
}
626629
assertEquals(2, categories.size());
627-
assertEquals(Integer.valueOf(42), categories.get(Aggregation.class));
630+
assertEquals(Integer.valueOf(40), categories.get(Aggregation.class));
628631
assertEquals(Integer.valueOf(3), categories.get(Suggest.Suggestion.class));
629632
}
630633

634+
public void testProvidedNamedXContents() {
635+
List<NamedXContentRegistry.Entry> namedXContents = RestHighLevelClient.getProvidedNamedXContents();
636+
assertEquals(2, namedXContents.size());
637+
Map<Class<?>, Integer> categories = new HashMap<>();
638+
List<String> names = new ArrayList<>();
639+
for (NamedXContentRegistry.Entry namedXContent : namedXContents) {
640+
names.add(namedXContent.name.getPreferredName());
641+
Integer counter = categories.putIfAbsent(namedXContent.categoryClass, 1);
642+
if (counter != null) {
643+
categories.put(namedXContent.categoryClass, counter + 1);
644+
}
645+
}
646+
assertEquals(1, categories.size());
647+
assertEquals(Integer.valueOf(2), categories.get(Aggregation.class));
648+
assertTrue(names.contains(ChildrenAggregationBuilder.NAME));
649+
assertTrue(names.contains(MatrixStatsAggregationBuilder.NAME));
650+
}
651+
631652
private static class TrackingActionListener implements ActionListener<Integer> {
632653
private final AtomicInteger statusCode = new AtomicInteger(-1);
633654
private final AtomicReference<Exception> exception = new AtomicReference<>();

client/rest/src/main/java/org/elasticsearch/client/RestClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ private static HttpRequestBase addRequestBody(HttpRequestBase httpRequest, HttpE
553553
return httpRequest;
554554
}
555555

556-
private static URI buildUri(String pathPrefix, String path, Map<String, String> params) {
556+
static URI buildUri(String pathPrefix, String path, Map<String, String> params) {
557557
Objects.requireNonNull(path, "path must not be null");
558558
try {
559559
String fullPath;

client/rest/src/test/java/org/elasticsearch/client/RestClientTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.apache.http.HttpHost;
2424
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
2525

26+
import java.net.URI;
27+
import java.util.Collections;
28+
2629
import static org.junit.Assert.assertEquals;
2730
import static org.junit.Assert.fail;
2831
import static org.mockito.Mockito.mock;
@@ -77,6 +80,22 @@ public void testPerformAsyncWithWrongEndpoint() throws Exception {
7780
}
7881
}
7982

83+
public void testBuildUriLeavesPathUntouched() {
84+
{
85+
URI uri = RestClient.buildUri("/foo$bar", "/index/type/id", Collections.<String, String>emptyMap());
86+
assertEquals("/foo$bar/index/type/id", uri.getPath());
87+
}
88+
{
89+
URI uri = RestClient.buildUri(null, "/foo$bar/ty/pe/i/d", Collections.<String, String>emptyMap());
90+
assertEquals("/foo$bar/ty/pe/i/d", uri.getPath());
91+
}
92+
{
93+
URI uri = RestClient.buildUri(null, "/index/type/id", Collections.singletonMap("foo$bar", "x/y/z"));
94+
assertEquals("/index/type/id", uri.getPath());
95+
assertEquals("foo$bar=x/y/z", uri.getQuery());
96+
}
97+
}
98+
8099
private static RestClient createRestClient() {
81100
HttpHost[] hosts = new HttpHost[]{new HttpHost("localhost", 9200)};
82101
return new RestClient(mock(CloseableHttpAsyncClient.class), randomLongBetween(1_000, 30_000), new Header[]{}, hosts, null, null);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5bf8d8b7d885e25c343c187d1849580e21ef3fce

core/licenses/lucene-analyzers-common-7.0.0-snapshot-a0aef2f.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9696b87e27ea949fabc62606833ab63e6e5473b9

core/licenses/lucene-backward-codecs-7.0.0-snapshot-a0aef2f.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)