A large binary tree with uncertain tree hierarchy. Now we need to realize the following requirements:
1. Record hierarchical relationships. For example: to give you a node id:9, needs to find out the son or grandson under this node, or. Or all descendant nodes
2. I would also like to query the statistical requirements
for requirement 1, I am talking about the node id stored in redis, and the structure is that zset, key is node id,score is hierarchical relationship. If it is a son node, score is-1 and grandson is-2. The levels are infinite, and there may be many layers. The later the score is, the smaller it is.
but there is a problem with this storage, that is, it is not easy to query statistical requirements. For example, I need to query all the new nodes under a node for the day. For this kind of demand, at present, all I can think of is to get the id, of all the descendant nodes under the current node from redis, and then go to the database through id to find out the new nodes of the day through in Filter. This has a problem, that is, if there are too many descendant nodes, the efficiency of in query is very low, and the service will fail.
I wonder if anyone has a better plan. Neo4j, is currently being studied as a graphic database. I wonder if such a requirement can be achieved. Has a great god ever used it?