Skip to content

Commit

Permalink
Remove KNN delete models
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Dec 27, 2023
1 parent f84bb56 commit d6d7f9b
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.*;
import org.opensearch.core.xcontent.DeprecationHandler;
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.knn.plugin.KNNPlugin;
import org.opensearch.search.SearchHit;
import org.opensearch.test.rest.OpenSearchRestTestCase;
Expand Down Expand Up @@ -209,7 +214,6 @@ private boolean isIndexCleanupRequired(final String index) {
}

private void wipeIndexContent(String indexName) throws IOException, ParseException {
deleteModels(getModelIds());
deleteAllDocs(indexName);
}

Expand All @@ -228,18 +232,6 @@ private List<String> getModelIds() throws IOException, ParseException {
return Arrays.stream(searchResponse.getHits().getHits()).map(SearchHit::getId).collect(Collectors.toList());
}

private void deleteModels(final List<String> modelIds) throws IOException {
for (final String testModelID : modelIds) {
final String restURIGetModel = String.join("/", KNNPlugin.KNN_BASE_URI, MODELS, testModelID);
final Response getModelResponse = adminClient().performRequest(new Request("GET", restURIGetModel));
if (RestStatus.OK != RestStatus.fromCode(getModelResponse.getStatusLine().getStatusCode())) {
continue;
}
final String restURIDeleteModel = String.join("/", KNNPlugin.KNN_BASE_URI, MODELS, testModelID);
adminClient().performRequest(new Request("DELETE", restURIDeleteModel));
}
}

private void deleteAllDocs(final String indexName) throws IOException {
final String restURIDeleteByQuery = String.join("/", indexName, "_delete_by_query");
final Request request = new Request("POST", restURIDeleteByQuery);
Expand Down

0 comments on commit d6d7f9b

Please sign in to comment.