2
votes

Neptune 1.0.2.1 + Gremlin + nodejs.

I have a vertext and property, e.g. Vertex - Device, property - Test, the Test property could store different type of data, e.g. number and string

Vertex 1 - Test = ['ABCD','xyz'] Vertex 2 - Test = [123,'XYZ']

I want to do a 'containing' search, e.g. Test=A, or Test=123 regardless the datatype.

I was trying

queryText = 'BC' //this throw error
or queryText = 123 //this actually works
//I expect both case should hit the result.

g.V().hasLabel('Device').or(__.has('Test', parseFloat(queryText)), __.has('Test', textP.containing(queryText)));

but get 'InternalFailureException\' error

Is it possible I can write a single query regardless the datatype?

if not possible, or at least make textP.containing work with multiple query assuming I know the datatype? right now the containing search throw error if the property contains number

1
Which version of the Neptune Engine are you using? I was not able to reproduce the error you saw so far. This worked for me with one of my grapgs. gremlin> g.V('3').or(has('city',TextP.containing('sti')),has('city',123))Kelvin Lawrence
See answer I think you have a bracket in the wrong place.Kelvin Lawrence

1 Answers

2
votes

It looks like you have the closing bracket in the wrong place inside the or() step. You need to close the first has step before the comma.

In your example

g.V().hasLabel('Device').or(__.has('Test', parseFloat(queryText), __.has('Test', textP.containing(queryText))));

Which should be

g.V().hasLabel('Device').or(__.has('Test', parseFloat(queryText)), __.has('Test', textP.containing(queryText)));

EDITED and UPDATED

With the corrected query and additional clarification about the data model containing different types for the same property key, I was able to reproduce what you are seeing. However, the same behavior can be seen using TinkerGraph as well as Neptune. The error message generated is is a little different but the meaning is the same. Given the fact that TinkerGraph behaves the same way I am of the opinion that Neptune is behaving consistently with the "reference" implementation. That said, this raises a question as to whether the TextP predicates should be smarter and check the type of the property before attempting the test.

gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV('test').property('x',12.5)
==>v[0]
gremlin> g.addV('test').property('x','ABCDEF')
==>v[2]
gremlin> g.V().hasLabel('test').or(has('x',12.3),has('x',TextP.containing('CDE')))
java.math.BigDecimal cannot be cast to java.lang.String
Type ':help' or ':h' for help.
Display stack trace? [yN]  

ADDITIONAL UPDATE

I created a Jira issue so the Apache TinkerPop community can consider making a change to the TextP predicates.

https://issues.apache.org/jira/browse/TINKERPOP-2375