PLEASE NOTE:
We are working on updating this book for the latest version. Some content might be out of date.
We are working on updating this book for the latest version. Some content might be out of date.
Retrieving a Documentedit
Now that we have some data stored in Elasticsearch, we can get to work on the business requirements for this application. The first requirement is the ability to retrieve individual employee data.
This is easy in Elasticsearch. We simply execute
an HTTP GET
request and
specify the address of the document—the index, type, and ID.
Using
those three pieces of information, we can return the original JSON document:
GET /megacorp/employee/1
And the response contains some metadata about the document, and John Smith’s
original JSON document as the _source
field:
{ "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_version" : 1, "found" : true, "_source" : { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests": [ "sports", "music" ] } }