Skip to content

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

Merged
MaojiaSheng merged 8 commits intovolcengine:mainfrom
0xble:upstream-time-filters-pr-20260413
Apr 15, 2026
Merged

feat(retrieval): add time filters to find and search#1429
MaojiaSheng merged 8 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
and HTTP API, while the Rust CLI keeps a smaller --after / --before
surface.

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, keeps the CLI mapping to
--after / --before only, 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.
  • Simplified the CLI down to ov find/search --after ... --before ..., which map to API since / until without the extra shortcut flags.
  • 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
  • uv run --isolated --with pytest --with pytest-asyncio python -m pytest tests/unit/test_search_filters.py tests/server/test_sdk_time_filters.py tests/server/test_api_search.py -q still fails on this host while importing pydantic_core with macOS code-signature validation (mapping process and mapped file (non-platform) have different Team IDs). That reproduces the earlier local environment issue even outside the repo .venv.

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 trimmed the CLI down after review feedback so the user-facing surface is just
--after / --before. If you would prefer an even smaller initial PR, I can
still 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

@0xble
Copy link
Copy Markdown
Contributor Author

0xble commented Apr 15, 2026

Changed the CLI to --after / --before only because I think that is even simpler. The docs and local ov_cli test pass are updated to match.

0xble added 2 commits April 14, 2026 23:06
# Conflicts:
#	openviking/server/routers/search.py
#	openviking/utils/embedding_utils.py
@0xble
Copy link
Copy Markdown
Contributor Author

0xble commented Apr 15, 2026

Did one simplify pass on the current branch head. This only narrows the CLI helper to take the already-converted after / before string slices instead of borrowed Option<String> values; behavior stays the same.

@0xble
Copy link
Copy Markdown
Contributor Author

0xble commented Apr 15, 2026

Added one short comment in the time-filter merge helper and updated the checklist so the PR body matches the current branch state. Behavior is unchanged.

@MaojiaSheng MaojiaSheng self-requested a review April 15, 2026 03:51
@MaojiaSheng MaojiaSheng self-assigned this Apr 15, 2026
@MaojiaSheng MaojiaSheng merged commit 0005364 into volcengine:main Apr 15, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants