Skip to content

feat(retrieval): add time filters to find and search#1429

Open
0xble wants to merge 4 commits intovolcengine:mainfrom
0xble:upstream-time-filters-pr-20260413
Open

feat(retrieval): add time filters to find and search#1429
0xble wants to merge 4 commits intovolcengine:mainfrom
0xble:upstream-time-filters-pr-20260413

Conversation

@0xble
Copy link
Copy Markdown
Contributor

@0xble 0xble commented Apr 14, 2026

Description

This PR adds native time filtering to retrieval. find and search can now
filter semantic results by created_at or updated_at through the Python SDK,
HTTP API, and Rust CLI.

OpenViking already stores these timestamps on indexed context records, but
retrieval could not query against them directly. This patch adds since,
until, and time_field to the retrieval surface, adds CLI support for
--since, --until, --time-field, --last, and --on, and preserves
created_at on rewrites so the filters stay meaningful after reindex and
update flows.

Related Issue

None.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Added since, until, and time_field request fields to retrieval in the Python SDK, local client, HTTP server, and Rust HTTP client.
  • Added a shared merge_time_filter() helper that compiles relative or absolute bounds into the existing metadata filter tree.
  • Added CLI support for ov find and ov search with --since, --until, --time-field, --last, and --on.
  • Preserved created_at for leaf records on rewrite and reindex, and derived timestamps from canonical file metadata so created_at and updated_at keep stable semantics.
  • Added server, unit, and CLI tests, and updated the English and Chinese retrieval docs.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Validation run locally on macOS:

  • cargo test -p ov_cli --bin ov -- tests::resolve_time_flags_prefers_last_for_since tests::resolve_time_flags_expands_on_to_both_bounds tests::retrieval_time_field_maps_to_api_values
  • uv run --with pytest-asyncio pytest tests/unit/test_search_filters.py tests/server/test_sdk_time_filters.py -q could not complete locally because .venv hit a macOS code-signature mismatch while importing pydantic_core (mapping process and mapped file have different Team IDs). That looks environment-specific rather than a failure in the retrieval patch itself.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Not applicable.

Additional Notes

I kept this as an additive upstream change rather than the hard-cut CLI
migration used in my fork. If you would prefer an even smaller initial PR, I
can split the write-path timestamp preservation from the retrieval API and CLI
surface.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 90
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Missing License Header

New file in openviking/ directory is missing the required AGPL-3.0 license header.

from __future__ import annotations

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@MaojiaSheng
Copy link
Copy Markdown
Collaborator

I suggest just keep "--since, --until", and don't make it too complecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants