Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get last document from index in Elasticsearch

I’m playing around the package github.com/olivere/elastic; all works fine, but I’ve a question: is it possible to get the last N inserted documents?
The From statement has 0 as default starting point for the Search action and I didn’t understand if is possible to omit it in search.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Tldr;

Although I am not aware of a feature in elasticsearch api to retrieve the latest inserted documents.

There is a way to achieve something alike if you store the ingest time of the documents.

Then you can sort on the ingest time, and retrieve the top N documents.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading