# Elasticsearch Search Query returning only 10 hits

**URL:** https://discuss.elastic.co/t/elasticsearch-search-query-returning-only-10-hits/319670
**Category:** Elasticsearch
**Tags:** painless
**Created:** [November 23, 2022, 2:38pm UTC](https://discuss.elastic.co/t/elasticsearch-search-query-returning-only-10-hits/319670 "2022-11-23T14:38:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ankita\_Pachauri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankita_pachauri/32/61469_2.png) [@Ankita\_Pachauri](https://discuss.elastic.co/u/Ankita_Pachauri)
#### Post date: [November 23, 2022, 2:38pm UTC](https://discuss.elastic.co/t/elasticsearch-search-query-returning-only-10-hits/319670/1 "2022-11-23T14:38:46Z")

</div>

Hi Team,  
I have a search query which is extracting the data from metricbeat index and the output shows me the same hits as the size mentioned in the query. However, if i apply painless script to transform the data, it is only returning 10 hits. How can i get the more hits.

My query is as follows:

```auto
> {
> "size": 0,
> "query": {
> "bool": {
> "must": [
> {
> "range": {
> "@timestamp": {
> "gte": "now-3m",
> "lte": "now"
> }
> }
> }
> ]
> }
> },
> "aggregations": {
> "bucketAgg": {
> "terms": {
> "field": "agent.hostname.keyword",
> "size": 500,
> "order": {
> "metricAgg": "desc"
> }
> },
> "aggregations": {
> "metricAgg": {
> "avg": {
> "field": "system.load.1"
> }
> },
> "Account": {
> "terms": {
> "field": "cloud.account.id.keyword",
> "size": 500
> }
> },
> "ID": {
> "terms": {
> "field": "cloud.instance.id.keyword",
> "size": 500
> }
> },
> "Region": {
> "terms": {
> "field": "cloud.region.keyword",
> "size": 500
> }
> },
> "Time": {
> "terms": {
> "field": "@timestamp",
> "size": 500
> }
> }
> }
> }
> }
> }

```

Blockquote

And the transform is:

`> def hosts=data.mysearch.aggregations.bucketAgg.buckets; return hosts.stream().filter(h->{ def cpu_usage=h.metricAgg.value; return cpu_usage>0; }).map(h->{def cpu_usage=h.metricAgg.value; def cpu_usage_round=BigDecimal.valueOf(cpu_usage*1).setScale(2, RoundingMode.HALF_EVEN); def acc=h.Account.buckets[0].key; def reg=h.Region.buckets[0].key; def id=h.ID.buckets[0].key; def date=h.Time.buckets[0].key_as_string; return['host': h.key, 'cpu_usage': cpu_usage*1, 'cpu_usage_round': cpu_usage_round, 'acc': acc, 'reg': reg, 'date': date, 'id': id];}).collect(Collectors.toList());`

Can you please suggest after applying the transform how can i achieve more than 10 records?

//Ankita

---

<div class="post-metadata">

### Author: ![Ankita\_Pachauri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankita_pachauri/32/61469_2.png) [@Ankita\_Pachauri](https://discuss.elastic.co/u/Ankita_Pachauri)
#### Post date: [November 26, 2022, 10:32am UTC](https://discuss.elastic.co/t/elasticsearch-search-query-returning-only-10-hits/319670/2 "2022-11-26T10:32:23Z")

</div>

Hi Team,

Anyone?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 24, 2022, 10:32am UTC](https://discuss.elastic.co/t/elasticsearch-search-query-returning-only-10-hits/319670/3 "2022-12-24T10:32:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
