Repository navigation
Description
Description
When a Content Drive field filter (e.g. a Text field contains-match) is fully resolvable against the search index — no Tag, no Relationship, no workflow, no free-text term — the system still repeats the expensive database candidate-scan query multiple times per request instead of once. On a ~21,000-item folder this took ~4 repeats and made the response ~6x slower than an equivalent search (606ms vs 88ms).
The routing to the index is correct per ADR-0018 (fields flagged searchable on the content type are index-resolved by design — this is not a mis-routing bug). The inefficiency is in the DB-first hybrid chunk loop, which keeps re-scanning in fixed-size chunks (BROWSER_CONTENT_CHUNK_SIZE, default 900) until enough matches survive index narrowing, regardless of match density.
buildPureESQuery (BrowserAPIImpl) already builds nearly everything needed for a single-pass, index-only query for this specific case, but is missing a folder-scoping clause (conFolder, an already-used, low-risk ES field). Adding it and routing to this path only when zero DB-routed criteria, no workflow filter, and no free-text term are present should collapse the repeated scans to one.
Adding some independent measurements that corroborate this issue, gathered testing against a large dataset (~718,174 contentlets):
- Filtering by a specific searchable field (Content Type: File Asset + File Name filter) took ~2 minutes to return a response, versus ~31.5 seconds for the equivalent global search filter term — roughly 3.8x slower, consistent with the field-filter re-scan behavior described here.
- Combining a secondary-language filter with the global search filter took ~12 seconds to generate a response.
- A plain global search in Content Drive took ~25 seconds to return results, versus ~24ms for the same term in the Search All portlet.
These numbers are from a larger dataset than referenced in the issue description, so the relative slowdown compounds further at scale — an additional data point for the "falls within 20% of an equivalent content-search operation" acceptance criterion.
Acceptance Criteria
- A field filter with no DB-required criteria over a large folder resolves with at most one database candidate-scan, not four
- Response time for that case falls to within 20% of an equivalent content-search operation
- Filters combined with Tag, Relationship, workflow, or free-text terms are unaffected — same result sets, same database-first resolution, no behavior change
- Result sets for Text, Date-range, Multi-select, and Category field filters are unchanged from current behavior
- The mandatory read-permission filter continues to run, sourced from the database, on every request
- No dedicated feature flag — ships as default behavior; the general search-strategy config remains the fallback escape hatch
Coordination note
Shares the underlying candidate-scan query with #37183 (spike on that query's plan instability). Whatever #37183 changes about that query must continue to work correctly when invoked at most once per request, as this fix will do for its case.
Parent Epic
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Aug 24, 2026
PRs linked to this issue
dario-daza commentedon Aug 25, 2026
Adding some independent measurements that corroborate this issue, gathered testing against a large dataset (~718,174 contentlets):
These numbers are from a larger dataset than referenced in the issue description, so the relative slowdown compounds further at scale — an additional data point for the "falls within 20% of an equivalent content-search operation" acceptance criterion.
fix(content-drive): fix real bugs found running BrowserAPITest field-…
fix(content-drive): bound ES fan-out and preserve DB order in single-…
test(content-drive): make the single-pass test CI-safe and cover pagi…
fix(content-drive): cap ES sub-query results to candidate count, not …
fix(content-drive): check natural DB exhaustion before the scan-limit…
test(content-drive): pin the ES sub-query "size" fix with >10 matches…
fix(content-drive): clamp the single-pass chunk size to the scan limit (
dario-daza commentedon Sep 24, 2026
✅ QA PASSED
Tested the fix from #37395 against a large customer-scale dataset (~718k contentlets) on a local stack running
trunk(OpenSearch migration phase 2).Method: A/B comparison on the same image and data, run in three rounds (B → A → B):
BROWSER_SINGLE_PASS_CHUNK_SIZE=900)Latencies are medians of 10 runs after a warm-up. Chunk counts come from
BrowserAPIImpldebug logs.Field filter with sparse / no matches (the case this issue targets)
hasMore=true); B completeBesides the latency gain, the wider chunk avoids hitting the 10s scan budget (
BROWSER_DB_MAX_SCAN_TIME_MILLIS) on large folders. Before the fix, those searches returned an empty or partial first page.Correctness
BROWSER_DB_MAX_SCAN_ROWS=5000, the chunk size is 5000 and the results are unchanged. No new feature flag is involved.Notes / follow-ups (non-blocking)
/api/content/_search, consistent with the PR's deferral to docs(content-drive): spec for materialized folder-first CTE fix (#37229) #37230.search.query.max_query_string_length: 32000) andPhaseRouterfalls back to OS 1.x. This affects A and B equally and is tracked in [DEFECT] Content Drive search drops all contentlets on large sites: ES inode batch exceeds max query-string length #37695.Not covered in this run: Tag filters (the dataset has no tags), a restricted-user permission check, and the UI payload check in Content Drive.