ercsonusharma commented on code in PR #4645:
URL: https://github.com/apache/solr/pull/4645#discussion_r3691680038
##########
solr/core/src/java/org/apache/solr/schema/numericrange/AbstractNumericRangeField.java:
##########
@@ -153,34 +172,120 @@ protected void init(IndexSchema schema, Map<String,
String> args) {
+ typeName);
}
}
+ }
- // Range fields do not support docValues - validate this wasn't explicitly
enabled
- if (hasProperty(DOC_VALUES)) {
- throw new SolrException(
- ErrorCode.SERVER_ERROR,
- "docValues=true enabled but "
- + getClass().getSimpleName()
- + " does not support docValues for field type "
- + typeName);
- }
+ @Override
+ protected void checkSupportsDocValues() {
+ // DocValues are supported for both single and multiValued range fields
(backed by binary
+ // docValues).
}
@Override
public List<IndexableField> createFields(SchemaField field, Object value) {
- IndexableField indexedField = createField(field, value);
List<IndexableField> fields = new ArrayList<>();
+ IndexableField indexedField = createField(field, value);
if (indexedField != null) {
fields.add(indexedField);
}
+ if (field.hasDocValues() && !field.multiValued()) {
+ // Single-valued: one flat BinaryDocValues blob (read directly, no
dictionary). multiValued
+ // docValues are built from all values at once in
createFieldsFromAllValues (one blob holding
+ // every range), since BinaryDocValues holds only one value per document.
+ NumericRangeValue rv = parseRangeValue(value.toString());
+ fields.add(
+ new BinaryDocValuesField(
+ field.getName(),
BytesRef.deepCopyOf(encodePackedValue(field.getName(), rv))));
+ }
+
if (field.stored()) {
fields.add(getStoredField(field, value.toString()));
}
return fields;
}
+ @Override
+ public boolean shouldCreateFieldsFromAllValues() {
+ // multiValued docValues range fields pack every range of a document into
ONE BinaryDocValues
+ // blob (flat, no dictionary), so the type needs all values together to
build it.
+ return true;
+ }
+
+ @Override
+ public List<IndexableField> createFieldsFromAllValues(
+ SchemaField field, Collection<Object> values) {
Review Comment:
absolutely, it's the right time to keep the sorting in place for future
optimizations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]