Skip to content

Commit b5f2f12

Browse files
committed
fix: add keyword index for type field to fix Qdrant codebase_search error
Fixes #8963 The codebase_search tool was failing with a "Index required but not found for type" error when using Qdrant. This was because the search() method filters by the type field to exclude metadata points, but no keyword index was created for this field. Added creation of a keyword index for the type field in the _createPayloadIndexes() method to enable proper filtering of metadata points during search operations.
1 parent eb68c65 commit b5f2f12

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ export class QdrantVectorStore implements IVectorStore {
296296
* Creates payload indexes for the collection, handling errors gracefully.
297297
*/
298298
private async _createPayloadIndexes(): Promise<void> {
299+
// Create index for the 'type' field to enable metadata filtering
300+
try {
301+
await this.client.createPayloadIndex(this.collectionName, {
302+
field_name: "type",
303+
field_schema: "keyword",
304+
})
305+
} catch (indexError: any) {
306+
const errorMessage = (indexError?.message || "").toLowerCase()
307+
if (!errorMessage.includes("already exists")) {
308+
console.warn(
309+
`[QdrantVectorStore] Could not create payload index for type on ${this.collectionName}. Details:`,
310+
indexError?.message || indexError,
311+
)
312+
}
313+
}
314+
315+
// Create indexes for pathSegments fields
299316
for (let i = 0; i <= 4; i++) {
300317
try {
301318
await this.client.createPayloadIndex(this.collectionName, {

0 commit comments

Comments
 (0)