@@ -26,6 +26,7 @@ public sealed class VectorStoreWriter<T> : IngestionChunkWriter<T>
2626 private readonly VectorStore _vectorStore ;
2727 private readonly int _dimensionCount ;
2828 private readonly VectorStoreWriterOptions _options ;
29+ private readonly bool _keysAreStrings ;
2930
3031 private VectorStoreCollection < object , Dictionary < string , object ? > > ? _vectorStoreCollection ;
3132
@@ -42,6 +43,12 @@ public VectorStoreWriter(VectorStore vectorStore, int dimensionCount, VectorStor
4243 _vectorStore = Throw . IfNull ( vectorStore ) ;
4344 _dimensionCount = Throw . IfLessThanOrEqual ( dimensionCount , 0 ) ;
4445 _options = options ?? new VectorStoreWriterOptions ( ) ;
46+
47+ // Not all vector store support string as the key type, examples:
48+ // Qdrant: https://github.com/microsoft/semantic-kernel/blob/28ea2f4df872e8fd03ef0792ebc9e1989b4be0ee/dotnet/src/VectorData/Qdrant/QdrantCollection.cs#L104
49+ // When https://github.com/microsoft/semantic-kernel/issues/13141 gets released,
50+ // we need to remove this workaround.
51+ _keysAreStrings = vectorStore . GetType ( ) . Name != "QdrantVectorStore" ;
4552 }
4653
4754 /// <summary>
@@ -78,7 +85,7 @@ public override async Task WriteAsync(IAsyncEnumerable<IngestionChunk<T>> chunks
7885 var key = Guid . NewGuid ( ) ;
7986 Dictionary < string , object ? > record = new ( )
8087 {
81- [ KeyName ] = key ,
88+ [ KeyName ] = _keysAreStrings ? key . ToString ( ) : key ,
8289 [ ContentName ] = chunk . Content ,
8390 [ EmbeddingName ] = chunk . Content ,
8491 [ ContextName ] = chunk . Context ,
@@ -122,7 +129,7 @@ private VectorStoreCollectionDefinition GetVectorStoreRecordDefinition(Ingestion
122129 {
123130 Properties =
124131 {
125- new VectorStoreKeyProperty ( KeyName , typeof ( Guid ) ) ,
132+ new VectorStoreKeyProperty ( KeyName , _keysAreStrings ? typeof ( string ) : typeof ( Guid ) ) ,
126133
127134 // By using T as the type here we allow the vector store
128135 // to handle the conversion from T to the actual vector type it supports.
0 commit comments