@@ -26,25 +26,22 @@ You can build it locally and install it in your local repository.
26
26
27
27
## 📋 Table Of Content
28
28
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
+
48
45
## 1. Installation
49
46
50
47
### 1.1 Prerequisites
@@ -137,7 +134,7 @@ Add the following dependency to your `pom.xml` file:
137
134
<dependency >
138
135
<groupId >com.datastax.astra</groupId >
139
136
<artifactId >astra-db-java</artifactId >
140
- <version >1.1 .0</version >
137
+ <version >1.3 .0</version >
141
138
</dependency >
142
139
```
143
140
@@ -183,22 +180,30 @@ public class GettingStarted {
183
180
}
184
181
```
185
182
186
- ## 3. QuickStart with Local Instance
183
+ ## 3. QuickStart with Local Instances
187
184
188
- ### 3.1. Start Data Api.
185
+ ### 3.1. Start Data Api with DSE
189
186
190
187
- Start the 2 containers with the following command:
191
188
192
189
``` console
193
190
docker-compose up -d
194
191
```
195
192
193
+ ### 3.2. Start Data Api with HCD
194
+
195
+ ```
196
+ docker-compose -f docker-compose-hcd.yml up -d
197
+ ```
198
+
196
199
- Check the status of the containers with the following command:
197
200
198
201
``` console
199
202
docker-compose ps
200
203
```
201
204
205
+ ### 3.3. Datq Api Information
206
+
202
207
> _ Output_
203
208
> ``` console
204
209
> NAME IMAGE COMMAND
@@ -239,27 +244,41 @@ curl -X 'POST' \
239
244
}'
240
245
```
241
246
242
- ### 3.2 . Using Java client with local instance
247
+ ### 3.4 . Using Java client with Local Instance
243
248
244
249
``` java
245
250
public class QuickStartLocal {
246
251
247
252
public static void main (String [] args ) {
248
253
249
254
// Create a token
250
- String token = new TokenProviderStargateV2 (" cassandra" , " cassandra" ). getToken();
255
+ String token = new UsernamePasswordTokenProvider (" cassandra" , " cassandra" ). getToken();
251
256
System . out. println(" Token: " + token);
252
257
253
258
// Initialize the client
254
259
DataAPIClient client = new DataAPIClient (token, builder(). withDestination(CASSANDRA ). build());
255
260
System . out. println(" Connected to Data API" );
256
261
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
+
257
268
Database db = client. getDatabase(" http://localhost:8181" , " default_keyspace" );
258
269
System . out. println(" Connected to Database" );
259
270
260
271
// 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-....." ));
263
282
}
264
283
}
265
284
```
0 commit comments