You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by md...@apache.org on 2020/05/08 14:44:27 UTC

[lucene-solr] branch branch_8x updated (edbb21c -> b5793f4)

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

mdrob pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from edbb21c  Ensure nightly doesn't cause timeouts
     new bad85f7  SOLR-13190 Backport unit test
     new b5793f4  SOLR-14465: Solr query handling code catches FuzzyTermsException

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../solr/handler/component/QueryComponent.java     |  9 ++-
 .../org/apache/solr/search/FuzzySearchTest.java    | 67 ++++++++++++++++++++++
 2 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 solr/core/src/test/org/apache/solr/search/FuzzySearchTest.java


[lucene-solr] 01/02: SOLR-13190 Backport unit test

Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bad85f7c5aceb048e23fa343357dd807954d9ca7
Author: Mike Drob <md...@apple.com>
AuthorDate: Fri May 8 09:25:49 2020 -0500

    SOLR-13190 Backport unit test
---
 .../org/apache/solr/search/FuzzySearchTest.java    | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/solr/core/src/test/org/apache/solr/search/FuzzySearchTest.java b/solr/core/src/test/org/apache/solr/search/FuzzySearchTest.java
new file mode 100644
index 0000000..f84cf10
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/search/FuzzySearchTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.search;
+
+import java.io.IOException;
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@LuceneTestCase.Slow
+public class FuzzySearchTest extends SolrCloudTestCase {
+  private final static String COLLECTION = "c1";
+  private CloudSolrClient client;
+
+  @BeforeClass
+  public static void setupCluster() throws Exception {
+    configureCluster(1).addConfig(COLLECTION, configset("cloud-minimal")).configure();
+  }
+
+  @Before
+  public void setupCollection() throws Exception {
+    client = cluster.getSolrClient();
+    client.setDefaultCollection(COLLECTION);
+
+    CollectionAdminRequest.createCollection(COLLECTION, 1, 1).process(client);
+    cluster.waitForActiveCollection(COLLECTION, 1, 1);
+  }
+
+  @Test
+  public void testTooComplex() throws IOException, SolrServerException {
+    SolrInputDocument doc = new SolrInputDocument();
+
+    doc.setField("id", "1");
+    doc.setField("text", "foo");
+    client.add(doc);
+    client.commit(); // Must have index files written, but the contents don't matter
+
+    SolrQuery query = new SolrQuery("text:headquarters\\(在日米海軍横須賀基地司令部庁舎\\/旧横須賀鎮守府会議所・横須賀海軍艦船部\\)~");
+
+    BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.query(query));
+    assertTrue("Should be client error, not server error", e.code() >= 400 && e.code() < 500);
+  }
+}


[lucene-solr] 02/02: SOLR-14465: Solr query handling code catches FuzzyTermsException

Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b5793f465b0327e11f0896c7eec8e522fdd2ed7d
Author: Mike Drob <md...@apache.org>
AuthorDate: Thu May 7 17:47:03 2020 -0500

    SOLR-14465: Solr query handling code catches FuzzyTermsException
    
    This reverts commit 7ea7ed72aca556f957a5de55911c852124db8715.
---
 .../java/org/apache/solr/handler/component/QueryComponent.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index b03997a..9f8b355 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -215,7 +215,7 @@ public class QueryComponent extends SearchComponent
           rb.setFilters( filters );
         }
       }
-    } catch (SyntaxError | FuzzyTermsEnum.FuzzyTermsException e) {
+    } catch (SyntaxError e) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
     }
 
@@ -1486,7 +1486,12 @@ public class QueryComponent extends SearchComponent
     SolrQueryResponse rsp = rb.rsp;
 
     SolrIndexSearcher searcher = req.getSearcher();
-    searcher.search(result, cmd);
+
+    try {
+      searcher.search(result, cmd);
+    } catch (FuzzyTermsEnum.FuzzyTermsException e) {
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
+    }
     rb.setResult(result);
 
     ResultContext ctx = new BasicResultContext(rb);