olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
https://olivere.github.io/elastic/
MIT License
7.39k stars 1.15k forks source link

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

Open orhan-cmd opened 1 year ago

orhan-cmd commented 1 year ago

Please use the following questions as a guideline to help me answer your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[x] elastic.v7 (for Elasticsearch 7.x) [ ] elastic.v6 (for Elasticsearch 6.x) [ ] elastic.v5 (for Elasticsearch 5.x) [ ] elastic.v3 (for Elasticsearch 2.x) [ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

The code should compile without errors and execute a search on the Elasticsearch client, returning a scrollable search result with the specified query, aggregation, size, track total hits, pretty, and sort options.

Please describe the actual behavior

The code is producing an error message that indicates the methods Aggregation, Size, TrackTotalHits, Pretty, Sort, and Do are not recognized. The error message suggests that there may be an issue with the syntax or reference of the Elasticsearch client methods.

Any steps to reproduce the behavior?

To reproduce this issue, try running the code provided in an IDE or text editor that supports Go, with the appropriate Elasticsearch client library imported and the required dependencies installed. Check that the method names are spelled correctly and that the appropriate functions and arguments are used. If the error persists, it may be helpful to review the Elasticsearch client documentation or seek assistance from the Elasticsearch community.

Code :

    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())

image