My query doesn't work

Hello,

here is how my graph looks like:

I would like to get the property ‘value’ of the vertex ‘String’ by only traversing the edge ‘UID’ from the vertex ‘PageTemplate’ and the current state. The edge ‘STATE_OF’ has two properties ‘from’ and ‘to’.

My query attempt:

SELECT FROM (TRAVERSE out(‘UID’).out(‘STATE_OF’)[to = 922337203685477] FROM PageTemplate)

It returns the vertex ‘PageTemplate’ and I don’t unterstand completely the command TRAVERSE. After FROM you specify the begin of the traversal. In my case I should use ‘PageTemplate’, but the result is I get the vertex ‘PageTemplate’ back and not the vertex/property I traverse to. What do I have to change?

Many thanks in advance

Philip

Hey teufel.
Can you please clarify which IDs does the vertices “String” and “PageTemplate” have?
And is “current state” also a vertex?

In the meanwhile you can read the traverse documentation if you haven’t already.
http://orientdb.com/docs/3.1.x/java/Java-Traverse.html

Cheers

Hi LMarziali,

#41:0 is “PageTemplate” without properties, #57:0 is “State” without properties and #25:0 “String” with the property “value”. The current state is not a vertex. In the edge “STATE_OF” are two properties “from” and “to”. When “to” has the maximum long value, it’s the current state.

Hi,
try this:
SELECT out("UID").out("STATE_OF").value as value, out("UID").outE("STATE_OF").to as current_state FROM PageTemplate unwind value, current_state

Hope it helps

Regards,
Michela

1 Like

Hi Michela,

I get the result that I want, but when I have more ‘STATE_OF’ edges. How can I filter? I tried this:

SELECT out(“UID”).out(“STATE_OF”)[to = 922337203685477].value as value FROM PageTemplate

But it returns nothing…

Thanky you very much for your help!

Hi @teufel

if “to” is on the edge, you can do it as follows:

SELECT 
out(“UID”).outE(“STATE_OF”)[to = 922337203685477].inV().value as value 
FROM PageTemplate

Thanks

Luigi

1 Like

Thank you @luigidellaquila!