99import com .marklogic .client .type .XsDoubleSeqVal ;
1010import org .junit .jupiter .api .Assertions ;
1111import org .junit .jupiter .api .BeforeEach ;
12- import org .junit .jupiter .api .Disabled ;
1312import org .junit .jupiter .api .Test ;
1413import org .junit .jupiter .api .extension .ExtendWith ;
1514
@@ -49,11 +48,12 @@ void vectorFunctionsHappyPath() {
4948 .bind (op .as ("base64Encode" , op .vec .base64Encode (op .col ("sampleVector" ))))
5049 .bind (op .as ("base64Decode" , op .vec .base64Decode (op .col ("base64Encode" ))))
5150 .bind (op .as ("subVector" , op .vec .subvector (op .col ("sampleVector" ), op .xs .integer (1 ), op .xs .integer (1 ))))
51+ .bind (op .as ("vectorScore" , op .vec .vectorScore (op .xs .unsignedInt (1 ), op .xs .doubleVal (0.5 ))))
5252 .select (
5353 op .col ("cosineSimilarity" ), op .col ("dotProduct" ), op .col ("euclideanDistance" ),
5454 op .col ("name" ), op .col ("dimension" ), op .col ("normalize" ),
5555 op .col ("magnitude" ), op .col ("get" ), op .col ("add" ), op .col ("subtract" ),
56- op .col ("base64Encode" ), op .col ("base64Decode" ), op .col ("subVector" )
56+ op .col ("base64Encode" ), op .col ("base64Decode" ), op .col ("subVector" ), op . col ( "vectorScore" )
5757 )
5858 .limit (5 );
5959 List <RowRecord > rows = resultRows (plan );
@@ -77,6 +77,8 @@ void vectorFunctionsHappyPath() {
7777 assertEquals (3 , ((ArrayNode ) row .get ("base64Decode" )).size ());
7878 assertEquals (5.6 , row .getDouble ("get" ));
7979 assertEquals (1 , ((ArrayNode ) row .get ("subVector" )).size ());
80+ double vectorScore = row .getDouble ("vectorScore" );
81+ assertTrue (vectorScore > 0 , "Unexpected value: " + vectorScore );
8082 });
8183 }
8284
@@ -106,20 +108,4 @@ void cosineSimilarity_InvalidVector() {
106108 assertTrue (actualMessage .contains ("arg2 is not of type vec:vector" ), "Unexpected message: " + actualMessage );
107109 }
108110
109- @ Test
110- @ Disabled ("See ticket MLE-15508" )
111- void vectorScore () {
112- PlanBuilder .ModifyPlan plan =
113- op .fromView ("vectors" , "persons" )
114- .bind (op .as ("vectorScore" , op .vec .vectorScore (op .xs .unsignedInt (1 ), op .xs .doubleVal (2 ))))
115- .select (op .col ("vectorScore" ))
116- .limit (5 );
117- List <RowRecord > rows = resultRows (plan );
118- assertEquals (2 , rows .size ());
119- rows .forEach (row -> {
120- double vectorScore = row .getDouble ("vectorScore" );
121- assertTrue (vectorScore > 0 , "Unexpected value: " + vectorScore );
122- });
123- }
124-
125111}
0 commit comments