Skip to content

feat(search): scope searches to a drive via the driveId field - #3424

Merged
dschmidt merged 5 commits into
mainfrom
feat/search-scope
Sep 1, 2026
Merged

feat(search): scope searches to a drive via the driveId field#3424
dschmidt merged 5 commits into
mainfrom
feat/search-scope

Conversation

@dschmidt

@dschmidt dschmidt commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Replaces #3299, which GitHub auto-closed when its base branch refactor/search-mapping was deleted on the #3345 merge. Same two commits, rebased onto main, plus parity pins (SCOPE-06..09).

scope: takes an opaque resource id, which is hostile to hand-written queries. Accept driveId:"<storage$space>" as a regular KQL field instead: it resolves to the indexed RootID and a bare drive id is completed to the root resource id. Combined with path: this gives a readable location scope with no token stripping, both compose with groups, OR and NOT like any other field. MS KQL has no driveId property (it scopes via path: or the SharePoint ListId/SiteId managed properties, and exposes driveId only as response metadata); the field is named after the Graph parentReference.driveId our clients actually see.

Second commit prunes the space fan-out when top-level AND conjuncts pin the query to a single root; conservative rules, the restriction stays in the query, mountpoints are kept for path mapping.

Follow-up (deliberately not here): parse the query once in the service and hand the AST to the engines, which currently re-parse per space; that changes the engine interface.

scope: takes an opaque resource id, which is hostile to hand-written
queries. Accept driveId:"<storage$space>" as a regular KQL field
instead: it resolves to the indexed RootID, and a bare drive id is
completed to the root resource id (a space root's opaque id is its
space id). Full root ids pass through untouched.

Combined with path: this gives a readable location scope without any
token stripping: both are plain fields, so they compose with groups,
OR and NOT like everything else.
When top-level AND conjuncts pin the query to a single root
(driveId/RootID restrictions), only that space's index is asked; the
restriction itself stays in the query, so this is purely an
optimization. Conservative by design: any top-level OR, negated or
group-nested restriction leaves the fan-out untouched, searching a
space too many is wasted work while skipping one would be wrong.
Mountpoints are kept for result path mapping.

Costs one extra parse of the query in the service; parsing once and
handing the AST to the engines (which currently re-parse per space) is
a follow-up that changes the engine interface.
SCOPE-06..09 cover the completed root id, negation and composition; the cross-space fixture root follows the space-root convention (opaque id = space id).
@codacy-production

codacy-production Bot commented Aug 31, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 duplication

Metric Results
Duplication 5

View in Codacy

🟢 Coverage 86.44% diff coverage · +0.03% coverage variation

Metric Results
Coverage variation +0.03% coverage variation (-1.00%)
Diff coverage 86.44% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d38fbc8) 85544 19909 23.27%
Head commit (2041fdc) 85603 (+59) 19948 (+39) 23.30% (+0.03%)

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 (#3424) 59 51 86.44%

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 marked this pull request as ready for review August 31, 2026 13:37
@dschmidt
dschmidt marked this pull request as draft August 31, 2026 14:03
@dschmidt
dschmidt marked this pull request as ready for review August 31, 2026 19:14

@butonic butonic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

well, ok ... so you are adding an alias ... but KQL queries are not really hand written in the first place.

@dschmidt

dschmidt commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

true, but even if it's only for developers I want to establish the mental model that "search fields" match "driveItem properties" as closely as possible - and usually we're dealing with driveIds and not rootIds (the only occurence of rootId I found in the libre graph spec was for remoteItems)

thanks for the review :)

@dschmidt
dschmidt merged commit 7d4c6d6 into main Sep 1, 2026
62 of 63 checks passed
@dschmidt
dschmidt deleted the feat/search-scope branch September 1, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants