Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.19] Fix model search for deleting connector #3673

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import static org.opensearch.ml.common.CommonValue.ML_CONNECTOR_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
import static org.opensearch.ml.common.CommonValue.TENANT_ID_FIELD;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -137,9 +136,6 @@ private void checkForModelsUsingConnector(String connectorId, String tenantId, A
private SearchDataObjectRequest buildModelSearchRequest(String connectorId, String tenantId) {
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.matchQuery(MLModel.CONNECTOR_ID_FIELD, connectorId));
if (mlFeatureEnabledSetting.isMultiTenancyEnabled()) {
sourceBuilder.query(QueryBuilders.matchQuery(TENANT_ID_FIELD, tenantId));
}

return SearchDataObjectRequest.builder().indices(ML_MODEL_INDEX).tenantId(tenantId).searchSourceBuilder(sourceBuilder).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.TermQueryBuilder;
import org.opensearch.ml.common.AccessMode;
import org.opensearch.ml.common.CommonValue;
import org.opensearch.ml.common.MLModelGroup;
import org.opensearch.ml.common.exception.MLResourceNotFoundException;
import org.opensearch.ml.common.transport.model_group.MLRegisterModelGroupInput;
Expand Down Expand Up @@ -224,17 +223,13 @@ public void validateUniqueModelGroupName(String name, String tenantId, ActionLis
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
BoolQueryBuilder query = new BoolQueryBuilder();
query.filter(new TermQueryBuilder(MLRegisterModelGroupInput.NAME_FIELD + ".keyword", name));
if (tenantId != null) {
query.filter(new TermQueryBuilder(CommonValue.TENANT_ID_FIELD, tenantId));
}

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(query);
SearchRequest searchRequest = new SearchRequest(ML_MODEL_GROUP_INDEX).source(searchSourceBuilder);

SearchDataObjectRequest searchDataObjectRequest = SearchDataObjectRequest
.builder()
.indices(searchRequest.indices())
.tenantId(tenantId)
.searchSourceBuilder(searchRequest.source())
.tenantId(tenantId)
.build();
Expand Down
Loading