如何解决一个错误消息,指示在Go中无法识别Elasticsearch客户端方法的问题?

huangapple go评论82阅读模式
英文:

How to troubleshoot an error message indicating that Elasticsearch client methods are not recognized in Go?

问题

我正在尝试在Go中执行Elasticsearch客户端(olivere/elastic)上的搜索操作,使用适用于Elasticsearch 7.x版本的客户端库。期望的行为是在没有错误的情况下编译代码,并返回具有指定查询、聚合、大小、跟踪总命中数、漂亮输出和排序选项的可滚动搜索结果。

然而,实际行为是产生一个错误消息,提示方法Aggregation、Size、TrackTotalHits、Pretty、Sort和Do未被识别。这个错误消息可能表明Elasticsearch客户端方法的语法或引用存在问题。

有人能否提供排除此问题并帮助我解决错误的步骤?此外,请查看我目前正在使用的代码:

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

谢谢您的帮助!

英文:

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!

答案1

得分: 2

滚动 API 用于滚动浏览文档,而不是聚合。参考链接

英文:

The scroll API is used to scroll through documents, not aggregations. The ref.

huangapple
  • 本文由 发表于 2023年3月30日 13:45:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75884503.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定