Skip to content

Commit 0984db0

Browse files
committed
add test feature to gate the tests
1 parent 70dd8e7 commit 0984db0

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mget/90_synthetic_source.yml

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setup:
66
---
77
keyword:
88
- requires:
9-
cluster_features: ["gte_v8.4.0"]
9+
cluster_features: [ "gte_v8.4.0" ]
1010
reason: introduced in 8.4.0
1111

1212
- do:
@@ -23,15 +23,15 @@ keyword:
2323

2424
- do:
2525
index:
26-
index: test
27-
id: 1
26+
index: test
27+
id: 1
2828
body:
2929
kwd: foo
3030

3131
- do:
3232
index:
33-
index: test
34-
id: 2
33+
index: test
34+
id: 2
3535
body:
3636
kwd: bar
3737

@@ -40,21 +40,25 @@ keyword:
4040
mget:
4141
index: test
4242
body:
43-
ids: [1, 2]
44-
- match: {docs.0._index: "test"}
45-
- match: {docs.0._id: "1"}
43+
ids: [ 1, 2 ]
44+
- match: { docs.0._index: "test" }
45+
- match: { docs.0._id: "1" }
4646
- match:
4747
docs.0._source:
4848
kwd: foo
4949

50-
- match: {docs.1._index: "test"}
51-
- match: {docs.1._id: "2"}
50+
- match: { docs.1._index: "test" }
51+
- match: { docs.1._id: "2" }
5252
- match:
5353
docs.1._source:
5454
kwd: bar
5555

5656
---
5757
keyword with normalizer:
58+
- requires:
59+
- cluster_features: "mapper.keyword.keyword_normalizer_synthetic_source"
60+
- reason: "Behavior changed in #126623"
61+
5862
- do:
5963
indices.create:
6064
index: test-keyword-with-normalizer
@@ -113,7 +117,7 @@ keyword with normalizer:
113117
mget:
114118
index: test-keyword-with-normalizer
115119
body:
116-
ids: [ 1, 2, 3 ]
120+
ids: [ 1, 2, 3 ]
117121
- match: { docs.0._index: "test-keyword-with-normalizer" }
118122
- match: { docs.0._id: "1" }
119123
- match:
@@ -200,7 +204,7 @@ keyword with normalizer, source keep mode all:
200204
mget:
201205
index: test-keyword-with-normalizer
202206
body:
203-
ids: [ 1, 2, 3 ]
207+
ids: [ 1, 2, 3 ]
204208
- match: { docs.0._index: "test-keyword-with-normalizer" }
205209
- match: { docs.0._id: "1" }
206210
- match:
@@ -228,7 +232,7 @@ keyword with normalizer, source keep mode all:
228232
---
229233
stored text:
230234
- requires:
231-
cluster_features: ["gte_v8.5.0"]
235+
cluster_features: [ "gte_v8.5.0" ]
232236
reason: introduced in 8.5.0
233237

234238
- do:
@@ -246,39 +250,39 @@ stored text:
246250

247251
- do:
248252
index:
249-
index: test
250-
id: 1
253+
index: test
254+
id: 1
251255
body:
252256
text: the quick brown fox
253257

254258
- do:
255259
index:
256-
index: test
257-
id: 2
260+
index: test
261+
id: 2
258262
body:
259263
text: jumped over the lazy dog
260264

261265
- do:
262266
mget:
263267
index: test
264268
body:
265-
ids: [1, 2]
266-
- match: {docs.0._index: "test"}
267-
- match: {docs.0._id: "1"}
269+
ids: [ 1, 2 ]
270+
- match: { docs.0._index: "test" }
271+
- match: { docs.0._id: "1" }
268272
- match:
269273
docs.0._source:
270274
text: the quick brown fox
271275

272-
- match: {docs.1._index: "test"}
273-
- match: {docs.1._id: "2"}
276+
- match: { docs.1._index: "test" }
277+
- match: { docs.1._id: "2" }
274278
- match:
275279
docs.1._source:
276280
text: jumped over the lazy dog
277281

278282
---
279283
force_synthetic_source_ok:
280284
- requires:
281-
cluster_features: ["gte_v8.4.0"]
285+
cluster_features: [ "gte_v8.4.0" ]
282286
reason: introduced in 8.4.0
283287

284288
- do:
@@ -297,15 +301,15 @@ force_synthetic_source_ok:
297301

298302
- do:
299303
index:
300-
index: test
301-
id: 1
304+
index: test
305+
id: 1
302306
body:
303307
obj.kwd: foo
304308

305309
- do:
306310
index:
307-
index: test
308-
id: 2
311+
index: test
312+
id: 2
309313
body:
310314
obj:
311315
kwd: bar
@@ -315,7 +319,7 @@ force_synthetic_source_ok:
315319
mget:
316320
index: test
317321
body:
318-
ids: [1, 2]
322+
ids: [ 1, 2 ]
319323
- match:
320324
docs.0._source:
321325
obj.kwd: foo

server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.common.lucene.search.AutomatonQueries;
4040
import org.elasticsearch.common.unit.Fuzziness;
4141
import org.elasticsearch.core.Nullable;
42+
import org.elasticsearch.features.NodeFeature;
4243
import org.elasticsearch.index.IndexMode;
4344
import org.elasticsearch.index.IndexSortConfig;
4445
import org.elasticsearch.index.IndexVersion;
@@ -92,6 +93,10 @@
9293
*/
9394
public final class KeywordFieldMapper extends FieldMapper {
9495

96+
public static final NodeFeature KEYWORD_NORMALIZER_SYNTHETIC_SOURCE = new NodeFeature(
97+
"mapper.keyword.keyword_normalizer_synthetic_source"
98+
);
99+
95100
private static final Logger logger = LogManager.getLogger(KeywordFieldMapper.class);
96101

97102
public static final String CONTENT_TYPE = "keyword";

server/src/main/java/org/elasticsearch/index/mapper/MapperFeatures.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public Set<NodeFeature> getTestFeatures() {
6868
DateFieldMapper.INVALID_DATE_FIX,
6969
NPE_ON_DIMS_UPDATE_FIX,
7070
RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING,
71-
USE_DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ
71+
USE_DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ,
72+
KeywordFieldMapper.KEYWORD_NORMALIZER_SYNTHETIC_SOURCE
7273
);
7374
}
7475
}

0 commit comments

Comments
 (0)