Skip to content

Commit 60cda2a

Browse files
committed
Merge branch 'master' into feature/runtime_fields
2 parents a16b080 + 500e12f commit 60cda2a

File tree

474 files changed

+1489
-892
lines changed

Some content is hidden

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

474 files changed

+1489
-892
lines changed

distribution/docker/src/docker/config/log4j2.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ appender.deprecation_rolling.type = Console
1212
appender.deprecation_rolling.name = deprecation_rolling
1313
appender.deprecation_rolling.layout.type = ECSJsonLayout
1414
appender.deprecation_rolling.layout.type_name = deprecation
15+
appender.deprecation_rolling.filter.rate_limit.type = RateLimitingFilter
16+
17+
appender.header_warning.type = HeaderWarningAppender
18+
appender.header_warning.name = header_warning
1519

1620
logger.deprecation.name = org.elasticsearch.deprecation
17-
logger.deprecation.level = warn
21+
logger.deprecation.level = deprecation
1822
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
23+
logger.deprecation.appenderRef.header_warning.ref = header_warning
1924
logger.deprecation.additivity = false
2025

2126
appender.index_search_slowlog_rolling.type = Console

docs/reference/indices/put-mapping.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Defaults to `false`.
7474
fields, this mapping can include:
7575

7676
* Field name
77-
* <<field-datatypes,Field data type>>
77+
* <<mapping-types,Field data type>>
7878
* <<mapping-params,Mapping parameters>>
7979

8080
For existing fields, see <<updating-field-mappings>>.

docs/reference/mapping.asciidoc

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,14 @@ treated. Examples of metadata fields include the document's
2222
<<mapping-index-field,`_index`>>, <<mapping-id-field,`_id`>>, and
2323
<<mapping-source-field,`_source`>> fields.
2424

25-
<<mapping-types,Fields>> or _properties_::
25+
<<mapping-types,Fields>>::
2626

2727
A mapping contains a list of fields or `properties` pertinent to the
28-
document.
28+
document. Each field has its own <<mapping-types, data type>>.
2929

3030
NOTE: Before 7.0.0, the 'mappings' definition used to include a type name.
3131
For more details, please see <<removal-of-types>>.
3232

33-
[discrete]
34-
[[field-datatypes]]
35-
== Field data types
36-
37-
Each field has a data `type` which can be:
38-
39-
* a simple type like <<text,`text`>>, <<keyword,`keyword`>>, <<date,`date`>>, <<number,`long`>>,
40-
<<number,`double`>>, <<boolean,`boolean`>> or <<ip,`ip`>>.
41-
* a type which supports the hierarchical nature of JSON such as
42-
<<object,`object`>> or <<nested,`nested`>>.
43-
* or a specialised type like <<geo-point,`geo_point`>>,
44-
<<geo-shape,`geo_shape`>>, or <<completion-suggester,`completion`>>.
45-
46-
It is often useful to index the same field in different ways for different
47-
purposes. For instance, a `string` field could be <<mapping-index,indexed>> as
48-
a `text` field for full-text search, and as a `keyword` field for
49-
sorting or aggregations. Alternatively, you could index a string field with
50-
the <<analysis-standard-analyzer,`standard` analyzer>>, the
51-
<<english-analyzer,`english`>> analyzer, and the
52-
<<french-analyzer,`french` analyzer>>.
53-
54-
This is the purpose of _multi-fields_. Most data types support multi-fields
55-
via the <<multi-fields>> parameter.
56-
5733
[[mapping-limit-settings]]
5834
[discrete]
5935
=== Settings to prevent mappings explosion

docs/reference/mapping/types/keyword.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
The keyword family includes the following field types:
99

10-
* <<keyword,`keyword`>>, which is used for structured content such as IDs, email
10+
* <<keyword-field-type,`keyword`>>, which is used for structured content such as IDs, email
1111
addresses, hostnames, status codes, zip codes, or tags.
1212
* <<constant-keyword-field-type,`constant_keyword`>> for keyword fields that always contain
1313
the same value.

docs/reference/search/search-your-data/search-shard-routing.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ _search shard routing_ or _routing_.
1212
=== Adaptive replica selection
1313

1414
By default, {es} uses _adaptive replica selection_ to route search requests.
15-
This method selects an eligible node using <<allocation-awareness,allocation
16-
awareness>> and the following criteria:
15+
This method selects an eligible node using <<shard-allocation-awareness,shard
16+
allocation awareness>> and the following criteria:
1717

1818
* Response time of prior requests between the coordinating node
1919
and the eligible node

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static class Builder extends ParametrizedFieldMapper.Builder {
9292
}
9393
});
9494
private final Parameter<Double> nullValue = new Parameter<>("null_value", false, () -> null,
95-
(n, c, o) -> XContentMapValues.nodeDoubleValue(o), m -> toType(m).nullValue);
95+
(n, c, o) -> o == null ? null : XContentMapValues.nodeDoubleValue(o), m -> toType(m).nullValue).acceptsNull();
9696

9797
private final Parameter<Map<String, String>> meta = Parameter.metaParam();
9898

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentJoinAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected class DenseCollectionStrategy implements CollectionStrategy {
190190
private final BitArray ordsBits;
191191

192192
public DenseCollectionStrategy(long maxOrd, BigArrays bigArrays) {
193-
ordsBits = new BitArray((int) maxOrd, context.bigArrays());
193+
ordsBits = new BitArray(maxOrd, context.bigArrays());
194194
}
195195

196196
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.search.aggregations.metrics;
21+
22+
import org.elasticsearch.ElasticsearchException;
23+
import org.elasticsearch.ExceptionsHelper;
24+
import org.elasticsearch.action.index.IndexRequestBuilder;
25+
import org.elasticsearch.common.breaker.CircuitBreakingException;
26+
import org.elasticsearch.common.settings.Settings;
27+
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
28+
import org.elasticsearch.search.aggregations.Aggregator;
29+
import org.elasticsearch.search.aggregations.BucketOrder;
30+
import org.elasticsearch.test.ESIntegTestCase;
31+
32+
import java.util.Map;
33+
import java.util.stream.IntStream;
34+
35+
import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality;
36+
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
37+
38+
public class CardinalityWithRequestBreakerIT extends ESIntegTestCase {
39+
40+
/**
41+
* Test that searches using cardinality aggregations returns all request breaker memory.
42+
*/
43+
public void testRequestBreaker() throws Exception {
44+
final String requestBreaker = randomIntBetween(1, 10000) + "kb";
45+
logger.info("--> Using request breaker setting: {}", requestBreaker);
46+
47+
indexRandom(true, IntStream.range(0, randomIntBetween(10, 1000))
48+
.mapToObj(i ->
49+
client().prepareIndex("test").setId("id_" + i)
50+
.setSource(Map.of("field0", randomAlphaOfLength(5), "field1", randomAlphaOfLength(5)))
51+
).toArray(IndexRequestBuilder[]::new));
52+
53+
client().admin().cluster().prepareUpdateSettings()
54+
.setTransientSettings(Settings.builder().put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(),
55+
requestBreaker))
56+
.get();
57+
58+
try {
59+
client().prepareSearch("test")
60+
.addAggregation(terms("terms").field("field0.keyword")
61+
.collectMode(randomFrom(Aggregator.SubAggCollectionMode.values()))
62+
.order(BucketOrder.aggregation("cardinality", randomBoolean()))
63+
.subAggregation(cardinality("cardinality").precisionThreshold(randomLongBetween(1, 40000)).field("field1.keyword")))
64+
.get();
65+
} catch (ElasticsearchException e) {
66+
if (ExceptionsHelper.unwrap(e, CircuitBreakingException.class) == null) {
67+
throw e;
68+
}
69+
}
70+
71+
client().admin().cluster().prepareUpdateSettings()
72+
.setTransientSettings(Settings.builder().putNull(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey()))
73+
.get();
74+
75+
// validation done by InternalTestCluster.ensureEstimatedStats()
76+
}
77+
}

server/src/main/java/org/elasticsearch/action/search/DfsQueryPhase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* @see CountedCollector#onFailure(int, SearchShardTarget, Exception)
4141
*/
4242
final class DfsQueryPhase extends SearchPhase {
43-
private final ArraySearchPhaseResults<SearchPhaseResult> queryResult;
43+
private final QueryPhaseResultConsumer queryResult;
4444
private final List<DfsSearchResult> searchResults;
4545
private final AggregatedDfs dfs;
4646
private final Function<ArraySearchPhaseResults<SearchPhaseResult>, SearchPhase> nextPhaseFactory;

server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.search.SearchShardTarget;
3232
import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContextBuilder;
3333
import org.elasticsearch.search.aggregations.InternalAggregations;
34+
import org.elasticsearch.search.builder.SearchSourceBuilder;
3435
import org.elasticsearch.search.query.QuerySearchResult;
3536

3637
import java.util.ArrayDeque;
@@ -43,6 +44,7 @@
4344
import java.util.concurrent.atomic.AtomicReference;
4445
import java.util.function.Consumer;
4546

47+
import static org.elasticsearch.action.search.SearchPhaseController.getTopDocsSize;
4648
import static org.elasticsearch.action.search.SearchPhaseController.mergeTopDocs;
4749
import static org.elasticsearch.action.search.SearchPhaseController.setShardIndex;
4850

@@ -52,7 +54,7 @@
5254
* This implementation can be configured to batch up a certain amount of results and reduce
5355
* them asynchronously in the provided {@link Executor} iff the buffer is exhausted.
5456
*/
55-
class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult> {
57+
public class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult> {
5658
private static final Logger logger = LogManager.getLogger(QueryPhaseResultConsumer.class);
5759

5860
private final Executor executor;
@@ -76,43 +78,39 @@ class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult
7678
* Creates a {@link QueryPhaseResultConsumer} that incrementally reduces aggregation results
7779
* as shard results are consumed.
7880
*/
79-
QueryPhaseResultConsumer(Executor executor,
80-
SearchPhaseController controller,
81-
SearchProgressListener progressListener,
82-
ReduceContextBuilder aggReduceContextBuilder,
83-
NamedWriteableRegistry namedWriteableRegistry,
84-
int expectedResultSize,
85-
int bufferSize,
86-
boolean hasTopDocs,
87-
boolean hasAggs,
88-
int trackTotalHitsUpTo,
89-
int topNSize,
90-
boolean performFinalReduce,
91-
Consumer<Exception> onPartialMergeFailure) {
81+
public QueryPhaseResultConsumer(SearchRequest request,
82+
Executor executor,
83+
SearchPhaseController controller,
84+
SearchProgressListener progressListener,
85+
NamedWriteableRegistry namedWriteableRegistry,
86+
int expectedResultSize,
87+
Consumer<Exception> onPartialMergeFailure) {
9288
super(expectedResultSize);
9389
this.executor = executor;
9490
this.controller = controller;
9591
this.progressListener = progressListener;
96-
this.aggReduceContextBuilder = aggReduceContextBuilder;
92+
this.aggReduceContextBuilder = controller.getReduceContext(request);
9793
this.namedWriteableRegistry = namedWriteableRegistry;
98-
this.topNSize = topNSize;
99-
this.pendingMerges = new PendingMerges(bufferSize, trackTotalHitsUpTo);
100-
this.hasTopDocs = hasTopDocs;
101-
this.hasAggs = hasAggs;
102-
this.performFinalReduce = performFinalReduce;
94+
this.topNSize = getTopDocsSize(request);
95+
this.performFinalReduce = request.isFinalReduce();
10396
this.onPartialMergeFailure = onPartialMergeFailure;
97+
SearchSourceBuilder source = request.source();
98+
this.hasTopDocs = source == null || source.size() != 0;
99+
this.hasAggs = source != null && source.aggregations() != null;
100+
int bufferSize = (hasAggs || hasTopDocs) ? Math.min(request.getBatchedReduceSize(), expectedResultSize) : expectedResultSize;
101+
this.pendingMerges = new PendingMerges(bufferSize, request.resolveTrackTotalHitsUpTo());
104102
}
105103

106104
@Override
107-
void consumeResult(SearchPhaseResult result, Runnable next) {
105+
public void consumeResult(SearchPhaseResult result, Runnable next) {
108106
super.consumeResult(result, () -> {});
109107
QuerySearchResult querySearchResult = result.queryResult();
110108
progressListener.notifyQueryResult(querySearchResult.getShardIndex());
111109
pendingMerges.consume(querySearchResult, next);
112110
}
113111

114112
@Override
115-
SearchPhaseController.ReducedQueryPhase reduce() throws Exception {
113+
public SearchPhaseController.ReducedQueryPhase reduce() throws Exception {
116114
if (pendingMerges.hasPendingMerges()) {
117115
throw new AssertionError("partial reduce in-flight");
118116
} else if (pendingMerges.hasFailure()) {

0 commit comments

Comments
 (0)