Search code examples
databaseazure-cosmosdbgremlin

Gremlin Syntax to Query Cosmos Db Based on date


Could you please guide me on how to write a gremlin query that will return only projects that have started past a specific date?

My first query returns all project vertices within program05:

g.V('program05').has('partitionkey', 'program05').out('hasprojects')

I would like to filter it down to return only projects that have started after '20/19/2018 4:37:12 PM' , a program vertex has a propertt of startDate

I have tried :

g.V('program05').has('partitionkey', 'program05').out('hasprojects').has('startDate').has('startDate',gt, '20/19/2018 4:37:12 PM')

but i get an Error: Unable to resolve symbol 'lt' in the current context. I have tried other opions too with no luck


Solution

  • The predicate logic (javadoc) for strings seems to work based on ASCII values of the string, so your current storage of the date in text format will not work month over month.

    I would suggest storing that as epoch seconds and then using the following query to get that data you want.

    Assuming you meant the date 2/19/2018 4:37:12 PM

    g.V() 
     .has('partitionkey','program05')
     .out('hasprojects')
     .has('startDate',P.gt(1519058232))