草庐IT

Elasticsearch:Top metrics 聚合

全部标签

elasticsearch - Golang : Using ElasticSearch library called Goes, 如何为 bool should 方法编写可执行代码?

我正在使用gos库(https://github.com/OwnLocal/goes),它是Golang中ElasticSearch的包装器。在ElasticSearch查询中,我们可以这样运行:{"query":{"match":{"user_id_1":"438018"}}}而且有效。对于使用gos的golang,你可以像这样运行它:varquery=map[string]interface{}{"query":map[string]interface{}{"match":map[string]interface{}{"user_id_1":"438018",},},}这是我的问题

elasticsearch - 如何用 Go 构造 Elasticsearch 查询?

我正在为Go使用olivere的Elasticsearch库-https://github.com/olivere/elastic我无法正确构建搜索查询,它一直返回0个匹配项。termQuery:=elasticClient.NewTermQuery("hash","hashedID")fmt.Println(termQuery)searchResult,err:=qs.client.Search().Index("someIndex").Type("node").Query(termQuery).Pretty(true).Do(ctx)iferr!=nil{returnnil}sea

elasticsearch - 如何检查 ElasticSearch BulkProcessor 服务是否存在

我正在为golang使用elastic包。我想使用它的BulkProcessor在后台发送大量文档。如wiki所示,我可以创建一个处理器。但我不想每次发送文件时都创建它。我想知道连接中是否存在处理器服务并将数据传递给现有处理器而不是创建新处理器。我怎样才能实现它? 最佳答案 注册批量处理器与发送文件分开。批量处理器的生命周期与您的进程一样长,因此要确保您只创建一次,请在进程启动时创建它。然后在您申请的其他地方,您可以随时发送文件。或者,如果您必须按需进行,您可以使用sync.Once以确保创建只发生一次。

elasticsearch - 如何有效地只获取文档的一个字段进行 Elasticsearch

我是elasticsearch的新手,遇到了一些技术难题。目前我有存储在每小时索引中的文档,它们是时间序列数据。我想弄清楚的是如何有效地只提取key字段值,它被定义为"key":{"type":"long"}.我最初尝试了天真的方法,即滚动浏览所有索引并提取字段,但显然这不会很快完成,每个每小时索引都有大约10M文档,滚动3个索引已经花费了很长时间。然后我来到termsaggregations,尝试将key字段作为聚合项:"aggregations":{"test_group":{"terms":{"field":"key","size":100000}}}这给了我更好的性能,但当用户

elasticsearch - 有没有办法通过 Elasticsearch 查询故意返回空值?

我必须在我的代码中返回一个elasticsearch查询(Golang使用olivere的elasticv.5库),如果出现特定情况,我希望能够传递一个耗时最短且始终返回null的查询。有没有标准的方法来做到这一点?我尝试使用带有空字符串作为参数的Term查询:elastic.NewTermQuery("","")但这似乎不是一个有效的查询。有什么好的方法吗? 最佳答案 如果“始终返回null”是指不匹配:{"bool":{"must_not":{"match_all":{}}}}我确信match_all的实现非常有效。

docker - 无法在 Raspberry Pi 上运行 elasticsearch 镜像

尝试在我的树莓派上运行elasticsearch图像时出现错误。它在我的Mac上运行良好,所以它可能是特定于操作系统的。我可以运行其他图像。pi@raspberrypi:~/folder/folder$dockerrunnode:latestpi@raspberrypi:~/folder/folder$dockerrundocker.elastic.co/elasticsearch/elasticsearch:5.6.3standard_init_linux.go:195:execuserprocesscaused"execformaterror"广泛搜索了standard_init_

elasticsearch - 将 Elasticsearch DSL 翻译成 gopkg.in/olivere/elastic.v5

我有json,我想使用https://godoc.org/gopkg.in/olivere/elastic.v5将其转换为Elasticsearch查询JSON={"query":{"bool":{"filter":[{"exists":{"field":"Videos.en"}}]}}}很简单!到目前为止我所得到的——这显然是行不通的——是:enVidsQuery,err:=elastic.NewBoolQuery().Filter(elastic.Exists("field","Videos.en"))elastic在我的导入中引用了“gopkg.in/olivere/elasti

mongodb 聚合在 golang 中给出错误

我想要分组方法类型并根据它们的类型对它们进行计数。这些方法是字符串。我写了下面的代码。但是它给出了一个错误。pipeline:=[]bson.D{bson.D{{"$unwind","$method"},},bson.D{{"$group",bson.M{"_id":"$method","count":bson.M{"$sum":1}}},},query:=bson.D{{"aggregate","API_ACCESS_LOGS"},//useragentsisacollectionname{"pipeline",pipeline},}err=session.DB("vamps-log

elasticsearch - GoLang 从 Elasticsearch 结果中解码 JSON

我有从Elasticsearch返回的数据,使用“github.com/olivere/elastic”。那种工作,当我将它添加到我的结构并将其串起来时,就像这样,data:=Api{Total:myTotal,Data:string(result),}c.JSON(http.StatusOK,totalData)api是这样的结构,typeApistruct{Totalinterface{}Datainterface{}}这将返回数据正常,从1到请求的任意数量的结果。加载到数据接口(interface)的结果如何不转义什么的,例如"Data":"{\"CID\":\"XXXXXXXX

mongodb - 使用 MongoDB 和 Golang 通过聚合和查找查找重复项

我需要使用MongoDB和Golang进行聚合和查找来查找重复项。这是我的Event结构。//EventdescribesthemodelofanEventtypeEventstruct{IDstring`bson:"_id"json:"_id"valid:"alphanum,printableascii"`OldIDstring`bson:"old_id"json:"old_id"valid:"alphanum,printableascii"`ParentIDstring`bson:"_parent_id"json:"_parent_id"valid:"alphanum,printa