Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nov30th opened this issue Apr 15, 2024 · 2 comments
Open

Comments

@nov30th
Copy link

nov30th commented Apr 15, 2024

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.

@nov30th nov30th added the bug label Apr 15, 2024
@tsegismont tsegismont added this to the 4.5.8 milestone May 18, 2024
@tsegismont
Copy link
Contributor

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
Copy link
Author

nov30th commented May 18, 2024

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

@vietj vietj modified the milestones: 4.5.8, 4.5.9 May 24, 2024
@vietj vietj modified the milestones: 4.5.9, 4.5.10 Jul 17, 2024
@vietj vietj modified the milestones: 4.5.10, 4.5.11 Sep 4, 2024
@vietj vietj modified the milestones: 4.5.11, 4.5.12 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants