Gremlin Python Search node based on Regex in node Property

533 views
Skip to first unread message

Debasish Kanhar

unread,
Sep 28, 2017, 6:36:36 AM9/28/17
to Gremlin-users
Hi all,

I'm pretty new to Gremlin Python so all this question might seem trivial:

So, I have a graph pushed, and have setup connection with it.

I run the following:

 g.V().hasLabel('CASE_REQUEST_ID').valueMap()

It outputs as 
==>[NodeProperty:[nan],id:[d81f011b-23cd-4013-90a0-8fd9319a7ac0],value:[{'CASE_REQUEST_ID': '5236', 'ENTITY_NAME': 'Microsoft'}]]
==>[NodeProperty:[nan],id:[7936a098-8b38-4122-86d9-bb0ee3ac69c7],value:[{'CASE_REQUEST_ID': '5236', 'ENTITY_NAME': 'Microsoft'}]]
==>[NodeProperty:[nan],id:[307fa5ef-b0cc-4fe6-a61c-39eccfa88c6d],value:[{'CASE_REQUEST_ID': '5236', 'ENTITY_NAME': 'Microsoft'}]]

What I want to do is fetch all nodes having "{'CASE_REQUEST_ID': '5236'" in its value.

I was able to do that from Gremlin Shell by starting bin/gremlin.sh

 g.V().has('value', Text.textContains('CASE_REQUEST_ID': '5236'))

Returns me:
==>v[368660512]
==>v[204812520]
==>v[204882120]
==>v[245764296]
==>v[204808408]


But how do I implement same query using Gremlin python, GLV variant?

Using Gremlin+Python I can do g.V().hasLabel(label).has(property_name, property_value).next() to get values based on absolute matches but how to handle partial matches?

If GLV can't tackle such problem, then what other should I use to resolve such issues.?

Thanks
Debasish

Stephen Mallette

unread,
Sep 28, 2017, 6:58:57 AM9/28/17
to Gremlin-users
Text.textContains() is something specific to JanusGraph. You would have to revert to submitting a Gremlin string in that case as gremlin-python doesn't know anything about provider specific language additions so it can't generate the appropriate bytecode to send to the server. 

I don't think we've had any discussion on how best to address this issue. Ultimately, it might be up to providers to supply the appropriate extensions to the GLVs in their own packaging. In this case, JanusGraph would minimally need to provide a serializer that can convert the Text.textContains() into their predicate. You would register that serializer with gremlin server. The client side would require the python serializer as well as support for Text in the python language.

I can't immediately think of anything that would make this any much easier for providers or users. I thought a lambda solution might work:


but that won't help JanusGraph optimize the traversal in any way even if you could use the Text predicate because JansuGraph can't analyze the contents of a lambda. 

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/9cc52fe6-a3ec-4c36-95b6-cffe00fef031%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Dale

unread,
Sep 28, 2017, 8:33:25 AM9/28/17
to gremli...@googlegroups.com
Is script submission out for GLVs?  I didn't see it in the docs.

Robert Dale

Stephen Mallette

unread,
Sep 28, 2017, 8:38:00 AM9/28/17
to Gremlin-users
all GLVs come with a driver that allows for script submission - that's all i meant:


Robert Dale

unread,
Sep 28, 2017, 9:27:59 AM9/28/17
to gremli...@googlegroups.com
Ah, there it is. I keep forgetting that 'remote clients' and GLVs are considered as vastly different beasts and in completely different sections.  I think it's confusing.

Robert Dale


Robert Dale

To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CAA-H438JdR-brFV9vHY%3D2DAmM4%3DDk5NU3gaTX_qA64jGnQKXqg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
Robert Dale

Stephen Mallette

unread,
Sep 28, 2017, 10:06:41 AM9/28/17
to Gremlin-users
It would be nice if that whole body of work was revamped in a more cohesive way. I sense it's not just a cut/paste job. :/


Robert Dale


Robert Dale

To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.

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

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

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

--
Robert Dale

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CABed_4rwXG_hTG4fHP5c0pPLz%3D%3DvriOGK_2TFUEOzJkxEQumig%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages