# Elasticsearch API request

**URL:** https://discuss.elastic.co/t/elasticsearch-api-request/385892
**Category:** Elasticsearch
**Created:** [April 15, 2026, 5:51am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892 "2026-04-15T05:51:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Cdotisp\_Delhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cdotisp_delhi/32/143888_2.png) [@Cdotisp\_Delhi](https://discuss.elastic.co/u/Cdotisp_Delhi)
#### Post date: [April 15, 2026, 5:51am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/1 "2026-04-15T05:51:02Z")

</div>

GET /lb-2026.04/\_search  
{  
"size": 10000,  
"aggs": {  
"last\_entry": {  
"max": {  
"field": "@timestamp"  
}  
}  
}  
}

I want to retrieve all latest timestamp documents from Index lb-2026.04 but number of documents are exceeding from 10K they are approximately 15K. Is there a way to achieve this in a single request??

---

<div class="post-metadata">

### Author: ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)
#### Post date: [April 15, 2026, 6:43am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/3 "2026-04-15T06:43:28Z")

</div>

Welcome to the forum @Cdotisp_Delhi !!

I replied too quickly, not reading the question carefully. Sorry for this.

Your question's wording is slightly ambiguous:

> [@Cdotisp\_Delhi](#):
>
> I want to retrieve all latest timestamp documents

Are you saying you have maybe 15K documents all with the same "max" value of `@timestamp` from the index? That wasn't my first reading, seems unlikely, but maybe that is what you want?

And please note the size parameter is **not** relevant to the max aggregation you included, the max aggregation is applied to all matching documents anyways, in your case all documents in the index.

If you want just more results returned, the simplest way is to use `index.max_result_window`, increasing from default 10,000.

```auto
PUT lb-2026.04/_settings
{
"index.max_result_window": 20000
}

```

then you can query that index with size parameter up to 20000. But the default is 10K for a reason, please don't increase too much without some thought.

So also ask yourself if you really need _all_ the results in one request? What if result set is not 15K, rather 150K or 1.5M results?

The official [docs](https://www.elastic.co/docs/reference/elasticsearch/index-settings/index-modules) suggest the more correct solution would be to use scroll or search\_after, and get all docs in chunks. But if you just want a quick fix for today, increasing `index.max_result_window` is IMO easiest.

---

<div class="post-metadata">

### Author: ![Cdotisp\_Delhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cdotisp_delhi/32/143888_2.png) [@Cdotisp\_Delhi](https://discuss.elastic.co/u/Cdotisp_Delhi)
#### Post date: [April 15, 2026, 6:51am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/4 "2026-04-15T06:51:28Z")

</div>

> [@RainTown](#):
>
> ```auto
> PUT lb-2026.04/_settings
> {
> "index.max_result_window": 20000
> }
> 
> ```

Thanks a lot Kevin, it worked, Kudos to you!!! Humans are more dependable than AI.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 15, 2026, 7:58am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/5 "2026-04-15T07:58:06Z")

</div>

Hey

Glad you solved it but I'm reading again your question and I wanted to ask what do you mean by

> I want to retrieve all latest timestamp documents from Index lb-2026.04

Do you want to get the last 10 documents for example?

In which case, you just need to use [sort](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/sort-search-results):

```auto
GET /lb-2026.04/_search
{
  "sort" : [
    { "@timestamp" : {"order" : "desc"}
  ]
}

```

You can also get more documents with:

```auto
GET /lb-2026.04/_search
{
  "size": 100,
  "sort" : [
    { "@timestamp" : {"order" : "desc"}
  ]
}

```

Would that solve the question?

TBH: I don't like much modifying the `index.max_result_window` as it has [consequences](https://www.elastic.co/docs/reference/elasticsearch/index-settings/index-modules):

> The maximum value of `from + size` for searches to this index. Defaults to `10000` . **Search requests take heap memory and time proportional to `from + size` and this limits that memory**. See [Scroll](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/paginate-search-results#scroll-search-results) or [Search After](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/paginate-search-results#search-after) for a more efficient alternative to raising this.

---

<div class="post-metadata">

### Author: ![Cdotisp\_Delhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cdotisp_delhi/32/143888_2.png) [@Cdotisp\_Delhi](https://discuss.elastic.co/u/Cdotisp_Delhi)
#### Post date: [April 22, 2026, 6:00am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/6 "2026-04-22T06:00:09Z")

</div>

Lets say the last timestamp documents were fetched to elasticsearch index (lb-2026.04) was: Apr 21 06:43 after that no documents were fetched at all , then i want all the documents that are fetched at Apr 21 06:43 , they may be 2k or 5k or 10k or 15k, that was my question

---

<div class="post-metadata">

### Author: ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)
#### Post date: [April 22, 2026, 10:22am UTC](https://discuss.elastic.co/t/elasticsearch-api-request/385892/7 "2026-04-22T10:22:47Z")

</div>

If your timestamps are at per-minute granularity then that would be a little bit unusual, in my experience?

I see you accepted a previous answer, but for that requirement you probably need 2 calls

One aggregation call to get the max value, and then one query to find all docs matching that specific value. And if you really have no idea at all how many docs would match, then calls using the scroll or search\_after mechanisms would seem the best approach to me, rather than tweaking the max\_result\_window parameter.

You can also query all docs with returned docs sorted on @timestamp as per @dadoonet , and let client pick out those that match the value of the first doc returned, but a priori you won’t know how many that will be. If it’s more than current value of max\_result\_window you would need to make multiple calls anyway.
