Repository navigation
feat: incremental Meilisearch indexing with HF Hub ID tracker #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat: incremental Meilisearch indexing with HF Hub ID tracker
- Add `--incremental` flag to `populate-search-engine` command: only embeds new/changed chunks and deletes stale ones, uploading directly to the main index (no temp-index swap needed). - Introduce `src/doc_builder/embeddings_tracker.py` to persist the set of indexed document IDs as JSON in the HF Hub dataset `hf-doc-build/doc-builder-embeddings-tracker`. - Add `migrations/export_meili_ids_to_hf.py` as a one-time bootstrap script to seed the tracker from the existing Meilisearch index. - Add `get_all_document_ids` and `delete_documents_from_db` helpers to `meilisearch_helper.py`. - Replace all hardcoded `https://edge.meilisearch.com` references with a `--meilisearch_url` CLI argument (mirrors the existing `--meilisearch_key` pattern) across all commands and migration scripts. - Update the CI workflow to use `--incremental` and supply the new `MEILISEARCH_URL` and `HF_TOKEN` secrets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| One-time migration script: export all existing Meilisearch document IDs to the | ||
| HF Hub tracker dataset (hf-doc-build/doc-builder-embeddings-tracker). | ||
|
|
||
| This bootstraps the tracker so that subsequent `populate-search-engine | ||
| --incremental` runs can diff against it instead of re-indexing everything. | ||
|
|
||
| Usage: | ||
| uv run python migrations/export_meili_ids_to_hf.py \ | ||
| --meilisearch_key <key> \ | ||
| --meilisearch_url <url> \ | ||
| [--hf_token <token>] # falls back to HF_TOKEN env var | ||
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| import meilisearch | ||
|
|
||
| from doc_builder.build_embeddings import MEILI_INDEX | ||
| from doc_builder.meilisearch_helper import get_all_document_ids | ||
| from doc_builder.embeddings_tracker import save_tracker | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description="Export all Meilisearch document IDs to the HF Hub tracker dataset.") | ||
| parser.add_argument("--meilisearch_key", type=str, required=True, help="Meilisearch API key") | ||
| parser.add_argument("--meilisearch_url", type=str, required=True, help="Meilisearch URL") | ||
| parser.add_argument( | ||
| "--hf_token", | ||
| type=str, | ||
| required=False, | ||
| default=None, | ||
| help="HuggingFace token with write access (falls back to HF_TOKEN env var)", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| client = meilisearch.Client(args.meilisearch_url, args.meilisearch_key) | ||
|
|
||
| print(f"Fetching all document IDs from Meilisearch index '{MEILI_INDEX}'...") | ||
| ids = get_all_document_ids(client, MEILI_INDEX) | ||
| print(f"Found {len(ids)} documents in '{MEILI_INDEX}'") | ||
|
|
||
| print("Pushing ID list to HF Hub tracker...") | ||
| save_tracker(ids, hf_token=args.hf_token) | ||
| print("Done. The tracker is now ready for incremental updates.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.