Datetime in index has 4 zeros prefixed to milliseconds

47 views
Skip to first unread message

Iain Roberts

unread,
Dec 14, 2021, 6:58:45 AM12/14/21
to RavenDB - an awesome database
Hi,

I have been trying to figure out why I cannot get a match when doing exact match on a datetime with milliseconds. Something I find odd is how the index is storing the milliseconds. The date "2021-12-14T11:22:28.322Z" is indexed as "2021-12-14T11:22:28.0000322Z". Why the zero prefill?

I have created a document via the raven db studio. Can you please confirm if this is a bug or expected? 

Document:
{
    "Name": "2021-12-14T11:22:28.322Z",
    "@metadata": {
        "@collection": "Dog"
    }
}

Index:
docs.Dog.Select(x => new {
    Name = x.Name
})

Indexed Data:
{
    "Name": "2021-12-14T11:22:28.0000322Z",
    "Name_Time": [
        " \u0001\blo^@\u00172fB",
        "$\bFf}t\u0001;\u00164",
        "(D67o \u000bY3",
        ",\u0004#3>z\u0000]K",
        "0\"\u001b\u001bwP\u0005l",
        "4\u0002\u0011Y_=\u0000.",
        "8\u0011\rM{h\u0002",
        "<\u0001\blo^@",
        "@\bFf}t",
        "DD67o",
        "H\u0004#3>",
        "L\"\u001b\u001b",
        "P\u0002\u0011Y",
        "T\u0011\r",
        "X\u0001\b",
        "\\\b"
    ],
    "id()": "d106c204-1c1c-43f3-91e7-fc967a3e6084",
    "@metadata": {
        "@attachments": [],
        "@counters": [],
        "@timeseries": []
    }
}

Query
Name = "2021-12-14T11:22:28.322Z" matches
Name = "2021-12-14T11:22:28.0000322Z" matches
Name = "2021-12-14T11:22:28.3220000Z" does not match

It is the last one that is causing me issues, I need to remove trailing zeros.

Cheers,

Iain

Iain Roberts

unread,
Dec 14, 2021, 7:05:48 AM12/14/21
to RavenDB - an awesome database
I'll also add I have had lots of issues doing greater than searches. I was searching where timestamp > last seen timestamp. Sometimes I get a value less than timestamp. In the end I started using Ticks and storing as Integer and it worked fine.

Oren Eini (Ayende Rahien)

unread,
Dec 16, 2021, 1:48:31 AM12/16/21
to rav...@googlegroups.com
This is strange, can you create a test case for that? There are a bunch of optimizations around date queries that may be relevant here, but they are all known to be working.

--
You received this message because you are subscribed to the Google Groups "RavenDB - an awesome database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/86322681-2d33-446e-bb45-997d40bde060n%40googlegroups.com.


--
Oren Eini
CEO   /   Hibernating Rhinos LTD
Skype:  ayenderahien
Support:  sup...@ravendb.net
  

Oren Eini (Ayende Rahien)

unread,
Dec 16, 2021, 1:55:06 AM12/16/21
to rav...@googlegroups.com
Hm...
That certainly looks like a bug, but an interesting one.
RavenDB will auto detect dates by their format, and we support a few notations here. 
Looks like we are not handling this scenario properly. 

--
You received this message because you are subscribed to the Google Groups "RavenDB - an awesome database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Dec 16, 2021, 1:56:44 AM12/16/21
to rav...@googlegroups.com

Oren Eini (Ayende Rahien)

unread,
Dec 16, 2021, 2:28:03 AM12/16/21
to rav...@googlegroups.com

Iain Roberts

unread,
Dec 19, 2021, 7:16:21 PM12/19/21
to RavenDB - an awesome database
Gone for a few days and a PR is raised. Well done. I'll move any conversations onto the issue.
Reply all
Reply to author
Forward
0 new messages