From 16a787a85067e00362808040fee10685f44901d7 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Wed, 6 Jan 2016 22:19:49 +0000 Subject: [PATCH] SOLR-8498: Improve error message when a large value is stored in an indexed string field git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1723419 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 ++ .../java/org/apache/solr/update/DirectUpdateHandler2.java | 8 ++++++++ 2 files changed, 10 insertions(+) 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.",