question

Ahrnndz avatar image
Ahrnndz asked Erick Ramirez answered

What is the syntax for the "greater than" operator on Date types in Gremlin?

I have a DSE 6.8.9 server running in a docker container with DSE Graph enabled. I have created a simple graph using the following schema commands inside a gremlin console:

schema.vertexLabel('test_time').ifNotExists().partitionBy('tt_id', Int)property('dtime', Date).create()
schema.vertexLabel('test_time').searchIndex().ifNotExists().by('tt_id').by('dtime').create()
g.addV('test_time').property('tt_id',6001).property('dtime','2010-10-02' as LocalDate).iterate()

When I go to query for this vertex from the console the following query works without issue:

g.V().hasLabel('test_time').has('dtime', LocalDate.parse('2010-10-02'))

However an error is thrown when I use a predicate step such as gt() or lte() like in the command below:

g.V().hasLabel('test_time').has('dtime', gt(LocalDate.parse('2010-10-02')))

Output:

Invalid Date String:'2010-10-02'
Type ':help' or ':h' for help.
Display stack trace? [yN]Y
org.apache.solr.common.SolrException: Invalid Date String:'2010-10-02'
        at org.apache.solr.util.DateMathParser.parseMath(DateMathParser.java:234)
        at org.apache.solr.schema.TrieField.getRangeQuery(TrieField.java:432)
        at org.apache.solr.parser.SolrQueryParserBase.getRangeQuery(SolrQueryParserBase.java:754)
        at org.apache.solr.parser.QueryParser.Term(QueryParser.java:398)
        at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:186)
        at org.apache.solr.parser.QueryParser.Query(QueryParser.java:107)
        at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:96)
        at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:155)
        at org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:50)
        at org.apache.solr.search.QParser.getQuery(QParser.java:163)
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:208)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:281)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:184)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:2197)
        at com.datastax.bdp.search.solr.cql.CqlSolrQueryExecutor.executeSolrQuery(CqlSolrQueryExecutor.java:455)
        at com.datastax.bdp.search.solr.cql.CqlSolrQueryExecutor.doExecute(CqlSolrQueryExecutor.java:191)
        at com.datastax.bdp.search.solr.cql.CqlSolrQueryExecutor.execute(CqlSolrQueryExecutor.java:131)
        at com.datastax.bdp.cassandra.cql3.SolrQueryOperationFactory.lambda$executeSolrStatement$1(SolrQueryOperationFactory.java:124)
        at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
        at org.apache.cassandra.concurrent.TPCRunnable.run(TPCRunnable.java:101)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Why would the predicate step cause the Date String to become invalid and whats the correct syntax to use?

dsegraphgremlin
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

It appears as though graph traversals that have an inequality criteria (such as greater than or less than) do not work when it involves querying the DSE Search index on a Date type.

Please log a ticket with DataStax Support so we can gather additional information about your cluster to assist with the investigation on the issue with our Engineering team. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.