dsmiley commented on code in PR #4053:
URL: https://github.com/apache/solr/pull/4053#discussion_r2722994417
##########
solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java:
##########
@@ -484,43 +488,75 @@ void writeDoc(
LeafReaderContext context = leaves.get(ord);
int fieldIndex = 0;
for (FieldWriter fieldWriter : writers) {
- if (fieldWriter.write(sortDoc, context, ew, fieldIndex)) {
- ++fieldIndex;
- }
+ fieldIndex += fieldWriter.write(sortDoc, context, ew, fieldIndex);
}
}
public List<FieldWriter> getFieldWriters(String[] fields, SolrQueryRequest
req)
throws IOException {
DocValuesIteratorCache dvIterCache = new
DocValuesIteratorCache(req.getSearcher(), false);
-
SolrReturnFields solrReturnFields = new SolrReturnFields(fields, req);
+ boolean includeStoredFields =
req.getParams().getBool(INCLUDE_STORED_FIELDS_PARAM, false);
List<FieldWriter> writers = new ArrayList<>();
+ Set<SchemaField> docValueFields = new LinkedHashSet<>();
+ Map<String, SchemaField> storedFields = new LinkedHashMap<>();
+
for (String field : req.getSearcher().getFieldNames()) {
if (!solrReturnFields.wantsField(field)) {
continue;
}
SchemaField schemaField = req.getSchema().getField(field);
- if (!schemaField.hasDocValues()) {
- throw new IOException(schemaField + " must have DocValues to use this
feature.");
- }
- boolean multiValued = schemaField.multiValued();
FieldType fieldType = schemaField.getType();
- FieldWriter writer;
- if (fieldType instanceof SortableTextField &&
!schemaField.useDocValuesAsStored()) {
- if (solrReturnFields.getRequestedFieldNames() != null
- && solrReturnFields.getRequestedFieldNames().contains(field)) {
- // Explicitly requested field cannot be used due to not having
useDocValuesAsStored=true,
- // throw exception
+ // Check if field can use DocValues
+ boolean canUseDocValues =
+ schemaField.hasDocValues()
+ && (!(fieldType instanceof SortableTextField) ||
schemaField.useDocValuesAsStored());
Review Comment:
Could the selection logic here, even if somewhat trivial, be extracted so
it's also used in multiple places in ExportWriter? That would help keep them
in sync and also show via find-usages that the logic is used from multiple
use-cases.
--
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]