Skip to content

fix: optimise OpenSearch query for merge suggestions (CM-1012)#3924

Merged
skwowet merged 5 commits intomainfrom
bugfix/CM-765
Mar 18, 2026
Merged

fix: optimise OpenSearch query for merge suggestions (CM-1012)#3924
skwowet merged 5 commits intomainfrom
bugfix/CM-765

Conversation

@skwowet
Copy link
Collaborator

@skwowet skwowet commented Mar 17, 2026

Summary

  • Limit OpenSearch clause expansion in merge suggestion queries by capping fuzzy expansion in both member and organization searches with max_expansions: 3
  • Cap organization prefix query expansion with rewrite: 'top_terms_3' to reduce clause growth
  • Reduce organization query fan-out by lowering the processed identity cap from 100 to 75 and reducing org identity chunk size from 20 to 15
  • Normalize cleaned organization identity values to lowercase so prefix queries stay aligned with the lowercase analyzer used by nested_identities.string_value

Note

Medium Risk
Changes OpenSearch query construction for member/org merge suggestions (fuzzy/prefix expansion, chunking, normalization), which can affect both performance and which entities get suggested for merge. Adds a new Temporal workflow for testing org merge suggestions, but it’s non-production unless invoked explicitly.

Overview
Optimizes merge-suggestion OpenSearch queries to reduce clause explosion: caps fuzzy matching with max_expansions: 3 (members + orgs), constrains org prefix queries via rewrite: 'top_terms_3', and lowers org identity fan-out (process up to 75 identities, chunk size 15).

Also normalizes cleaned org identity values to lowercase to better align with the index analyzer, and introduces a testOrganizationMergeSuggestions Temporal workflow (exported from workflows.ts) to fetch organizations by ID and log computed suggestions in parallel.

Written by Cursor Bugbot for commit ee8cfa9. This will update automatically on new commits. Configure here.

@skwowet skwowet self-assigned this Mar 17, 2026
Copilot AI review requested due to automatic review settings March 17, 2026 19:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Optimizes OpenSearch merge-suggestion queries to reduce clause explosion and improve match precision/performance in the merge suggestions worker.

Changes:

  • Added expansion caps for fuzzy queries (max_expansions: 3) in both organization and member merge suggestions.
  • Limited organization prefix query expansion via rewrite: 'top_terms_3' and reduced org identity query chunk size to 15.
  • Switched organization “weak identity” matching from match to match_phrase.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
services/apps/merge_suggestions_worker/src/activities/organizationMergeSuggestions.ts Tightens org identity query construction (chunk size, fuzzy/prefix expansion limits, weak match change).
services/apps/merge_suggestions_worker/src/activities/memberMergeSuggestions.ts Caps fuzzy query expansion to reduce query clause growth.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

skwowet added 5 commits March 18, 2026 01:42
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
…ssing

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet skwowet changed the title fix: optimise OpenSearch query for merge suggestions (CM-765) fix: optimise OpenSearch query for merge suggestions (CM-1012) Mar 17, 2026
@skwowet skwowet merged commit 8e6ce76 into main Mar 18, 2026
12 checks passed
@skwowet skwowet deleted the bugfix/CM-765 branch March 18, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants