vert-x3 / vertx-mongo-client

Mongo Client for Eclipse Vert.x
http://vertx.io
Apache License 2.0
60 stars 99 forks source link

Unable to use datetime type in aggregations match in time series collection #315

Open nov30th opened 6 months ago

nov30th commented 6 months ago

Questions

Unable to use datetime type in aggregations match, I've tested the mongodb 7.0 (mongoDB Compass) there is no any data with time series collection when aggregations with the timestamp(datetime) key gt or lt with $date or $DateFromString or any other in documents, there is new date and ISODate working, but I can not find any solution to give the match aggregations with date obj.

Version

Which version(s) did you encounter this bug ?

4.5.4

Context

there is no way to put the date in JsonObject for aggregations match

Do you have a reproducer?


        JsonArray pipeline = new JsonArray()
                .add(new JsonObject()
                        .put("$match", new JsonObject()
                                .put("meta.key", key)
                                .put("meta.exchange", exchange)
                                .put("meta.marketType", marketType)
                                .put("timestamp", new JsonObject()
                                        .put("$gte", minuteBeginDate))
                        ))
...
mongoClient.aggregate(collectionName, pipeline).toFlowable().toList()

minuteBeginDate could be timestamp or Instant or Date or {"$date": "xxx date" }

Extra

I've search in google also in issues in this project, with GPT, there is no working solution. Even in offical mongoDB Compass is only "new date" and "ISODate" working, I found no way to let the mongo use the "new date" or "ISODate" in JsonObject.

tsegismont commented 5 months ago

Can you please add instructions for creating the collection and adding a few documents which should be returned or filtered-out by the query?

nov30th commented 5 months ago

I was changed the part of my project by using com.mongodb.client directly, I will change it back later to let you have the full testing code.

minuteBeginDate could be timestamp or Instant or Date or {"$date": "xxx date" }

during my testing today, it seems my simply testing code working with {"$date": Instant obj }, I'm not sure if it is the only working way that I haven't tried in above I think