|
33 | 33 | public class LinearRetrieverBuilderParsingTests extends AbstractXContentTestCase<LinearRetrieverBuilder> { |
34 | 34 | private static List<NamedXContentRegistry.Entry> xContentRegistryEntries; |
35 | 35 |
|
| 36 | + private static final ScoreNormalizer[] SCORE_NORMALIZERS = new ScoreNormalizer[] { |
| 37 | + null, |
| 38 | + MinMaxScoreNormalizer.INSTANCE, |
| 39 | + L2ScoreNormalizer.INSTANCE, |
| 40 | + IdentityScoreNormalizer.INSTANCE }; |
| 41 | + |
36 | 42 | @BeforeClass |
37 | 43 | public static void init() { |
38 | 44 | xContentRegistryEntries = new SearchModule(Settings.EMPTY, emptyList()).getNamedXContents(); |
@@ -69,9 +75,7 @@ protected LinearRetrieverBuilder createTestInstance() { |
69 | 75 | new CompoundRetrieverBuilder.RetrieverSource(TestRetrieverBuilder.createRandomTestRetrieverBuilder(), null) |
70 | 76 | ); |
71 | 77 | weights[i] = randomFloat(); |
72 | | - normalizers[i] = randomFrom( |
73 | | - new ScoreNormalizer[] { null, MinMaxScoreNormalizer.INSTANCE, L2ScoreNormalizer.INSTANCE, IdentityScoreNormalizer.INSTANCE } |
74 | | - ); |
| 78 | + normalizers[i] = randomFrom(SCORE_NORMALIZERS); |
75 | 79 | } |
76 | 80 |
|
77 | 81 | return new LinearRetrieverBuilder(innerRetrievers, fields, query, normalizer, rankWindowSize, weights, normalizers); |
@@ -112,12 +116,7 @@ protected NamedXContentRegistry xContentRegistry() { |
112 | 116 | } |
113 | 117 |
|
114 | 118 | private static ScoreNormalizer randomScoreNormalizer() { |
115 | | - int random = randomInt(2); |
116 | | - return switch (random) { |
117 | | - case 0 -> MinMaxScoreNormalizer.INSTANCE; |
118 | | - case 1 -> L2ScoreNormalizer.INSTANCE; |
119 | | - default -> IdentityScoreNormalizer.INSTANCE; |
120 | | - }; |
| 119 | + return randomFrom(SCORE_NORMALIZERS); |
121 | 120 | } |
122 | 121 |
|
123 | 122 | public void testTopLevelNormalizer() throws IOException { |
|
0 commit comments