epugh commented on code in PR #1996:
URL: https://github.com/apache/solr/pull/1996#discussion_r1355179911
##########
solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java:
##########
@@ -844,4 +844,61 @@ public String getMessage() {
return "Early Client Disconnect";
}
}
+
+ /**
+ * Creates a complete field list using the provided field list by expanding
any glob patterns into
+ * field names
+ *
+ * @param fields the original set of fields provided
+ * @param searcher an index searcher to access schema info
+ * @return a complete list of fields included any fields matching glob
patterns
+ * @throws IOException if a provided field does not exist or cannot be
retrieved from the schema
+ * info
+ */
+ private List<SchemaField> expandFieldList(String[] fields, SolrIndexSearcher
searcher)
+ throws IOException {
+ List<SchemaField> expandedFields = new ArrayList<>(fields.length);
+ Set<String> fieldsProcessed = new HashSet<>();
+ for (String field : fields) {
+ try {
+ if (field.contains("*")) {
+ getGlobFields(field, searcher, fieldsProcessed, expandedFields);
+ } else {
+ if (fieldsProcessed.add(field)) {
+ expandedFields.add(searcher.getSchema().getField(field));
+ }
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ return expandedFields;
+ }
+
+ /**
+ * Create a list of schema fields that match a given glob pattern
+ *
+ * @param fieldPattern the glob pattern to match
+ * @param searcher an index search to access schema info
+ * @param fieldsProcessed the set of field names already processed to avoid
duplicating
+ * @param expandedFields the list of fields to add expanded field names into
+ */
+ private void getGlobFields(
+ String fieldPattern,
+ SolrIndexSearcher searcher,
+ Set<String> fieldsProcessed,
+ List<SchemaField> expandedFields) {
+ for (FieldInfo fi : searcher.getFieldInfos()) {
+ if (GlobPatternUtil.matches(fieldPattern, fi.getName())) {
+ SchemaField schemaField = searcher.getSchema().getField(fi.getName());
+ if (fieldsProcessed.add(fi.getName())
+ && schemaField.hasDocValues()
+ && (!(schemaField.getType() instanceof SortableTextField)
Review Comment:
I vote for consistency if possible, since I think of both /select and
/export as the same, just one is faster than the other ;-). If that isn't
possible, then maybe if the ref guide makes it really clear "This is why you
use /select and ramifications" and "THis is why you use /export and it's
ramifications", then that might cover these differences. I can see the bug
reports if we aren't clear ;-).
--
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]