Jonck van der Kogel
Jonck van der Kogel

Reputation: 3293

Visualizing graph with OrientDB Studio

I'm working with OrientDB (2.2.10) and occasionaly I would like to visually inspect my dataset to make sure I'm doing things correctly. On this page of OrientDB http://orientdb.com/orientdb/ you see a nice visualization of a large graph with the following query:

select * from V limit -1;

So I tried the same query on my dataset but the result is so extremely sluggish that I can't work with it. My dataset is not extremely large (few hundred vertices, couple thousand edges) but still the result is unworkable. I tried all major browsers but with all I have the same result. Also my computer is not underpowered, I have a quad-core i7 with 16GB RAM.

As a very simple example I have the following graph: BAR --WITHIN---> CITY --LOCATED_IN--> COUNTRY

Here: Find "friends of friends" with OrientDB SQL I was able to get at least an example of how to do this type of query on a graph. I managed to get a subset of my graph for example as follows:

select expand(
bothE('WITHIN').bothV()
) from Bar where barName='Foo' limit -1

This get's me the graph of 1 Bar vertex, the edge WITHIN and the City vertex. But if I now want to go one step further by also fetching the country which the city is located in I cannot get this style of query to work for me. I tried this:

select expand(
bothE('WITHIN').bothV()
.bothE('LOCATED_IN').bothV()
) from Bar where barName='Foo' limit -1

This results in the same subset being shown. However, if I first run the first query and then without clearing the canvas run the second query I do get the 3 vertices. So it seems I'm close but I would like to get all 3 vertices and it's edges in one query, not having to run first the one and then the other. Could someone point me in the right direction?

Upvotes: 0

Views: 1131

Answers (2)

Alessandro Rota
Alessandro Rota

Reputation: 3570

You could use

traverse * from (select from bar where barName='Foo') while $depth <= 4

Example: I tried with this little graph

enter image description here

and I got

enter code here

Hope it helps.

Upvotes: 1

Oleksandr Gubchenko
Oleksandr Gubchenko

Reputation: 1369

If you want to get all three vertices, it would be much easier start from the middle (city) and than get in and out to get bar and contry. I've tried with a similar little structure: OrientDB Bar Structure

To get city, bar name and country you can try a query like this:

select name, in("WITHIN").name as barName,out("LOCATED_IN").name as barCountry from (select from City where name='Milan') unwind barName, barCountry

And the output will be:

OrientDB Bar Query Output

Hope it helps. If it is not suitable for your case, let me know.

Upvotes: 1

Related Questions