Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Heng Qian <[email protected]>
  • Loading branch information
qianheng-aws committed Sep 29, 2024
1 parent 347c098 commit 0c142be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ protected <T> SearchRequest buildSearchRequest(Map<String, String> parameters) t
searchSourceBuilder.parseXContent(queryParser);
searchSourceBuilder.fetchSource(sourceFields, null);
searchSourceBuilder.size(docSize);
SearchRequest searchRequest = new SearchRequest().source(searchSourceBuilder).indices(index);
return searchRequest;
return new SearchRequest().source(searchSourceBuilder).indices(parameters.getOrDefault(INDEX_FIELD, index));
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/opensearch/agent/tools/LogPatternTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ protected String getQueryBody(String queryText) {

@Override
public <T> void run(Map<String, String> parameters, ActionListener<T> listener) {
// LogPatternTool needs to pass index and input as parameter in runtime. See [[${validate}]]
super.index = parameters.get(INDEX_FIELD);
int topNPattern = parameters.containsKey(TOP_N_PATTERN) ? getPositiveInteger(parameters, TOP_N_PATTERN) : this.topNPattern;
int sampleLogSize = parameters.containsKey(SAMPLE_LOG_SIZE) ? getPositiveInteger(parameters, SAMPLE_LOG_SIZE) : this.sampleLogSize;
Pattern pattern = parameters.containsKey(PATTERN) ? Pattern.compile(parameters.get(PATTERN)) : this.pattern;
Expand Down Expand Up @@ -214,6 +212,7 @@ public String getType() {

@Override
public boolean validate(Map<String, String> parameters) {
// LogPatternTool needs to pass index and input as parameter in runtime.
return super.validate(parameters) && parameters.containsKey(INDEX_FIELD) && !StringUtils.isBlank(parameters.get(INDEX_FIELD));
}

Expand Down

0 comments on commit 0c142be

Please sign in to comment.