# How to use term aggregation with search and pagination?

**URL:** <https://discuss.elastic.co/t/how-to-use-term-aggregation-with-search-and-pagination/185636>\
**Category:** Elasticsearch\
**Created:** [June 13, 2019, 12:12pm UTC](https://discuss.elastic.co/t/how-to-use-term-aggregation-with-search-and-pagination/185636 "2019-06-13T12:12:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tushar\_chevulkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tushar_chevulkar/32/46270_2.png) [@tushar\_chevulkar](https://discuss.elastic.co/u/tushar_chevulkar)\
**Post date:** [June 13, 2019, 12:12pm UTC](https://discuss.elastic.co/t/how-to-use-term-aggregation-with-search-and-pagination/185636/1 "2019-06-13T12:12:18Z")

</div>

Is it possible to use pagination in term aggregation query with a search term?  
I need to paginate the result of the following query I am not able to find any solution ?

```
{
	"sort": [{
		"create_date": {
			"order": "desc"
		}
	}],
	"query": {
		"bool": {
			"must": []
		}
	},
	"aggs": {
		"genres": {
			"terms": {
				"field": "mentions.keyword",
				"include": "insta.*"
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [June 13, 2019, 1:35pm UTC](https://discuss.elastic.co/t/how-to-use-term-aggregation-with-search-and-pagination/185636/2 "2019-06-13T13:35:17Z")

</div>

You probably need the[composite aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html)

---

<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:** [July 11, 2019, 1:35pm UTC](https://discuss.elastic.co/t/how-to-use-term-aggregation-with-search-and-pagination/185636/3 "2019-07-11T13:35:20Z")

</div>

Closed on July 11, 2019, 1:35pm UTC

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