Skip to content

Apache Lucene open-source search software

SOLR-220 -- adding a nicer error message when you sort on an undefined field.

Ryan McKinleyd273f5415148
diff --git a/src/java/org/apache/solr/search/QueryParsing.java b/src/java/org/apache/solr/search/QueryParsing.java
index 3b35c108529..dfdbe68f824 100644
--- a/src/java/org/apache/solr/search/QueryParsing.java
+++ b/src/java/org/apache/solr/search/QueryParsing.java
@@ -199,7 +199,13 @@ public class QueryParsing {
}
else {
// getField could throw an exception if the name isn't found
- SchemaField f = schema.getField(part);
+ SchemaField f = null;
+ try{
+ f = schema.getField(part);
+ }
+ catch( SolrException e ){
+ throw new SolrException( 400, "can not sort on undefined field: "+part, e );
+ }
if (f == null || !f.indexed()){
throw new SolrException( 400, "can not sort on unindexed field: "+part );
}