Nested Properties support in JanusGraph

503 views
Skip to first unread message

Debasish Kanhar

unread,
Dec 16, 2017, 6:34:22 AM12/16/17
to JanusGraph users
Hi,

I know about meta properties, and can add them using:
http://tinkerpop.apache.org/docs/current/reference/#vertex-properties

But I'm able to add properties only till 2 levels. i.e. I'm able to add meta properties to properties but is there way to add meta properties to meta properties? I followed the following query:
gremlin> v = g.addV().property('name','marko').property('name','marko a. rodriguez').next()

gremlin> g.V(v).properties().property('date',2014)
==>vp[name->marko a. rodriguez]

gremlin
> g.V(v).properties().properties().property('date1',2015)
org
.janusgraph.graphdb.relations.SimpleJanusGraphProperty cannot be cast to org.apache.tinkerpop.gremlin.structure.Element
Type ':help' or ':h' for help.
Display stack trace? [yN]


Is there a way to add properties of properties?

Also, I'm playing around with Cardinality, and I want to make a Vertex property as List of Key-value pairs:
The structure in my client (Python) is as follows:
ARTICLES: [
                {
                    ARTICLE_ID: 12345,
                    ARTICLE_TITLE: Text,
                    ARTICLE_URL: Text,
                    PRIMARY_SOURCE: Text,
                    SECONDARY_SOURCE: Text,
                    ARTICLE_PUBLISHED_DATE: Text    
                },
                {
                    ARTICLE_ID: 12346,
                    ARTICLE_TITLE: Text,
                    ARTICLE_URL: Text,
                    PRIMARY_SOURCE: Text,
                    SECONDARY_SOURCE: Text,
                    ARTICLE_PUBLISHED_DATE: Text       
                }
        ]

Is there any possible way to address this? I tried doing Cardinality, but it also expects Data type to be specified, and JanusGraph native data types are normal objects like Int, Long but not any standard Key-Value pairs.

My following query returned me error while Schema Generation:
gremlin> caseInfos = mgmt.makePropertyKey('caseInfos').cardinality(Cardinality.LIST).make()
Need to specify a datatype
Type ':help' or ':h' for help.
Display stack trace? [yN]

These data types seems like basic support needed and if there are any suggestions on how to approach such data structure, all suggestions are really helpful

Thanks


Florian Hockmann

unread,
Dec 18, 2017, 4:18:11 AM12/18/17
to JanusGraph users
Hi Debasish,

no, adding meta-properties to meta-properties is not possible (at least not to my knowledge). When you just start with a new schema then I would also strongly consider if you really need meta-properties at all as they might not be supported anymore in TinkerPop 4 as Marko wrote at Gremlin-users:
 I also believe we should get rid of multi- and meta-properties and get back to TinkerPop2 data structure semantics. 

The same applies to multi-properties, but can't you simply model the properties ARTICLE_IDARTICLE_TITLEARTICLE_URL, and so on as normal properties?

Debasish Kanhar

unread,
Dec 18, 2017, 5:59:49 AM12/18/17
to JanusGraph users
Hi Florian,

Thanks for response. So if my understanding is correct then Tinkerpop 4 might remove Multi Properties (Same key storing separate values) and meta properties (Key-value pair inside a key) right? That is going to be huge loss.

As per your question, can I model my properties in better way? I don't seem to find a better way, and if you can suggest it will be great.

So my each node is Entity node. Each entity can be fetched from N number of articles. So, basically for each entity/node I'll have multiple Article_ID, Article_Title etc as its properties corresponding to each source of article. The only way I could think to implement this data structure is to have either List of Multi properties. If you have any suggestion to model this data structure please let me know.

Antriksh Shah

unread,
Dec 18, 2017, 9:08:59 AM12/18/17
to JanusGraph users
Hey Debashish,

Is there any particular reason why you are going ahead with a graph database for this usecase?
Moreover I got confused between entities and articles. Could you please explain these two.

If my understanding is correct, could you have a vertex call entity and a vertex called article. Those properties of articles which can help fetch entity could go as the edge property.
So two vertex types -> entity and articles. 
Since articles help look up vertex-> those fields which help in the lookup become edge property.
Reply all
Reply to author
Forward
0 new messages