@@ -334,7 +334,8 @@ describe('Confluence plain search ranking', () => {
334334
335335describe ( 'Jira plain search ranking' , ( ) => {
336336 const search = '/ex/jira/cloud/rest/api/3/search/jql'
337- type Issue = string | { key : string ; summary : string }
337+ /** `outsideMatch` marks an issue whose text lacks a query term, so an all-terms clause excludes it. */
338+ type Issue = string | { key : string ; summary : string ; outsideMatch ?: boolean }
338339 /**
339340 * Answers the all-terms query with `exact`, the all-terms summary query with `titled`, and the
340341 * half-the-terms summary query with `half`, or their failures.
@@ -354,7 +355,9 @@ describe('Jira plain search ranking', () => {
354355 const jql = options ?. body ?. jql ?? ''
355356 if ( jql . includes ( 'summary ~' ) ) {
356357 const rows = jql . includes ( ' OR ' ) ? half : titled
357- const picked = typeof rows === 'function' ? rows ( ) : rows
358+ const picked = ( typeof rows === 'function' ? rows ( ) : rows ) . filter (
359+ ( row ) => ! jql . includes ( 'text ~' ) || typeof row === 'string' || ! row . outsideMatch
360+ )
358361 return { issues : issues ( picked ) . slice ( 0 , options ?. body ?. maxResults ) }
359362 }
360363 return { issues : issues ( exact . ids ) , ...( exact . more ? { nextPageToken : 'page-2' } : { } ) }
@@ -502,4 +505,17 @@ describe('Jira plain search ranking', () => {
502505 const page = await searchAtlassian ( api , 'jira' , query )
503506 expect ( page . documents . map ( ( document ) => document . id ) ) . toEqual ( [ 'ALL-1' , 'HALF-1' , 'NEW-3' ] )
504507 } )
508+
509+ it ( 'keeps half-the-terms summaries to issues that match every term somewhere' , async ( ) => {
510+ const api = jira (
511+ overflowing ,
512+ [ ] ,
513+ [
514+ { key : 'OUTSIDE-1' , summary : 'Merged results dashboard' , outsideMatch : true } ,
515+ { key : 'INSIDE-1' , summary : 'Merged results broke the dashboard' } ,
516+ ]
517+ )
518+ const page = await searchAtlassian ( api , 'jira' , query )
519+ expect ( page . documents . map ( ( document ) => document . id ) ) . toEqual ( [ 'INSIDE-1' , 'NEW-3' , 'NEW-2' ] )
520+ } )
505521} )
0 commit comments