Skip to content

Commit 2894a1c

Browse files
committed
Add doc
1 parent f5a8286 commit 2894a1c

File tree

5 files changed

+53
-30
lines changed

5 files changed

+53
-30
lines changed

README.MD

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
193190
docker-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
199202
docker-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
245250
public 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
```

astra-db-java/src/main/java/com/datastax/astra/client/Collection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ public Page<T> findPage(Filter filter, FindOptions options) {
14641464

14651465
// load sortVector if available
14661466
float[] sortVector = null;
1467-
if (options.getIncludeSortVector() &&
1467+
if (options.getIncludeSortVector() != null &&
14681468
apiResponse.getStatus() != null &&
14691469
apiResponse.getStatus().get(SORT_VECTOR.getKeyword()) != null) {
14701470
sortVector = apiResponse.getStatus().get(SORT_VECTOR.getKeyword(), float[].class);

astra-db-java/src/main/java/com/datastax/astra/client/model/Page.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ public class Page<R> {
6464
/**
6565
* Default constructor.
6666
*
67-
* @param pageState String
67+
* @param pageState
68+
* page state with the offset of the page
6869
* @param results List
70+
* list of items for the page
71+
* @param sortVector float[]
72+
* the sort vector if asked.
6973
*/
7074
public Page(String pageState, List<R> results, float[] sortVector) {
7175
this.pageState = pageState;

astra-db-java/src/test/java/com/datastax/astra/test/integration/collection/AbstractCollectionITTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.datastax.astra.client.DataAPIClients;
55
import com.datastax.astra.client.Database;
66
import com.datastax.astra.client.admin.AstraDBAdmin;
7-
import com.datastax.astra.client.admin.DatabaseAdmin;
87
import com.datastax.astra.client.exception.TooManyDocumentsToCountException;
98
import com.datastax.astra.client.model.CollectionOptions;
109
import com.datastax.astra.client.model.Command;
@@ -25,7 +24,6 @@
2524
import com.datastax.astra.client.model.Update;
2625
import com.datastax.astra.client.model.UpdateResult;
2726
import com.datastax.astra.internal.api.ApiResponse;
28-
import com.datastax.astra.internal.command.LoggingCommandObserver;
2927
import com.datastax.astra.test.TestConstants;
3028
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
3129
import com.dtsx.astra.sdk.utils.AstraEnvironment;

astra-db-java/src/test/java/com/datastax/astra/test/integration/collection_vectorize/LocalVectorizeITTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import com.datastax.astra.client.Database;
55
import com.datastax.astra.client.model.EmbeddingProvider;
66
import lombok.extern.slf4j.Slf4j;
7+
import org.junit.jupiter.api.Disabled;
78
import org.junit.jupiter.api.Test;
89

910
import java.util.Map;
1011

1112
@Slf4j
13+
@Disabled
1214
public class LocalVectorizeITTest extends AbstractVectorizeITTest {
1315

1416
@Override

0 commit comments

Comments
 (0)