feat(contextCenter): support sortBy/sortOrder on page hierarchy search - #31598
feat(contextCenter): support sortBy/sortOrder on page hierarchy search#31598sonika-shah wants to merge 3 commits into
Conversation
Adds sortBy/sortOrder query params to GET /v1/contextCenter/pages/search/hierarchy so newly created articles/quick links can surface at the top of the left-tree hierarchy. Threads a SearchSortFilter from the resource through KnowledgePageRepository, the SearchClient interface, and the ES/OS clients. - Default sort is updatedAt desc (newest first); sortBy accepts name/createdAt/ updatedAt, sortOrder accepts asc/desc, invalid values return 400 (reuses the existing resolveSortField/resolveSortOrder validators). - fullyQualifiedName (keyword, unique per page) is always appended as a stable tiebreaker so from/size pagination cannot miss or duplicate hits when the primary sort field is non-unique.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
limit=1000000 on the search hierarchy path becomes the ES/OpenSearch query size, which exceeds the default index.max_result_window (10000) and makes the shard fail with search_phase_execution_exception (500). The three test pages fit comfortably in a small window, so query with limit=1000.
Addresses PR review: - Drop 'createdAt' from the hierarchy sortBy allowableValues/description. resolveSortField maps createdAt -> the updatedAt field (the index has no createdAt), so advertising it was misleading. Advertise name + updatedAt only; the updatedAt-desc default already surfaces newly-created pages at the top. - Replace the raw "fullyQualifiedName"/"desc" literals in the ES/OS hierarchy sort helper with Entity.FIELD_FULLY_QUALIFIED_NAME and a SORT_ORDER_DESC constant.
|
Superseded by #31625, which targets |
Code Review ✅ Approved 1 resolved / 1 findingsAdds validated sortBy and sortOrder parameters to context-page hierarchy search, threading the sort filter through the repository and search backends with a stable tiebreaker. Addressed the createdAt sorting mapping issue. ✅ 1 resolved✅ Bug: sortBy=createdAt silently sorts by updatedAt
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
What
Adds
sortBy/sortOrderquery params toGET /v1/contextCenter/pages/search/hierarchyso the Context Center left-tree can control ordering — e.g. a newly created article or quick link surfaces at the top instead of the bottom.Fixes open-metadata/openmetadata-collate#4781(item 1 — article hierarchy sorting).How
Threads a
SearchSortFilterfrom the resource throughKnowledgePageRepository→ theSearchClientinterface → the ES/OS client implementations:KnowledgePageResource—listHierarchyWithSearchgainssortBy(name/createdAt/updatedAt) andsortOrder(asc/desc). Reuses the existingresolveSortField/resolveSortOrdervalidators, so invalid values return 400. Default isupdatedAt desc(newest first).ElasticSearchClient/OpenSearchClient— a sharedbuildPageHierarchySortOptionsapplies the requested primary sort, then always appendsfullyQualifiedName(keyword, unique per page) as a stable tiebreaker sofrom/sizepagination cannot miss or duplicate hits when the primary sort field (e.g.updatedAt) is non-unique.SearchClient/KnowledgePageRepository— signature threading only.The Collate
ElasticSearchClientExt/OpenSearchClientExtoverride these same methods; the matching Collate change is in openmetadata-collate (linked below) and depends on this PR + a submodule bump.Tests
KnowledgePageHierarchyITgains three cases:testSearchHierarchyRejectsInvalidSortBy→ 400testSearchHierarchyRejectsInvalidSortOrder→ 400testSearchHierarchySortsByName→ ascaaa < mmm < zzz, desc reversed (Awaitility-gated on the search index)Verified locally:
mvn spotless:check,compile(openmetadata-service), andtest-compile(openmetadata-integration-tests) all pass.Greptile Summary
The PR adds configurable, stable ordering to Context Center hierarchy search.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
Reviews (3): Last reviewed commit: "refactor(contextCenter): honest sort con..." | Re-trigger Greptile
Context used: