Get data from Elasticsearch by id using http

InstructorWill Button

Share this video with your friends

Send Tweet

Elasticsearch provides a powerful API over http for accessing its features. In this lesson, you will be introduced to the API and learn how to use it to get data from Elasticsearch using the browser and the popular command curl. We will see how adding query stream parameters can exclude or include the properties that we desire from our data.

Setup is specified in the README.md of the repository linked below.

Nikos Tsirakis
~ 7 years ago

Hello just an FYI, anyone that is using latest version of elastic he will need to update the npm packages as well.

EddiG
~ 7 years ago

Hi! If you run the elasticsearch and kibana in the docker container you may have a trouble with importing data: http://elasticsearch:9200/_bulk => getaddrinfo ENOTFOUND elasticsearch elasticsearch:9200. The solution for me was to change the ESCLUSTER constant in the utils/import.js to http://localhost:9200

Jessica Dembe
~ 6 years ago

Hello just an FYI, anyone that is using latest version of elastic he will need to update the npm packages as well.

As of 12/15/18, 14.2.0 worked for me.

Israel M
~ 6 years ago

I have been struggling to make the elastic search images with docker-compose... anyways I am on Ubuntu 18.04 and the examples showed here are meant to work with elastic search 5 so if you use elastic search 6 the import.js wont work you need to specify the API version to match your elastic search version.

the following will work if you have docker installed:

$ docker network create elastic

then run docker: $ docker run -d --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:5.6.14

in actions/import.js update the api version to 5.6.

I hope this helps someone else.

Daniel Kukula
~ 5 years ago

diff --git a/package.json b/package.json index c79b341..64f25c5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "dependencies": { "csvtojson": "^1.1.0",

  • "elasticsearch": "^12.1.3"
  • "elasticsearch": "^15.4.1" }, "devDependencies": {}, "scripts": { diff --git a/utils/import.js b/utils/import.js index 548e8ce..4d575b3 100644 --- a/utils/import.js +++ b/utils/import.js @@ -9,7 +9,7 @@ const TYPE = 'episode'; const BULK = []; const CLIENT = new ELASTICSEARCH.Client({ host: ESCLUSTER,
  • apiVersion: '5.0'
  • apiVersion: '5.6' });
Daniel Kukula
~ 5 years ago

Can't edit previous comment - change "elasticsearch": "^15.4.1" in pacage json and apiVersion: '5.6' in imports.js if you have problems

vj-raghavan
~ 5 years ago

All,

If you are stuck getting the GitHub repo to work with latest version of docker and Elastic Search etc. I have created a repo where I have updated dependencies and update docker references to the latest version and got it working.

https://github.com/vj-raghavan/elasticsearch-samples