Querying on multiple LINKMAP items with SQL

19 views
Skip to first unread message

Eric24

unread,
Nov 13, 2017, 6:42:54 PM11/13/17
to orient-...@googlegroups.com

I have a class that contains a LINKMAP field called links. This class is used recursively to create arbitrary hierarchical groupings (something like the time-series example, but not with the fixed year/month/day structure).

A query like this:

select expand(links['2017'].links['07'].links['15'].links['10'].links) from data where key='AAA'

Returns the actual records contained in the last layer of "links". This works exactly as expected.


But a query like this (note the 10,11 in the second to last layer of "links"):

select expand(links['2017'].links['07'].links['15'].links['10','11'].links) from data where key='AAA'

Returns two rows of the last layer of "links" instead:

{"1000":"#23:0","1001":"#24:0","1002":"#23:1"}
{"1003":"#24:1","1004":"#23:2"}


Using unionAll or intersect (with or without UNWIND) results in this single record:

[{"1000":"#23:0","1001":"#24:0","1002":"#23:1"},{"1003":"#24:1","1004":"#23:2"}]


But nothing I've tried (including various attempts at "compound" SELECTs) will get the expand to work as it does with the original example (i.e. return the actual records represented in the last LINKMAP).

Is there a SQL syntax that will achieve this?

Note: Even this (slightly modified) example from the ODB docs does not result in a list of linked records:

select expand(records) from
(select unionAll(years['2017'].links['07'].links['15'].links['10'].links, years['2017'].links['07'].links['15'].links['11'].links) as records from data where key='AAA')

Ref: https://orientdb.com/docs/2.2/Time-series-use-case.html

Reply all
Reply to author
Forward
0 new messages