unipop
unipop copied to clipboard
Elastic Edges Example
Was digging through the code a bit trying to find an example of what I would do if my documents in elastic search represent nodes and edges. For instance I have documents that look like the following, how would I represent that using unipop? User A and User B are nodes, and a case could be made for the message also being a node and the edge contains the timestamp.
{
"userA": "000000001",
"timestamp": "2015-01-01T05:14:22",
"message": "Writing on your wall",
"userB": "000000002"
}
From what I can tell, my guess would be that I use an ElasticEdgeController, but its not entirely clear how to actually use that to build my graph and run gremlin queries across it. Can you provide an example of how to do that?
For already existing documents you have the Schema based controllers (SchemaVertexController, SchemaEdgeController, and SchemaControllerManager). To use them you need to define a GraphElementSchemaProvider, which tells the controllers how the documents are arranged to form a graph. You can see an example here: https://github.com/rmagen/unipop/blob/master/unipop-elastic/test/org/unipop/elastic/schema/misc/ModernGraphElementSchemaProvider.java
The example is rather elaborate because it needs to support the many many gremlin tests available.
We're working on better documentation for all usecases. Let me know if you have any more questions.