Skip to content

Commit e29c011

Browse files
committed
add java doc for function
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 411dc73 commit e29c011

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/utils/AgentModelsSearcher.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ public AgentModelsSearcher(Map<String, Tool.Factory> toolFactories) {
2424
}
2525
}
2626

27-
public SearchRequest constructQueryRequestToSearchModelId(String candidateModelId) {
27+
/**
28+
* Construct a should query to search all agent which containing candidate model Id
29+
30+
@param candidateModelId the candidate model Id
31+
@return a should search request towards agent index.
32+
*/
33+
public SearchRequest constructQueryRequestToSearchModelIdInsideAgent(String candidateModelId) {
2834
SearchRequest searchRequest = new SearchRequest(ML_AGENT_INDEX);
2935
BoolQueryBuilder shouldQuery = QueryBuilders.boolQuery();
3036
for (String keyField : relatedModelIdSet) {

plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public void onFailure(Exception e) {
264264

265265
private void checkAgentBeforeDeleteModel(String modelId, ActionListener<Boolean> actionListener) {
266266
// check whether agent are using them
267-
SearchRequest searchAgentRequest = agentModelsSearcher.constructQueryRequestToSearchModelId(modelId);
267+
SearchRequest searchAgentRequest = agentModelsSearcher.constructQueryRequestToSearchModelIdInsideAgent(modelId);
268268
client.search(searchAgentRequest, ActionListener.wrap(searchResponse -> {
269269
SearchHit[] searchHits = searchResponse.getHits().getHits();
270270
if (searchHits.length == 0) {

plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ private void prepare() throws IOException {
812812
}).when(client).execute(eq(GetSearchPipelineAction.INSTANCE), any(), any());
813813
configDataMap = Map
814814
.of("single_model_id", "test_id", "list_model_id", List.of("test_id"), "test_map_id", Map.of("model_id", "test_id"));
815-
doAnswer(invocation -> new SearchRequest()).when(agentModelsSearcher).constructQueryRequestToSearchModelId(any());
815+
doAnswer(invocation -> new SearchRequest()).when(agentModelsSearcher).constructQueryRequestToSearchModelIdInsideAgent(any());
816816

817817
GetResponse getResponse = prepareMLModel(MLModelState.REGISTERED, null, false);
818818
doAnswer(invocation -> {

0 commit comments

Comments
 (0)