Skip to content

Commit 0f21a6a

Browse files
authored
Merge branch 'main' into feature/deepinfra-embedding-fix
2 parents e1d4f7b + d8af426 commit 0f21a6a

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

src/services/code-index/vector-store/__tests__/qdrant-client.spec.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/services/code-index/vector-store/qdrant-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class QdrantVectorStore implements IVectorStore {
330330
* Creates payload indexes for the collection, handling errors gracefully.
331331
*/
332332
private async _createPayloadIndexes(): Promise<void> {
333-
// Create index for the "type" field (used to filter out metadata documents)
333+
// Create index for the 'type' field to enable metadata filtering
334334
try {
335335
await this.client.createPayloadIndex(this.collectionName, {
336336
field_name: "type",
@@ -340,13 +340,13 @@ export class QdrantVectorStore implements IVectorStore {
340340
const errorMessage = (indexError?.message || "").toLowerCase()
341341
if (!errorMessage.includes("already exists")) {
342342
console.warn(
343-
`[QdrantVectorStore] Could not create payload index for 'type' on ${this.collectionName}. Details:`,
343+
`[QdrantVectorStore] Could not create payload index for type on ${this.collectionName}. Details:`,
344344
indexError?.message || indexError,
345345
)
346346
}
347347
}
348348

349-
// Create indexes for path segments (for directory filtering)
349+
// Create indexes for pathSegments fields
350350
for (let i = 0; i <= 4; i++) {
351351
try {
352352
await this.client.createPayloadIndex(this.collectionName, {

0 commit comments

Comments
 (0)