SOLR-12702: Add zscores Stream Evaluator

This commit is contained in:
Joel Bernstein 2018-08-27 10:54:36 -04:00
parent 08a6d13c92
commit 94503719ec
3 changed files with 13 additions and 5 deletions

View File

@ -254,6 +254,8 @@ public class Lang {
.withFunctionName("getCache", GetCacheEvaluator.class)
.withFunctionName("removeCache", RemoveCacheEvaluator.class)
.withFunctionName("listCache", ListCacheEvaluator.class)
.withFunctionName("zscores", NormalizeEvaluator.class)
// Boolean Stream Evaluators
.withFunctionName("and", AndEvaluator.class)

View File

@ -70,7 +70,7 @@ public class TestLang extends LuceneTestCase {
"mod", "ceil", "floor", "sin", "asin", "sinh", "cos", "acos", "cosh", "tan", "atan", "tanh", "round", "sqrt",
"cbrt", "coalesce", "uuid", "if", "convert", "valueAt", "memset", "fft", "ifft", "euclidean","manhattan",
"earthMovers", "canberra", "chebyshev", "ones", "zeros", "setValue", "getValue", "knnRegress", "gaussfit",
"outliers", "stream", "getCache", "putCache", "listCache", "removeCache"};
"outliers", "stream", "getCache", "putCache", "listCache", "removeCache", "zscores"};
@Test
public void testLang() {

View File

@ -1327,7 +1327,7 @@ public class MathExpressionTest extends SolrCloudTestCase {
@Test
public void testStandardize() throws Exception {
String cexpr = "let(echo=true, a=standardize(matrix(array(1,2,3), array(4,5,6))), b=standardize(array(4,5,6)))";
String cexpr = "let(echo=true, a=standardize(matrix(array(1,2,3), array(4,5,6))), b=standardize(array(4,5,6)), c=zscores(array(4,5,6)))";
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
paramsLoc.set("expr", cexpr);
paramsLoc.set("qt", "/stream");
@ -1353,9 +1353,15 @@ public class MathExpressionTest extends SolrCloudTestCase {
List<Number> array3 = (List<Number>)tuples.get(0).get("b");
assertEquals(array3.size(), 3);
assertEquals(array2.get(0).doubleValue(), -1, 0.0);
assertEquals(array2.get(1).doubleValue(), 0, 0.0);
assertEquals(array2.get(2).doubleValue(), 1, 0.0);
assertEquals(array3.get(0).doubleValue(), -1, 0.0);
assertEquals(array3.get(1).doubleValue(), 0, 0.0);
assertEquals(array3.get(2).doubleValue(), 1, 0.0);
List<Number> array4 = (List<Number>)tuples.get(0).get("c");
assertEquals(array4.size(), 3);
assertEquals(array4.get(0).doubleValue(), -1, 0.0);
assertEquals(array4.get(1).doubleValue(), 0, 0.0);
assertEquals(array4.get(2).doubleValue(), 1, 0.0);
}
@Test