# Unresolved reference 'Aggregation, Size, TrackTotalHits, Pretty, Sort, and Do'

**URL:** <https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884>\
**Category:** Elasticsearch\
**Created:** [March 30, 2023, 5:39am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884 "2023-03-30T05:39:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![golofetuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/golofetuk/32/114272_2.png) [@golofetuk](https://discuss.elastic.co/u/golofetuk)\
**Post date:** [March 30, 2023, 5:39am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884/1 "2023-03-30T05:39:50Z")

</div>

I am trying to execute a search on the Elasticsearch client in Go [olivere/elastic](https://github.com/olivere/elastic), using the appropriate client library for Elasticsearch version 7.x. The expected behavior is to compile the code without errors and return a scrollable search result with the specified query, aggregation, size, track total hits, pretty, and sort options.

However, the actual behavior is producing an error message that suggests the methods Aggregation, Size, TrackTotalHits, Pretty, Sort, and Do are not recognized. This error message may indicate an issue with the syntax or reference of the Elasticsearch client methods.

Can anyone suggest steps to troubleshoot this issue and help me resolve the error? Additionally, please find below the code I am currently working with:

```go
searchResult, err := r.elasticClient.
    Scroll().
    Index(r.index).
    Query(query).
    Aggregation("agg", agg).
    Size(limit).
    TrackTotalHits(true).
    Pretty(true).
    Sort("startTime", true).
    Do(context.Background())

```

Thank you for your assistance!

Errors on my IDE:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f174cfa535dc03a074920d43ff2d3a995a03502.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 30, 2023, 6:00am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884/2 "2023-03-30T06:00:17Z")

</div>

Which version of Elasticsearch are you using?

Any particular reason you are not using [the official go client](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/overview.html)? If I look at the github repository for the client you are using it says it is deprecated:

> Deprecated: Use the official Elasticsearch client for Go at [GitHub - elastic/go-elasticsearch: The official Go client for Elasticsearch](https://github.com/elastic/go-elasticsearch)

---

<div class="post-metadata">

**Author:** ![golofetuk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/golofetuk/32/114272_2.png) [@golofetuk](https://discuss.elastic.co/u/golofetuk)\
**Post date:** [March 30, 2023, 6:22am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884/3 "2023-03-30T06:22:41Z")

</div>

I cannot switch that package, even the package that you mentioned doesn't have any doc about agg and scroll.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 30, 2023, 7:34am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884/4 "2023-03-30T07:34:24Z")

</div>

I do not use the go client, but it seems [it has support for scroll queries](https://github.com/elastic/go-elasticsearch/blob/main/esapi/api.scroll.go). In more recent versions it is recommended [to use search\_after with PIT](https://www.elastic.co/guide/en/elasticsearch/reference/8.6/paginate-search-results.html#scroll-search-results). Not sure how this is supported in the client.

For the client you are using you probably need to reach out to the creator.

---

<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:** [April 27, 2023, 7:34am UTC](https://discuss.elastic.co/t/unresolved-reference-aggregation-size-tracktotalhits-pretty-sort-and-do/328884/5 "2023-04-27T07:34:28Z")

</div>

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