dot notation vs traverse ?

151 views
Skip to first unread message

cp2

unread,
Mar 4, 2014, 9:23:31 PM3/4/14
to orient-...@googlegroups.com
If I have a hierarchy like continent, country, state, county, city
What is the most straightforward/ and or computationally cheap way to get all of the cities in a continent and the continent for a city?

Is there something like 
select out().country.out().state.out().county().city from continent where name = 'europe' to get all the cities in europe.
I have been playing around with this but dont seem to be able to get it right
(traverse seems like overkill when I know the path)

I would also like to be able to to do opposite  
as cheaply as possible to get the continent from the city
like select $this.in().county.in().state.in().country.in().continent

thanks,

charles

Andrey Lomakin

unread,
Mar 5, 2014, 5:06:42 AM3/5/14
to orient-database
Hi you mean that query like

On Wed, Mar 5, 2014 at 4:23 AM, cp2 <charles...@gmail.com> wrote:
out().country.out().state.out().county().city


does not work ?
What is result of this query ?

--
Best regards,
Andrey Lomakin.

Orient Technologies
the Company behind OrientDB

cp2

unread,
Mar 6, 2014, 2:02:19 PM3/6/14
to orient-...@googlegroups.com
Andrey --
 
I get a Null Pointer exception.

repro detail after signature below:

Thanks,

Charles


create class continent extends v
--Class created successfully. Total classes in database now: 11
create class country extends v
--Class created successfully. Total classes in database now: 12
create class city extends v
--Class created successfully. Total classes in database now: 13
create vertex continent set name='europe'
--Created vertex 'continent#11:0{name:europe} v1' in 0.024000 sec(s).
create vertex country set name='france'
--Created vertex 'country#12:0{name:france} v1' in 0.002000 sec(s).
create vertex city set name = 'paris'
--Created vertex 'city#13:0{name:paris} v1' in 0.001000 sec(s).
create edge from 11:0 to 12:0
--Created edge '[e[#11:0->#12:0][#11:0-E->#12:0]]' in 0.011000 sec(s).
create edge from 12:0 to 13:0
--Created edge '[e[#12:0->#13:0][#12:0-E->#13:0]]' in 0.004000 sec(s).

select from continent where name = 'europe'
-- 0   |#11:0|europe|#12:0   -- ok
select out() from continent where name = 'europe'
-- 0   |#-2:1|[1] -- ok
select expand(out()) from continent where name = 'europe'
-- 0   |#12:0|france|#11:0|#13:0 -- ok
select out().country from continent where name = 'europe'
-- 0   |#-2:1|[1] -- ok
select out().country.out() from continent where name = 'europe'
-- Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select out().country.out() from continent where name = 'europe'
-- Error: java.lang.NullPointerException

 

Riccardo Tasso

unread,
Mar 6, 2014, 3:07:41 PM3/6/14
to orient-...@googlegroups.com
2014-03-06 20:02 GMT+01:00 cp2 <charles...@gmail.com>:
select out().country.out() from continent where name = 'europe'

Hi, I think it's wrong: country is not a field name.
Try SELECT out().out() FROM Continent WHRE name = 'europe'

Cheers,
   Riccardo

Charles Porter

unread,
Mar 6, 2014, 3:21:52 PM3/6/14
to orient-...@googlegroups.com

select out().out() from continent where name = 'europe'

#   |@RID |out

--0   |#-2:1|[0] 

-Charles



--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/Wngp4c-JdSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

odbuser

unread,
Mar 7, 2014, 1:10:39 AM3/7/14
to orient-...@googlegroups.com
OrientDB 1.7rc2 from a few hours ago:

Changing the syntax for traversing the edge works.  out().out() is the preferred syntax but it doesn't work.

This works:
select out_.out_ from continent where name = 'europe'

Or better yet:
select expand(out_.out_) from continent where name = 'europe'

I'd also expect this one to work but it fails with
select expand(out('').out('')) from continent where name = 'europe'

Error: com.orientechnologies.orient.enterprise.channel.binary.OResponseProcessingException: Exception during response processing.
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select expand(out('').out('')) from continent where name = 'europe'
Error: java.lang.StringIndexOutOfBoundsException: String index out of range: 0

Damian Bronecki

unread,
Mar 7, 2014, 3:38:41 AM3/7/14
to orient-...@googlegroups.com
Try to write this query without quotes:
 
select expand(out().out()) from continent where name = 'europe'

Charles Porter

unread,
Mar 7, 2014, 1:30:46 PM3/7/14
to orient-...@googlegroups.com
Based on the comments of odbuser2, this seems to be a bug.
I will create an 'issue'.
-Charles






On Fri, Mar 7, 2014 at 12:38 AM, Damian Bronecki <broneck...@gmail.com> wrote:
Try to write this query without quotes:
 
select expand(out().out()) from continent where name = 'europe'

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/Wngp4c-JdSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

odbuser

unread,
Mar 7, 2014, 2:22:39 PM3/7/14
to orient-...@googlegroups.com
That's the form that we would expect to work but it does not.
Reply all
Reply to author
Forward
0 new messages