88import com .marklogic .client .test .Common ;
99import com .marklogic .client .test .junit5 .RequiresML12 ;
1010import com .marklogic .client .type .PlanSearchOptions ;
11+ import org .junit .jupiter .api .BeforeEach ;
1112import org .junit .jupiter .api .Disabled ;
1213import org .junit .jupiter .api .Test ;
1314import org .junit .jupiter .api .extension .ExtendWith ;
15+ import org .junit .jupiter .params .ParameterizedTest ;
16+ import org .junit .jupiter .params .provider .ValueSource ;
1417
1518import java .util .List ;
1619
1720import static org .junit .jupiter .api .Assertions .assertEquals ;
1821
22+ /**
23+ * These tests do not attempt to verify that a score method produces a particular ordering. Instead, they verify
24+ * that each score method option is accepted by the server.
25+ */
1926@ ExtendWith (RequiresML12 .class )
2027class FromSearchDocsWithOptionsTest extends AbstractOpticUpdateTest {
2128
22- @ Test
23- void bm25 () {
24- // Note that this does not actually test that the scoring is correct.
25- // It only tests that including the BM25 scoring option and a valid bm25LengthWeight do not cause any problems.
29+ @ BeforeEach
30+ void setupTest () {
2631 rowManager .withUpdate (false );
32+ }
33+
34+ @ ValueSource (strings = {"bm25" , "zero" , "random" , "simple" , "logtfidf" , "logtf" })
35+ @ ParameterizedTest
36+ void scoreMethod (String scoreMethod ) {
2737 PlanSearchOptions options = op .searchOptions ()
28- .withScoreMethod (PlanSearchOptions .ScoreMethod .BM25 )
29- .withBm25LengthWeight (0.25 );
38+ .withScoreMethod (PlanSearchOptions .ScoreMethod .valueOf (scoreMethod .toUpperCase ()));
39+
40+ if ("bm25" .equalsIgnoreCase (scoreMethod )) {
41+ options .withBm25LengthWeight (0.25 );
42+ }
43+
3044 List <RowRecord > rows = resultRows (op .fromSearchDocs (op .cts .wordQuery ("saxophone" ), null , options ));
3145 assertEquals (2 , rows .size ());
3246 }
@@ -47,10 +61,9 @@ void bm25ViaSearchOptions() {
4761
4862 @ Test
4963 void qualityWeight () {
50- // Note that this does not actually test that the scoring is correct.
51- // It only tests that including a valid qualityWeight value does not cause any problems.
52- rowManager .withUpdate (false );
53- PlanSearchOptions options = op .searchOptions ().withScoreMethod (PlanSearchOptions .ScoreMethod .LOGTFIDF ).withQualityWeight (0.75F );
64+ PlanSearchOptions options = op .searchOptions ()
65+ .withScoreMethod (PlanSearchOptions .ScoreMethod .LOGTFIDF )
66+ .withQualityWeight (0.75F );
5467 List <RowRecord > rows = resultRows (op .fromSearchDocs (op .cts .wordQuery ("saxophone" ), null , options ));
5568 assertEquals (2 , rows .size ());
5669 }
0 commit comments