-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add full-text search using Bleve #10
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
Conversation
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
- Add internal/search package wrapping Bleve for full-text indexing - Index bean title and body fields for search - Expose search via `search` field in GraphQL BeanFilter - Search is composable with existing filters (status, type, tags, etc.) - Lazy index initialization on first search or mutation - Synchronous index updates on Create/Update/Delete - Auto-rebuild index on Load() for file watcher mode - Store index in .beans/.index/ (auto-created, gitignored) - beans init now creates .beans/.gitignore to ignore .index/
- Add internal/search package wrapping Bleve for full-text indexing - Use BM25 scoring algorithm for better relevance ranking - Index bean title and body fields for search - Expose search via `search` field in GraphQL BeanFilter - Search is composable with existing filters (status, type, tags, etc.) - Lazy index initialization on first search or mutation - Synchronous index updates on Create/Update/Delete - Auto-rebuild index on Load() for file watcher mode - Store index in .beans/.index/ (auto-created, gitignored) - beans init now creates .beans/.gitignore to ignore .index/
1c7ee93 to
9358830
Compare
Add -S/--search flag for full-text search in title and body. Composable with all other filters (status, type, tags, etc.). Examples: beans list --search "authentication" beans list -S "login" -s todo beans list --search "auth*" --type bug
Add documentation for search syntax in: - beans list command help (--search/-S flag) - GraphQL schema (BeanFilter.search field) Documents fuzzy matching (~), wildcards (*), phrases, boolean operators, and field-specific searches.
be31eb2 to
b3ed604
Compare
- Remove unused pendingReload variable in watcher.go - Add DefaultSearchLimit constant to document the 1000 result limit
- Remove redundant `combined` field from search index (Bleve searches all fields by default) - Add warning logging for non-fatal search index errors instead of silently discarding them - Add SetWarnWriter() to configure or disable warning output - Suppress warnings in tests via SetWarnWriter(nil)
- Hold write lock for entire Search() operation using defer - Eliminates brief unlocked window between lock transitions - Simpler to reason about with negligible performance impact
- Use write lock only for lazy index initialization - Release lock before performing Bleve search (thread-safe) - Use read lock only when reading from beans map This allows concurrent searches to run in parallel and prevents searches from blocking writes during the actual search operation.
- NewIndex now returns a boolean indicating if the index was rebuilt - Core logs a warning when search index is rebuilt (corruption or first use) - Helps users understand when their search index was regenerated
- Search errors are now propagated to the caller via GraphQL - Users will see actual errors rather than empty results on failure
- Slug is now indexed alongside title and body for full-text search - Users can search by slug content or use field-specific queries (slug:auth) - Updated CLI help and GraphQL schema documentation
- Replace boolean 'rebuilt' with IndexStatus enum (Opened, Created, Recovered) - Differentiate between new index and corrupted index recovery - Only rebuild index when newly created or recovered from corruption - Skip unnecessary rebuild when opening existing valid index - Warning now only shown for actual corruption recovery
- Switch from disk-based Bleve index to in-memory using NewMemOnly() - Remove IndexStatus enum and corruption recovery logic - Remove .gitignore creation for .index/ directory - Replace RebuildFromBeans() with simpler IndexBeans() batch method - Simplify ensureSearchIndexLocked() in Core The index is rebuilt on each invocation, which is fast for typical project sizes (milliseconds for ~100 beans). This eliminates disk I/O, corruption handling, and the need to gitignore the index directory.
Change "failed to rebuild search index" to "failed to reinitialize search index after reload" to better describe when this warning occurs.
ae91ae4 to
44137bb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
BeanFilter.searchand CLIbeans list --search.beans/.index/(gitignored automatically)Changes
internal/search/package - Bleve wrapper for indexing and searching beanssearch: StringtoBeanFilterinput type-S/--searchflag tobeans listcommandbeans init- Now creates.beans/.gitignoreto ignore the search indexSearch Syntax
Supports Bleve query string syntax:
loginlogin~login~2log*"user login"user AND loginuser OR logintitle:loginbody:authUsage
Test plan
internal/search/packageinternal/beancore/