Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-8498: Improve error message when a large value is stored in an indexed string field

Shalin Shekhar Mangar16a787a85067
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 18ca8f2551a..6ce68fa8266 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -438,6 +438,8 @@ Other Changes
* SOLR-8482: add & use QueryCommand.[gs]etTerminateEarly accessors. (Christine Poerschke)
+* SOLR-8498: Improve error message when a large value is stored in an indexed string field. (shalin)
+
================== 5.4.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 42b1edafd7d..5bb915189b0 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -43,6 +43,7 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.util.BytesRefHash;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
@@ -169,6 +170,13 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
return addDoc0(cmd);
} catch (SolrException e) {
throw e;
+ } catch (IllegalArgumentException iae) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ String.format(Locale.ROOT, "Exception writing document id %s to the index; possible analysis error: "
+ + iae.getMessage()
+ + (iae.getCause() instanceof BytesRefHash.MaxBytesLengthExceededException ?
+ ". Perhaps the document has an indexed string field (solr.StrField) which is too large" : ""),
+ cmd.getPrintableId()), iae);
} catch (RuntimeException t) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
String.format(Locale.ROOT, "Exception writing document id %s to the index; possible analysis error.",