Connect to OpenSearch Using cURL
In this example, we will use curl command to communicate with the OpenSearch cluster.
Prerequisites
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.
Examples
- 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.
1curl -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).
12345curl -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.
1curl -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
By Instaclustr Support
Need Support?
Experiencing difficulties on the website or console?
Already have an account?
Need help with your cluster?
Contact Support
Why sign up?