【发布时间】:2016-02-05 05:00:08
【问题描述】:
我在 Morphia 中创建聚合时遇到问题,documentation 真的不清楚。这是原始查询:
db.collection('events').aggregate([
{
$match: {
"identifier": {
$in: [
userId1, userId2
]
},
$or: [
{
"info.name": "messageType",
"info.value": "Push",
"timestamp": {
$gte: newDate("2015-04-27T19:53:13.912Z"),
$lte: newDate("2015-08-27T19:53:13.912Z")
}
}
]
}{
$unwind: "$info"
},
{
$match: {
$or: [
{
"info.name": "messageType",
"info.value": "Push"
}
]
}
]);
他们文档中的唯一示例是使用 out 并且有一些示例 here 但我无法使其工作。
我什至没有通过第一场比赛,这就是我所拥有的:
ArrayList<String> ids = new ArrayList<>();
ids.add("199941");
ids.add("199951");
Query<Event> q = ads.getQueryFactory().createQuery(ads);
q.and(q.criteria("identifier").in(ids));
AggregationPipeline pipeline = ads.createAggregation(Event.class).match(q);
Iterator<Event> iterator = pipeline.aggregate(Event.class);
一些帮助或指导以及如何开始查询或它是如何工作的将会很棒。
【问题讨论】: