跳到正文
Skillpedia
数据库40k · #7367

qdrant-sliding-time-window

它能做什么

这个工具可以帮你管理随时间变化的数据,比如社交媒体帖子或新闻。它能确保只有最近的信息查询快速、容易找到,而较旧的数据可以访问得慢一些,或者直接删除。

适用场景

  • ✓我想在社交网络上只搜索最近的帖子。
  • ✓我希望旧新闻文章能被自动删除。
  • ✓我想整理系统日志,只保留最近几个月的记录。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/qdrant-scaling/scaling-data-volume/sliding-time-window/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/qdrant-scaling/scaling-data-volume/sliding-time-window/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“怎样才能让我的新闻搜索只显示过去一周的文章?”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会把数据按时间组织成“窗口”。它可以把旧数据移到较慢的存储中,也可以直接删除,从而确保最近的数据始终能快速访问。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Scaling with a Sliding Time Window

Use when only recent data needs fast search -- social media posts, news articles, support tickets, logs, job listings. Old data either becomes irrelevant or can tolerate slower access.

Three strategies: shard rotation (recommended), collection rotation (when per-period config differs), and filter-and-delete (simplest, for continuous cleanup).

Shard Rotation (Recommended)

Use when: data has natural time boundaries (daily, weekly, monthly). Preferred because queries span all time periods in one request without application-level fan-out. User-defined sharding

  1. Create a collection with user-defined sharding enabled
  2. Create one shard key per time period (e.g., 2025-01, 2025-02, ..., 2025-06)
  3. Ingest data into the current period's shard key
  4. When a new period starts, create a new shard key and redirect writes
  5. Delete the oldest shard key outside the retention window
  • Deleting a shard key reclaims all resources instantly (no fragmentation, no optimizer overhead)
  • Pre-create the next period's shard key before rotation to avoid write disruption
  • Use shard_key_selector at query time to search only specific periods for efficiency
  • Shard keys can be placed on specific nodes for hot/cold tiering

Collection Rotation (Alias Swap)

Use when: you need per-period collection configuration (e.g., different quantization or storage settings). Collection aliases

  1. Create one collection per time period, point a write alias at the newest
  2. Query across all active collections in parallel, merge results client-side
  3. When a new period starts, create the new collection and swap the write alias Switch collection
  4. Drop the oldest collection outside the window

Trade-off vs shard rotation: allows per-collection config differences, but requires application-level fan-out and more operational overhead.

Filter-and-Delete

Use when: data arrives continuously without clear time boundaries, or you want the simplest setup.

  1. Store a timestamp payload on every point, create a payload index on it Payload index
  2. Filter to the desired window at query time using range condition Range filter
  3. Periodically delete expired points using delete-by-filter Delete points
  • Run cleanup during off-peak hours in batches (10k-50k points) to avoid optimizer locks
  • Deletes are not free: tombstoned points degrade search until optimizer compacts segments
  • Does not reclaim disk instantly (compaction is asynchronous)

Hot/Cold Tiers

Use when: recent data needs fast in-RAM search, older data should remain searchable at lower performance.

  • Shard rotation: place current shard key on fast-storage nodes, move older shard keys to cheaper nodes via shard placement. All queries still go through a single collection.
  • Collection rotation: keep current collection in RAM (always_ram: true), move older collections to mmap/on-disk vectors. Quantization

What NOT to Do

  • Do not use filter-and-delete for high-volume time-series with millions of daily deletes (use rotation instead)
  • Do not forget to index the timestamp field (range filters without an index cause full scans)
  • Do not use collection rotation when shard rotation would suffice (unnecessary fan-out complexity)
  • Do not drop a shard key or collection before verifying its period is fully outside the retention window
  • Do not skip pre-creating the next period's shard key or collection (write failures during rotation are hard to recover)
常见问题

按时间组织数据的最佳方式是什么?

一般推荐使用分片轮换,因为它可以在所有时间段内快速搜索,同时不会增加额外的复杂度。

旧数据会怎样?

可以根据你的需求,将其移到较慢的存储中,或者彻底删除。

删除旧数据安全吗?

安全。工具提供了安全的旧数据删除方法,确保重要信息始终可以访问。

详情

作者的原始描述

Guides sliding time window scaling in Qdrant. Use when someone asks 'only recent data matters', 'how to expire old vectors', 'time-based data rotation', 'delete old data efficiently', 'social media feed search', 'news search', 'log search with retention', or 'how to keep only last N months of data'.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7367
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能