algolia-search
它能做什么
这个技能为你的 AI 智能体提供使用 Algolia 构建快速搜索的模式。适合为网站或应用添加搜索功能的开发者。
适用场景
- ✓当你想为 React 或 Next.js 网站添加即时搜索时。
- ✓当你需要让 Algolia 搜索索引与数据保持同步时。
- ✓当搜索结果不相关,你想要调整它们时。
技能链接
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/algolia-search/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的 Next.js 商店添加 Algolia 即时搜索,并提供按品牌和价格筛选的功能。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能为智能体提供关于 InstantSearch hooks、服务端渲染和索引策略的指导。智能体会把这些应用到你的项目中,并留意常见的陷阱。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Algolia Search Integration
Patterns
React InstantSearch with Hooks
Modern React InstantSearch setup using hooks for type-ahead search.
Uses react-instantsearch-hooks-web package with algoliasearch client. Widgets are components that can be customized with classnames.
Key hooks:
- useSearchBox: Search input handling
- useHits: Access search results
- useRefinementList: Facet filtering
- usePagination: Result pagination
- useInstantSearch: Full state access
Next.js Server-Side Rendering
SSR integration for Next.js with react-instantsearch-nextjs package.
Use <InstantSearchNext> instead of <InstantSearch> for SSR. Supports both Pages Router and App Router (experimental).
Key considerations:
- Set dynamic = 'force-dynamic' for fresh results
- Handle URL synchronization with routing prop
- Use getServerState for initial state
Data Synchronization and Indexing
Indexing strategies for keeping Algolia in sync with your data.
Three main approaches:
- Full Reindexing - Replace entire index (expensive)
- Full Record Updates - Replace individual records
- Partial Updates - Update specific attributes only
Best practices:
- Batch records (ideal: 10MB, 1K-10K records per batch)
- Use incremental updates when possible
- partialUpdateObjects for attribute-only changes
- Avoid deleteBy (computationally expensive)
⚠️ Sharp Edges
| Issue | Severity | Solution |
|---|---|---|
| Issue | critical | See docs |
| Issue | high | See docs |
| Issue | medium | See docs |
| Issue | medium | See docs |
| Issue | medium | See docs |
| Issue | medium | See docs |
| Issue | medium | See docs |
| Issue | medium | See docs |
常见问题
它使用哪些包?
它使用 react-instantsearch 包,并配合 algoliasearch 客户端用于 React 和 Next.js。
我应该如何更新索引?
在可能的情况下,它推荐增量或部分更新,并把记录按约 1000 到 10000 条一组进行批量处理。
为什么要避免 deleteBy?
该技能说明 deleteBy 计算开销很大,因此应尽量避免使用。
详情
作者的原始描述
Expert patterns for Algolia search implementation, indexing strategies, React InstantSearch, and relevance tuning Use when: adding search to, algolia, instantsearch, search api, search functionality.
热度
- GitHub 星标
- 33k
- 排名
- #8723
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
owasp-security
33k教你的智能体掌握面向网页应用、API、移动端、容器和 AI 智能体的 OWASP 安全指南,以便发现常见弱点并提出修复建议。
agent-management
33k让你的智能体使用 AI Maestro 命令行工具创建、列出、休眠、唤醒、重命名和删除 AI 智能体,管理每个智能体的生命周期。
agent-messaging
33k让你的智能体使用智能体消息协议,在 AI 智能体之间发送、接收和回复带签名的消息,大部分在你自己的电脑上完成。
docs-search
33k让你的智能体搜索自动生成的代码文档,查找函数签名、类定义和注释,从而在修改代码之前核对真实的 API。