Skip to content

Feature/add metadata filter to use case builder retrieve kb#1427

Open
takke1986 wants to merge 4 commits intoaws-samples:mainfrom
takke1986:feature/add-metadata-filter-to-use-case-builder-retrieve-kb
Open

Feature/add metadata filter to use case builder retrieve kb#1427
takke1986 wants to merge 4 commits intoaws-samples:mainfrom
takke1986:feature/add-metadata-filter-to-use-case-builder-retrieve-kb

Conversation

@takke1986
Copy link
Contributor

@takke1986 takke1986 commented Jan 30, 2026

Description of Changes

Please explain the changes in detail.
If there is any impact on existing users (compatibility, degradation, breaking changes, etc.), be sure to include it in the explanation.

Summary

Add the ability to specify metadata filters in the {{retrieveKnowledgeBase}} tag using a simple key=value format.

Features

  • Simple filter syntax: {{retrieveKnowledgeBase:query:category=AWS,year>2020}}
  • Supported operators:
    • = (equals), != (notEquals)
    • >, <, >=, <= (numeric comparisons)
    • ~= (stringContains), ^= (startsWith)
    • @ (in), !@ (notIn) with | as value separator

Changes

  • Extended Lambda function to parse filter string and build RetrievalFilter objects
  • Filters are automatically combined with existing hiddenStaticExplicitFilters and dynamicFilters using AND logic
  • Added Lambda environment variables for dynamic filter token verification
  • Updated help documentation in all supported languages (ja, en, zh, th, vi, ko)
  • Backward compatible with existing {{retrieveKnowledgeBase}} usage without filters

Example Usage

{{retrieveKnowledgeBase:Question:category=AWS,year>2020,tag@AWS|Bedrock|SageMaker}}

Checklist

  • Modified relevant documentation
  • Verified operation in local environment
  • Executed npm run cdk:test and if there are snapshot differences, execute npm run cdk:test:update-snapshot to update snapshots

Related Issues

#1416

Please list related issues as much as possible.

takashi added 4 commits January 30, 2026 22:20
…eBase tag

Add the ability to specify metadata filters in the {{retrieveKnowledgeBase}} tag
using a simple key=value format (e.g., {{retrieveKnowledgeBase:query:category=AWS}}).

Supported operators:
- = (equals), != (notEquals)
- >, <, >=, <= (numeric comparisons)
- ~= (stringContains), ^= (startsWith)
- @ (in), !@ (notIn) with | as value separator

The filters are automatically combined with existing hiddenStaticExplicitFilters
and dynamicFilters using AND logic. Backward compatible with existing usage.
Add USER_POOL_ID, USER_POOL_CLIENT_ID, USER_POOL_PROXY_ENDPOINT to
retrieveKnowledgeBase Lambda for dynamic filter token verification
- Add filter syntax documentation to retrieveKnowledgeBase description
- Add filter example (RAG with Filter) to help section
- Support all languages: ja, en, zh, th, vi, ko
- Korean: Add complete help section as it was missing
Update test snapshots to include USER_POOL_ID, USER_POOL_CLIENT_ID,
and USER_POOL_PROXY_ENDPOINT in retrieveKnowledgeBase Lambda function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant