Curl and elasticSearch

One of the most useful utilities is “curl”. This wonderful tool can be used to transfer data from one platform to another. It is relatively easy to install in Windows, whereas under linux, it is often already installed. It must be run from the terminal in Linux or the command line in Windows. One example is transfer of data from a webserver. But other protocols can be used as well: ftp, file, pop3 etc.


An example is given below. One sees the command line that is used to invoke the curl utility. Curl is invoked by typing “curl”. The first parameter is the host that must be accessed. In this case I will access a webserver from which the data are retrieved. In this case, I will access, my own website. Doing so, I transfer the html that is generated from the webserver.



A similar statement can be user to retrieve data from a FTP server. Take as example: curl –user . This will open a FTP server.

We may use curl to add data into ElasticSearch. Doing so, we transfer data from a local platform to the ElasticSearch database. We use this command from the windows platform: curl -XPUT “”  -d”{“”title””:””TestTom”” , “”director””:””Tom van Maanen””,””year””: 1957}”. Note: from linux the aspostophes are different. There the command should be curl -XPUT ‘′  -d'{“title”:”TestTom” , “director”:”Tom van Maanen”,”year”: 1957}’. On windows, we see:


The reaction from ElasticSearch (“created”:true) indicates that the record is correctly inserted.


In a similar exercise, we may retrieve records from the ElasticSearch database. We use: curl -XGET “” -d “{“”query”” : {“”match”” : {“”title”” : “”TestTom””}}}”.


We get something like:



We see the same records that we inserted.