我有带有“标签”数组作为属性的文档。现在我想查询所有不同的标签项。
{
"name": "test1",
"tags": ["tag1","tag2", "tag3"]
},
{
"name": "test2",
"tags": ["tag1"]
}
mongo shell 中的解决方案:
db.ApiModel.distinct("tags")
这给了我:
["tag1", "tag2", "tag3"]
但是我怎样才能用 Panache 达到同样的效果呢?PanacheMongoEntity 不提供特定的不同方法。我也不知道如何使用这种find
方法来实现我的目标,或者是否可以使用这种方法。
我所能想到的就是找到所有带有find("tags", "*")
(is * the wildcard?) 的标签,然后在 Java 中处理重复项,但我不相信这是预期的用途。