Skip to content

Commit

Permalink
Add bwc test for model id
Browse files Browse the repository at this point in the history
Signed-off-by: Vijayan Balasubramanian <[email protected]>
  • Loading branch information
VijayanB committed Dec 7, 2024
1 parent 5ede283 commit 795651b
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,32 @@ public void testKNNModelDefault() throws Exception {
}
}

public void testNonKNNIndex_withModelId() throws Exception {
final String modelId = "random-model-id";
final String trainingIndex = "random-training-id";
if (isRunningAgainstOldCluster()) {
// Create a training index and randomly ingest data into it
createBasicKnnIndex(trainingIndex, TRAINING_FIELD, DIMENSIONS);
bulkIngestRandomVectors(trainingIndex, TRAINING_FIELD, NUM_DOCS, DIMENSIONS);

trainKNNModel(modelId, trainingIndex, TRAINING_FIELD, DIMENSIONS, MODEL_DESCRIPTION);
validateModelCreated(modelId);

createKnnIndex(testIndex, createKNNDefaultScriptScoreSettings(), createKnnIndexMapping(TEST_FIELD, modelId));
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, DOC_ID, NUM_DOCS);
} else {
QUERY_COUNT = NUM_DOCS;
DOC_ID = NUM_DOCS;
validateKNNScriptScoreSearch(testIndex, TEST_FIELD, DIMENSIONS, QUERY_COUNT, K, SpaceType.L2);
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, DOC_ID, NUM_DOCS);
QUERY_COUNT = QUERY_COUNT + NUM_DOCS;
validateKNNScriptScoreSearch(testIndex, TEST_FIELD, DIMENSIONS, QUERY_COUNT, K, SpaceType.L2);
deleteKNNIndex(testIndex);
deleteModel(modelId);
deleteIndex(trainingIndex);
}
}

// Delete Models and ".opensearch-knn-models" index to clear cluster metadata
@AfterClass
public static void wipeAllModels() throws IOException {
Expand Down

0 comments on commit 795651b

Please sign in to comment.