@@ -32,6 +32,7 @@ import {
32
32
createRelationships ,
33
33
defineSorters ,
34
34
filter ,
35
+ FullTextIndex ,
35
36
INACTIVE ,
36
37
matchChangesetAndChangedProps ,
37
38
matchProjectSens ,
@@ -514,6 +515,12 @@ export class EngagementRepository extends CommonRepository {
514
515
private createIndexes ( ) {
515
516
return this . getConstraintsFor ( IEngagement ) ;
516
517
}
518
+ @OnIndex ( 'schema' )
519
+ private async createSchemaIndexes ( ) {
520
+ await this . db . query ( ) . apply ( NameIndex . create ( ) ) . run ( ) ;
521
+ await this . db . query ( ) . apply ( LanguageNameIndex . create ( ) ) . run ( ) ;
522
+ await this . db . query ( ) . apply ( InternshipNameIndex . create ( ) ) . run ( ) ;
523
+ }
517
524
}
518
525
519
526
export const engagementFilters = filter . define ( ( ) => EngagementFilters , {
@@ -526,6 +533,25 @@ export const engagementFilters = filter.define(() => EngagementFilters, {
526
533
) ,
527
534
} ) ,
528
535
status : filter . stringListProp ( ) ,
536
+ name : filter . fullText ( {
537
+ index : ( ) => NameIndex ,
538
+ matchToNode : ( q ) =>
539
+ q . match ( [
540
+ node ( 'node' , 'Engagement' ) ,
541
+ relation ( 'either' , '' , undefined , ACTIVE ) ,
542
+ node ( '' , 'BaseNode' ) ,
543
+ relation ( 'out' , '' , undefined , ACTIVE ) ,
544
+ node ( 'match' ) ,
545
+ ] ) ,
546
+ // UI joins project & language/intern names with dash
547
+ // Remove it from search if users type it
548
+ normalizeInput : ( v ) => v . replaceAll ( / - / g, '' ) ,
549
+ // Treat each word as a separate search term
550
+ // Each word could point to a different node
551
+ // i.e. "project - language"
552
+ separateQueryForEachWord : true ,
553
+ minScore : 0.9 ,
554
+ } ) ,
529
555
projectId : filter . pathExists ( ( id ) => [
530
556
node ( 'node' ) ,
531
557
relation ( 'in' , '' , 'engagement' ) ,
@@ -658,3 +684,22 @@ const multiPropsAsSortString = (props: string[]) =>
658
684
' + ' ,
659
685
props . map ( ( prop ) => `coalesce(${ prop } .value, "")` ) ,
660
686
) + ' as sortValue' ;
687
+
688
+ const NameIndex = FullTextIndex ( {
689
+ indexName : 'EngagementName' ,
690
+ labels : [ 'ProjectName' , 'LanguageName' , 'LanguageDisplayName' , 'UserName' ] ,
691
+ properties : 'value' ,
692
+ analyzer : 'standard-folding' ,
693
+ } ) ;
694
+ const LanguageNameIndex = FullTextIndex ( {
695
+ indexName : 'LanguageEngagementName' ,
696
+ labels : [ 'ProjectName' , 'LanguageName' , 'LanguageDisplayName' ] ,
697
+ properties : 'value' ,
698
+ analyzer : 'standard-folding' ,
699
+ } ) ;
700
+ const InternshipNameIndex = FullTextIndex ( {
701
+ indexName : 'InternshipEngagementName' ,
702
+ labels : [ 'ProjectName' , 'UserName' ] ,
703
+ properties : 'value' ,
704
+ analyzer : 'standard-folding' ,
705
+ } ) ;
0 commit comments