Skip to content

Commit

Permalink
Improve samples
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbrooke committed Sep 18, 2023
1 parent a30128c commit 1a19335
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion samples/DeleteOneDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

public class DeleteOneDocument {
public static void main(String[] args) {
PushSource source = new PushSource("my_api_key", "my_org_id");
URL sourceUrl = new URL("https://api.cloud.coveo.com/push/v1/organizations/org_id/sources/source_id");
PushSource source = new PushSource("my_api_key", sourceUrl);
String documentId = "https://my.document.uri";
Boolean deleteChildren = true;

Expand Down
6 changes: 4 additions & 2 deletions samples/PushOneDocument.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import com.coveo.pushapiclient.BackoffOptionsBuilder;
import com.coveo.pushapiclient.DocumentBuilder;
import com.coveo.pushapiclient.PushSource;
import com.coveo.pushapiclient.PlatformUrlBuilder;

import java.io.IOException;
import java.net.http.HttpResponse;

public class PushOneDocument {
public static void main(String[] args) {
PushSource source = new PushSource("my_api_key", "my_org_id", new BackoffOptionsBuilder().withMaxRetries(5).withRetryAfter(10000).build());
PushSource source = PushSource.fromPlatformUrl("my_api_key", "my_org_id", "my_source_id");

DocumentBuilder documentBuilder = new DocumentBuilder("https://my.document.uri", "My document title")
.withData("these words will be searchable");

try {
HttpResponse<String> response = source.addOrUpdateDocument("my_source_id", documentBuilder);
HttpResponse<String> response = source.addOrUpdateDocument(documentBuilder);
System.out.println(String.format("Push document status: %s", response.statusCode()));
System.out.println(String.format("Push document response: %s", response.body()));
} catch (IOException e) {
Expand Down
3 changes: 2 additions & 1 deletion samples/PushOneDocumentWithMetadata.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.coveo.pushapiclient.BackoffOptions;
import com.coveo.pushapiclient.BackoffOptionsBuilder;
import com.coveo.pushapiclient.DocumentBuilder;
import com.coveo.pushapiclient.PlatformUrlBuilder;
import com.coveo.pushapiclient.PushSource;

import java.io.IOException;
Expand All @@ -9,7 +10,7 @@

public class PushOneDocumentWithMetadata {
public static void main(String[] args) {
PushSource source = new PushSource("my_api_key", "my_org_id", new BackoffOptionsBuilder().withTimeMultiple(1).build());
PushSource source = PushSource.fromPlatformUrl("my_api_key", "my_org_id", "my_source_id", new PlatformUrlBuilder().build(), new BackoffOptionsBuilder().withTimeMultiple(1).build());
DocumentBuilder documentBuilder = new DocumentBuilder("https://my.document.uri", "My document title")
.withData("these words will be searchable")
.withAuthor("bob")
Expand Down

0 comments on commit 1a19335

Please sign in to comment.