英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论