Thanks Luigi, that works. Also I have another question about optionals.
Starting with the same example, let's say that Folders may contain Files
and I want to get the files of the children folders (not the current folder
(of course that's just an example, it's pretty useless because we would
usually get the files of the parent folder...). I'd like to do something
like:
MATCH {class: Folder, as: parent}-parent_of->{class: Folder, as: child,
optional: true}->contains->{class: File, as: file, optional: true} RETURN
parent, child, file
But it does not wok because "optional" must be at the end of a match
chain... Any idea of a workaround for that ?
Le dimanche 2 avril 2017 11:24:34 UTC+2, Luigi Dell'Aquila a écrit :
>
> No, sorry, you don't need the SELECT and the UNWIND, you can just use the
> inner match:
>
> MATCH {class: Folder, as: parent}.outE("parent_of"){as: theEdge, optional:
> true} RETURN parent, theEdge, theEdge.inV() as child
>
> (there was also a mistake in my previous answer, it was inV(), not in() )
>
> Thanks
>
> Luigi
>
>
> 2017-04-02 11:22 GMT+02:00 Luigi Dell'Aquila <[email protected]
> <javascript:>>:
>
>> Hi Nicolas,
>>
>> I'm afraid it's not supported yet, you can work around it with a
>> SELECT/MATCH like follows:
>>
>> SELECT FROM (
>> MATCH {class: Folder, as: parent}.outE("parent_of"){as: theEdge,
>> optional: true} RETURN parent, theEdge, theEdge.in() as child
>> ) UNWIND child
>>
>> I hope it helps
>>
>> Thanks
>>
>> Luigi
>>
>>
>>
>> 2017-03-31 14:20 GMT+02:00 nicolas treiber <[email protected]
>> <javascript:>>:
>>
>>> Hello,
>>>
>>> I'm facing a problem with a MATCH query in orientDB 2.2. I have a folder
>>> tree structure (a 'Forlder' node, and a 'parent_of' edge) and I have data
>>> on the relationships. What I try to achieve is to get all the tree at once
>>> with the relationships data. I successfully got the tree without the data
>>> that way:
>>> MATCH {class: Folder, as: parent}-parent_of->{class: Folder, as: child,
>>> optional: true} RETURN parent, child
>>> (I need the optional set to true to get the folders with no child)
>>>
>>> To get the edges' data I proceeded that way:
>>> MATCH {class: Folder, as: parent).outE('parent_of'){as:
>>> edge}.inV(){class: Folder, as child, optional: true} RETURN parent, edge,
>>> child
>>> But it acts like there were no "optional", and folder without any child
>>> are ignored.
>>> I tried to add "optional: true" to the edge, but it unauthorized.
>>> And finally i tried:
>>> MATCH {class: Folder, as: parent).(outE('parent_of'){as:
>>> edge}.inV()){class: Folder, as child, optional: true} RETURN parent, edge,
>>> child
>>> With that i have all the folders but edge is always empty, like if the
>>> aliases in parenthesis were ignored.
>>>
>>> How can I fix that ?
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "OrientDB" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected] <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.