suggest an example to write spring-boot based rest api using janusgraph

My Json Data is documents is like below, please also suggest relevant data model in JanusGraph (i.e. edge & vertex & properties of vertex choices) As shown in below jsons, Lev1 is parent of Lev2, and Lev2 is parent of Lev3 and so on
8 Replies
gatrad
gatrad11mo ago
Lev 1 { "entries": { "_class": "com.dto.db.Content", "topLevelDomain": "trust", "type": "Lev1", "id": "L1-01", "version": 1, "region": "XX", "state": "EDIT", "properties": { "pId81": "aaa", "pId82": "bbb", "pId83": "ccc" }, "relations": { "children": [ { "id": "L2-01", "type": "Lev2" } ] }, "log": { "createdBy": "abc", "createdAt": "2022-11-14 05:50:57" } } } Lev 2 { "entries": { "_class": "com.dto.db.Content", "topLevelDomain": "trust", "type": "Lev2", "id": "L2-01", "version": 1, "region": "XX", "state": "EDIT", "properties": { "pId14": "zzz", "pId15": "yyy", "pId16": "xxx" }, "relations": { "parents": [ { "id": "L1-01", "type": "Lev1" } ], "children": [ { "id": "L3-01", "type": "Lev3" } ] }, "log": { "createdBy": "abc", "createdAt": "2022-11-14 05:50:57" } } } @Florian Hockmann Please let me know if I am pursuing in right direction when i am thinking to use JanusGraph kind of solution for storing and retriving json documents which are having hierarchical relationships
Florian Hockmann
Florian Hockmann11mo ago
Not sure what you expect to be honest. You are asking in the title for an "example to write spring-boot based rest api" and then in the description you even want a complete data model. If you have some concrete questions like should X be a vertex property or an edge, then we can help you. But expecting community members to create a full data model for you and also implement a REST API for that model is just too much in my opinion. It's also not really possible to suggest a good data model without knowing what you want to do with that data. You should start with writing down questions that you want to answer with your graph and then you can try to create a data model which allows to answer these questions with Gremlin queries
gatrad
gatrad10mo ago
@Florian Hockmann Sorry for confusion by asking multi-faceted question Clarification : I am not expecting community members to write code for me. 1. on spring boot, I am looking for any reference sample spring-boot based api implementation which is leveraging janusgraph and cassandra for creation/update/delete/read of some very simple and elementory graph. @Florian Hockmann As for the data model , you are correct. What I want to know is in janusgraph is it ok to store various fields of json as vertex property and represent relations block as edge? The query which i will be doing on data is 1. get full data hierarchy (with all vertexs+ attributes and its related vertexs+attributes) 2. get vertex individually 3. fetch vertexes data with some attribute based sorting on vertex data (like order by some attribute in sql)
Florian Hockmann
Florian Hockmann10mo ago
OK, thanks for the clarification. I suggest that you create separate questions in the future as that makes it easier for others to quickly see what a question is about so they know whether the question is also interesting to them / whether they can help you I can't really say anything about Spring Boot as I'm not using JanusGraph in Java. Maybe someone else can help you with that
Florian Hockmann
Florian Hockmann10mo ago
is it ok to store various fields of json as vertex property: That shouldn't be a problem in general. Although I would check for your storage backend how well it can handle big string values (although the example JSON documents from your question don't look big to me). Since you are asking for Cassandra, you can check for example this SO post: https://stackoverflow.com/questions/36342531/efficient-way-to-store-a-json-string-in-a-cassandra-column represent relations block as edge: Sure, why not? Your relations look exactly like an edge in a graph database.The type could maybe be the edge label and the created timestamps could be edge properties (if I'm interpreting your example correctly) Your queries also shouldn't be a problem for JanusGraph in general. For queries 1 and 2 you just need to define which properties your want to use to search for the vertices so you can create an index (probably a composite index) on them. 3. fetch vertexes data with some attribute based sorting on vertex data: For this, you probably need a mixed index: https://docs.janusgraph.org/schema/index-management/index-performance/#mixed-index Mixed indices are backed by an index backend like Elasticsearch or Solr. These support richer index queries that for example use the order of property values. Composite indixes which are backed by the storage backend (e.g. Cassandra) only support retrieving vertices based on exact property matches
Stack Overflow
Efficient way to store a JSON string in a Cassandra column?
Cassandra newbie question. I'm collecting some data from a social networking site using REST calls. So I end up with the data coming back in JSON format. The JSON is only one of the columns in my...
gatrad
gatrad10mo ago
@Florian Hockmann Thank you for such a detailed answer. one more doubt I have on type of values I should store for example, i.e. lets say my Vertices are "Lev1" and "Lev2" etc. Now for each of those Vertices. I need to store properties like "id", "version" , "complexFieldMaps", "vertexCreatedBy",... so on and so forth. Now some of the properties like "id", "version" will have String, Integer type value (primitive data types), but properties like "complexFieldMaps" I need to store JSON doc as value. is it allowed in Janusgraph OR should we model our data in some other way rather than storing custom jsons as vertex properties' value? Note that our READ queries will just need to get all properties of any given vertex.
Florian Hockmann
Florian Hockmann10mo ago
The data types supported by JanusGraph are listed here: https://docs.janusgraph.org/schema/#defining-property-keys I would simply serialize your JSON documents as string properties like suggested in the SO answer, especially since you write that you only want to retrieve all properties together. https://stackoverflow.com/a/50478005/6753576
Stack Overflow
How to store JSON or Nested types in JanusGraph?
What is the recommended approach to store JSON or nested type as a property of a vertex? Should it be converted to a string and stored ? Or, Should a separate vertex be created and the JSON contents
gatrad
gatrad10mo ago
@Florian Hockmann Thanks
Want results from more Discord servers?
Add your server