Skip to content

refactor(search): stream bleve descendants - #3495

Open
dschmidt wants to merge 1 commit into
mainfrom
feat/search-hierarchy-tokenizer
Open

refactor(search): stream bleve descendants#3495
dschmidt wants to merge 1 commit into
mainfrom
feat/search-hierarchy-tokenizer

Conversation

@dschmidt

@dschmidt dschmidt commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

@dschmidt dschmidt added the Type:Maintenance E.g. technical debt, packaging, etc. label Sep 8, 2026
@codacy-production

codacy-production Bot commented Sep 8, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 20 complexity

Metric Results
Complexity 20

View in Codacy

🟢 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

View coverage diff in Codacy

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.

@dschmidt dschmidt changed the title feat(search): hierarchy tokenizer for bleve path fields feat(search): hierarchy tokenizer for bleve Sep 8, 2026
@dschmidt
dschmidt requested a balanced review from Copilot September 8, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@dschmidt dschmidt changed the title feat(search): hierarchy tokenizer for bleve feat(search): hierarchical path and geohash terms for bleve Sep 8, 2026
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch from 61c3aa1 to f9f9a8a Compare September 8, 2026 16:07
@dschmidt
dschmidt marked this pull request as ready for review September 8, 2026 16:09
@dschmidt

Copy link
Copy Markdown
Contributor Author

Marking it as draft again because the important core change was extracted to #3510.

@dschmidt
dschmidt marked this pull request as draft September 10, 2026 17:38
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch from fc7658b to 703cd75 Compare September 11, 2026 07:19
@dschmidt dschmidt changed the title feat(search): hierarchical path and geohash terms for bleve feat(search): stream descendants and geohash sibling for bleve Sep 11, 2026
@dschmidt
dschmidt changed the base branch from main to fix/bleve-path-performance September 11, 2026 07:19
Base automatically changed from fix/bleve-path-performance to main September 11, 2026 09:55
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch from 703cd75 to 83df7be Compare September 11, 2026 11:00
@dschmidt dschmidt changed the title feat(search): stream descendants and geohash sibling for bleve feat(search): stream descendants page by page in the bleve batch Sep 11, 2026
@dschmidt dschmidt changed the title feat(search): stream descendants page by page in the bleve batch refactor(search): stream descendants page by page in the bleve batch Sep 11, 2026
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch from 83df7be to 47cbb2a Compare September 11, 2026 11:01
@dschmidt dschmidt changed the title refactor(search): stream descendants page by page in the bleve batch refactor(search): stream bleve descendants Sep 11, 2026
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch 2 times, most recently from 1492b97 to e4d4b68 Compare September 11, 2026 11:07
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.
@dschmidt
dschmidt force-pushed the feat/search-hierarchy-tokenizer branch from e4d4b68 to c24333f Compare September 11, 2026 11:12
@dschmidt
dschmidt marked this pull request as ready for review September 12, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type:Maintenance E.g. technical debt, packaging, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants