feat(search): scope searches to a drive via the driveId field - #3424
Conversation
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).
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 5 |
🟢 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 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.
butonic
left a comment
There was a problem hiding this comment.
well, ok ... so you are adding an alias ... but KQL queries are not really hand written in the first place.
|
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 :) |
scope:takes an opaque resource id, which is hostile to hand-written queries. AcceptdriveId:"<storage$space>"as a regular KQL field instead: it resolves to the indexedRootIDand a bare drive id is completed to the root resource id. Combined withpath: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 viapath:or the SharePoint ListId/SiteId managed properties, and exposes driveId only as response metadata); the field is named after the GraphparentReference.driveIdour 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.