Dynamic bidirectional matching tree menu resource hierarchy retrieval method and system

Through the method of dynamic bidirectional recursive matching of parent and child chains, the problem of parent-child node separation in tree menu resource search is solved, ensuring that the complete hierarchical path of keyword-related nodes is retained, improving operation efficiency and reducing time complexity.

CN120470149APending Publication Date: 2025-08-12FUJIAN TQ ONLINE INTERACTIVE INC
0 Cites 1 Cited by

Patent Information

Application Number
CN202510543223.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

In the existing tree menu resource search method, the one-way filtering logic causes parent-child nodes to be split, and users cannot directly locate the context of resources in the tree structure through keywords, resulting in low operation efficiency and lack of dynamic display capabilities of related resource paths.

Method used

The method of dynamic bidirectional recursion matching parent and child chain is adopted. Through the current node as the starting point, it creates a Boolean array to record the matching results, and combines short-circuit optimization to achieve efficient filtering to ensure that the complete hierarchical path of the keyword-associated node is retained.

Benefits of technology

The complete path display of parent-child nodes in tree data retrieval is realized, which improves operation efficiency, solves the problem of parent-child node splitting in traditional methods, and reduces the time complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470149A_ABST
    Figure CN120470149A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer communication, in particular to a dynamic two-way matching tree menu resource hierarchy retrieval method and system.The method comprises the following steps that 1, when a user inputs a search keyword, whether the keyword is empty or not is judged, if not, a current node serves as a dynamic starting point, and if yes, the current node serves as a dynamic starting point; bidirectional recursion is carried out on the parent level and the child level; 2, in the bidirectional recursion process, detecting whether the current node can be matched with the keyword or not, and judging whether a matching result is stored in an array or not according to a detection result; and step 3, after bidirectional recursion is completed, traversing the array, and returning a final result according to a traversal result. According to the method, through dynamic bidirectional recursive matching of the father chain and the sub-chain, it is ensured that a complete hierarchical path of a keyword association node is reserved, efficient filtering is achieved in combination with short-circuit optimization, and the problem that father and sub-nodes are split in traditional tree data retrieval is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer communication technology, and in particular to a dynamic two-way matching tree menu resource hierarchical retrieval method and system. Background Art

[0002] Existing tree-based menu resource search methods are typically based solely on precise keyword matching of the current node. If a child node matches but the parent node is not associated, or if a parent node matches but the child node is not expanded, this will result in a broken hierarchy, forcing the user to repeatedly expand nodes to locate the target resource. For example, traditional solutions cannot dynamically display the complete associated path through parent node backtracking or child node recursion. The core issues are: the one-way filtering logic separates the parent-child hierarchical relationship, preventing users from directly locating the resource context in the tree structure through keywords; manual layer-by-layer operations are inefficient; and the lack of bidirectional recursive matching results in a lack of the ability to dynamically display related resource paths. Summary of the Invention

[0003] The purpose of the present invention is to provide a dynamic two-way matching tree menu resource hierarchical retrieval method and system, which ensures the preservation of the complete hierarchical path of keyword-related nodes through dynamic two-way recursive matching of parent chains and child chains, combines short-circuit optimization to achieve efficient filtering, and solves the problem of parent-child node separation in traditional tree data retrieval.

[0004] The technical solution of the present invention:

[0005] A dynamic two-way matching tree menu resource hierarchical retrieval method, the method comprising the following steps:

[0006] Step 1: When the user enters a search keyword, determine whether the keyword is empty. If not, use the current node as the dynamic starting point and recurse to the parent and child nodes in both directions.

[0007] Step 2: In the bidirectional recursive process, check whether the current node can match the keyword, and determine whether to store the matching result in an array based on the test result;

[0008] Step 3: After the bidirectional recursion is completed, traverse the array and return the final result based on the traversal result.

[0009] Furthermore, step 1 is further specified as follows: when the user enters a search keyword, determine whether the keyword is empty. If it is empty, directly return to display all data; if it is not empty, use the current node as the dynamic starting point and recurse bidirectionally to the parent and child levels at the same time; and create an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process, and record true if it matches and false if it does not match.

[0010] Furthermore, the step 2 is further specifically as follows:

[0011] Step 21: In the bidirectional recursive process, first check whether the current node can match the keyword. If it matches, store the matching result in an array.

[0012] Step 22: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, store the matching result in an array to achieve parent chain backtracking;

[0013] If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

[0014] Furthermore, the step 21 is further specifically as follows: in the bidirectional recursive process, first detecting whether the current node can match the keyword, and if so, storing the matching result in an array;

[0015] If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched;

[0016] If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

[0017] Furthermore, step 3 is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is returned immediately, that is, the current node, parent node and child node are all displayed.

[0018] A dynamic two-way matching tree menu resource hierarchical retrieval system, the system includes a judgment module, a detection module and a traversal module;

[0019] Judgment module: When the user enters a search keyword, it determines whether the keyword is empty. If it is not empty, it uses the current node as the dynamic starting point and recurses to the parent and child nodes in both directions.

[0020] Detection module: In the bidirectional recursive process, it detects whether the current node can match the keyword, and determines whether to store the matching result into the array based on the detection result;

[0021] Traversal module: After the bidirectional recursion is completed, the array is traversed and the final result is returned based on the traversal result.

[0022] Furthermore, the judgment module is further specified as follows: when the user enters a search keyword, it determines whether the keyword is empty. If it is empty, it directly returns to display all data; if it is not empty, it takes the current node as the dynamic starting point and recurses bidirectionally to the parent and child levels at the same time; and creates an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process. If it matches, it is recorded as true, and if it does not match, it is recorded as false.

[0023] Furthermore, the detection module is further specifically:

[0024] Detection module A: In the bidirectional recursive process, first detect whether the current node can match the keyword. If it does, store the matching result in an array.

[0025] Detection module B: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, the matching result is stored in an array to achieve parent chain backtracking;

[0026] If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

[0027] Furthermore, the detection module A is further specifically configured to: first detect whether the current node can match the keyword in a bidirectional recursive process, and if so, store the matching result in an array;

[0028] If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched;

[0029] If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

[0030] Furthermore, the traversal module is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is returned immediately, that is, the current node, parent node and child node are all displayed.

[0031] Beneficial effects of the present invention:

[0032] The present invention ensures the preservation of the complete hierarchical path of keyword-related nodes through dynamic bidirectional recursive matching of parent chains and child chains, and realizes efficient filtering by combining short-circuit optimization, thus solving the problem of parent-child node separation in traditional tree-based data retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1It is a schematic flow chart of the method of the present invention.

[0034] Figure 2 It is a system principle block diagram of the present invention.

[0035] Figure 3 It is a schematic diagram of the effect of the present invention. DETAILED DESCRIPTION

[0036] The present invention will be further described below with reference to the accompanying drawings.

[0037] like Figure 1 and Figure 3 The present invention provides a dynamic two-way matching tree menu resource hierarchical retrieval method, the method comprising the following steps:

[0038] Step 1: When the user enters a search keyword, determine whether the keyword is empty. If not, use the current node as the dynamic starting point and recurse to the parent and child nodes in both directions.

[0039] Step 2: In the bidirectional recursive process, check whether the current node can match the keyword, and determine whether to store the matching result in an array based on the test result;

[0040] Step 3: After the bidirectional recursion is completed, traverse the array and return the final result based on the traversal result.

[0041] Furthermore, step 1 is further specified as follows: when the user enters a search keyword, determine whether the keyword is empty. If it is empty, directly return to display all data; if it is not empty, use the current node as the dynamic starting point and recurse bidirectionally to the parent and child levels at the same time; and create an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process, and record true if it matches and false if it does not match.

[0042] Furthermore, the step 2 is further specifically as follows:

[0043] Step 21: In the bidirectional recursive process, first check whether the current node can match the keyword. If it matches, store the matching result in an array.

[0044] Step 22: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, store the matching result in an array to achieve parent chain backtracking;

[0045] If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

[0046] Furthermore, the step 21 is further specifically as follows: in the bidirectional recursive process, first detecting whether the current node can match the keyword, and if so, storing the matching result in an array;

[0047] If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched;

[0048] If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

[0049] Furthermore, step 3 is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is returned immediately, that is, the current node, parent node and child node are all displayed.

[0050] The present invention will be further described below in conjunction with a specific embodiment:

[0051] A dynamic two-way matching tree menu resource hierarchical retrieval method, the method comprising the following steps:

[0052] Step 1: When the user enters a search keyword, determine whether the keyword is empty. If not, use the current node as the dynamic starting point and recurse to the parent and child nodes in both directions.

[0053] When the user enters a search keyword, it is determined whether the keyword is empty. If it is empty, all data will be returned directly; if it is not empty, the current node will be used as the dynamic starting point, and recursion will be performed in both directions to the parent and child nodes. An array that only stores Boolean values will be created as a state container. This array is used to record the matching results of each node during the bidirectional recursion process. If it matches, it will be recorded as true, and if it does not match, it will be recorded as false.

[0054] Example: Step 1: Dynamic starting point selection and state initialization

[0055] When the user enters a search keyword ("value"), the system starts the filtering process through the filter function "handlePermFilter". If the keyword is empty ("!value"), all data will be returned directly; if there is a valid keyword, an empty array "array" will be created as a state container to record the matching results of each node in the recursive process. Unlike the traditional solution that traverses from the root node, this method implements dynamic starting point selection by calling the node recursive function "getReturnNode(node,array,value)" - starting from the node currently operated by the user ("node" parameter), and expanding in both directions to the parent and child levels. For example, in the organizational structure tree, if the user selects the "Platform Technology Department" node, the system will trigger recursion directly from this node, rather than starting the entire tree traversal from the root node "NetDragon Group".

[0056] The core of this design is "local bidirectional recursion", which means starting from the current node, tracing back to the parent chain and traversing the child chain downward. In the code, the temporary array "array" only stores Boolean values ("true" / "false"), and shares the state during the recursive process by passing references. This lightweight design that only stores Boolean values avoids the memory overhead of complex objects, while ensuring that the matching status of parent and child nodes can be dynamically accumulated during the recursive process. For example, when the user's operation node is "Platform Technology Department", the recursion will cover its parent chain ("Platform Technology Department> Program Center> NetDragon Group") and child chains (such as "Platform Technology Department> Payment Group and Account Group"), greatly reducing the scope of invalid traversal.

[0057] The code is as follows:

[0058]

[0059]

[0060] Step 2: In the bidirectional recursive process, check whether the current node can match the keyword, and determine whether to store the matching result in an array based on the test result;

[0061] Step 21: In the bidirectional recursive process, first check whether the current node can match the keyword. If it matches, store the matching result in an array.

[0062] In the bidirectional recursive process, first check whether the current node can match the keyword. If it matches, store the matching result in an array.

[0063] If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched;

[0064] If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

[0065] Step 22: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, store the matching result in an array to achieve parent chain backtracking;

[0066] If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

[0067] Example: Step 2: Node matching detection and bidirectional recursive expansion

[0068] The recursive function "getReturnNode" starts from the current node and performs matching detection and bidirectional recursion. First, it determines whether the label of the current node contains the keyword, that is, the code "node.data?.label?.indexOf(value)!==-1". If it matches ("isPass" is "true"), the result is stored in "array"; if it does not match and the current node is not the root node ("node.level!==1"), its parent node ("node.parent") is recursively checked to realize the parent chain backtracking. For example, when a user searches for "Platform Technology Department", if the node "Platform Technology Department" is matched successfully, its parent node "Program Center" will be activated due to recursive backtracking and stored in the `true` mark in `array` even if it is not matched, thereby retaining the complete path on the front end (such as "NetDragon Group>Program Center>Platform Technology Department").

[0069] While the parent chain is backtracking, all child nodes of the current node are traversed to achieve child chain recursion. That is, the code "node.children.forEach(child=>getReturnNode(child,array,value))" traverses all child nodes of the current node to achieve child chain recursion. For example, if the node "Platform Technology Department" is matched successfully, then the "Platform Technology Department" and its child chains (such as "Payment Group and Account Group") will be marked. This two-way recursive mechanism ensures that the complete association structure of the matching nodes is preserved, solving the problem of "parent-child node separation" in traditional solutions. The code limits the parent chain backtracking depth through "node.level!==1" to avoid infinite loops; while the child chain traversal has no hierarchical restrictions and can cover all descendant nodes.

[0070] Step 3: After the bidirectional recursion is completed, traverse the array and return the final result based on the traversal result.

[0071] After the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one of the current node, parent node or child node is matched successfully, the final result is returned immediately, that is, the current node, parent node and child node are all displayed.

[0072] Example: Step 3: Rapid result aggregation and filtering decisions

[0073] After the recursion is completed, the filter function "handlePermFilter" traverses the "array" array. If there is any "true" value in the array (that is, at least one node in the current node, parent chain, or child chain is matched successfully), the calculation is terminated immediately and "true" is returned, that is, the code "result=result||item". For example, when the content of "array" is "[false,true,false]", traversing to the second element returns the result, skipping subsequent invalid operations. This operation uses the "short-circuit optimization" mechanism. When there is at least one true in the array, result will immediately become true, and subsequent items will no longer affect the final result. The time complexity is reduced from O(n) of full traversal to O(1)~O(log n) (In computer science, Big-O notation is used to describe the time complexity or space complexity of an algorithm. This means evaluating the speed of code execution, O(1)>O(logn)>O(n)). For example, when searching for "Platform Technology Department", if the child node matches, its parent chain "Platform Technology Department>Platform Technology Department>Program Center" and child chains (if any) are retained, forming the complete path "NetDragon Group>Program Center>Platform Technology Department>Payment Team and Account Team".

[0074] like Figure 2 ,The present invention also provides a dynamic two-way matching tree menu resource hierarchical retrieval system, the system includes a judgment module, a detection module and a traversal module;

[0075] Judgment module: When the user enters a search keyword, it determines whether the keyword is empty. If it is not empty, it uses the current node as the dynamic starting point and recurses to the parent and child nodes in both directions.

[0076] Detection module: In the bidirectional recursive process, it detects whether the current node can match the keyword, and determines whether to store the matching result into the array based on the detection result;

[0077] Traversal module: After the bidirectional recursion is completed, the array is traversed and the final result is returned based on the traversal result.

[0078] Furthermore, the judgment module is further specified as follows: when the user enters a search keyword, it determines whether the keyword is empty. If it is empty, it directly returns to display all data; if it is not empty, it takes the current node as the dynamic starting point and recurses bidirectionally to the parent and child levels at the same time; and creates an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process. If it matches, it is recorded as true, and if it does not match, it is recorded as false.

[0079] Furthermore, the detection module is further specifically:

[0080] Detection module A: In the bidirectional recursive process, first detect whether the current node can match the keyword. If it does, store the matching result in an array.

[0081] Detection module B: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, the matching result is stored in an array to achieve parent chain backtracking;

[0082] If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

[0083] Furthermore, the detection module A is further specifically configured to: first detect whether the current node can match the keyword in a bidirectional recursive process, and if so, store the matching result in an array;

[0084] If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched;

[0085] If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

[0086] Furthermore, the traversal module is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is returned immediately, that is, the current node, parent node and child node are all displayed.

[0087] In summary, the present invention ensures the preservation of the complete hierarchical path of keyword-related nodes through dynamic bidirectional recursive matching of parent chains and child chains, combines short-circuit optimization to achieve efficient filtering, and solves the problem of parent-child node separation in traditional tree-based data retrieval.

