@@ -542,14 +542,18 @@ describe("QdrantVectorStore", () => {
542542 } )
543543 expect ( mockQdrantClientInstance . deleteCollection ) . not . toHaveBeenCalled ( )
544544
545- // Verify payload index creation
545+ // Verify payload index creation - 'type' field first, then pathSegments
546+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
547+ field_name : "type" ,
548+ field_schema : "keyword" ,
549+ } )
546550 for ( let i = 0 ; i <= 4 ; i ++ ) {
547551 expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
548552 field_name : `pathSegments.${ i } ` ,
549553 field_schema : "keyword" ,
550554 } )
551555 }
552- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
556+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
553557 } )
554558 it ( "should not create a new collection if one exists with matching vectorSize and return false" , async ( ) => {
555559 // Mock getCollection to return existing collection info with matching vector size
@@ -572,14 +576,18 @@ describe("QdrantVectorStore", () => {
572576 expect ( mockQdrantClientInstance . createCollection ) . not . toHaveBeenCalled ( )
573577 expect ( mockQdrantClientInstance . deleteCollection ) . not . toHaveBeenCalled ( )
574578
575- // Verify payload index creation still happens
579+ // Verify payload index creation still happens - 'type' field first, then pathSegments
580+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
581+ field_name : "type" ,
582+ field_schema : "keyword" ,
583+ } )
576584 for ( let i = 0 ; i <= 4 ; i ++ ) {
577585 expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
578586 field_name : `pathSegments.${ i } ` ,
579587 field_schema : "keyword" ,
580588 } )
581589 }
582- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
590+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
583591 } )
584592 it ( "should recreate collection if it exists but vectorSize mismatches and return true" , async ( ) => {
585593 const differentVectorSize = 768
@@ -625,14 +633,18 @@ describe("QdrantVectorStore", () => {
625633 } ,
626634 } )
627635
628- // Verify payload index creation
636+ // Verify payload index creation - 'type' field first, then pathSegments
637+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
638+ field_name : "type" ,
639+ field_schema : "keyword" ,
640+ } )
629641 for ( let i = 0 ; i <= 4 ; i ++ ) {
630642 expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledWith ( expectedCollectionName , {
631643 field_name : `pathSegments.${ i } ` ,
632644 field_schema : "keyword" ,
633645 } )
634646 }
635- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
647+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
636648 ; ( console . warn as any ) . mockRestore ( ) // Restore console.warn
637649 } )
638650 it ( "should log warning for non-404 errors but still create collection" , async ( ) => {
@@ -646,7 +658,7 @@ describe("QdrantVectorStore", () => {
646658 expect ( mockQdrantClientInstance . getCollection ) . toHaveBeenCalledTimes ( 1 )
647659 expect ( mockQdrantClientInstance . createCollection ) . toHaveBeenCalledTimes ( 1 )
648660 expect ( mockQdrantClientInstance . deleteCollection ) . not . toHaveBeenCalled ( )
649- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
661+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
650662 expect ( console . warn ) . toHaveBeenCalledWith (
651663 expect . stringContaining ( `Warning during getCollectionInfo for "${ expectedCollectionName } "` ) ,
652664 genericError . message ,
@@ -693,11 +705,16 @@ describe("QdrantVectorStore", () => {
693705 expect ( result ) . toBe ( true )
694706 expect ( mockQdrantClientInstance . createCollection ) . toHaveBeenCalledTimes ( 1 )
695707
696- // Verify all payload index creations were attempted
697- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
708+ // Verify all payload index creations were attempted (6: type + 5 pathSegments)
709+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
698710
699- // Verify warnings were logged for each failed index
700- expect ( console . warn ) . toHaveBeenCalledTimes ( 5 )
711+ // Verify warnings were logged for each failed index (now 6)
712+ expect ( console . warn ) . toHaveBeenCalledTimes ( 6 )
713+ // Verify warning for 'type' index
714+ expect ( console . warn ) . toHaveBeenCalledWith (
715+ expect . stringContaining ( `Could not create payload index for type` ) ,
716+ indexError . message ,
717+ )
701718 for ( let i = 0 ; i <= 4 ; i ++ ) {
702719 expect ( console . warn ) . toHaveBeenCalledWith (
703720 expect . stringContaining ( `Could not create payload index for pathSegments.${ i } ` ) ,
@@ -826,7 +843,7 @@ describe("QdrantVectorStore", () => {
826843 expect ( mockQdrantClientInstance . getCollection ) . toHaveBeenCalledTimes ( 2 )
827844 expect ( mockQdrantClientInstance . deleteCollection ) . toHaveBeenCalledTimes ( 1 )
828845 expect ( mockQdrantClientInstance . createCollection ) . toHaveBeenCalledTimes ( 1 )
829- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
846+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
830847 ; ( console . warn as any ) . mockRestore ( )
831848 } )
832849
@@ -923,7 +940,7 @@ describe("QdrantVectorStore", () => {
923940 on_disk : true ,
924941 } ,
925942 } )
926- expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 5 )
943+ expect ( mockQdrantClientInstance . createPayloadIndex ) . toHaveBeenCalledTimes ( 6 )
927944 ; ( console . warn as any ) . mockRestore ( )
928945 } )
929946
0 commit comments