Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[input_mongodb] Bloblang query is not working with ISODate field #2889

Closed
lytuan99 opened this issue Sep 22, 2024 · 1 comment
Closed

[input_mongodb] Bloblang query is not working with ISODate field #2889

lytuan99 opened this issue Sep 22, 2024 · 1 comment

Comments

@lytuan99
Copy link

lytuan99 commented Sep 22, 2024

Input_mongodb can not query with ISODate field of MongoDB connection.

I've tried many ways in configuring input below, all of those command can not get data.

    query: |
      root.createdAt = {"$lte": now()}
## in history queries mongodb: "$lte": "2024-09-22T08:58:00.139917+07:00"
##
    query: |
      root.createdAt = {"$lte": timestamp_unix() - 90 * 86400}
## in history queries mongodb: "$lte": new NumberInt("1597405526")
##
    query: |
      root.createdAt = {"$gte": (timestamp_unix() - 90 * 86400).ts_format()}
## in history queries mongodb: "$gte": "2024-06-24T08:58:55+07:00"
## .....

In my IDE, I execute the query below, and it works.

db.orders.find({
  createdAt: {
    $gte: new Date("2024-02-02"),
  },
});

image

Did I miss something or the RedPanda-connect should add a new feature for ISODate object?

@mihaitodor
Copy link
Collaborator

Hey @lytuan99 👋 Try root.created_at = {"$gte": "2024-02-02".ts_strptime("%Y-%m-%d")} for example. Also, this should work: root.created_at = {"$gte": now().ts_parse("2006-01-02T15:04:05Z07:00")}. The 2006-01-02T15:04:05Z07:00 format is the reference format used for RFC3339 in Go as documented here: https://pkg.go.dev/time#pkg-constants.

PS: Converting this to a discussion as mentioned in #2026.

@redpanda-data redpanda-data locked and limited conversation to collaborators Sep 22, 2024
@mihaitodor mihaitodor converted this issue into discussion #2890 Sep 22, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants