Skip to content

Commit f582418

Browse files
committed
Fix missing option serialization after backport
Relates #29465
1 parent 3c21e46 commit f582418

File tree

18 files changed

+33
-152
lines changed

18 files changed

+33
-152
lines changed

docs/reference/migration/migrate_7_0/aggregations.asciidoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ These `execution_hint` are removed and should be replaced by `global_ordinals`.
99

1010
The dynamic cluster setting named `search.max_buckets` now defaults
1111
to 10,000 (instead of unlimited in the previous version).
12-
Requests that try to return more than the limit will fail with an exception.
12+
Requests that try to return more than the limit will fail with an exception.
13+
14+
==== `missing` option of the `composite` aggregation has been removed
15+
16+
The `missing` option of the `composite` aggregation, deprecated in 6.x,
17+
has been removed. `missing_bucket` should be used instead.

plugins/analysis-nori/src/test/java/org/elasticsearch/index/analysis/NoriAnalysisTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testNoriTokenizer() throws Exception {
9898
.build();
9999
TestAnalysis analysis = createTestAnalysis(settings);
100100
Tokenizer tokenizer = analysis.tokenizer.get("my_tokenizer").create();
101-
tokenizer.setReader(new StringReader("뿌리가 깊은 나무"));
101+
tokenizer.setReader(new StringReader(""));
102102
assertTokenStreamContents(tokenizer, new String[] {"뿌리", "가", "깊", "은", "나무"});
103103
tokenizer.setReader(new StringReader("가늠표"));
104104
assertTokenStreamContents(tokenizer, new String[] {"가늠표", "가늠", "표"});

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/230_composite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ setup:
327327
---
328328
"Composite aggregation and array size":
329329
- skip:
330-
version: " - 6.99.99"
331-
reason: starting in 7.0 the composite sources do not allocate arrays eagerly.
330+
version: " - 6.3.99"
331+
reason: starting in 6.4 the composite sources do not allocate arrays eagerly.
332332

333333
- do:
334334
search:

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/BinaryValuesSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class BinaryValuesSource extends SingleDimensionValuesSource<BytesRef> {
5050

5151
BinaryValuesSource(BigArrays bigArrays, LongConsumer breakerConsumer,
5252
MappedFieldType fieldType, CheckedFunction<LeafReaderContext, SortedBinaryDocValues, IOException> docValuesFunc,
53-
DocValueFormat format, boolean missingBucket, Object missing, int size, int reverseMul) {
54-
super(bigArrays, format, fieldType, missingBucket, missing, size, reverseMul);
53+
DocValueFormat format, boolean missingBucket, int size, int reverseMul) {
54+
super(bigArrays, format, fieldType, missingBucket, size, reverseMul);
5555
this.breakerConsumer = breakerConsumer;
5656
this.docValuesFunc = docValuesFunc;
5757
this.values = bigArrays.newObjectArray(Math.min(size, 100));

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ private SingleDimensionValuesSource<?> createValuesSource(BigArrays bigArrays, I
271271
vs::globalOrdinalsValues,
272272
config.format(),
273273
config.missingBucket(),
274-
config.missing(),
275274
size,
276275
reverseMul
277276
);
@@ -288,7 +287,6 @@ private SingleDimensionValuesSource<?> createValuesSource(BigArrays bigArrays, I
288287
vs::bytesValues,
289288
config.format(),
290289
config.missingBucket(),
291-
config.missing(),
292290
size,
293291
reverseMul
294292
);
@@ -304,7 +302,6 @@ private SingleDimensionValuesSource<?> createValuesSource(BigArrays bigArrays, I
304302
vs::bytesValues,
305303
config.format(),
306304
config.missingBucket(),
307-
config.missing(),
308305
size,
309306
reverseMul
310307
);
@@ -318,7 +315,6 @@ private SingleDimensionValuesSource<?> createValuesSource(BigArrays bigArrays, I
318315
vs::doubleValues,
319316
config.format(),
320317
config.missingBucket(),
321-
config.missing(),
322318
size,
323319
reverseMul
324320
);
@@ -337,7 +333,6 @@ private SingleDimensionValuesSource<?> createValuesSource(BigArrays bigArrays, I
337333
rounding,
338334
config.format(),
339335
config.missingBucket(),
340-
config.missing(),
341336
size,
342337
reverseMul
343338
);

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.elasticsearch.common.io.stream.StreamInput;
2424
import org.elasticsearch.common.io.stream.StreamOutput;
2525
import org.elasticsearch.common.io.stream.Writeable;
26-
import org.elasticsearch.common.logging.DeprecationLogger;
27-
import org.elasticsearch.common.logging.Loggers;
2826
import org.elasticsearch.common.xcontent.ToXContentFragment;
2927
import org.elasticsearch.common.xcontent.XContentBuilder;
3028
import org.elasticsearch.index.query.QueryShardException;
@@ -42,15 +40,12 @@
4240
* A {@link ValuesSource} builder for {@link CompositeAggregationBuilder}
4341
*/
4442
public abstract class CompositeValuesSourceBuilder<AB extends CompositeValuesSourceBuilder<AB>> implements Writeable, ToXContentFragment {
45-
private static final DeprecationLogger DEPRECATION_LOGGER =
46-
new DeprecationLogger(Loggers.getLogger(CompositeValuesSourceBuilder.class));
4743

4844
protected final String name;
4945
private String field = null;
5046
private Script script = null;
5147
private ValueType valueType = null;
5248
private boolean missingBucket = false;
53-
private Object missing = null;
5449
private SortOrder order = SortOrder.ASC;
5550
private String format = null;
5651

@@ -72,12 +67,15 @@ public abstract class CompositeValuesSourceBuilder<AB extends CompositeValuesSou
7267
if (in.readBoolean()) {
7368
this.valueType = ValueType.readFromStream(in);
7469
}
75-
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
70+
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
7671
this.missingBucket = in.readBoolean();
7772
} else {
7873
this.missingBucket = false;
7974
}
80-
this.missing = in.readGenericValue();
75+
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
76+
// skip missing value
77+
in.readGenericValue();
78+
}
8179
this.order = SortOrder.readFromStream(in);
8280
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
8381
this.format = in.readOptionalString();
@@ -103,7 +101,9 @@ public final void writeTo(StreamOutput out) throws IOException {
103101
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
104102
out.writeBoolean(missingBucket);
105103
}
106-
out.writeGenericValue(missing);
104+
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
105+
out.writeGenericValue(null);
106+
}
107107
order.writeTo(out);
108108
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
109109
out.writeOptionalString(format);
@@ -125,9 +125,6 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params)
125125
builder.field("script", script);
126126
}
127127
builder.field("missing_bucket", missingBucket);
128-
if (missing != null) {
129-
builder.field("missing", missing);
130-
}
131128
if (valueType != null) {
132129
builder.field("value_type", valueType.getPreferredName());
133130
}
@@ -142,7 +139,7 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params)
142139

143140
@Override
144141
public final int hashCode() {
145-
return Objects.hash(field, missingBucket, missing, script, valueType, order, format, innerHashCode());
142+
return Objects.hash(field, missingBucket, script, valueType, order, format, innerHashCode());
146143
}
147144

148145
protected abstract int innerHashCode();
@@ -158,7 +155,6 @@ public boolean equals(Object o) {
158155
Objects.equals(script, that.script()) &&
159156
Objects.equals(valueType, that.valueType()) &&
160157
Objects.equals(missingBucket, that.missingBucket()) &&
161-
Objects.equals(missing, that.missing()) &&
162158
Objects.equals(order, that.order()) &&
163159
Objects.equals(format, that.format()) &&
164160
innerEquals(that);
@@ -229,28 +225,6 @@ public ValueType valueType() {
229225
return valueType;
230226
}
231227

232-
/**
233-
* Sets the value to use when the source finds a missing value in a
234-
* document.
235-
*
236-
* @deprecated Use {@link #missingBucket(boolean)} instead.
237-
*/
238-
@SuppressWarnings("unchecked")
239-
@Deprecated
240-
public AB missing(Object missing) {
241-
if (missing == null) {
242-
throw new IllegalArgumentException("[missing] must not be null");
243-
}
244-
DEPRECATION_LOGGER.deprecated("[missing] is deprecated. Please use [missing_bucket] instead.");
245-
this.missing = missing;
246-
return (AB) this;
247-
}
248-
249-
@Deprecated
250-
public Object missing() {
251-
return missing;
252-
}
253-
254228
/**
255229
* If true an explicit `null bucket will represent documents with missing values.
256230
*/
@@ -328,18 +302,14 @@ public String format() {
328302

329303
public final CompositeValuesSourceConfig build(SearchContext context) throws IOException {
330304
ValuesSourceConfig<?> config = ValuesSourceConfig.resolve(context.getQueryShardContext(),
331-
valueType, field, script, missing, null, format);
305+
valueType, field, script, null,null, format);
332306

333-
if (config.unmapped() && field != null && missing == null && missingBucket == false) {
307+
if (config.unmapped() && field != null && missingBucket == false) {
334308
// this source cannot produce any values so we refuse to build
335309
// since composite buckets are not created on null values by default.
336310
throw new QueryShardException(context.getQueryShardContext(),
337311
"failed to find field [" + field + "] and [missing_bucket] is not set");
338312
}
339-
if (missingBucket && missing != null) {
340-
throw new QueryShardException(context.getQueryShardContext(),
341-
"cannot use [missing] option in conjunction with [missing_bucket]");
342-
}
343313
return innerBuild(context, config);
344314
}
345315
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceConfig.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class CompositeValuesSourceConfig {
3232
private final ValuesSource vs;
3333
private final DocValueFormat format;
3434
private final int reverseMul;
35-
private final Object missing;
3635
private final boolean missingBucket;
3736

3837
/**
@@ -42,18 +41,15 @@ class CompositeValuesSourceConfig {
4241
* @param vs The underlying {@link ValuesSource}.
4342
* @param format The {@link DocValueFormat} of this source.
4443
* @param order The sort order associated with this source.
45-
* @param missing The missing value or null if documents with missing value should be ignored.
4644
*/
4745
CompositeValuesSourceConfig(String name, @Nullable MappedFieldType fieldType, ValuesSource vs, DocValueFormat format,
48-
SortOrder order, boolean missingBucket, @Nullable Object missing) {
46+
SortOrder order, boolean missingBucket) {
4947
this.name = name;
5048
this.fieldType = fieldType;
5149
this.vs = vs;
5250
this.format = format;
5351
this.reverseMul = order == SortOrder.ASC ? 1 : -1;
5452
this.missingBucket = missingBucket;
55-
assert missingBucket == false || missing == null;
56-
this.missing = missing;
5753
}
5854

5955
/**
@@ -85,13 +81,6 @@ DocValueFormat format() {
8581
return format;
8682
}
8783

88-
/**
89-
* The missing value for this configuration or null if documents with missing value should be ignored.
90-
*/
91-
Object missing() {
92-
return missing;
93-
}
94-
9584
/**
9685
* If true, an explicit `null bucket represents documents with missing values.
9786
*/

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceParserHelper.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ static <VB extends CompositeValuesSourceBuilder<VB>, T> void declareValuesSource
3838
ValueType targetValueType) {
3939
objectParser.declareField(VB::field, XContentParser::text,
4040
new ParseField("field"), ObjectParser.ValueType.STRING);
41-
objectParser.declareField(VB::missing, XContentParser::objectText,
42-
new ParseField("missing"), ObjectParser.ValueType.VALUE);
4341
objectParser.declareBoolean(VB::missingBucket, new ParseField("missing_bucket"));
4442

4543
objectParser.declareField(VB::valueType, p -> {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected CompositeValuesSourceConfig innerBuild(SearchContext context, ValuesSo
226226
// is specified in the builder.
227227
final DocValueFormat docValueFormat = format() == null ? DocValueFormat.RAW : config.format();
228228
final MappedFieldType fieldType = config.fieldContext() != null ? config.fieldContext().fieldType() : null;
229-
return new CompositeValuesSourceConfig(name, fieldType, vs, docValueFormat, order(), missingBucket(), missing());
229+
return new CompositeValuesSourceConfig(name, fieldType, vs, docValueFormat, order(), missingBucket());
230230
} else {
231231
throw new IllegalArgumentException("invalid source, expected numeric, got " + orig.getClass().getSimpleName());
232232
}

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DoubleValuesSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class DoubleValuesSource extends SingleDimensionValuesSource<Double> {
4545

4646
DoubleValuesSource(BigArrays bigArrays, MappedFieldType fieldType,
4747
CheckedFunction<LeafReaderContext, SortedNumericDoubleValues, IOException> docValuesFunc,
48-
DocValueFormat format, boolean missingBucket, Object missing, int size, int reverseMul) {
49-
super(bigArrays, format, fieldType, missingBucket, missing, size, reverseMul);
48+
DocValueFormat format, boolean missingBucket, int size, int reverseMul) {
49+
super(bigArrays, format, fieldType, missingBucket, size, reverseMul);
5050
this.docValuesFunc = docValuesFunc;
5151
this.bits = missingBucket ? new BitArray(bigArrays, 100) : null;
5252
this.values = bigArrays.newDoubleArray(Math.min(size, 100), false);

0 commit comments

Comments
 (0)