File tree Expand file tree Collapse file tree 1 file changed +12
-17
lines changed
astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Original file line number Diff line number Diff line change 88
99public class CreateCollection {
1010 public static void main (String [] args ) {
11- // Given an active db
1211 AstraDB db = new AstraDB ("<token>" , "<api_endpoint>" );
1312
14- /*
15- * Create collection with no vector.
16- */
13+ // Create a non-vector collection
1714 AstraDBCollection collection1 = db .createCollection ("collection_simple" );
1815
19- // Create collection with vector
16+ // Create a vector collection
2017 AstraDBCollection collection2 = db .createCollection (
21- "collection_vector1" ,
22- 14 ,
23- SimilarityMetric .cosine );
18+ "collection_vector1" ,
19+ 14 ,
20+ SimilarityMetric .cosine );
2421
25- // Create collection with vector ( builder)
22+ // Create a vector collection with a builder
2623 AstraDBCollection collection3 = db .createCollection (CollectionDefinition
27- .builder ()
28- .name ("collection_vector2" )
29- .vector (1536 , SimilarityMetric .euclidean )
30- .build ());
24+ .builder ()
25+ .name ("collection_vector2" )
26+ .vector (1536 , SimilarityMetric .euclidean )
27+ .build ());
3128
32- /*
33- * Collection name should follow [a-zA-Z][a-zA-Z0-9_]* pattern (snake case)
34- */
29+ // Collection names should use snake case ([a-zA-Z][a-zA-Z0-9_]*)
3530 try {
3631 db .createCollection ("invalid.name" );
3732 } catch (JsonApiException e ) {
38- // will fail
33+ // invalid.name is not valid
3934 }
4035 }
4136}
You can’t perform that action at this time.
0 commit comments