44
44
45
45
public class SemanticTextIndexVersionIT extends ESIntegTestCase {
46
46
private static final IndexVersion SEMANTIC_TEXT_INTRODUCED_VERSION = IndexVersion .fromId (8512000 );
47
-
47
+ private static final double PERCENTAGE_TO_TEST = 0.5 ;
48
48
private Set <IndexVersion > availableVersions ;
49
- private static final int MIN_NUMBER_OF_TESTS_TO_RUN = 10 ;
50
49
51
50
@ Before
52
51
public void setup () throws Exception {
53
52
Utils .storeSparseModel (client ());
54
53
availableVersions = IndexVersionUtils .allReleasedVersions ().stream ()
55
54
.filter (indexVersion -> indexVersion .after (SEMANTIC_TEXT_INTRODUCED_VERSION ))
56
55
.collect (Collectors .toSet ());
57
-
58
- logger .info ("Available versions for testing: {}" , availableVersions );
59
56
}
60
57
61
58
@ Override
@@ -86,7 +83,7 @@ private Settings getIndexSettingsWithVersion(IndexVersion version) {
86
83
* @return Map of created indices with their versions
87
84
*/
88
85
protected Map <String , IndexVersion > createRandomVersionIndices () throws IOException {
89
- int versionsCount = Math .min ( MIN_NUMBER_OF_TESTS_TO_RUN , availableVersions .size ());
86
+ int versionsCount = ( int ) Math .ceil ( availableVersions .size () * PERCENTAGE_TO_TEST );
90
87
List <IndexVersion > selectedVersions = randomSubsetOf (versionsCount , availableVersions );
91
88
Map <String , IndexVersion > result = new HashMap <>();
92
89
@@ -100,11 +97,14 @@ protected Map<String, IndexVersion> createRandomVersionIndices() throws IOExcept
100
97
return result ;
101
98
}
102
99
100
+ /**
101
+ * This test creates an index, ingests data, and performs searches (including highlighting when applicable)
102
+ * for a selected subset of index versions.
103
+ */
103
104
public void testSemanticText () throws Exception {
104
105
Map <String , IndexVersion > indices = createRandomVersionIndices ();
105
106
for (String indexName : indices .keySet ()) {
106
107
IndexVersion version = indices .get (indexName );
107
- logger .info ("Testing index [{}] with version [{}] [{}]" , indexName , version , version .toReleaseVersion ());
108
108
109
109
// Test index creation
110
110
assertTrue ("Index " + indexName + " should exist" , indexExists (indexName ));
@@ -155,14 +155,14 @@ public void testSemanticText() throws Exception {
155
155
assertHitCount (response , 1L );
156
156
});
157
157
158
- //Semantic Search with highlighter only available from 8.18 and 9.0
159
158
Settings settings = client ().admin ()
160
159
.indices ()
161
160
.prepareGetSettings (TimeValue .THIRTY_SECONDS , indexName )
162
161
.get ()
163
162
.getIndexToSettings ()
164
163
.get (indexName );
165
164
165
+ //Semantic Search with highlighter only available from 8.18 and 9.0
166
166
if (InferenceMetadataFieldsMapper .isEnabled (settings )) {
167
167
SearchSourceBuilder sourceHighlighterBuilder = new SearchSourceBuilder ()
168
168
.query (new SemanticQueryBuilder ("semantic_field" , "inference" ))
0 commit comments