Apache Lucene open-source search software
SOLR-8458: Add Streaming Expressions tests for parameter substitution
Kevin Risden26027259a5ff
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6fbc11b611f..87accb90805 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -262,6 +262,8 @@ Other Changes* SOLR-8184: Negative tests for JDBC Connection String (Susheel Kumar, Jason Gerlowski, Kevin Risden)+* SOLR-8458: Add Streaming Expressions tests for parameter substitution (Joel Bernstein, Cao Manh Dat, Dennis Gove, Kevin Risden)+================== 6.0.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this releasediff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.javaindex 4d8e616c671..1f1a5bfc118 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java@@ -177,6 +177,55 @@ public class StreamExpressionTest extends SolrCloudTestCase {assertLong(tuples.get(1), "a_i", 3);}+ @Test+ public void testParameterSubstitution() throws Exception {++ new UpdateRequest()+ .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "0")+ .add(id, "2", "a_s", "hello2", "a_i", "2", "a_f", "0")+ .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")+ .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")+ .add(id, "1", "a_s", "hello1", "a_i", "1", "a_f", "1")+ .commit(cluster.getSolrClient(), COLLECTION);++ String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTION;+ List<Tuple> tuples;+ TupleStream stream;++ // Basic test+ Map<String,String> params = new HashMap<>();+ params.put("expr","merge("+ + "${q1},"+ + "${q2},"+ + "on=${mySort})");+ params.put(CommonParams.QT, "/stream");+ params.put("q1", "search(" + COLLECTION + ", q=\"id:(0 3 4)\", fl=\"id,a_s,a_i,a_f\", sort=${mySort})");+ params.put("q2", "search(" + COLLECTION + ", q=\"id:(1)\", fl=\"id,a_s,a_i,a_f\", sort=${mySort})");+ params.put("mySort", "a_f asc");+ stream = new SolrStream(url, params);+ tuples = getTuples(stream);++ assertEquals(4, tuples.size());+ assertOrder(tuples, 0,1,3,4);++ // Basic test desc+ params.put("mySort", "a_f desc");+ stream = new SolrStream(url, params);+ tuples = getTuples(stream);++ assertEquals(4, tuples.size());+ assertOrder(tuples, 4,3,1,0);++ // Basic w/ multi comp+ params.put("q2", "search(" + COLLECTION + ", q=\"id:(1 2)\", fl=\"id,a_s,a_i,a_f\", sort=${mySort})");+ params.put("mySort", "\"a_f asc, a_s asc\"");+ stream = new SolrStream(url, params);+ tuples = getTuples(stream);++ assertEquals(5, tuples.size());+ assertOrder(tuples, 0,2,1,3,4);+ }+@Testpublic void testUniqueStream() throws Exception {