Skip to content

fix(search): hierarchy tokenizer for bleve path fields - #3510

Merged
fschade merged 1 commit into
mainfrom
fix/bleve-path-performance
Sep 11, 2026
Merged

fix(search): hierarchy tokenizer for bleve path fields#3510
fschade merged 1 commit into
mainfrom
fix/bleve-path-performance

Conversation

@dschmidt

@dschmidt dschmidt commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

Path in bleve was a keyword, so the descendant lookup (delete/move/restore/purge), the scoped search and the KQL path: predicate expanded into one term searcher per descendant and OOM-killed the server on large folders.

Path is now analyzed into its ancestor prefixes (./a/b.txt., ./a, ./a/b.txt), like path_hierarchy in OpenSearch. All three call sites are a single term query. Schema 4 → 5 (v4 never shipped).

The same tokenizer with tag_depth is registered as the geohash analyzer so #3272 can add its field additively. Minimal version of #3495: no descendant streaming, no geohash sibling.

Peak live heap, descendant lookup at 100k files: 1217 MB → 133 MB.

Related Issue

How Has This Been Tested

  • Tokenizer unit tests
  • Parity: MOVE-03 (sibling folder sharing the prefix), MOVE-04 (special characters in the path)

Types of changes

  • performance improvement

This is an (imho) important performance fix. We've broken the index scheme for the next release already so now is the PERFECT time to get it in.

I've separated the breaking parts from my original PR into this. This already gets us a 10x less memory usage effect. So I would strongly suggest to merge it for the 8.0.0 release. The other improvements are non breaking and can happen at another time in the 8.x cycle.

BTW: I don't have any other breaking changes planned (alas this wasn't planned but it was brought up and debugged just in time by another user/contributor).
I put everything breaking into my refactor PR, which I separated out of a feature branch with all my stuff merged together and working. So I'm pretty confident that everything I've been working on can be added gradually during the 8.x series without a single breaking change.

@codacy-production

codacy-production Bot commented Sep 10, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 21 complexity

Metric Results
Complexity 21

View in Codacy

🟢 Coverage 77.67% diff coverage · +0.05% coverage variation

Metric Results
Coverage variation +0.05% coverage variation (-1.00%)
Diff coverage 77.67% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e503c2c) 88539 20997 23.71%
Head commit (9cc7757) 88613 (+74) 21062 (+65) 23.77% (+0.05%)

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 (#3510) 103 80 77.67%

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 Add hierarchy tokenizer for path-based folder queries fix(search): hierarchy tokenizer for bleve path fields Sep 10, 2026
@dschmidt
dschmidt marked this pull request as ready for review September 10, 2026 17:34
@dschmidt
dschmidt requested review from butonic and fschade September 10, 2026 17:38
Comment thread services/search/pkg/mapping/opts.go Outdated
@dschmidt
dschmidt force-pushed the fix/bleve-path-performance branch 2 times, most recently from d20d3a0 to 66f992d Compare September 10, 2026 18:42
Path was a keyword, so the descendant lookup behind delete/move/restore/purge, the scoped search and the KQL path predicate expanded into one term searcher per descendant and OOM-killed the server on large folders (#1269, #3469).

Path is now analyzed into its ancestor prefixes, like path_hierarchy in OpenSearch: ./a/b.txt becomes ., ./a, ./a/b.txt. A folder's descendants are every document carrying the folder's path as a term, so all three call sites are a single term query. Schema 4 -> 5, v4 never shipped.

The same tokenizer with tag_depth is registered as the geohash analyzer, so #3272 can add its geohash field without another schema change.
@fschade
fschade enabled auto-merge September 11, 2026 07:48
@fschade
fschade merged commit de37922 into main Sep 11, 2026
68 checks passed
@fschade
fschade deleted the fix/bleve-path-performance branch September 11, 2026 09:55
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenCloud Team Board Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants