I am working on a proof of concept that aggregates user comments across N number of dimensional hierarchies. The idea is that when looking at a report in the application a user would put a comment on some data. The coordinate of that comment would be stored as a graph. Likewise the relationship of the members of the dimensions would also. be stored in the graph. Then when users request comments based on a given intersection the application would show all comments on that data point and related data points in the hierarchy.
Sample Graph:
g.addV('Comment')
.property(id, '1')
.property('author', 'john')
.property('content','why is the revenue so high?')
.next()
g.addV('Comment')
.property(id, '8')
.property('author', 'mary')
.property('content','refunds lower than expected')
.next()
g.addV('Element')
.property(id, '2')
.property('name', 'sales revenue')
.property('dimension', 'account')
.property('hierarchy','account')
.next()
g.addV('Element')
.property(id, '3')
.property('name', 'gross revenue')
.property('dimension', 'account')
.property('hierarchy','account').next()
g.addV('Element')
.property(id, '4')
.property('name', 'net revenue')
.property('dimension', 'account')
.property('hierarchy','account').next()
g.addV('Element')
.property(id, '5')
.property('name', 'NY')
.property('dimension', 'location')
.property('hierarchy','location').next()
g.addV('Element')
.property(id, '6')
.property('name', 'NE')
.property('dimension', 'location')
.property('hierarchy','location').next()
g.addV('Element')
.property(id, '7')
.property('name', 'US')
.property('dimension', 'location')
.property('hierarchy','location').next()
g.V('3').addE('parent').to(__.V('2')).property('weight',1.0).next()
g.V('4').addE('parent').to(__.V('3')).property('weight',1.0).next()
g.V('6').addE('parent').to(__.V('5')).property('weight',1.0).next()
g.V('7').addE('parent').to(__.V('6')).property('weight',1.0).next()
g.V('2').addE('dimension').to(__.V('1')).property('weight',1.0).next()
g.V('5').addE('dimension').to(__.V('1')).property('weight',1.0).next()
g.V('4').addE('dimension').to(__.V('8')).property('weight',1.0).next()
g.V('5').addE('dimension').to(__.V('8')).property('weight',1.0).next()
I am trying to write a query (gremlin or cypher) that would return all the comments given a collection of element vertices.
- given "sales revenue" and "NY" the query should return 1 comment
- given "sales revenue" and "US" the query should return 1 comment, traversing all the parent links to find the comment
- given "net revenue" and "US" the query should return 2 comments traversing all parent links finding 1 comment at the intersection of "Net Revenue and NY" and another at the intersection of "NY and Sales Revenue"
I am new to gremlin and cypher so in testing I have been able to start at an element vertex and loop to find a comment, but that is where my success ended.
Thanks!