Skip to content

Commit c5123a0

Browse files
committed
Gate binary doc values search tests behind node feature
1 parent 9f60db7 commit c5123a0

File tree

4 files changed

+124
-62
lines changed

4 files changed

+124
-62
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/390_doc_values_search.yml

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ setup:
3939
keyword:
4040
type: keyword
4141
index: false
42-
keyword_high_cardinality:
43-
type: keyword
44-
index: false
45-
doc_values:
46-
cardinality: high
4742
boolean:
4843
type: boolean
4944
index: false
@@ -68,7 +63,6 @@ setup:
6863
short: 1
6964
date: "2017/01/01"
7065
keyword: "key1"
71-
keyword_high_cardinality: "key1"
7266
boolean: "false"
7367
ip: "192.168.0.1"
7468
geo_point: [13.5, 34.89]
@@ -87,7 +81,6 @@ setup:
8781
short: 2
8882
date: "2017/01/02"
8983
keyword: "key2"
90-
keyword_high_cardinality: "key2"
9184
boolean: "true"
9285
ip: "192.168.0.2"
9386
geo_point : [-63.24, 31.0]
@@ -278,12 +271,6 @@ setup:
278271
body: { query: { match: { keyword: { query: "key1" } } } }
279272
- length: { hits.hits: 1 }
280273

281-
- do:
282-
search:
283-
index: test
284-
body: { query: { match: { keyword_high_cardinality: { "query": "key1" } } } }
285-
- length: { hits.hits: 1 }
286-
287274
---
288275
"Test terms query on keyword field where only doc values are enabled":
289276

@@ -293,11 +280,6 @@ setup:
293280
body: { query: { terms: { keyword: [ "key1", "key2" ] } } }
294281
- length: { hits.hits: 2 }
295282

296-
- do:
297-
search:
298-
index: test
299-
body: { query: { terms: { keyword_high_cardinality: [ "key1", "key2" ] } } }
300-
301283
---
302284
"Test range query on keyword field where only doc values are enabled":
303285

@@ -307,12 +289,6 @@ setup:
307289
body: { query: { range: { keyword: { gte: "key1" } } } }
308290
- length: { hits.hits: 2 }
309291

310-
- do:
311-
search:
312-
index: test
313-
body: { query: { range: { keyword_high_cardinality: { gte: "key1" } } } }
314-
- length: { hits.hits: 2 }
315-
316292
---
317293
"Test fuzzy query on keyword field where only doc values are enabled":
318294

@@ -322,12 +298,6 @@ setup:
322298
body: { query: { fuzzy: { keyword: { value: "kay1", fuzziness: 1 } } } }
323299
- length: { hits.hits: 1 }
324300

325-
- do:
326-
search:
327-
index: test
328-
body: { query: { fuzzy: { keyword_high_cardinality: { value: "kay1", fuzziness: 1 } } } }
329-
- length: { hits.hits: 1 }
330-
331301
---
332302
"Test prefix query on keyword field where only doc values are enabled":
333303

@@ -337,12 +307,6 @@ setup:
337307
body: { query: { prefix: { keyword: { value: "key" } } } }
338308
- length: { hits.hits: 2 }
339309

340-
- do:
341-
search:
342-
index: test
343-
body: { query: { prefix: { keyword_high_cardinality: { value: "key" } } } }
344-
- length: { hits.hits: 2 }
345-
346310
---
347311
"Test case insensitive term query on keyword field where only doc values are enabled":
348312

@@ -352,12 +316,6 @@ setup:
352316
body: { query: { term: { keyword: { value: "KeY1", case_insensitive: true } } } }
353317
- length: { hits.hits: 1 }
354318

355-
- do:
356-
search:
357-
index: test
358-
body: { query: { term: { keyword_high_cardinality: { value: "KeY1", case_insensitive: true } } } }
359-
- length: { hits.hits: 1 }
360-
361319
---
362320
"Test wildcard query on keyword field where only doc values are enabled":
363321

