@@ -122,6 +122,13 @@ export async function getOrganizationMergeSuggestions(
122
122
return [ ]
123
123
}
124
124
125
+ const noMergeIds = await organizationMergeSuggestionsRepo . findNoMergeIds ( fullOrg . id )
126
+ const excludeIds = [ fullOrg . id ]
127
+
128
+ if ( noMergeIds && noMergeIds . length > 0 ) {
129
+ excludeIds . push ( ...noMergeIds )
130
+ }
131
+
125
132
const identitiesShould = [ ]
126
133
const identitiesPartialQuery = {
127
134
should : [
@@ -145,8 +152,8 @@ export async function getOrganizationMergeSuggestions(
145
152
minimum_should_match : 1 ,
146
153
must_not : [
147
154
{
148
- term : {
149
- uuid_organizationId : fullOrg . id ,
155
+ terms : {
156
+ uuid_organizationId : excludeIds ,
150
157
} ,
151
158
} ,
152
159
] ,
@@ -166,7 +173,7 @@ export async function getOrganizationMergeSuggestions(
166
173
)
167
174
168
175
// limit to prevent exceeding OpenSearch's maxClauseCount (1024)
169
- for ( const identity of identities . slice ( 0 , 140 ) ) {
176
+ for ( const identity of identities . slice ( 0 , 120 ) ) {
170
177
if ( identity . value . length > 0 ) {
171
178
// weak identity search
172
179
identitiesShould . push ( {
@@ -236,18 +243,6 @@ export async function getOrganizationMergeSuggestions(
236
243
identitiesPartialQuery . should . pop ( )
237
244
}
238
245
239
- const noMergeIds = await organizationMergeSuggestionsRepo . findNoMergeIds ( fullOrg . id )
240
-
241
- if ( noMergeIds && noMergeIds . length > 0 ) {
242
- for ( const noMergeId of noMergeIds ) {
243
- identitiesPartialQuery . must_not . push ( {
244
- term : {
245
- uuid_organizationId : noMergeId ,
246
- } ,
247
- } )
248
- }
249
- }
250
-
251
246
const similarOrganizationsQueryBody = {
252
247
query : {
253
248
bool : identitiesPartialQuery ,
0 commit comments