Apache Solr open-source search software
SOLR-528: Better error message when defaultSearchField is bogus or not indexed
Chris M. Hostetterb6fe0f58d050
diff --git a/CHANGES.txt b/CHANGES.txtindex 10d09c55834..c4c8662a899 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -331,6 +331,9 @@ Bug Fixesfield using bogus fieldtype and multiple copyFields to a non-multiValuefield. (Shalin Shekhar Mangar via hossman)+23. SOLR-528: Better error message when defaultSearchField is bogus or not+ indexed. (Lars Kotthoff via hossman)+Other Changes1. SOLR-135: Moved common classes to org.apache.solr.common and altered thebuild scripts to make two jars: apache-solr-1.3.jar anddiff --git a/src/java/org/apache/solr/schema/IndexSchema.java b/src/java/org/apache/solr/schema/IndexSchema.javaindex 7236bc315e3..7425fac0a27 100644--- a/src/java/org/apache/solr/schema/IndexSchema.java+++ b/src/java/org/apache/solr/schema/IndexSchema.java@@ -511,7 +511,13 @@ public final class IndexSchema {} else {defaultSearchFieldName=node.getNodeValue().trim();// throw exception if specified, but not found or not indexed- if (defaultSearchFieldName!=null) getIndexedField(defaultSearchFieldName);+ if (defaultSearchFieldName!=null) {+ SchemaField defaultSearchField = getFields().get(defaultSearchFieldName);+ if ((defaultSearchField == null) || !defaultSearchField.indexed()) {+ String msg = "default search field '" + defaultSearchFieldName + "' not defined or not indexed" ;+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );+ }+ }log.info("default search field is "+defaultSearchFieldName);}