@@ -362,7 +362,7 @@ impl ChromaCollection {
362
362
#[ derive( Deserialize , Debug ) ]
363
363
pub struct GetResult {
364
364
pub ids : Vec < String > ,
365
- pub metadatas : Option < Vec < Option < Vec < Option < Metadata > > > > > ,
365
+ pub metadatas : Option < Vec < Option < Metadata > > > ,
366
366
pub documents : Option < Vec < Option < String > > > ,
367
367
pub embeddings : Option < Vec < Option < Embedding > > > ,
368
368
}
@@ -751,6 +751,55 @@ mod tests {
751
751
assert_eq ! ( get_all_result. ids. len( ) , collection. count( ) . await . unwrap( ) ) ;
752
752
}
753
753
754
+ #[ tokio:: test]
755
+ async fn test_get_all_metadatas_from_collection ( ) {
756
+ let client = ChromaClient :: new ( Default :: default ( ) ) ;
757
+
758
+ let collection = client
759
+ . await
760
+ . unwrap ( )
761
+ . get_or_create_collection ( TEST_COLLECTION , None )
762
+ . await
763
+ . unwrap ( ) ;
764
+
765
+ let test_metadatas = vec ! [
766
+ json!( { "key1" : "value1" } ) . as_object( ) . unwrap( ) . clone( ) ,
767
+ json!( { "key2" : "value2" } ) . as_object( ) . unwrap( ) . clone( ) ,
768
+ ] ;
769
+
770
+ let collection_entries = CollectionEntries {
771
+ ids : vec ! [ "test1" , "test2" ] ,
772
+ metadatas : Some ( test_metadatas) ,
773
+ documents : Some ( vec ! [ "Document content 1" , "Document content 2" ] ) ,
774
+ embeddings : None ,
775
+ } ;
776
+
777
+ let response = collection. add ( collection_entries, Some ( Box :: new ( MockEmbeddingProvider ) ) ) ;
778
+ assert ! ( response. await . is_ok( ) ) ;
779
+
780
+ let get_query = GetOptions {
781
+ ids : vec ! [ ] ,
782
+ where_metadata : None ,
783
+ limit : None ,
784
+ offset : None ,
785
+ where_document : None ,
786
+ include : Some ( vec ! [ "metadatas" . into( ) ] ) ,
787
+ } ;
788
+
789
+ let get_result = collection. get ( get_query) . await . unwrap ( ) ;
790
+
791
+ assert ! (
792
+ get_result. metadatas. is_some( ) ,
793
+ "Expected metadata to be present in the response"
794
+ ) ;
795
+
796
+ assert_eq ! (
797
+ get_result. metadatas. unwrap( ) . len( ) ,
798
+ 2 ,
799
+ "Expected two metadata entries in the response"
800
+ ) ;
801
+ }
802
+
754
803
#[ tokio:: test]
755
804
async fn test_update_collection ( ) {
756
805
let client = ChromaClient :: new ( Default :: default ( ) ) ;
0 commit comments