revert(search): restore the v0.9.23 Jira text search · simstudioai/sim@269e673 · GitHub
Skip to content

Commit 269e673

Browse files
committed
revert(search): restore the v0.9.23 Jira text search
Reverts the Jira summary tiers (#9111, #9115, #9121, #9129). A plain Jira search again returns the all-terms text match in Jira's order, as in v0.9.23. The stemmedTerms helper stays; cross-source ranking uses it.
1 parent ae6ac39 commit 269e673

3 files changed

Lines changed: 30 additions & 291 deletions

File tree

‎apps/sim/lib/sim-search/live/atlassian.test.ts‎

Lines changed: 0 additions & 189 deletions

‎apps/sim/lib/sim-search/live/atlassian.ts‎

Lines changed: 24 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
confluenceTextClause,
1414
holdsHalfTheTerms,
1515
jiraTextClause,
16-
stemmedTerms,
1716
} from '@/lib/sim-search/live/text-match'
1817
import type {
1918
NativeClient,
@@ -117,14 +116,6 @@ async function sites(client: NativeClient) {
117116
return array(await client.json('/oauth/token/accessible-resources', { memo: true }))
118117
}
119118

120-
/**
121-
* Issues fetched for the half-the-terms summary tier: summary pair matches within the all-terms
122-
* match. Jira returns them newest first, not by relevance, and the page is then filtered to
123-
* summaries holding enough terms, so it starts from a wider pool than the caller's limit or the
124-
* any-term fallback's.
125-
*/
126-
const HALF_TERM_CANDIDATES = 50
127-
128119
/**
129120
* One Atlassian site's page; `ranking` marks a page whose order or completeness differs from the
130121
* all-terms search.
@@ -184,89 +175,33 @@ export async function searchAtlassian(
184175
const cloudId = string(site.id)
185176
const origin = string(site.url).replace(/\/$/, '')
186177
if (provider === 'jira') {
187-
/** One JQL page, each issue with its summary and raw fields. */
188-
const searchIssues = async (
189-
jql: string,
190-
{ cursor, maxResults = input.limit }: { cursor?: string; maxResults?: number } = {}
191-
) => {
192-
const data = object(
193-
await client.json(`/ex/jira/${segment(cloudId)}/rest/api/3/search/jql`, {
194-
body: {
195-
jql: scopeAtlassianQuery(jql, scope, order),
196-
maxResults,
197-
fields: ['summary', 'description', 'updated', 'creator', 'status'],
198-
...(cursor ? { nextPageToken: cursor } : {}),
199-
},
200-
signal: input.signal,
201-
})
202-
)
203-
return {
204-
issues: array(data.issues).map((row) => {
205-
const fields = object(row.fields)
206-
return {
207-
document: issue(row, cloudId, origin),
208-
summary: string(fields.summary),
209-
fields,
210-
}
211-
}),
212-
next: string(data.nextPageToken) || undefined,
213-
}
214-
}
215-
const exact = await searchIssues(
216-
input.native?.query || (text ? jiraTextClause(text, input.textMatch) : ''),
217-
{ cursor: input.native?.cursor && single ? input.native.cursor : undefined }
178+
const data = object(
179+
await client.json(`/ex/jira/${segment(cloudId)}/rest/api/3/search/jql`, {
180+
body: {
181+
jql: scopeAtlassianQuery(
182+
input.native?.query || (text ? jiraTextClause(text, input.textMatch) : ''),
183+
scope,
184+
order
185+
),
186+
maxResults: input.limit,
187+
fields: ['summary', 'description', 'updated', 'creator', 'status'],
188+
...(input.native?.cursor && single ? { nextPageToken: input.native.cursor } : {}),
189+
},
190+
signal: input.signal,
191+
})
218192
)
219-
const exactPage: SitePage = {
220-
documents: exact.issues
221-
.filter(
222-
({ summary, fields }) =>
223-
!relevant || relevant(`${summary}\n${textContent(fields.description)}`)
224-
)
225-
.map(({ document }) => document),
226-
excluded: false,
227-
next: exact.next,
228-
}
229-
// JQL has no relevance order, so an all-terms match larger than a page comes back newest
230-
// first. Within that match, issues whose summary holds every term lead it instead, then
231-
// those whose summary holds at least half of three or more terms (most terms first); a
232-
// summary match never brings in an issue lacking one of the terms.
233-
if (!text || input.native || order || input.textMatch === 'any' || !exact.next)
234-
return exactPage
235-
const terms = stemmedTerms(text)
236-
const [every, half] = await Promise.allSettled([
237-
searchIssues(jiraTextClause(text, 'all', 'summary')),
238-
terms.count >= 3
239-
? searchIssues(
240-
`${jiraTextClause(text, 'any', 'summary')} AND ${jiraTextClause(text)}`,
241-
{ maxResults: HALF_TERM_CANDIDATES }
242-
)
243-
: undefined,
244-
])
245-
// A cancelled search stops here; any other failure keeps the all-terms page.
246-
input.signal?.throwIfAborted()
247-
const everyTerm =
248-
every.status === 'fulfilled' ? every.value.issues.map(({ document }) => document) : []
249-
const halfTerms =
250-
half.status === 'fulfilled' && half.value
251-
? half.value.issues
252-
.map(({ document, summary }) => ({ document, held: terms.held(summary) }))
253-
.filter(({ held }) => held >= terms.required)
254-
.sort((left, right) => right.held - left.held)
255-
.map(({ document }) => document)
256-
: []
257-
const titled = [...everyTerm, ...halfTerms]
258-
if (!titled.length) return exactPage
259-
const seen = new Set<string>()
260193
return {
261-
documents: [...titled, ...exactPage.documents]
262-
.filter(({ id }) => {
263-
if (seen.has(id)) return false
264-
seen.add(id)
265-
return true
194+
documents: array(data.issues)
195+
.filter((row) => {
196+
const fields = object(row.fields)
197+
return (
198+
!relevant ||
199+
relevant(`${string(fields.summary)}\n${textContent(fields.description)}`)
200+
)
266201
})
267-
.slice(0, input.limit),
202+
.map((row) => issue(row, cloudId, origin)),
268203
excluded: false,
269-
ranking: 'relevance',
204+
next: string(data.nextPageToken) || undefined,
270205
}
271206
}
272207
const searchPages = async (clause: string, cursor?: string) => {
@@ -330,9 +265,7 @@ export async function searchAtlassian(
330265
? ' Matches other than pages, blog posts, and spaces (attachments, comments, whiteboards, folders, databases) were excluded because they cannot be read.'
331266
: '') +
332267
(pages.some((result) => result.ranking === 'relevance')
333-
? provider === 'jira'
334-
? ' 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.'
335-
: ' 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.'
268+
? ' 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.'
336269
: '') +
337270
(pages.some((result) => result.ranking === 'unavailable')
338271
? ' Relevance ranking was unavailable, so this page keeps the order of the all-terms search.'

‎apps/sim/lib/sim-search/live/text-match.ts‎

Lines changed: 6 additions & 11 deletions

0 commit comments

Comments
 (0)