Getting a document
After having indexed a document, during your application life it must probably be retrieved.
The GET REST call allows getting a document in real time without the need for a refresh operation.
Getting ready
You need a working ElasticSearch cluster and the indexed document from the Indexing a document recipe.
How to do it...
The GET method allows returning a document given its index, type, and ID.
The REST API URL is as follows:
http://<server>/<index_name>/<type_name>/<id>
For getting a document, we need to perform the following steps:
If we consider the document, which we had indexed in the previous recipe, the call will be as follows:
curl –XGET http://localhost:9200/myindex/order/2qLrAfPVQvCRMe7Ku8r0Tw?pretty=true
The result returned by ElasticSearch should be the indexed document and it should be as follows:
{ "_index":"myindex","_type":"order","_id":"2qLrAfPVQvCRMe7Ku8r0Tw","_version":1,"exists":true, "_source" : { "id" : "1234", "date" : "2013...