dsmiley commented on code in PR #2686: URL: https://github.com/apache/lucene-solr/pull/2686#discussion_r1799803611
########## solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java: ########## @@ -130,9 +131,26 @@ public SolrIndexSplitter(SplitIndexCommand cmd) { } routeFieldName = cmd.routeFieldName; if (routeFieldName == null) { - field = searcher.getSchema().getUniqueKeyField(); + // To support routing child documents, use the root field if it exists (which would be populated with unique field), + // otherwise use the unique key field + field = searcher.getSchema().getFieldOrNull(IndexSchema.ROOT_FIELD_NAME); + if(field == null) { + field = searcher.getSchema().getUniqueKeyField(); + } } else { - field = searcher.getSchema().getField(routeFieldName); + SchemaField uniqueField = searcher.getSchema().getUniqueKeyField(); + if (uniqueField.getName().equals(routeFieldName)) { + // Explicitly routing based on unique field + // To support routing child documents, use the root field if it exists (which would be populated with unique field), + // otherwise use the unique key field + field = searcher.getSchema().getFieldOrNull(IndexSchema.ROOT_FIELD_NAME); + if (field == null) { + field = searcher.getSchema().getUniqueKeyField(); + } + } else { + // Custom routing + field = searcher.getSchema().getField(routeFieldName); + } Review Comment: Notice it's conditional based on the router having a "field" in the JSON. It's rare to use that. Also if we don't support something (child docs + whatever), we ought to throw an exception instead of do the wrong thing. See `org.apache.solr.schema.IndexSchema#isUsableForChildDocs` -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org