我有一个mongodb集合,用于存储具有以下模式的日志文件......
{
_id: ObjectId('4f442120eb03305789000000'),
remote_addr: "127.0.0.1",
account_id: 123,
user: 'frank',
time: ISODate("2000-10-10T20:55:36Z"),
url: "http://test.com/apache_pb.gif",
user_agent: "Mozilla/4.08 [en] (Win98; I ;Nav)"
}
我需要一个或几个mongodb / mongoid查询,以便我回答以下问题...
What users visited http://test.com/category/.*?/checkout at least 10 times within the last 7 days, visits restricted by account_id 123?
What users visited http://test2.com/category/.*?/checkout at least 5 times within the last 7 days AND also visited http://test3.com/landing at least 1 time within the last 30 days, visits restricted by account_id 123?
What users visited http://test3.com/category/.*?/checkout no more than 10 times within the last 20 days OR visited http://google.com/ exactly 1 time more than 10 days ago, visits restricted by account_id 123?
最终目标当然是获取符合问题标准的唯一身份用户列表。不确定这是否可以通过纯查询完成,或者是否需要一些中间代码(我使用rails)来完成结果。可能需要一个聚合管道来预先计算访问次数(通过帐户,用户,可正确的URL)?这可以通过可扩展和高效的方式完成吗?