Adding query planning tool search template validation and integration tests#4177
Adding query planning tool search template validation and integration tests#4177mingshl merged 6 commits intoopensearch-project:mainfrom joshpalis:integ
Conversation
| private static final String DEFAULT_SYSTEM_PROMPT = | ||
| "You are an OpenSearch Query DSL generation assistant, translating natural language questions to OpenSeach DSL Queries"; | ||
|
|
||
| private static final Logger logger = LogManager.getLogger(QueryPlanningTool.class); |
There was a problem hiding this comment.
can you use the same logger like the rest of the repo?
There was a problem hiding this comment.
Ill remove the logger, left over from debugging
| private void validateTemplateFields(Map<String, String> template) { | ||
| // Validate templateId | ||
| String templateId = template.get(TEMPLATE_ID_FIELD); | ||
| if (templateId == null || templateId.trim().isEmpty()) { |
There was a problem hiding this comment.
is it the same validation of search template or similar to opensearch core?
There was a problem hiding this comment.
This validation is specifically for the query planning tool configuration, it ensures that each entry of the search_templates field contains both template_id and template_description
|
|
||
| // Validate templateDescription | ||
| String templateDescription = template.get(TEMPLATE_DESCRIPTION_FIELD); | ||
| if (templateDescription == null || templateDescription.trim().isEmpty()) { |
There was a problem hiding this comment.
nit: can we use .isBlank() instead of .trim().isEmpty()
isBalnk() is more efficient
plugin/build.gradle
Outdated
| zipArchive("org.opensearch.plugin:opensearch-job-scheduler:${opensearch_build}") | ||
| zipArchive("org.opensearch.plugin:opensearch-knn:${opensearch_build}") | ||
| zipArchive("org.opensearch.plugin:neural-search:${opensearch_build}") |
There was a problem hiding this comment.
Can we remove these?
There was a problem hiding this comment.
ah yeah, left over from debugging, Ill remove in the next commit
plugin/build.gradle
Outdated
| plugin(provider(new Callable<RegularFile>(){ | ||
| @Override | ||
| RegularFile call() throws Exception { | ||
| return new RegularFile() { | ||
| @Override | ||
| File getAsFile() { | ||
| return configurations.zipArchive.asFileTree.matching{include "**/opensearch-knn-${opensearch_build}.zip"}.getSingleFile() | ||
| } | ||
| } | ||
| } | ||
| })) | ||
| plugin(provider(new Callable<RegularFile>(){ | ||
| @Override | ||
| RegularFile call() throws Exception { | ||
| return new RegularFile() { | ||
| @Override | ||
| File getAsFile() { | ||
| return configurations.zipArchive.asFileTree.matching{include "**/neural-search-${opensearch_build}.zip"}.getSingleFile() | ||
| } | ||
| } | ||
| } | ||
| })) |
There was a problem hiding this comment.
Can we remove these too
There was a problem hiding this comment.
Why do we need to have these plugins in the integTest setup?
| GetStoredScriptRequest getStoredScriptRequest = new GetStoredScriptRequest(templateId); | ||
| client.admin().cluster().getStoredScript(getStoredScriptRequest, ActionListener.wrap(getStoredScriptResponse -> { | ||
| parameters.put(TEMPLATE_FIELD, gson.toJson(getStoredScriptResponse.getSource().getSource())); | ||
| if (getStoredScriptResponse.getSource() == null) { |
There was a problem hiding this comment.
We can just check and replace TEMPLATE_FIELD
if (getStoredScriptResponse.getSource() != null) {
parameters.put(TEMPLATE_FIELD, gson.toJson(getStoredScriptResponse.getSource().getSource()));
}and add
parameters.put(TEMPLATE_FIELD, DEFAULT_SEARCH_TEMPLATE);at the top of both the conditions
|
you need to meet the codecov for your if else condition |
Signed-off-by: Joshua Palis <jpalis@amazon.com>
|
The CI on linux 21 passed. approved |
Description
search_templatesto require bothtemplate_idandtemplate_descriptionAdditionally includes changes from #4176, will rebase once its merged
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.