From 79cd3a5cd6b66147450a76e83631f5e185c5953b Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 15 Oct 2026 23:37:18 -0700 Subject: [PATCH 1/2] improvement(search): follow Jira summaries holding every term with those holding half of them --- .../sim/lib/sim-search/live/atlassian.test.ts | 13 +++++++++ apps/sim/lib/sim-search/live/atlassian.ts | 28 +++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/apps/sim/lib/sim-search/live/atlassian.test.ts b/apps/sim/lib/sim-search/live/atlassian.test.ts index 0c3fce42808..13d36f8d857 100644 --- a/apps/sim/lib/sim-search/live/atlassian.test.ts +++ b/apps/sim/lib/sim-search/live/atlassian.test.ts @@ -489,4 +489,17 @@ describe('Jira plain search ranking', () => { const page = await searchAtlassian(api, 'jira', query) expect(page.documents.map((document) => document.id)[0]).toBe('HALF-9') }) + + it('follows summaries holding every term with those holding half of them', async () => { + const api = jira( + { ids: ['NEW-3', 'NEW-2', 'NEW-1'], more: true }, + ['ALL-1'], + [ + { key: 'ALL-1', summary: 'Merged results pipelines' }, + { key: 'HALF-1', summary: 'Merged results dashboard' }, + ] + ) + const page = await searchAtlassian(api, 'jira', query) + expect(page.documents.map((document) => document.id)).toEqual(['ALL-1', 'HALF-1', 'NEW-3']) + }) }) diff --git a/apps/sim/lib/sim-search/live/atlassian.ts b/apps/sim/lib/sim-search/live/atlassian.ts index 5524763dbf8..4ad3b5d949b 100644 --- a/apps/sim/lib/sim-search/live/atlassian.ts +++ b/apps/sim/lib/sim-search/live/atlassian.ts @@ -226,8 +226,8 @@ export async function searchAtlassian( next: exact.next, } // JQL has no relevance order, so an all-terms match larger than a page comes back newest - // first; issues whose summary holds every term, or else at least half of three or more - // terms (most terms first), lead it instead. + // first; issues whose summary holds every term lead it instead, then those holding at + // least half of three or more terms (most terms first). if (!text || input.native || order || input.textMatch === 'any' || !exact.next) return exactPage const terms = stemmedTerms(text) @@ -241,15 +241,21 @@ export async function searchAtlassian( ]) // A cancelled search stops here; any other failure keeps the all-terms page. input.signal?.throwIfAborted() - let titled = + const everyTerm = every.status === 'fulfilled' ? every.value.issues.map(({ document }) => document) : [] - if (!titled.length && half.status === 'fulfilled' && half.value) { - titled = half.value.issues - .map(({ document, summary }) => ({ document, held: terms.held(summary) })) - .filter(({ held }) => held >= terms.required) - .sort((left, right) => right.held - left.held) - .map(({ document }) => document) - } + const halfTerms = + half.status === 'fulfilled' && half.value + ? half.value.issues + .map(({ document, summary }) => ({ document, held: terms.held(summary) })) + .filter(({ held }) => held >= terms.required) + .sort((left, right) => right.held - left.held) + .map(({ document }) => document) + : [] + const titled = [ + ...new Map( + [...everyTerm, ...halfTerms].map((document) => [document.id, document]) + ).values(), + ] if (!titled.length) return exactPage const leading = new Set(titled.map((document) => document.id)) return { @@ -323,7 +329,7 @@ export async function searchAtlassian( : '') + (pages.some((result) => result.ranking === 'relevance') ? provider === 'jira' - ? ' More issues contained every word than fit on one page, so issues whose summary holds every word, or else most of them, come first; refine the query, or page with a native JQL query.' + ? ' More issues contained every word than fit on one page, so issues whose summary holds every word, then most of them, come first; refine the query, or page with a native JQL query.' : ' More pages contained every word than fit on one page, so this page is ordered by Confluence relevance search; refine the query, or page with a native CQL query.' : '') + (pages.some((result) => result.ranking === 'unavailable') From 5257c825b54c3d02bd6914a3c76c2a2a98db3c00 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 15 Oct 2026 23:38:28 -0700 Subject: [PATCH 2/2] improvement(search): dedupe the Jira summary tiers and the all-terms page in one pass --- apps/sim/lib/sim-search/live/atlassian.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/sim/lib/sim-search/live/atlassian.ts b/apps/sim/lib/sim-search/live/atlassian.ts index 4ad3b5d949b..b355b316c83 100644 --- a/apps/sim/lib/sim-search/live/atlassian.ts +++ b/apps/sim/lib/sim-search/live/atlassian.ts @@ -251,18 +251,17 @@ export async function searchAtlassian( .sort((left, right) => right.held - left.held) .map(({ document }) => document) : [] - const titled = [ - ...new Map( - [...everyTerm, ...halfTerms].map((document) => [document.id, document]) - ).values(), - ] + const titled = [...everyTerm, ...halfTerms] if (!titled.length) return exactPage - const leading = new Set(titled.map((document) => document.id)) + const seen = new Set() return { - documents: [ - ...titled, - ...exactPage.documents.filter((document) => !leading.has(document.id)), - ].slice(0, input.limit), + documents: [...titled, ...exactPage.documents] + .filter(({ id }) => { + if (seen.has(id)) return false + seen.add(id) + return true + }) + .slice(0, input.limit), excluded: false, ranking: 'relevance', }