0

I have a collection in Mongo called 'collectionX'. I want to query whole data, except I want to filter out by event_date that is after July 1st (event, creationdate - unix milisecond timestamp). However I am using this query in azure data copy tool and I get an error of an invalid use of filtering.

db.CollectionX.find({
  "events": {
    "$elemMatch": {
      "creationDate.$date": { "$gt": NumberLong(1725072000000) }
    }
  }
})

Tried multiple queries, do I write Mongo queries here or something else?

json structure ->

  "_identitificationID": {
    "$originalID": "xyz123"
  },
  "events": [
    {
      "_identificationID": {
        "$originalID": "xyz1234"
      },
      "messageId": "thatsmymessage",
      "creationDate": {
        "$date": 1671023788998
      },
      "myinformationID": "abc",
      "otherinfo": "123",
      "eventname": "somethinghappened"
    },
3
  • Does creationDate actually contain a document with a field $date? Commented Jul 22, 2024 at 18:19
  • added hierarchy Commented Jul 22, 2024 at 18:42
  • {"$date": 1671023788998} looks like MongoDB extended JSON. JSON doesn't have a Date datatype, so that may indicate that the field actually contains a UTC datetime. Commented Jul 22, 2024 at 18:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.