Search code examples
gremlintinkerpoptinkerpop3

How to use gremlin to get the timestamps which has no data?


g.V('JobDefinition').out("JobDefinitionToJobHistory").has("Timestamp", between("2022-02-01T00:00:00Z", "2022-02-07T00:00:00Z")).group().by("Timestamp").by(count())

I have a gremlin query and get the result below. As you can see from the result, there is no data in "2022-02-06T00:00:00Z" and "2022-02-07T00:00:00Z". But I don't know how to get the result ["2022-02-06T00:00:00Z", "2022-02-07T00:00:00Z"] by gremlin query. I want to get the timestamp list which don't have data. Can you give me some suggestions, thanks!

[
  {
    "2022-02-01T00:00:00Z": 1,
    "2022-02-02T00:00:00Z": 2,
    "2022-02-03T00:00:00Z": 2,
    "2022-02-04T00:00:00Z": 1,
    "2022-02-05T00:00:00Z": 1,
  }
]

Solution

  • Gremlin doesn't realize you are asking about a Date type. To Gremlin you just have a String so I don't think there is much it can do to help in this case. I could maybe think of some tricky things to make it work,(because with Gremlin you can do just about anything) but it will just overcomplicate your code and in the worst case make it perform worse.

    In this case, it might just be best to just post process your data in your application and inject the missing values after the query has been executed.