mkhludnev commented on code in PR #2536:
URL: https://github.com/apache/solr/pull/2536#discussion_r1670638010


##########
solr/core/src/java/org/apache/solr/schema/BinaryField.java:
##########
@@ -112,7 +125,31 @@ public IndexableField createField(SchemaField field, 
Object val) {
       len = buf.length;
     }
 
-    return new org.apache.lucene.document.StoredField(field.getName(), buf, 
offset, len);
+    return new BytesRef(buf, offset, len);
+  }
+
+  @Override
+  public List<IndexableField> createFields(SchemaField field, Object val) {
+    IndexableField fval = createField(field, val);
+
+    if (field.hasDocValues() && !field.multiValued()) {
+      IndexableField docval = new BinaryDocValuesField(field.getName(), 
getBytesRef(val));
+
+      // Only create list if we have 2 values...
+      if (fval != null) {
+        List<IndexableField> fields = new ArrayList<>(2);
+        fields.add(fval);
+        fields.add(docval);
+        return fields;
+      }
+
+      fval = docval;
+    }
+    return Collections.singletonList(fval);

Review Comment:
   May it be simplified as 
   ```
   Stream.of(createField(field, val), 
   (field.hasDocValues() && !field.multiValued()) ? new 
BinaryDocValuesField(field.getName(), getBytesRef(val)):null)
                    .filter(obj -> obj != null)
                    .collect(Collectors.toList());
   ```
   ?
   
   **UPD**: However, Streams may put too much footprint.



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