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

I am trying to execute a search on the Elasticsearch client in Go 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:

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:

Which version of Elasticsearch are you using?

Any particular reason you are not using the official go client? 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

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

I do not use the go client, but it seems it has support for scroll queries. In more recent versions it is recommended to use search_after with PIT. Not sure how this is supported in the client.

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

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