8
8
import com .marklogic .client .test .Common ;
9
9
import com .marklogic .client .test .junit5 .RequiresML12 ;
10
10
import com .marklogic .client .type .PlanSearchOptions ;
11
+ import org .junit .jupiter .api .BeforeEach ;
11
12
import org .junit .jupiter .api .Disabled ;
12
13
import org .junit .jupiter .api .Test ;
13
14
import org .junit .jupiter .api .extension .ExtendWith ;
15
+ import org .junit .jupiter .params .ParameterizedTest ;
16
+ import org .junit .jupiter .params .provider .ValueSource ;
14
17
15
18
import java .util .List ;
16
19
17
20
import static org .junit .jupiter .api .Assertions .assertEquals ;
18
21
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
+ */
19
26
@ ExtendWith (RequiresML12 .class )
20
27
class FromSearchDocsWithOptionsTest extends AbstractOpticUpdateTest {
21
28
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 () {
26
31
rowManager .withUpdate (false );
32
+ }
33
+
34
+ @ ValueSource (strings = {"bm25" , "zero" , "random" , "simple" , "logtfidf" , "logtf" })
35
+ @ ParameterizedTest
36
+ void scoreMethod (String scoreMethod ) {
27
37
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
+
30
44
List <RowRecord > rows = resultRows (op .fromSearchDocs (op .cts .wordQuery ("saxophone" ), null , options ));
31
45
assertEquals (2 , rows .size ());
32
46
}
@@ -47,10 +61,9 @@ void bm25ViaSearchOptions() {
47
61
48
62
@ Test
49
63
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 );
54
67
List <RowRecord > rows = resultRows (op .fromSearchDocs (op .cts .wordQuery ("saxophone" ), null , options ));
55
68
assertEquals (2 , rows .size ());
56
69
}
0 commit comments