Home > Blockchain >  Get last document from index in Elasticsearch
Get last document from index in Elasticsearch

Time:11-12

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.

CodePudding user response:

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.

  • Related