Skip to content

Apache Lucene 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.txt
index 10d09c55834..c4c8662a899 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -331,6 +331,9 @@ Bug Fixes
field using bogus fieldtype and multiple copyFields to a non-multiValue
field. (Shalin Shekhar Mangar via hossman)
+23. SOLR-528: Better error message when defaultSearchField is bogus or not
+ indexed. (Lars Kotthoff via hossman)
+
Other Changes
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
build scripts to make two jars: apache-solr-1.3.jar and
diff --git a/src/java/org/apache/solr/schema/IndexSchema.java b/src/java/org/apache/solr/schema/IndexSchema.java
index 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);
}