vertex as document usage

77 views
Skip to first unread message

Aris Alexis

unread,
Mar 23, 2015, 8:37:06 AM3/23/15
to orient-...@googlegroups.com
hi,

sorry for the noob question but i am using the graph database but some vertices i would like them to be documents.
for example the user vertex has a lot of sub documents for the location, phones etc.

can I do in my code ODocument od=vertex? and then how to save it? can I use the variables then like od.phones[0] or something?

do I have to open a new transactional connection to a document database or work with my existing connection for graph?

thanks

Colin

unread,
Mar 23, 2015, 10:06:17 AM3/23/15
to orient-...@googlegroups.com
Hi Aris,

A vertex is not a document but does make use of one internally.  You can treat a vertex like a document in that you can call setProperty with the same types that ODocument.field() can use.
Do note that save() is implicit when using a vertex.

If you don't wish to use OrientVertex objects, you can create ODocument objects.  To gain access to the underlying Document Database interface via the Graph Database, just call graph.getRawGraph().

Good luck!

-Colin

Orient Technologies

The Company behind OrientDB

Aris Alexis

unread,
Mar 23, 2015, 11:27:04 AM3/23/15
to orient-...@googlegroups.com
Hi. I am using the setProperty but I want to keep nested documents in that property like options for the user or accounts that are not just list string but maps. Any nice way of doing this with a vertex?

if i use a document object can i create edges for it? because my data is highly connected.

Best Regards,
Aris Giachnis

--

---
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/tyiGvLaLtuM/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.

Colin

unread,
Mar 23, 2015, 12:10:03 PM3/23/15
to orient-...@googlegroups.com, aris.al...@gmail.com
When you say nested documents, do you mean like a map or set of embedded or linked documents?

You can use all the same types in a vertex as you can with a document.  Just think of an OrientVertex as a hybrid of a node and a document.  Just stick with the Vertex and create edges for it while setting its properties like a document.

-Colin

Orient Technologies

The Company behind OrientDB


Aris Alexis

unread,
Mar 24, 2015, 5:47:06 AM3/24/15
to orient-...@googlegroups.com
Hi,

sorry that I still have questions over this.

To make it clear:

I have Vertex v. I am using the Graph database. I have declared the property "properties" as type EMBEDDED

then I do

ODocument doc = new ODocument("Properties");
doc.field( "city", new ODocument("City").field("name","Rome").field("country", "Italy") );

then I set v.setProperty("properties",doc);

and g.commit. note that g is a graph connection and I am not using the Document db connection.

is this a correct flow?

Colin

unread,
Mar 24, 2015, 10:48:21 AM3/24/15
to orient-...@googlegroups.com
Hey Aris,

You're close.  In place of the ODocument, use an OrientVertex for properties and city.

The OrientVertex will turn a passed-in ODocument that's embedded into an OrientVertex wrapping the ODocument.  So, just use an OrientVertex directly.

Just think of an OrientVertex as containing an ODocument with enhanced features.  There's no harm in using it like an ODocument, even if you never create edges.

Since you're already in the Graph Database, it makes it simpler to stay there.

-Colin

Orient Technologies

The Company behind OrientDB

Reply all
Reply to author
Forward
0 new messages