Skip to content

Conversation

rithin-pullela-aws
Copy link
Contributor

Description

Please refer to #4018 for detailed description of the issue.

Problem:

When using search templates with generative_qa_parameters, the RAG answer is missing from the response. This happens because:

  1. Direct searches call GenerativeSearchResponse.toXContent() → includes ext block with RAG answer
  2. Template searches call GenerativeSearchResponse.innerToXContent() → missing ext block

The core SearchTemplateResponse calls response.innerToXContent() instead of response.toXContent() to preserve the status field, but GenerativeSearchResponse only adds the ext block in toXContent().

Solution:

Override innerToXContent() in GenerativeSearchResponse to include the ext block, ensuring both direct and template searches return RAG responses.

Alternative Considered:
Modify core SearchTemplateResponse to use toXContent(), but this would lose the status field that templates require.

Related Issues

Resolves #4018

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 14, 2025 23:05 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 14, 2025 23:05 — with GitHub Actions Error
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 14, 2025 23:05 — with GitHub Actions Failure
@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 14, 2025 23:05 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws requested a deployment to ml-commons-cicd-env-require-approval August 15, 2025 00:08 — with GitHub Actions Waiting
@rithin-pullela-aws rithin-pullela-aws requested a deployment to ml-commons-cicd-env-require-approval August 15, 2025 00:08 — with GitHub Actions Waiting
@mingshl
Copy link
Collaborator

mingshl commented Aug 15, 2025

@rithin-pullela-aws nice way to compatible with search templates!!! can you add unit tests to verify your fix?

also @junqiu-lei can you help review this fix?

@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 15, 2025 18:31 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 15, 2025 18:31 — with GitHub Actions Failure
@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 15, 2025 18:31 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 15, 2025 18:31 — with GitHub Actions Failure
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.80%. Comparing base (f75ae1a) to head (321c32c).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4118      +/-   ##
============================================
- Coverage     81.81%   81.80%   -0.01%     
- Complexity     8847     8848       +1     
============================================
  Files           761      761              
  Lines         38099    38103       +4     
  Branches       4250     4250              
============================================
+ Hits          31170    31172       +2     
- Misses         5109     5110       +1     
- Partials       1820     1821       +1     
Flag Coverage Δ
ml-commons 81.80% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 15, 2025 23:21 — with GitHub Actions Failure
@junqiu-lei
Copy link
Member

@rithin-pullela-aws nice way to compatible with search templates!!! can you add unit tests to verify your fix?

also @junqiu-lei can you help review this fix?

Agree, please also add integ test for template search with generative_qa_parameters.

@mingshl
Copy link
Collaborator

mingshl commented Aug 18, 2025

@rithin-pullela-aws if we are taking this approach, we need all custom search responses with search extensions to have the same fix.

can you add the fix for this search response class too?

@rithin-pullela-aws
Copy link
Contributor Author

the fix for this search response class to

@rithin-pullela-aws if we are taking this approach, we need all custom search responses with search extensions to have the same fix.

can you add the fix for this search response class too?

@mingshl, already included in this PR :)

@mingshl
Copy link
Collaborator

mingshl commented Aug 25, 2025

the fix LGTM, is it difficult to add in UT and IT to verify the fix? you need create a search template and create a ml inference processor and rag processor and then verify in the search response has extension. Maybe you can add the new IT in here https://github.com/opensearch-project/ml-commons/blob/main/plugin/src/test/java/org/opensearch/ml/rest/RestMLInferenceSearchResponseProcessorIT.java

@rithin-pullela-aws
Copy link
Contributor Author

the fix LGTM, is it difficult to add in UT and IT to verify the fix? you need create a search template and create a ml inference processor and rag processor and then verify in the search response has extension. Maybe you can add the new IT in here https://github.com/opensearch-project/ml-commons/blob/main/plugin/src/test/java/org/opensearch/ml/rest/RestMLInferenceSearchResponseProcessorIT.java

@mingshl, was busy with other tasks. I will add an IT as you suggested

@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 25, 2025 17:33 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 25, 2025 17:33 — with GitHub Actions Failure
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 25, 2025 17:33 — with GitHub Actions Error
@rithin-pullela-aws rithin-pullela-aws temporarily deployed to ml-commons-cicd-env-require-approval August 25, 2025 17:33 — with GitHub Actions Inactive
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 25, 2025 18:43 — with GitHub Actions Failure
@rithin-pullela-aws rithin-pullela-aws had a problem deploying to ml-commons-cicd-env-require-approval August 25, 2025 18:43 — with GitHub Actions Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] SearchTemplate: Missing RAG response from generative_qa_parameters
4 participants