Using Strategy I'm able to transform g.V(id) to g.V().has("entityId", id) But is there a way I can remove id from gremlin output or replace it with entityId? Without making changes at the serializer level?
Asked
Active
Viewed 85 times
0
-
Mentioning serializers, I assume you mean the output from Gremlin Server towards a gremlin client. How general can your output be: can you always finish your queries with an elementMap() step? – HadoopMarc Feb 15 '22 at 06:51
-
Actually, we don't have any specific set of queries so it can be any query. – Harshit Sharma Feb 15 '22 at 09:16
-
Is there anything we can do by creating a new DSL? – Harshit Sharma Feb 15 '22 at 09:18
-
It sounds as if you are trying to work around having a backend database that does not support user provided IDs - is that the real issue? – Kelvin Lawrence Feb 15 '22 at 15:40
-
There are 2 Ids one is generated by graph database let's say id and the other is created by our application let say graphId. Now I want my client to use only graphId, not id. If client query g.V(id) then it should get transformed to g.V().has("graphId", id) and in output also they should see graphId not Id. – Harshit Sharma Feb 16 '22 at 04:18
-
I guess it would be doable to extend your DSL and override the methods like next, toList and map any Element instance to a new Element instance with the transformations you want. This is not trivial because Element instances can be present in nested output data structures. – HadoopMarc Feb 16 '22 at 06:46
-
It will be really helpful if you can an example also is it possible to do it using the strategy? – Harshit Sharma Feb 16 '22 at 07:36
-
Is it allowed to add custom DSL in Neptune? – Harshit Sharma Feb 16 '22 at 08:41
-
If you are using Neptune you can have the real vertex ID be your entity ID, which, so long as they are unique, would surely solve this entire problem for you. – Kelvin Lawrence Feb 16 '22 at 13:05
-
Actually, we are doing the same, our entityId is the same as Id. But later if we want to migrate from Neptune to some other graph DB then in that case it will become inconsistent. That is why we want to keep a separate field called entityId – Harshit Sharma Feb 16 '22 at 15:07