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
This commit is contained in:
Shalin Shekhar Mangar 2016-01-06 22:19:49 +00:00
parent 9f7f89fc97
commit 16a787a850
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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.",