Skip to content

Commit d6b48db

Browse files
authored
Merge branch 'main' into backport/backport-19817-to-main
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
2 parents 2c89745 + 3005a8c commit d6b48db

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3232
- Refactor the ThreadPoolStats.Stats class to use the Builder pattern instead of constructors ([#19317](https://github.com/opensearch-project/OpenSearch/pull/19317))
3333
- Refactor the IndexingStats.Stats class to use the Builder pattern instead of constructors ([#19306](https://github.com/opensearch-project/OpenSearch/pull/19306))
3434
- Remove FeatureFlag.MERGED_SEGMENT_WARMER_EXPERIMENTAL_FLAG. ([#19715](https://github.com/opensearch-project/OpenSearch/pull/19715))
35+
- Change the default value of doc_values in WildcardFieldMapper to true. ([#19796](https://github.com/opensearch-project/OpenSearch/pull/19796))
3536
- Make Engine#loadHistoryUUID() protected and Origin#isFromTranslog() public ([#19753](https://github.com/opensearch-project/OpenSearch/pull/19752))
3637

3738
### Fixed

plugins/arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/bootstrap/ServerConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ private static class Netty4Configs {
238238

239239
@SuppressForbidden(reason = "required for netty allocator configuration")
240240
public static void init(Settings settings) {
241-
checkSystemProperty("io.netty.allocator.numDirectArenas", "1");
241+
int numArenas = Integer.parseInt(System.getProperty("io.netty.allocator.numDirectArenas"));
242+
if (numArenas <= 0) {
243+
throw new IllegalStateException("io.netty.allocator.numDirectArenas must be > 0");
244+
}
242245
checkSystemProperty("io.netty.noUnsafe", "false");
243246
checkSystemProperty("io.netty.tryUnsafe", "true");
244247
checkSystemProperty("io.netty.tryReflectionSetAccessible", "true");

rest-api-spec/src/main/resources/rest-api-spec/test/search/270_wildcard_fieldtype_queries.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ setup:
1919
type: wildcard
2020
doc_values: true
2121

22+
- do:
23+
indices.create:
24+
index: test1
25+
body:
26+
mappings:
27+
properties:
28+
my_field:
29+
type: wildcard
30+
2231
- do:
2332
index:
2433
index: test
@@ -78,6 +87,19 @@ setup:
7887
- do:
7988
indices.refresh: {}
8089

90+
---
91+
# Verify that mappings doc_values is stored.
92+
"Mappings":
93+
- skip:
94+
version: "- 3.4.0"
95+
reason: "the default value of doc_values is false before 3.4.0"
96+
97+
- do:
98+
indices.get_mapping:
99+
index: test1
100+
- is_true: test1.mappings
101+
- match: { test1.mappings.properties.my_field.doc_values: true }
102+
81103
---
82104
"term query matches exact value":
83105
- do:

server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static final class Builder extends ParametrizedFieldMapper.Builder {
102102
);
103103
private final Parameter<String> normalizer = Parameter.stringParam("normalizer", false, m -> toType(m).normalizerName, "default");
104104
private final Parameter<Map<String, String>> meta = Parameter.metaParam();
105-
private final Parameter<Boolean> hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, false).alwaysSerialize();
105+
private final Parameter<Boolean> hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, true).alwaysSerialize();
106106
private final IndexAnalyzers indexAnalyzers;
107107

108108
public Builder(String name, IndexAnalyzers indexAnalyzers) {
@@ -328,7 +328,7 @@ public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchL
328328
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't " + "support formats.");
329329
}
330330

331-
if (hasDocValues()) {
331+
if (hasDocValues() && searchLookup != null) {
332332
return new DocValueFetcher(DocValueFormat.RAW, searchLookup.doc().getForField(this));
333333
}
334334

server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,16 @@ public void testEnableDocValues() throws IOException {
128128
assertEquals(DocValuesType.NONE, fields[0].fieldType().docValuesType());
129129
assertEquals(DocValuesType.SORTED_SET, fields[1].fieldType().docValuesType());
130130

131+
// doc_values is true by default
131132
mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "wildcard")));
132133
doc = mapper.parse(source(b -> b.field("field", "1234")));
133134
fields = doc.rootDoc().getFields("field");
135+
assertEquals(2, fields.length);
136+
assertEquals(DocValuesType.NONE, fields[0].fieldType().docValuesType());
137+
138+
mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "wildcard").field("doc_values", false)));
139+
doc = mapper.parse(source(b -> b.field("field", "1234")));
140+
fields = doc.rootDoc().getFields("field");
134141
assertEquals(1, fields.length);
135142
assertEquals(DocValuesType.NONE, fields[0].fieldType().docValuesType());
136143
}

0 commit comments

Comments
 (0)