Skip to content

Commit b44bdc1

Browse files
SOLR-10808: Enable docValues by default on specific fields (#2606)
Fields: - PrimitiveField (Numbers/Dates/String/UUID/Enum/Bool) - Without DenseVectors - SortableTextField - SortableBinaryField - ICUCollationField - CollationField - LatLonPointSpacialField
1 parent 74bfadf commit b44bdc1

File tree

16 files changed

+49
-41
lines changed

16 files changed

+49
-41
lines changed

solr/CHANGES.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ New Features
153153

154154
Improvements
155155
---------------------
156+
* SOLR-10808, SOLR-12963: The Solr schema version has been increased to 1.7.
157+
Starting in schema version 1.7, most fields/fieldTypes that support docValues will have them enabled by default.
158+
These field types include primitive (Numeric, Date, Bool, String, Enum, UUID), sorting (SortableTextField, SortableBinaryField, CollationField, ICUCollationField) and LatLonPointSpacialField.
159+
This behavior can be reverted by setting the 'docValues' parameter for a field or a field type to false, the default for schema versions 1.6 and below.
160+
Also in schema version 1.7, all fields/fieldTypes will be unable to be uninverted by default.
161+
This behavior can be reverted by setting the 'uninvertible' parameter for a field or a field type to true, the default for schema versions 1.6 and below.
162+
(Houston Putman, hossman)
163+
156164
* SOLR-17137: Enable Prometheus exporter to communicate with SSL protected Solr. (Eivind Bergstøl via Eric Pugh)
157165

158166
* SOLR-16921: use -solrUrl to derive the zk host connection for bin/solr zk subcommands (Eric Pugh)
@@ -183,13 +191,6 @@ Improvements
183191
Statuses are now removed 5 minutes after the read of a completed/failed status. Helps collection
184192
async backup/restore and other operations scale to 100+ shards. (Pierre Salagnac, David Smiley)
185193

186-
* SOLR-10808, SOLR-12963: The Solr schema version has been increased to 1.7.
187-
Starting in schema version 1.7, all fields/fieldTypes that support docValues will have them enabled by default.
188-
This behavior can be reverted by setting the 'docValues' parameter for a field or a field type to false, the default for schema versions 1.6 and below.
189-
Also in schema version 1.7, all fields/fieldTypes will be unable to be uninverted by default.
190-
This behavior can be reverted by setting the 'uninvertible' parameter for a field or a field type to true, the default for schema versions 1.6 and below.
191-
(Houston Putman, hossman)
192-
193194
* SOLR-10808 : The Solr schema version has been increased to 1.7. Since schema version 1.7, all fields/fieldTypes that
194195
support docValues will have them enabled by default. This behavior can be reverted by setting
195196
'docValues' parameter for a field or a field type to false, the default for schema versions 1.6 and below. (Houston Putman)

solr/core/src/java/org/apache/solr/schema/BinaryField.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ public List<IndexableField> createFields(SchemaField field, Object val) {
152152
protected void checkSupportsDocValues() { // we support DocValues
153153
}
154154

155-
@Override
156-
protected boolean doesTypeSupportDocValues() {
157-
return true;
158-
}
159-
160155
@Override
161156
public Object toNativeType(Object val) {
162157
if (val instanceof byte[]) {

solr/core/src/java/org/apache/solr/schema/CollationField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected void checkSupportsDocValues() { // we support DocValues
246246
}
247247

248248
@Override
249-
protected boolean doesTypeSupportDocValues() {
249+
protected boolean enableDocValuesByDefault() {
250250
return true;
251251
}
252252

solr/core/src/java/org/apache/solr/schema/DenseVectorField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public VectorEncoding getVectorEncoding() {
179179
}
180180

181181
@Override
182-
protected boolean doesTypeSupportDocValues() {
182+
protected boolean enableDocValuesByDefault() {
183183
return false;
184184
}
185185

solr/core/src/java/org/apache/solr/schema/FieldType.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected void setArgs(IndexSchema schema, Map<String, String> args) {
188188
args.remove("compressThreshold");
189189
}
190190
if (schemaVersion >= 1.6f) properties |= USE_DOCVALUES_AS_STORED;
191-
if (schemaVersion >= 1.7f && doesTypeSupportDocValues()) properties |= DOC_VALUES;
191+
if (schemaVersion >= 1.7f && enableDocValuesByDefault()) properties |= DOC_VALUES;
192192

193193
if (schemaVersion < 1.7f) properties |= UNINVERTIBLE;
194194

@@ -1161,15 +1161,17 @@ protected void checkSupportsDocValues() {
11611161
ErrorCode.SERVER_ERROR, "Field type " + this + " does not support doc values");
11621162
}
11631163

1164-
/** Returns whether this field type supports docValues. By default none do. */
1165-
protected boolean doesTypeSupportDocValues() {
1166-
try {
1167-
// TODO: In Solr 10.0 change this such that checkSupportsDocValues() calls this method instead
1168-
checkSupportsDocValues();
1169-
return true;
1170-
} catch (Exception ignored) {
1171-
return false;
1172-
}
1164+
/**
1165+
* Returns whether this field type should enable docValues by default for schemaVersion &gt;= 1.7.
1166+
* This should not be enabled for fields that did not have docValues implemented by Solr 9.7, as
1167+
* users may have indexed documents without docValues (since they weren't supported). Flipping the
1168+
* default docValues values when they upgrade to a new version will break their index
1169+
* compatibility.
1170+
*
1171+
* <p>New field types can enable this without issue, as long as they support docValues.
1172+
*/
1173+
protected boolean enableDocValuesByDefault() {
1174+
return false;
11731175
}
11741176

11751177
public static final String TYPE = "type";

solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected void checkSupportsDocValues() { // we support DocValues
7070
}
7171

7272
@Override
73-
protected boolean doesTypeSupportDocValues() {
73+
protected boolean enableDocValuesByDefault() {
7474
return true;
7575
}
7676

solr/core/src/java/org/apache/solr/schema/PointType.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ protected void checkSupportsDocValues() {
172172
}
173173
}
174174

175-
@Override
176-
protected boolean doesTypeSupportDocValues() {
177-
return true;
178-
}
179-
180175
/**
181176
* Calculates the range and creates a RangeQuery (bounding box) wrapped in a BooleanQuery (unless
182177
* the dimension is 1, one range for every dimension, AND'd together by a Boolean

solr/core/src/java/org/apache/solr/schema/PrimitiveFieldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected void checkSupportsDocValues() { // primitive types support DocValues
3939
}
4040

4141
@Override
42-
protected boolean doesTypeSupportDocValues() {
42+
protected boolean enableDocValuesByDefault() {
4343
return true;
4444
}
4545

solr/core/src/java/org/apache/solr/schema/SortableTextField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected void checkSupportsDocValues() {
151151
}
152152

153153
@Override
154-
protected boolean doesTypeSupportDocValues() {
154+
protected boolean enableDocValuesByDefault() {
155155
return true;
156156
}
157157

solr/core/src/test-files/solr/collection1/conf/schema-binaryfield.xml

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

3434
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
3535
<field name="data" type="binary" stored="true"/>
36-
<field name="data_dv" type="binary" stored="false" />
36+
<field name="data_dv" type="binary" stored="false" docValues="true" />
3737

3838

3939
<uniqueKey>id</uniqueKey>

0 commit comments

Comments
 (0)