-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Introduce Template query #16818
Introduce Template query #16818
Conversation
❌ Gradle check result for ff1acc0: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
a159416
to
cf97416
Compare
updated |
❌ Gradle check result for cf97416: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
@mingshl I sadly cannot do it (not a maintainers on |
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Show resolved
Hide resolved
7291dc7
to
86a56e1
Compare
resolved changelog conflict. |
❌ Gradle check result for 86a56e1: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Outdated
Show resolved
Hide resolved
copying my comment from RFC GET my-keyword/_search
{
"query": {
"template": {
"term": {
"text": {
"value": "${ext.ml_inference.params.inference_result}", // this is the field generated from ml_inference search request processor
}
}
}
},
"ext": {
"ml_inference": {
"params": {
"text": "sunny"
}
}
},
"search_pipeline_ext": {
"<processor_id>": {
"params": {
"<param_name>": {
"value": <value>,
"type": <type>
},
// OR shorthand notion when type isn't provided explicitly
"<param_name> : <param_value>"
}
}
} |
I think the And theoretically the field in search extensions can be used for multiple processors. But I like the idea that in the ml_inference search extension, in the future, we can let user define the interface of variables,but probably the definition of search extension can be part of model interface. Because it's likely that different model use the same variable name but in different types. That can be a future enhancement. tagging @b4sjoo here as he is commiter for model interface in ml-commons. cc @ylwu-amzn |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16818 +/- ##
=========================================
Coverage 72.24% 72.25%
+ Complexity 65421 65403 -18
=========================================
Files 5306 5309 +3
Lines 304215 304300 +85
Branches 44118 44124 +6
=========================================
+ Hits 219788 219866 +78
+ Misses 66414 66377 -37
- Partials 18013 18057 +44 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some concerns here:
- breaking API
- synchronization issues
- I'm not sure your substitution is doing what you think it's doing (or it's doing something not expected by a casual reader)
server/src/main/java/org/opensearch/index/query/QueryRewriteContext.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/BaseQueryRewriteContext.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/TemplateQueryBuilder.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/BaseQueryRewriteContext.java
Show resolved
Hide resolved
server/src/main/java/org/opensearch/index/query/BaseQueryRewriteContext.java
Show resolved
Hide resolved
Make QueryRewriteContext an interface. Rename existing impl to BaseQueryRewriteContext. Create coordinator-level context called QueryCoordinatorContext. It can expose pipelined search request, including PipelineProcessingContext to rewrite methods. Signed-off-by: Mingshi Liu <[email protected]>
Introduce template query that holds the content of query which can contain placeholders and can be filled by the variables from PipelineProcessingContext produced by search processors. This allows query rewrite by the search processors. Signed-off-by: Mingshi Liu <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]> Add changelog Signed-off-by: Mingshi Liu <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]>
Signed-off-by: Mingshi Liu <[email protected]>
e5784fd
to
fcc44d5
Compare
❌ Gradle check result for fcc44d5: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❕ Gradle check result for fcc44d5: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for your patience!
Introduce template query that holds the content of query which can contain placeholders and can be filled by the variables from PipelineProcessingContext produced by search processors. This allows query rewrite by the search processors. --------- Signed-off-by: Mingshi Liu <[email protected]> Co-authored-by: Michael Froh <[email protected]> (cherry picked from commit 13ab4ec) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
This Pull Request introduces the following key enhancements:
1. New 'Template' Query Type:
Implements a new query type that holds an object of query content.
Supports placeholders within the query content.
Passes the query content to search request processing.
2. Query Rewrite Context Refactoring:
Query Rewrite Context now carries the pipelineContext variables after all search request processors processed.
Template queries resolve placeholders during query rewrites.
Inner queries are constructed dynamically based on resolved placeholders.
Related Issues
#16823
opensearch-project/ml-commons#3054
Check List
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.