mgo $unwind aggregation result to Unknown element kind (0x2E)

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

mgo $unwind aggregation result to Unknown element kind (0x2E)

问题

我有一个类似这样的聚合查询:

$ db.histories.aggregate([{$match:{"issue_id":{$in:ids},"history_comment":{$exists:true,$not:{$size:0}}}},{$unwind:"$history_comment"}])

我想用mgo将其转换为go语言:

var h []History
query := []bson.M{
    {"$match": bson.M{
        "issue_id":        bson.M{"$in": IDs},
        "history_comment": bson.M{"$exists": true, "$not": bson.M{"$size": 0}}}},
    {"$unwind": "$history_comment"},
}

err := c.Pipe(query).All(&h)

但是我收到了一个错误信息:

Unknown element kind (0x2E)

这是怎么回事?我的查询有问题吗?

英文:

I have an aggregate query like this

$ db.histories.aggregate([{$match:{"issue_id":{$in:ids},"history_comment":{$exists:true,$not:{$size:0}}}},{$unwind:"$history_comment"}])

translating this to go using mgo

	var h []History
query := []bson.M{
	{"$match": bson.M{
		"issue_id":        bson.M{"$in": IDs},
		"history_comment": bson.M{"$exists": true, "$not": bson.M{"$size": 0}}}},
    {"$unwind": "$history_comment"},

}

err := c.Pipe(query).All(&h)

but I received an err

Unknown element kind (0x2E)
how is this possible? is my query wrong?

答案1

得分: 1

返回翻译的内容:

返回的错误指出传递给驱动程序的数据具有未知的元素类型。查看BSON规范,确实没有0x2E元素类型:

http://bsonspec.org/spec.html

如果您认为这是驱动程序中的问题,请提供一个可以加载到驱动程序中的有问题数据的转储,并提交一个问题报告。

谢谢。

英文:

The error returned is pointing out that the data being handed to the driver has an unknown element kind. Looking at the BSON specification, there's indeed no 0x2E element kind in there:

http://bsonspec.org/spec.html

If you think this is an issue in the driver, can you please provide a dump of the offending data that can be loaded into the driver, and open an issue with it?

Thank you.

huangapple
  • 本文由 发表于 2015年9月22日 20:02:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/32716402.html
匿名

发表评论

匿名网友

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

确定