@@ -26,25 +26,22 @@ You can build it locally and install it in your local repository.
2626
2727## 📋 Table Of Content
2828
29- 1 . Installation
30- 1 . Prerequisites
31- 2 . Packaging
32- 2 . QuickStart with Astra DB
33- 1 . Sign up for Astra DB
34- 2 . Create a Database
35- 3 . Get your credentials
36- 4 . Create a new project and add the dependency
37- 3 . QuickStart with DSE
38- 1 . Start Data Api.
39- 2 . Connection to DSE
40- 3 . Create a namespace
41- 4 . Create a collection
42- 4 . QuickStart with HCD
43- 1 . Start Data Api.
44- 2 . Connection to HCD
45- 3 . Create a namespace
46- 4 . Create a collection
47-
29+ 1 . [ Installation] ( #1-installation )
30+ 1 . [ Prerequisites] ( #11-prerequisites )
31+ 2 . [ Packaging] ( #12-packaging )
32+ 2 . [ QuickStart with Astra DB] ( #2-quickstart-with-astra-db )
33+ 1 . [ Sign up for Astra DB] ( #21-sign-up-for-astra-db )
34+ 2 . [ Create a Database] ( #22-create-a-database )
35+ 3 . [ Get your credentials] ( #23-get-your-credentials )
36+ 4 . [ Create a new project and add the dependency] ( #24-create-a-new-project-and-add-the-dependency )
37+ 3 . [ QuickStart with Local Instances] ( )
38+ 1 . [ Start Data Api with DSE] ( #31-start-data-api-with-dse )
39+ 2 . [ Start Data Api with HCD] ( #32-start-data-api-with-hcd )
40+ 3 . [ Datq Api Information] ( #33-datq-api-information )
41+ 4 . [ Using Java client with Local Instance] ( #34-using-java-client-with-local-instance )
42+ 4 . [ What's Next] ( #4-whats-next )
43+
44+
4845## 1. Installation
4946
5047### 1.1 Prerequisites
@@ -137,7 +134,7 @@ Add the following dependency to your `pom.xml` file:
137134<dependency >
138135 <groupId >com.datastax.astra</groupId >
139136 <artifactId >astra-db-java</artifactId >
140- <version >1.1 .0</version >
137+ <version >1.3 .0</version >
141138</dependency >
142139```
143140
@@ -183,22 +180,30 @@ public class GettingStarted {
183180}
184181```
185182
186- ## 3. QuickStart with Local Instance
183+ ## 3. QuickStart with Local Instances
187184
188- ### 3.1. Start Data Api.
185+ ### 3.1. Start Data Api with DSE
189186
190187- Start the 2 containers with the following command:
191188
192189``` console
193190docker-compose up -d
194191```
195192
193+ ### 3.2. Start Data Api with HCD
194+
195+ ```
196+ docker-compose -f docker-compose-hcd.yml up -d
197+ ```
198+
196199- Check the status of the containers with the following command:
197200
198201``` console
199202docker-compose ps
200203```
201204
205+ ### 3.3. Datq Api Information
206+
202207> _ Output_
203208> ``` console
204209> NAME IMAGE COMMAND
@@ -239,27 +244,41 @@ curl -X 'POST' \
239244}'
240245```
241246
242- ### 3.2 . Using Java client with local instance
247+ ### 3.4 . Using Java client with Local Instance
243248
244249``` java
245250public class QuickStartLocal {
246251
247252 public static void main (String [] args ) {
248253
249254 // Create a token
250- String token = new TokenProviderStargateV2 (" cassandra" , " cassandra" ). getToken();
255+ String token = new UsernamePasswordTokenProvider (" cassandra" , " cassandra" ). getToken();
251256 System . out. println(" Token: " + token);
252257
253258 // Initialize the client
254259 DataAPIClient client = new DataAPIClient (token, builder(). withDestination(CASSANDRA ). build());
255260 System . out. println(" Connected to Data API" );
256261
262+ // Create a default keyspace
263+ ((DataAPIDatabaseAdmin ) client
264+ .getDatabase(dataApiUrl)
265+ .getDatabaseAdmin()). createNamespace(keyspaceName, NamespaceOptions . simpleStrategy(1 ));
266+ System . out. println(" Keyspace created " );
267+
257268 Database db = client. getDatabase(" http://localhost:8181" , " default_keyspace" );
258269 System . out. println(" Connected to Database" );
259270
260271 // Create a collection. The default similarity metric is cosine.
261- Collection<Document > collection = db. createCollection(" vector_test" , 5 , COSINE );
262- System . out. println(" Created a Collection" );
272+ Collection<Document > collection = db. createCollection(" simple" , 5 , COSINE );
273+ System . out. println(" Created a Collection simple" );
274+
275+ // Create a collection with Vector embeddings OPEN AI
276+ Collection<Document > collectionLyrics = db. createCollection(" vector" , CollectionOptions . builder()
277+ .vectorSimilarity(SimilarityMetric . COSINE )
278+ .vectorDimension(1536 )
279+ .vectorize(" openai" , " text-embedding-3-small" )
280+ .build(),
281+ new CommandOptions<> (). embeddingAPIKey(" sk-....." ));
263282 }
264283}
265284```
0 commit comments