diff --git a/samples/StreamDocuments.java b/samples/StreamDocuments.java new file mode 100644 index 00000000..38963c84 --- /dev/null +++ b/samples/StreamDocuments.java @@ -0,0 +1,34 @@ +import com.coveo.pushapiclient.*; +import com.coveo.pushapiclient.exceptions.NoOpenStreamException; + +import java.io.IOException; +import java.util.HashMap; + +public class StreamDocuments { + + public static void main(String[] args) throws IOException, InterruptedException, NoOpenStreamException { + + PlatformUrl platformUrl = new PlatformUrlBuilder().withEnvironment(Environment.PRODUCTION).withRegion(Region.US).build(); + CatalogSource catalogSource = CatalogSource.fromPlatformUrl("my_api_key","my_org_id","my_source_id", platformUrl); + + StreamService streamService = new StreamService(catalogSource); + + DocumentBuilder document1 = new DocumentBuilder("https://my.document.uri", "My document title") + .withData("these words will be searchable") + .withAuthor("bob") + .withClickableUri("https://my.document.click.com") + .withFileExtension(".html") + .withMetadata(new HashMap<>() {{ + put("tags", new String[]{"the_first_tag", "the_second_tag"}); + put("version", 1); + put("somekey", "somevalue"); + }}); + + streamService.add(document1); + + DocumentBuilder document2 = new DocumentBuilder("https://my.document2.uri", "My document2 title"); + streamService.add(document2); + + streamService.close(); + } +} diff --git a/src/main/java/com/coveo/pushapiclient/StreamService.java b/src/main/java/com/coveo/pushapiclient/StreamService.java index 51ec841b..b583f6ce 100644 --- a/src/main/java/com/coveo/pushapiclient/StreamService.java +++ b/src/main/java/com/coveo/pushapiclient/StreamService.java @@ -62,7 +62,7 @@ public StreamService(StreamEnabledSource source) { * * *
- * For more code samples, visit Stream data to your catalog source + * For more code samples, @see `samples/StreamDocuments.java` * * @param document The documentBuilder to add to your source * @throws InterruptedException