RedisGraph How best to store nested objects so they are searchable

48 views Asked by At

RedisGraph can't store nested objects on nodes natively, apparently because Cypher does not. In my use-case, I want to store a map of uuids per node, like this example:

{
  "nodeid": 1,

  // other props...

  // Each node has a varying number of items in map, unknown keys and values, per record. 
  "map": {
    "uuid-1": ["uuid-2", "uuid-3"],
    "uuid-3": ["uuid-4", "uuid-5", "uuid-6"]
  }
}

Then I need to be able to search for all nodes having a top level map key entry of eg "uuid-3" (i.e. not including records where "uuid-3" is in the array.

Now, I tried serialising to a string and storing that on the node, which works but searching is messy. I then tried offloading the map to a RedisJson document linked to the node by the id so I could search the Json doc then get the Graph node.

However, I can't find a way to search the Json by key and, of course, can't make an index because the map data is not consistent.

I can think of a few secondary index type ways to do this but before I spend more time than I have I thought someone else might have been down this path already. Does anyone have any ideas for an efficient way to handle this situation in Redis? ie searching nested data by key rather than value?

Thanks, Murray

0

There are 0 answers