refactor(search): stream bleve descendants - #3495
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
🟢 Coverage 80.33% diff coverage · +0.10% coverage variation
Metric Results Coverage variation ✅ +0.10% coverage variation (-1.00%) Diff coverage ✅ 80.33% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (348890d) 88625 21132 23.84% Head commit (c24333f) 88580 (-45) 21209 (+77) 23.94% (+0.10%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#3495) 61 49 80.33% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🟢 Approval recommended
The schema, query, batching, and regression-test changes consistently implement bounded hierarchical path lookup.
Pull request overview
Adds hierarchical Bleve path indexing to prevent descendant queries from consuming memory proportional to folder size.
Changes:
- Adds and tests a reusable hierarchy tokenizer.
- Replaces wildcard path expansion with single-term queries.
- Streams batch operations through bounded, ID-paginated searches and bumps the schema version.
File summaries
| File | Description |
|---|---|
services/search/pkg/search/search.go |
Bumps the shared search schema to v5. |
services/search/pkg/query/bleve/compiler.go |
Compiles path predicates as term queries. |
services/search/pkg/query/bleve/compiler_test.go |
Updates path-query expectations. |
services/search/pkg/mapping/opts.go |
Defines the Bleve path analyzer name. |
services/search/pkg/mapping/bleve.go |
Assigns the hierarchy analyzer to path fields. |
services/search/pkg/bleve/testdata/mapping.golden.json |
Records the updated mapping. |
services/search/pkg/bleve/index.go |
Registers hierarchy analysis and paginates descendant lookup. |
services/search/pkg/bleve/hierarchy/hierarchy.go |
Implements the hierarchy tokenizer. |
services/search/pkg/bleve/hierarchy/hierarchy_test.go |
Tests tokenization, querying, and facets. |
services/search/pkg/bleve/hierarchy/hierarchy_suite_test.go |
Adds the tokenizer test suite. |
services/search/pkg/bleve/descendants_test.go |
Tests correctness, pagination, and bounded memory. |
services/search/pkg/bleve/descendants_bench_test.go |
Benchmarks descendant lookup memory. |
services/search/pkg/bleve/bleve.go |
Removes obsolete query escaping. |
services/search/pkg/bleve/batch.go |
Streams folder operations over descendants. |
services/search/pkg/bleve/backend.go |
Uses hierarchy terms for scoped searches. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
61c3aa1 to
f9f9a8a
Compare
|
Marking it as draft again because the important core change was extracted to #3510. |
fc7658b to
703cd75
Compare
703cd75 to
83df7be
Compare
83df7be to
47cbb2a
Compare
1492b97 to
e4d4b68
Compare
Move, delete, restore and purge walk a folder in pages of 20k sorted by id instead of collecting every descendant first: 133 MB -> 19 MB live heap at 100k files, flat over folder size. The walker yields the folder itself, the batch skips it by id.
e4d4b68 to
c24333f
Compare
Description
Move, delete, restore and purge collected every descendant before writing. They now walk the folder in pages of 20k, so live memory is bounded by the page, not the folder: 133 MB → 19 MB at 100k files. Follow-up to #3510.
Related Issue
Types of changes