Skip to content

feat(search): sort results via sortProperties / order_by - #3298

Draft
dschmidt wants to merge 7 commits into
feat/graph-search-queryfrom
feat/search-sort-properties
Draft

feat(search): sort results via sortProperties / order_by#3298
dschmidt wants to merge 7 commits into
feat/graph-search-queryfrom
feat/search-sort-properties

Conversation

@dschmidt

Copy link
Copy Markdown
Contributor

Adds MS-Graph-style sortProperties to the graph search endpoint and order_by to the search proto.

  • Sortable is any scalar field that is indexed and carried on the match entity, derived via reflection; multivalued and unknown fields are rejected with invalidRequest.
  • Native sorting in the bleve and OpenSearch backends, order-preserving cross-space merge (case-insensitive for lowercase-analyzed fields like name).
  • order_by is wired through the grpc service and its response cache key.

Spec: opencloud-eu/libre-graph-api#61
Stacked on #3211.

@codacy-production

codacy-production Bot commented Aug 12, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 133 complexity

Metric Results
Complexity 133

View in Codacy

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 force-pushed the feat/search-sort-properties branch from e443b80 to cc497cc Compare August 12, 2026 23:08
@dschmidt
dschmidt force-pushed the feat/search-sort-properties branch from cc497cc to 97626bb Compare August 18, 2026 17:11
@dschmidt
dschmidt force-pushed the feat/search-sort-properties branch from 97626bb to ac2f094 Compare September 7, 2026 22:35
Validated against the sortable-field whitelist (name, size,
lastModifiedDateTime, photo.takenDateTime) and forwarded to the search
service as order_by. Also fixes the stub search service's IndexSpace
signature (streaming response) so the suite builds again.

(cherry picked from commit 9aa6a34)
(cherry picked from commit 35a6cad8ea6a7890bdc0bc98c7ac97bdcbf477cc)
Sortable is every field that is indexed as a scalar and carried on the
match entity: name, size, lastModifiedDateTime, mimeType and the scalar
facet fields (photo.*, audio.*, image.*, location.*, ...). Both sets
are derived by reflection, so new facet fields become sortable
automatically. Multivalued fields (tags), bare facets and internal
index fields are rejected with invalidRequest at the graph layer.
CompareMatches provides the merge comparator for the service layer.

(cherry picked from commit bd32795)
The fan-out passes order_by through to each engine query; the merge
re-sorts the combined matches with CompareMatches and keeps the score
as tiebreaker (and as the sole criterion when no order_by is given).

(cherry picked from commit 66af40f)
@dschmidt
dschmidt force-pushed the feat/search-sort-properties branch from ac2f094 to 61cf668 Compare September 12, 2026 18:12
Name is analyzed (lowercaseKeyword) and therefore a text field, which
OpenSearch refuses to sort on without fielddata; enable it in the index
template. The keyword tokenizer emits one term per document, so the
fielddata cache stays small. The schema version has not shipped yet, so
no reindex is needed.

(cherry picked from commit f1d0e7b)
The grpc layer rebuilt the searcher request field by field and dropped
order_by; the response cache also ignored it, so differently sorted
searches collided on the same cache entry.

(cherry picked from commit 97626bb)
@dschmidt
dschmidt force-pushed the feat/search-sort-properties branch from 61cf668 to 3f2c988 Compare September 12, 2026 18:13
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.

1 participant