SOLR-9495: AIOBE with confusing message for incomplete sort spec in Streaming Expression

This commit is contained in:
Joel Bernstein 2016-12-30 19:54:00 -05:00
parent 36a691c50d
commit 61676188d7
2 changed files with 14 additions and 0 deletions

View File

@ -332,6 +332,10 @@ public class CloudSolrStream extends TupleStream implements Expressible {
String[] spec = s.trim().split("\\s+"); //This should take into account spaces in the sort spec.
if (spec.length != 2) {
throw new IOException("Invalid sort spec:" + s);
}
String fieldName = spec[0].trim();
String order = spec[1].trim();

View File

@ -162,6 +162,16 @@ public class StreamExpressionTest extends SolrCloudTestCase {
assertTrue(e.getMessage().contains("fl param expected for search function"));
}
try {
expression = StreamExpressionParser.parse("search(" + COLLECTIONORALIAS + ", q=\"blah\", fl=\"id, a_f\", sort=\"a_f\")");
stream = new CloudSolrStream(expression, factory);
tuples = getTuples(stream);
throw new Exception("Should be an exception here");
} catch(Exception e) {
assertTrue(e.getMessage().contains("Invalid sort spec"));
}
}
@Test