[0088] The above description is only a preferred embodiment of the present invention and should not be understood as limiting the present application. All equivalent changes and modifications made within the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A dynamic two-way matching tree menu resource hierarchical retrieval method, characterized in that: The method comprises the following steps, Step 1: When the user enters a search keyword, determine whether the keyword is empty. If not, use the current node as the dynamic starting point and recurse to the parent and child nodes in both directions. Step 2: In the bidirectional recursive process, check whether the current node can match the keyword, and determine whether to store the matching result in an array based on the test result; Step 3: After the bidirectional recursion is completed, traverse the array and return the final result based on the traversal result.

2. A dynamic two-way matching tree menu resource hierarchical retrieval method according to claim 1, characterized in that: The step 1 is further specifically as follows: when the user enters a search keyword, determine whether the keyword is empty. If it is empty, directly return to display all data; if it is not empty, use the current node as the dynamic starting point and recurse to the parent and child levels in both directions; And create an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process. If it matches, it is recorded as true, and if it does not match, it is recorded as false.

3. A dynamic two-way matching tree menu resource hierarchical retrieval method according to claim 2, characterized in that: The step 2 is further specifically as follows: Step 21: In the bidirectional recursive process, first check whether the current node can match the keyword. If it matches, store the matching result in an array. Step 22: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, store the matching result in an array to achieve parent chain backtracking; If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

4. A dynamic two-way matching tree menu resource hierarchical retrieval method according to claim 3, characterized in that: The step 21 is further specifically as follows: in the bidirectional recursive process, first detecting whether the current node can match the keyword, and if so, storing the matching result in an array; If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched; If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

5. A dynamic two-way matching tree menu resource hierarchical retrieval method according to claim 2, characterized in that: The step 3 is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is immediately returned, that is, the current node, parent node and child node are all displayed.

6. A dynamic two-way matching tree menu resource hierarchical retrieval system, characterized by: The system includes a judgment module, a detection module and a traversal module; Judgment module: When the user enters a search keyword, it determines whether the keyword is empty. If it is not empty, it uses the current node as the dynamic starting point and recurses to the parent and child nodes in both directions. Detection module: In the bidirectional recursive process, it detects whether the current node can match the keyword, and determines whether to store the matching result into the array based on the detection result; Traversal module: After the bidirectional recursion is completed, the array is traversed and the final result is returned based on the traversal result.

7. A dynamic two-way matching tree menu resource hierarchical retrieval system according to claim 6, characterized in that: The judgment module is further specifically configured to: when the user enters a search keyword, determine whether the keyword is empty. If it is empty, directly return to display all data; if it is not empty, use the current node as the dynamic starting point and recurse to the parent and child levels in both directions; And create an array that only stores Boolean values as a state container. This array is used to record the matching results of each node in the bidirectional recursive process. If it matches, it is recorded as true, and if it does not match, it is recorded as false.

8. A dynamic two-way matching tree menu resource hierarchical retrieval system according to claim 7, characterized in that: The detection module is further specifically: Detection module A: In the bidirectional recursive process, first detect whether the current node can match the keyword. If it does, store the matching result in an array. Detection module B: If there is no match and the current node is not the root node, recursively check whether its parent node can match the keyword. If it does, the matching result is stored in an array to achieve parent chain backtracking; If there is no match and the current node is the root node, recursively check whether its child nodes can match the keyword. If they match, the matching results are stored in an array, thereby realizing sub-chain recursion.

9. A dynamic two-way matching tree menu resource hierarchical retrieval system according to claim 8, characterized in that: The detection module A is further specifically configured to: first detect whether the current node can match the keyword in a bidirectional recursive process, and if so, store the matching result in an array; If the current node is not the root node, the parent node and child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched; If the current node is the root node, the child nodes of the current node will be activated and stored in the array due to recursive backtracking even if they are not matched.

10. A dynamic two-way matching tree menu resource hierarchical retrieval system according to claim 7, characterized in that: The traversal module is further specified as follows: after the bidirectional recursion is completed, the array is traversed. If there is any true value in the array, that is, at least one node among the current node, parent node or child node is matched successfully, the final result is immediately returned, that is, the current node, parent node and child node are all displayed.

Citation Information

Cited By

  • Tree structure data real-time filtering method and device for supporting cross-level aggregation and realized by using React

    CN120705372A