How to Connect to Elasticsearch

Connecting to Elasticsearch may require to import first the Server HTTPS certificate into the Java carcerts file. During our tests we runned Elasticsearch in a docker container called elasticsearch created using:

docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -it

Install the HTTPS Server Certificate in Java

Check the Java Location

Check the Java location in DbSchema in the Help / About Dialog.

Open a Command Line

Open a command line and change the folder to the Java location above \lib\security. A file named carcerts should exists in that folder.

Copy the HTTPS Certificate from Docker Container

Copy the http_ca.crt file from the Elasticsearch server in the current folder.

If you are using docker containers, copy it from the docker image using :

docker cp elasticsearch:/usr/share/elasticsearch/config/certs/http_ca.crt .

Import the Certificate

Import the certificate in the Java carcerts using this command:

..\..\bin\keytool -import -trustcacerts -keystore cacerts -storepass changeit -noprompt -alias elasticsearch -file http_ca.crt

Connect using DbSchema

Connecting using DbSchema usually require the elasticsearch password. When using docker containers, this is printed out when first creating the docker container.

How to connect to Elasticsearch

You can also choose to edit the JDBC URL and enter parameters like in the Elasticsearch documentation.

Connect to Elasticsearch using URL

The typical URL for HTTPS connections is:


Useful Elasticsearch Commands

To create an index in Elasticsearch, I used:

curl -k --user "elastic:iSSBS=-sjfdjEqmIvpfZ" -H "Content-Type: application/json"  -XPUT "https://localhost:9200/testindex?pretty" -d "{\"settings\" : {\"index\" : {\"number_of_shards\" : 3, \"number_of_replicas\" : 0 }}}"

To save a document, use

curl -k -H "Content-Type: application/json" --user "elastic:iSSBS=-sjfdjEqmIvpfZ" -XPOST "https://localhost:9200/testindex/_doc"  -d"{\"timestamp\": \"2018-01-24 13:34:56\",\"message\": \"User Clicked Button\",\"user_id\": 4,\"admin\": false}"

To list the indexes:

curl -k --user "elastic:iSSBS=-sjfdjEqmIvpfZ" "https://localhost:9200/_cat/indices"

Your Feedback

Please help us to improve the Elasticsearch support by writing us your feedback, using Help / Technical Support from the DbSchema menu.