You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gu...@apache.org on 2019/03/04 17:32:05 UTC

[lucene-solr] 06/10: SOLR-13151 fix mustMatch to match on value not the final collection name so that users can choose to fail on non-english text if desired.

This is an automated email from the ASF dual-hosted git repository.

gus pushed a commit to branch solr-13131
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 64d1601d4b4fae0c21b9a3c71c7be2ad38d2110f
Author: Gus Heck <gu...@apache.org>
AuthorDate: Sun Mar 3 15:26:40 2019 -0500

    SOLR-13151 fix mustMatch to match on value not the final collection
    name so that users can choose to fail on non-english text if desired.
---
 .../apache/solr/cloud/api/collections/CategoryRoutedAlias.java |  4 ++--
 .../processor/CategoryRoutedAliasUpdateProcessorTest.java      | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
index 5089eeb..7d73149 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
@@ -146,8 +146,8 @@ public class CategoryRoutedAlias implements RoutedAlias {
           "__CRA__");
     }
 
-    if (mustMatch != null && !mustMatch.matcher(candidateCollectionName).matches()) {
-      throw new SolrException(BAD_REQUEST, "Collection name " + candidateCollectionName
+    if (mustMatch != null && !mustMatch.matcher(dataValue).matches()) {
+      throw new SolrException(BAD_REQUEST, "Route value " + dataValue
           + " does not match " + ROUTER_MUST_MATCH + ": " + mustMatch);
     }
 
diff --git a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
index 813a326..77ecb22 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
@@ -223,16 +223,16 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro
   public void testMustMatch() throws Exception {
     String configName = getSaferTestName();
     createConfigSet(configName);
-    final String mustMatchRegex = ".+_solr";
+    final String mustMatchRegex = "HHS\\s.+_solr";
 
     final int maxCardinality = Integer.MAX_VALUE; // max cardinality for current test
 
     // Start with one collection manually created (and use higher numShards & replicas than we'll use for others)
     //  This tests we may pre-create the collection and it's acceptable.
-    final String colVogon = getAlias() + "__CRA__" + noSpaces(SHIPS[0]) + "_solr";
+    final String colVogon = getAlias() + "__CRA__" + noSpaces("HHS "+ SHIPS[0]) + "_solr";
 
     // we expect changes ensuring a legal collection name.
-    final String colHoG = getAlias() + "__CRA__" + noSpaces(SHIPS[1]) + "_solr";
+    final String colHoG = getAlias() + "__CRA__" + noSpaces("HHS "+ SHIPS[1]) + "_solr";
 
     List<String> retrievedConfigSetNames = new ConfigSetAdminRequest.List().process(solrClient).getConfigSets();
     List<String> expectedConfigSetNames = Arrays.asList("_default", configName);
@@ -249,13 +249,13 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro
         .process(solrClient);
 
     // now we index a document
-    addDocsAndCommit(true, newDoc(SHIPS[0] + "_solr"));
+    addDocsAndCommit(true, newDoc("HHS " + SHIPS[0] + "_solr"));
     //assertDocRoutedToCol(lastDocId, col23rd);
 
     String uninitialized = getAlias() + "__CRA__" + CategoryRoutedAlias.UNINITIALIZED;
     assertInvariants(colVogon, uninitialized);
 
-    addDocsAndCommit(true, newDoc(SHIPS[1] + "_solr"));
+    addDocsAndCommit(true, newDoc("HHS "+ SHIPS[1] + "_solr"));
 
     assertInvariants(colVogon, colHoG);