HoustonPutman commented on a change in pull request #2012: URL: https://github.com/apache/lucene-solr/pull/2012#discussion_r510461646
########## File path: solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java ########## @@ -280,30 +280,37 @@ protected void init() throws Exception { collectionsList = resolveCollectionListOrAlias(queryParams.get(COLLECTION_PROP, def)); // &collection= takes precedence if (core == null) { - // lookup core from collection, or route away if need to - String collectionName = collectionsList.isEmpty() ? null : collectionsList.get(0); // route to 1st - //TODO try the other collections if can't find a local replica of the first? (and do to V2HttpSolrCall) - boolean isPreferLeader = (path.endsWith("/update") || path.contains("/update/")); - core = getCoreByCollection(collectionName, isPreferLeader); // find a local replica/core for the collection - if (core != null) { - if (idx > 0) { - path = path.substring(idx); - } - } else { - // if we couldn't find it locally, look on other nodes - if (idx > 0) { - extractRemotePath(collectionName, origCorename); - if (action == REMOTEQUERY) { + // Let's try finding a local core + for (String collectionName: collectionsList) { + core = getCoreByCollection(collectionName, isPreferLeader); // find a local replica/core for the collection + if (core != null) { + if (idx > 0) { path = path.substring(idx); - return; } + break; + } + } + } + + // There is no local core so using remoteQuery + //TODO try the other collections if can't find a local replica of the first? (and do to V2HttpSolrCall) Review comment: You can probably remove this 😄 ########## File path: solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java ########## @@ -280,30 +280,37 @@ protected void init() throws Exception { collectionsList = resolveCollectionListOrAlias(queryParams.get(COLLECTION_PROP, def)); // &collection= takes precedence if (core == null) { - // lookup core from collection, or route away if need to - String collectionName = collectionsList.isEmpty() ? null : collectionsList.get(0); // route to 1st - //TODO try the other collections if can't find a local replica of the first? (and do to V2HttpSolrCall) - boolean isPreferLeader = (path.endsWith("/update") || path.contains("/update/")); - core = getCoreByCollection(collectionName, isPreferLeader); // find a local replica/core for the collection - if (core != null) { - if (idx > 0) { - path = path.substring(idx); - } - } else { - // if we couldn't find it locally, look on other nodes - if (idx > 0) { - extractRemotePath(collectionName, origCorename); - if (action == REMOTEQUERY) { + // Let's try finding a local core + for (String collectionName: collectionsList) { + core = getCoreByCollection(collectionName, isPreferLeader); // find a local replica/core for the collection + if (core != null) { + if (idx > 0) { path = path.substring(idx); - return; } + break; + } + } + } + + // There is no local core so using remoteQuery + //TODO try the other collections if can't find a local replica of the first? (and do to V2HttpSolrCall) + if (core == null) { + // lookup core from collection, or route away if need to + String collectionName = collectionsList.isEmpty() ? null : collectionsList.get(0); // route to 1st + + // if we couldn't find it locally, look on other nodes + if (idx > 0) { + extractRemotePath(collectionName, origCorename); + if (action == REMOTEQUERY) { + path = path.substring(idx); + return; } - //core is not available locally or remotely - autoCreateSystemColl(collectionName); - if (action != null) return; } + //core is not available locally or remotely + autoCreateSystemColl(collectionName); Review comment: Why is this being moved out of the `if (idx > 0)` conditional? Actually why does that conditional exist at all? ---------------------------------------------------------------- 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. 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