diff --git a/examples/README.md b/examples/README.md index e5c8bc514..e28fe26b1 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2006,6 +2006,64 @@ System.out.println(response); // This example will fail if `getUserByName` index doesn't exist. To create the index, see [Create a new index on a database.](#postindex) ``` +## postIndexInfo + +_POST `/{db}/_index_info`_ + +### [Example request](snippets/postIndexInfo/example_request.java) + +[embedmd]:# (snippets/postIndexInfo/example_request.java) +```java +// section: code imports +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; +// section: code +Cloudant service = Cloudant.newInstance(); + +PostIndexInfoOptions indexInfoOptions = + new PostIndexInfoOptions.Builder() + .db("products") + .build(); + +IndexInfoResult response = + service.postIndexInfo(indexInfoOptions).execute() + .getResult(); + +System.out.println(response); +// section: markdown +// This example requires the `appliances` design document to exist with a Cloudant Search index. To create the design document, see [Create or modify a design document.](#putdesigndocument) +``` + +### [Example request with type and keys](snippets/postIndexInfo/example_request_with_type_and_keys.java) + +[embedmd]:# (snippets/postIndexInfo/example_request_with_type_and_keys.java) +```java +// section: code imports +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; + +import java.util.Arrays; +// section: code +Cloudant service = Cloudant.newInstance(); + +PostIndexInfoOptions indexInfoOptions = + new PostIndexInfoOptions.Builder() + .db("products") + .keys(Arrays.asList("_design/appliances")) + .type(Arrays.asList("search")) + .build(); + +IndexInfoResult response = + service.postIndexInfo(indexInfoOptions).execute() + .getResult(); + +System.out.println(response); +// section: markdown +// This example requires the `appliances` design document to exist with a Cloudant Search index. To create the design document, see [Create or modify a design document.](#putdesigndocument) +``` + ## deleteLocalDocument _DELETE `/{db}/_local/{doc_id}`_ diff --git a/examples/snippets/postIndexInfo/example_request.java b/examples/snippets/postIndexInfo/example_request.java new file mode 100644 index 000000000..a8afc9acc --- /dev/null +++ b/examples/snippets/postIndexInfo/example_request.java @@ -0,0 +1,19 @@ +// section: code imports +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; +// section: code +Cloudant service = Cloudant.newInstance(); + +PostIndexInfoOptions indexInfoOptions = + new PostIndexInfoOptions.Builder() + .db("products") + .build(); + +IndexInfoResult response = + service.postIndexInfo(indexInfoOptions).execute() + .getResult(); + +System.out.println(response); +// section: markdown +// This example requires the `appliances` design document to exist with a Cloudant Search index. To create the design document, see [Create or modify a design document.](#putdesigndocument) diff --git a/examples/snippets/postIndexInfo/example_request_with_type_and_keys.java b/examples/snippets/postIndexInfo/example_request_with_type_and_keys.java new file mode 100644 index 000000000..91ddcb83b --- /dev/null +++ b/examples/snippets/postIndexInfo/example_request_with_type_and_keys.java @@ -0,0 +1,23 @@ +// section: code imports +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; + +import java.util.Arrays; +// section: code +Cloudant service = Cloudant.newInstance(); + +PostIndexInfoOptions indexInfoOptions = + new PostIndexInfoOptions.Builder() + .db("products") + .keys(Arrays.asList("_design/appliances")) + .type(Arrays.asList("search")) + .build(); + +IndexInfoResult response = + service.postIndexInfo(indexInfoOptions).execute() + .getResult(); + +System.out.println(response); +// section: markdown +// This example requires the `appliances` design document to exist with a Cloudant Search index. To create the design document, see [Create or modify a design document.](#putdesigndocument)