In this example, we will use curl command to communicate with the OpenSearch cluster.
Before making a curl request to the cluster, you first need to add your Public IP to your cluster firewall rules. Please visit our support documentation page
on how to do this.
- The following command demonstrates how to verify that you can connect to the cluster. This should return a brief response containing the cluster name, version, and a few other details.
curl -u icopensearch:<Password> "https://xxx.xxx.xxx.xxx:9200"
- The following command demonstrates how to index a document (The index ‘testing’ will automatically be created if it does not exist).
curl -X PUT -u icopensearch:<Password> "https://xxx.xxx.xxx.xxx:9200/testing/_doc/1?pretty" -H 'Content-Type: application/json' -d'
"description" : "this is a test",
"timestamp" : "1970-01-01T00:00:01"
- The following command demonstrates how to retrieve the document indexed in the previous step.
curl -u icopensearch:<Password> "https://xxx.xxx.xxx.xxx:9200/testing/_doc/1?pretty"
Please note, these examples use the default icopensearch user. For security reasons, we recommend changing the password for the icopensearch user. In addition, we recommend creating a different user for use by your application, with more limited permissions. For more information, please see our support documentation page on OpenSearch Security Access Control