kotman12 commented on code in PR #5113:
URL: https://github.com/apache/solr/pull/5113#discussion_r4261864780


##########
solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java:
##########
@@ -268,35 +279,38 @@ private void _write(OutputStream os) throws IOException {
       }
     }
     SolrParams params = req.getParams();
-    String fl = params.get("fl");
 
-    String[] fields = null;
-
-    if (fl == null) {
+    if (params.get(CommonParams.FL) == null) {

Review Comment:
   can you check this on the `SolrReturnFields` object? Just for brevity...



##########
solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java:
##########
@@ -483,49 +497,89 @@ void writeDoc(
       throws IOException {
     int ord = sortDoc.ord;
     LeafReaderContext context = leaves.get(ord);
+    if (transformer == null) {
+      for (FieldWriter fieldWriter : writers) {
+        fieldWriter.write(sortDoc, context, ew);
+      }
+      return;
+    }
+
+    SolrDocument doc = new SolrDocument();
+    EntryWriter docWriter =
+        new EntryWriter() {
+          @Override
+          public EntryWriter put(CharSequence k, Object v) {
+            doc.setField(k.toString(), materialize(v));
+            return this;
+          }
+        };
     for (FieldWriter fieldWriter : writers) {
-      fieldWriter.write(sortDoc, context, ew);
+      fieldWriter.write(sortDoc, context, docWriter);
+    }
+    transformer.transform(doc, sortDoc.docBase + sortDoc.docId, 
DocIterationInfo.NONE);

Review Comment:
   Will this will return the transformed fields out of `fl` order? Not a huge 
deal but just pointing it out.



##########
solr/solr-ref-guide/modules/query-guide/pages/exporting-result-sets.adoc:
##########
@@ -101,6 +101,9 @@ Note that sort fields still require docValues, regardless 
of this setting.
 
 Wildcard patterns can be used for the field list (e.g. `fl=*_i`) and will be 
expanded to the list of fields that match the pattern and are able to be 
exported, see <<Field Requirements>>.
 
+Field aliases (e.g. `fl=id,price:price_d`) and 
xref:document-transformers.adoc[document transformers] (e.g. `fl=id,[docid]`) 
are supported, and their output is also visible to a local streaming expression.
+Transformers are applied one document at a time, and those that depend on 
scores or on a list of matching documents won't work.

Review Comment:
   Generally transformers that don't return maps/lists/values won't work, 
right? I.e. `fl=id,myquery:[subquery]` won't work. The DocTransformer 
integration uncovers some gaps in the existing ExportWriter/javabin writer vs 
the text writer. It may not be a common use case here but maybe worth calling 
out.



-- 
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]

Reply via email to