@@ -367,12 +325,6 @@ setup:
367325
body: { query: { wildcard: { keyword: { value: "k*1" } } } }
368326
- length: { hits.hits: 1 }
369327

370-
- do:
371-
search:
372-
index: test
373-
body: { query: { wildcard: { keyword_high_cardinality: { value: "k*1" } } } }
374-
- length: { hits.hits: 1 }
375-
376328
---
377329
"Test case insensitive wildcard query on keyword field where only doc values are enabled":
378330

@@ -382,12 +334,6 @@ setup:
382334
body: { query: { wildcard: { keyword: { value: "K*1", case_insensitive: true } } } }
383335
- length: { hits.hits: 1 }
384336

385-
- do:
386-
search:
387-
index: test
388-
body: { query: { wildcard: { keyword_high_cardinality: { value: "K*1", case_insensitive: true } } } }
389-
- length: { hits.hits: 1 }
390-
391337
---
392338
"Test regexp query on keyword field where only doc values are enabled":
393339

@@ -397,12 +343,6 @@ setup:
397343
body: { query: { regexp: { keyword: { value: "k.*1" } } } }
398344
- length: { hits.hits: 1 }
399345

400-
- do:
401-
search:
402-
index: test
403-
body: { query: { regexp: { keyword_high_cardinality: { value: "k.*1" } } } }
404-
- length: { hits.hits: 1 }
405-
406346
---
407347
"Test match query on boolean field where only doc values are enabled":
408348

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
setup:
3+
- requires:
4+
cluster_features: ["mapper.keyword.store_high_cardinality_in_binary_doc_values"]
5+
reason: "testing binary doc values search"
6+
7+
- do:
8+
indices.create:
9+
index: test
10+
body:
11+
mappings:
12+
dynamic: false
13+
properties:
14+
keyword:
15+
type: keyword
16+
index: false
17+
doc_values:
18+
cardinality: high
19+
20+
- do:
21+
index:
22+
index: test
23+
id: "1"
24+
body:
25+
keyword: "key1"
26+
27+
- do:
28+
index:
29+
index: test
30+
id: "2"
31+
body:
32+
keyword: "key2"
33+
- do:
34+
indices.refresh: {}
35+
36+
---
37+
"Test match query on keyword field where only binary doc values are enabled":
38+
39+
- do:
40+
search:
41+
index: test
42+
body: { query: { match: { keyword: { query: "key1" } } } }
43+
- length: { hits.hits: 1 }
44+
45+
---
46+
"Test terms query on keyword field where only binary doc values are enabled":
47+
48+
- do:
49+
search:
50+
index: test
51+
body: { query: { terms: { keyword: [ "key1", "key2" ] } } }
52+
- length: { hits.hits: 2 }
53+
54+
---
55+
"Test range query on keyword field where only binary doc values are enabled":
56+
57+
- do:
58+
search:
59+
index: test
60+
body: { query: { range: { keyword: { gte: "key1" } } } }
61+
- length: { hits.hits: 2 }
62+
63+
---
64+
"Test fuzzy query on keyword field where only binary doc values are enabled":
65+
66+
- do:
67+
search:
68+
index: test
69+
body: { query: { fuzzy: { keyword: { value: "kay1", fuzziness: 1 } } } }
70+
- length: { hits.hits: 1 }
71+
72+
---
73+
"Test prefix query on keyword field where only binary doc values are enabled":
74+
75+
- do:
76+
search:
77+
index: test
78+
body: { query: { prefix: { keyword: { value: "key" } } } }
79+
- length: { hits.hits: 2 }
80+
81+
---
82+
"Test case insensitive term query on keyword field where only binary doc values are enabled":
83+
84+
- do:
85+
search:
86+
index: test
87+
body: { query: { term: { keyword: { value: "KeY1", case_insensitive: true } } } }
88+
- length: { hits.hits: 1 }
89+
90+
---
91+
"Test wildcard query on keyword field where only binary doc values are enabled":
92+
93+
- do:
94+
search:
95+
index: test
96+
body: { query: { wildcard: { keyword: { value: "k*1" } } } }
97+
- length: { hits.hits: 1 }
98+
99+
---
100+
"Test case insensitive wildcard query on keyword field where only binary doc values are enabled":
101+
102+
- do:
103+
search:
104+
index: test
105+
body: { query: { wildcard: { keyword: { value: "K*1", case_insensitive: true } } } }
106+
- length: { hits.hits: 1 }
107+
108+
---
109+
"Test regexp query on keyword field where only binary doc values are enabled":
110+
111+
- do:
112+
search:
113+
index: test
114+
body: { query: { regexp: { keyword: { value: "k.*1" } } } }
115+
- length: { hits.hits: 1 }

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public class MapperFeatures implements FeatureSpecification {
6363
static final NodeFeature BASE64_DENSE_VECTORS = new NodeFeature("mapper.base64_dense_vectors");
6464
public static final NodeFeature GENERIC_VECTOR_FORMAT = new NodeFeature("mapper.vectors.generic_vector_format");
6565
public static final NodeFeature FIX_DENSE_VECTOR_WRONG_FIELDS = new NodeFeature("mapper.fix_dense_vector_wrong_fields");
66+
static final NodeFeature STORE_HIGH_CARDINALITY_KEYWORDS_IN_BINARY_DOC_VALUES = new NodeFeature(
67+
"mapper.keyword.store_high_cardinality_in_binary_doc_values"
68+
);
6669

6770
@Override
6871
public Set<NodeFeature> getTestFeatures() {
@@ -106,7 +109,8 @@ public Set<NodeFeature> getTestFeatures() {
106109
INDEX_MAPPING_IGNORE_DYNAMIC_BEYOND_FIELD_NAME_LIMIT,
107110
EXCLUDE_VECTORS_DOCVALUE_BUGFIX,
108111
BASE64_DENSE_VECTORS,
109-
FIX_DENSE_VECTOR_WRONG_FIELDS
112+
FIX_DENSE_VECTOR_WRONG_FIELDS,
113+
STORE_HIGH_CARDINALITY_KEYWORDS_IN_BINARY_DOC_VALUES
110114
);
111115
if (ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled()) {
112116
features = new HashSet<>(features);

test/framework/src/main/java/org/elasticsearch/index/mapper/KeywordFieldSyntheticSourceSupport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ public class KeywordFieldSyntheticSourceSupport implements MapperTestCase.Synthe
2626
private final boolean store;
2727
private final FieldMapper.DocValuesParameter.Values docValues;
2828
private final String nullValue;
29+
private final boolean allowIgnoredSource;
2930

3031
KeywordFieldSyntheticSourceSupport(Integer ignoreAbove, boolean store, String nullValue, boolean allowIgnoredSource) {
3132
this.ignoreAbove = ignoreAbove;
3233
this.allIgnored = ignoreAbove != null && LuceneTestCase.rarely();
3334
this.store = store;
3435
this.nullValue = nullValue;
36+
this.allowIgnoredSource = allowIgnoredSource;
3537

3638
this.docValues = switch (ESTestCase.randomInt(allowIgnoredSource ? 2 : 1)) {
3739
case 0 -> new FieldMapper.DocValuesParameter.Values(true, FieldMapper.DocValuesParameter.Values.Cardinality.LOW);
@@ -50,7 +52,8 @@ public boolean ignoreAbove() {
5052
public boolean preservesExactSource() {
5153
// We opt in into fallback synthetic source implementation
5254
// if there is nothing else to use, and it preserves exact source data.
53-
return store == false
55+
return allowIgnoredSource
56+
&& store == false
5457
&& (docValues.enabled() == false || docValues.cardinality() == FieldMapper.DocValuesParameter.Values.Cardinality.HIGH);
5558
}
5659

0 commit comments

Comments
 (0)