Skip to content

Commit 4fc335b

Browse files
Fix model search for deleting connector (#3671) (#3673)
Signed-off-by: Daniel Widdis <[email protected]> (cherry picked from commit a381e10) Co-authored-by: Daniel Widdis <[email protected]>
1 parent 8783f3c commit 4fc335b

File tree

2 files changed

+0
-9
lines changed

2 files changed

+0
-9
lines changed

plugin/src/main/java/org/opensearch/ml/action/connector/DeleteConnectorTransportAction.java

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import static org.opensearch.ml.common.CommonValue.ML_CONNECTOR_INDEX;
99
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
10-
import static org.opensearch.ml.common.CommonValue.TENANT_ID_FIELD;
1110

1211
import java.io.IOException;
1312
import java.util.ArrayList;
@@ -137,9 +136,6 @@ private void checkForModelsUsingConnector(String connectorId, String tenantId, A
137136
private SearchDataObjectRequest buildModelSearchRequest(String connectorId, String tenantId) {
138137
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
139138
sourceBuilder.query(QueryBuilders.matchQuery(MLModel.CONNECTOR_ID_FIELD, connectorId));
140-
if (mlFeatureEnabledSetting.isMultiTenancyEnabled()) {
141-
sourceBuilder.query(QueryBuilders.matchQuery(TENANT_ID_FIELD, tenantId));
142-
}
143139

144140
return SearchDataObjectRequest.builder().indices(ML_MODEL_INDEX).tenantId(tenantId).searchSourceBuilder(sourceBuilder).build();
145141
}

plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.opensearch.index.query.BoolQueryBuilder;
3636
import org.opensearch.index.query.TermQueryBuilder;
3737
import org.opensearch.ml.common.AccessMode;
38-
import org.opensearch.ml.common.CommonValue;
3938
import org.opensearch.ml.common.MLModelGroup;
4039
import org.opensearch.ml.common.exception.MLResourceNotFoundException;
4140
import org.opensearch.ml.common.transport.model_group.MLRegisterModelGroupInput;
@@ -224,17 +223,13 @@ public void validateUniqueModelGroupName(String name, String tenantId, ActionLis
224223
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
225224
BoolQueryBuilder query = new BoolQueryBuilder();
226225
query.filter(new TermQueryBuilder(MLRegisterModelGroupInput.NAME_FIELD + ".keyword", name));
227-
if (tenantId != null) {
228-
query.filter(new TermQueryBuilder(CommonValue.TENANT_ID_FIELD, tenantId));
229-
}
230226

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

234230
SearchDataObjectRequest searchDataObjectRequest = SearchDataObjectRequest
235231
.builder()
236232
.indices(searchRequest.indices())
237-
.tenantId(tenantId)
238233
.searchSourceBuilder(searchRequest.source())
239234
.tenantId(tenantId)
240235
.build();

0 commit comments

Comments
 (0)