Method, device, electronic device and storage medium for querying association relationship
Through the combination of cache database and multiple databases, the efficiency and accuracy of relationship query in credit risk management is solved, and the correlation relationship between information subjects is effectively identified and analyzed, reducing computing resource consumption.
Patent Information
- Application Number
- CN202410845081.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-06-27
AI Technical Summary
In credit risk management, it is difficult to efficiently identify and analyze the correlation relationship between information subjects. In particular, repeated query tasks require frequent graph search calculations, waste computing resources, and the derived single-layer relationship cannot be accurately identified.
By storing query tasks and results by cache databases, a single-layer network plug-in, graph structure repository and relational database are used to obtain association relationships, so as to reuse cache query results and accurately identify single-layer relationships.
Reduce repeated calculations of association relationships, improve query efficiency, and identify single-layer derivative relationships defined by business through basic association relationship paths, realizing accurate identification and efficient processing of association relationships that require association relationships.
Smart Images

Figure CN118410066B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to an association relationship query method, device, electronic device and storage medium. Background Art
[0002] As financial institutions have increasingly higher requirements for credit risk management, in addition to monitoring traditional credit risk indicators, such as overdue days, overdue amount, overdue period, delay rate, non-performing rate, and bad debt rate, there is also a need to pay close attention to the credit relationships between information subjects derived from credit information, such as family businesses with credit relationships. In addition to credit relationships, there are also various basic relationship information between information subjects, such as employment relationships, legal person relationships, and personal investment relationships.
[0003] At present, most of the information subject association relationships on the market only support hierarchical queries of basic relationships in the graph structure repository. Each query task needs to interact with the graph structure repository to obtain the query results. This method requires a graph search calculation for repeated query tasks, which wastes computing resources. The basic relationship data is directly obtained from the graph structure storage data through the graph computing engine for display, and the derived single-layer relationship cannot be accurately identified, which is not conducive to identifying the relationship information that needs to be focused on. Summary of the invention
[0004] The present invention provides an association relationship query method, device, electronic equipment and storage medium, which are used to solve the defects of the association relationship query analysis method in the prior art.
[0005] The present invention provides a method for querying association relationships, the method comprising:
[0006] In response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in a cache database;
[0007] Determine that there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0008] Determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and return the first query result to the user;
[0009] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0010] According to a method for querying association relationships provided by the present invention, the method responding to the first query task initiated by the user further includes:
[0011] Determine the request ID and query task information of the first query task;
[0012] The request ID and the query task information are stored in the cache database in the form of a key-value pair.
[0013] According to an association relationship query method provided by the present invention, the calling of a single-layer network plug-in, a graph structure repository, a relational database, and the cache database to obtain a first query result of the first query task includes:
[0014] Identifying a relational pattern related to the first query task based on a single-layer network plug-in;
[0015] Based on the relationship model, query the related basic relationships of the first query task from the graph structure repository to obtain an association relationship result set;
[0016] Acquire node information and relationship information related to the association relationship result set from the cache database;
[0017] Based on the node information and the relationship information, acquiring node attributes and relationship attributes related to the first query task from a relationship database;
[0018] The node attributes, the relationship attributes, and the association relationship result set related to the first query task are integrated to obtain a first query result of the first query task.
[0019] A method for querying association relationships provided by the present invention further includes:
[0020] The request ID of the first query task and the first query result are stored in the cache database in the form of a key-value pair.
[0021] According to an association relationship query method provided by the present invention, the identifying of the relationship pattern related to the first query task based on a single-layer network plug-in includes:
[0022] parsing the query task information of the first query task, and determining the task type in the query task information;
[0023] Based on a preset json file, determine the target query path that matches the task type, wherein the preset json file includes predefined query paths for all single-layer relationship patterns, wherein the single-layer relationship patterns include relationship patterns with single basic relationship type labels and relationship patterns with combined basic relationship type labels, and the query path predefines the node types, relationship directions, and relationship types corresponding to all basic relationship type labels;
[0024] Based on the target query path, a relationship model related to the first query task is obtained.
[0025] According to a correlation relationship query method provided by the present invention, determining the target query path matching the task type based on a preset json file includes:
[0026] Determine whether the task type of the query task information has a matching preset single-layer relationship type in the directions object in the preset json file;
[0027] In the case where there is a matching preset single-layer relationship type, based on the general object in the preset json file, when it is determined that the starting node type of the query task information is an enterprise, determine the basic relationship type label that matches the query task information;
[0028] Based on the specific object in the preset json file, the basic relationship information corresponding to the basic relationship type label is defined, and the basic relationship information includes at least one of a node type, a relationship direction, and a relationship type.
[0029] A method for querying association relationships provided by the present invention further includes:
[0030] Based on the labelMap object in the preset json file, the enterprise label is mapped to the node label used in the graph structure repository, so that the graph structure repository can query the relevant basic relationship of the first query task.
[0031] The present invention also provides an association relationship query device, the device comprising:
[0032] A first association relationship query module, configured to determine, in response to a first query task initiated by a user, whether there is a second query task having the same query task information as the first query task in the cache database;
[0033] A second association relationship query module is used to determine whether there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0034] A third association relationship query module is used to determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database and the cache database to obtain a first query result of the first query task, and return the first query result to the user;
[0035] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0036] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned association relationship query methods is implemented.
[0037] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the association relationship query method described in any one of the above is implemented.
[0038] The present invention also provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned association relationship query methods.
[0039] The association relationship query method, device, electronic device and storage medium provided by the present invention determine whether there is a second query task with the same query task information as the first query task in the cache database in response to the first query task initiated by the user; determine whether there is a second query task with the same query task information as the first query task in the cache database, and return the second query result associated with the second query task in the cache database to the user; determine whether there is a second query task with the same query task information as the first query task in the cache database, call a single-layer network plug-in, a graph structure repository, a relational database and a cache database to obtain the first query result of the first query task, and return the first query result to the user; wherein the single-layer network plug-in is used to identify a single-layer relationship, the graph structure repository is used to store basic relationships, the relational database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results. The present invention can obtain repeated query tasks from the query result set stored in the cache database after the first query is completed, thereby reducing repeated calculations of association relationships. In addition, the single-layer network plug-in formed by the single-layer derivative relationship defined by the basic association relationship path identification business is embedded in the graph structure repository for relationship query call, so as to accurately identify the required association relationship. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 It is a flowchart of the association relationship query method provided by the present invention;
[0042] Figure 2 It is a structural schematic diagram of the association relationship query device provided by the present invention;
[0043] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The embodiment of the present invention provides a method for querying association relationships. Among them, the method for querying association relationships provided by the embodiment of the present invention mainly involves four parts: a cache database, a single-layer network plug-in, a graph structure repository, and a relational database. Among them, the cache database is used to store query tasks and query results; the single-layer network plug-in is used to identify single-layer relationships between information subjects, and single-layer relationships refer to direct relationships without considering complex paths or multi-layer relationships; the graph structure repository is used to store basic relationships between information subjects, and basic relationships are usually represented in the form of a graph, in which nodes represent information subjects and edges represent the relationships between them. The relational database is used to store node attributes and relationship attributes.
[0046] Figure 1 is a flow chart of the association relationship query method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0047] Step 110, in response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in the cache database;
[0048] A user can initiate a query task for the association relationship of an information subject, i.e., the first query task, through a certain interface or API. After the system detects the first query task, it will first check whether there is a historical query in the cache database that is the same as the query task information of the first query task, i.e., the second query task.
[0049] Further, the response to the first query task initiated by the user further includes:
[0050] Determine the request ID and query task information of the first query task;
[0051] Store the request ID and the query task information in the form of a key-value pair in the cache database.
[0052] In this step, in order to improve the query efficiency, the data will be first written into the cache database in the form of <unique ID of the request, query task information>.
[0053] For example, when the user initiates the first query task to query the 5-layer associated enterprises with an investment ratio greater than 50%, a guarantee relationship, and a family relationship of enterprise A as the starting point. After the system receives the first query task, it will parse the query task information in the first query task as "Starting point: A. Query relationship: Investment relationship with an investment ratio greater than 50%, guarantee relationship, family relationship. Relationship level: 5 layers. Target node: Enterprise", and generate a unique ID of the request, such as req_id_123. Then, the key-value pair <req_id_123, Starting point: A. Query relationship: Investment relationship with an investment ratio greater than 50%, guarantee relationship, family relationship. Relationship level: 5 layers. Target node: Enterprise> is written into the cache database.
[0054] Through the above cache mechanism, subsequent identical query tasks do not need to repeatedly call the graph structure repository for query, thereby reducing the consumption of computing resources.
[0055] Step 120, determine that there is a second query task in the cache database that is the same as the query task information of the first query task, and return the second query result associated with the second query task in the cache database to the user;
[0056] Check the key-value pairs of request ID - query task information stored in the cache database, and find a second query task with the same query task information (although the request IDs are different, but the query task information is the same). Since the second query result was written into the cache database when the second query task was first queried, the second query result associated with this request ID can be directly obtained from the cache database according to the request ID of the first query of the second query task.
[0057] Step 130, determining that there is no second query task in the cache database that has the same query task information as the first query task, calling the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and returning the first query result to the user;
[0058] Check the key-value pairs of request ID-query task information stored in the cache database and find that there is no identical query task information, that is, the query task information in the first query task is initiated by the user for the first time. Then call the single-layer network plug-in, graph structure repository, relational database and cache database to obtain the first query result of the first query task.
[0059] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relational database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0060] The method provided by the embodiment of the present invention determines whether there is a second query task with the same query task information as the first query task in the cache database in response to the first query task initiated by the user; determines whether there is a second query task with the same query task information as the first query task in the cache database, and returns the second query result associated with the second query task in the cache database to the user; determines whether there is a second query task with the same query task information as the first query task in the cache database, calls a single-layer network plug-in, a graph structure repository, a relational database, and a cache database to obtain the first query result of the first query task, and returns the first query result to the user. For repeated query tasks, they can be obtained from the query result set stored in the cache database after the first query is completed, thereby reducing repeated calculations of association relationships. In addition, the single-layer network plug-in formed by the single-layer derivative relationship defined by the basic association relationship path identification business is embedded in the graph structure repository for relationship query calls, thereby accurately identifying the required association relationships.
[0061] In some embodiments, the calling of the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain the first query result of the first query task includes:
[0062] Identifying a relational pattern related to the first query task based on a single-layer network plug-in;
[0063] Based on the relationship model, query the related basic relationships of the first query task from the graph structure repository to obtain an association relationship result set;
[0064] Acquire node information and relationship information related to the association relationship result set from the cache database;
[0065] Based on the node information and the relationship information, acquiring node attributes and relationship attributes related to the first query task from a relationship database;
[0066] The node attributes, the relationship attributes, and the association relationship result set related to the first query task are integrated to obtain a first query result of the first query task.
[0067] Here, the single-layer network plug-in is a predefined rule engine that analyzes the query conditions and data structures in the query task, thereby identifying the relationship patterns related to the query task. These relationship patterns may define the association relationship between information subjects, which helps to query the graph structure repository more efficiently.
[0068] Once the relationship patterns are identified, the system will use these relationship patterns as guidance to query the basic relationships related to the first query task from the graph structure repository. Here, the basic relationships refer to the nodes (i.e., the information subjects) stored in the graph structure repository and the edges between the nodes (i.e., the relationships between the information subjects). Summarizing all the basic relationships is the association relationship result set of the first query task, which contains all the nodes related to the first query task and the edges between them.
[0069] In this embodiment, the cache database also stores the node information and relationship information (i.e., edge information) involved in the graph structure repository. Nodes represent information subjects, such as individuals, companies, etc., and edges represent the relationships between them. Node information refers to the unique identifiers (such as IDs), names, etc. of these information subjects. Relationship information describes the way nodes are associated with each other. For example, in a business network, relationship information can indicate that one company is a subsidiary of another company, i.e., a control relationship.
[0070] It should be noted that a relational database is a database that uses tables to store data. In a relational database, data is usually organized into rows and columns, with each row representing a record and each column representing an attribute. Records here are divided into node records and relationship records, and attributes are divided into node attributes corresponding to node records and relationship attributes corresponding to relationship records. Node attributes describe the detailed characteristics of the node. For example, a person's name, gender, ID number, etc., or a company's registered name, date of establishment, etc. Relationship attributes describe the specific type of relationship between nodes. For example, legal person relationships, executive relationships, family relationships, investment relationships, etc.
[0071] Here, after obtaining the association result set, the relevant node information and relationship information are obtained from the cache database. Then, this information is used as the query condition to find the detailed attributes related to these node information and relationship information in the relationship database. These attributes provide richer context information for subsequent queries.
[0072] Finally, the system integrates the queried node attributes, relationship attributes, and the associated relationship result set obtained from the graph structure repository, for example, through format conversion, associated matching, and other steps to ensure that the final result set meets the requirements of the query task.
[0073] The integrated result is the first query result of the first query task. This result set contains all data and information related to the query task and is presented to the user in a graphical or structured manner.
[0074] In this embodiment, the advantages of a single-layer network plug-in, a graph structure repository, a relational database, and a cache database are utilized to efficiently process complex query tasks through steps such as identifying relational patterns, querying basic relations, obtaining node information and relational information, and integrating results. This not only improves query efficiency, but also provides richer and more accurate query results.
[0075] In some embodiments, the method further comprises:
[0076] The request ID of the first query task and the first query result are stored in the cache database in the form of a key-value pair.
[0077] In this embodiment, after obtaining the first query result of the first query task, the data is written into the cache database in the form of <requested unique ID, query task information>. Through the above cache mechanism, subsequent identical query tasks do not need to repeatedly call the graph structure repository for query, thereby reducing the consumption of computing resources.
[0078] In some embodiments, the identifying the relationship pattern related to the first query task based on the single-layer network plug-in includes:
[0079] parsing the query task information of the first query task, and determining the task type in the query task information;
[0080] Based on a preset json file, determine the target query path that matches the task type, wherein the preset json file includes predefined query paths for all single-layer relationship patterns, wherein the single-layer relationship patterns include relationship patterns with single basic relationship type labels and relationship patterns with combined basic relationship type labels, and the query path predefines the node types, relationship directions, and relationship types corresponding to all basic relationship type labels;
[0081] Based on the target query path, a relationship model related to the first query task is obtained.
[0082] First, the system needs to parse the query task information of the first query task submitted by the user. Through the parsing system, the user's query requirements can be determined, and the specific type of the first query task can be determined. For example, the task type is to query all positions of a person, or to query all investment relationships between two companies, etc.
[0083] Next, the system will search for a target query path that matches the task type in a preset json file based on the task type obtained by parsing. The json file in this embodiment is predefined and contains query paths for all single-layer relationship patterns, each of which represents a traversal method from a starting node to a target node.
[0084] The query path predefines the node type, relationship direction, and relationship type of all basic relationship type labels.
[0085] The node type here defines the node type involved in the query path, such as individuals, companies, etc. The relationship direction defines the direction of the node relationship traversal involved in the query path, such as from person to company, or from company to person, or from company to company, etc. The relationship type defines the specific association between the nodes involved in the query path, such as family relationship, investment relationship, etc.
[0086] In this embodiment, the system will traverse the predefined query paths in the json file to find the path that matches the current task type. The matching can be based on multiple dimensions such as task type, node type, relationship type, etc.
[0087] Once the target query path is determined, the system can obtain the relationship pattern related to the first query task based on the node type, relationship direction, relationship type, and relationship traversal pattern defined in the target query path. This relationship pattern will serve as a guide for subsequent query operations and help the system extract data related to the query task from the graph structure repository.
[0088] In this embodiment, the task type is determined by parsing the query task information, and then the matching target query path is found using the preset json file, and finally the relationship model related to the query task is obtained based on the target query path. This method improves the accuracy and efficiency of the query, and also makes the query configuration and maintenance of the system more flexible and convenient.
[0089] In some embodiments, determining the target query path matching the task type based on a preset json file includes:
[0090] Determine whether the task type of the query task information has a matching preset single-layer relationship type in the directions object in the preset json file;
[0091] In the case where there is a matching preset single-layer relationship type, based on the general object in the preset json file, when it is determined that the starting node type of the query task information is an enterprise, determine the basic relationship type label that matches the query task information;
[0092] Based on the specific object in the preset json file, the basic relationship information corresponding to the basic relationship type label is defined, and the basic relationship information includes at least one of a node type, a relationship direction, and a relationship type.
[0093] It should be noted here that the general object in the preset json file is used to store and define various single-layer relationship patterns that may be involved in the query, such as the relationship pattern of a single basic relationship type and the relationship pattern of a combined basic relationship type. These relationship types are pre-defined and used to match the relationship types in different query tasks. The general object in the preset json file is used to store and define all basic relationship types. For example, the "asSeed" field indicates whether the end node of the basic relationship of the data to be searched under this label can be used as the end node of a layer of relationship. If the value is true, it can be used as the end node, and if the value is false, it cannot be used as the end node. The "modeNames" field indicates that the content under this label is all basic relationship names. The specific object in the preset json file is used to define the basic relationship information corresponding to the basic relationship type label. This basic relationship information may include node type, relationship direction, relationship type, etc.
[0094] In this embodiment, the system needs to determine whether there is a matching preset single-layer relationship type in the directions object of the preset json file for the task type of the query task information. The directions object may contain multiple predefined single-layer relationship types, which correspond to different query task types. When a preset single-layer relationship type that matches the query task type is found in the directions object, the system will further check the general object in the preset json file. In the general object, the system will determine all basic relationship type labels that match the query task information based on the starting node type of the query task information.
[0095] Here, the basic relationship information corresponding to the basic relationship type label includes the relationship direction “direction”, the end node type “labelName” and the relationship type “typeName”. In this embodiment, the basic relationship information corresponding to each basic relationship mode type label can be flexibly defined according to actual query requirements.
[0096] For example, the relationship direction "direction" can include three types of objects, namely, the first relationship direction object "BOTH" represents a search without distinguishing directions; the second relationship direction object "OUTGOING" represents a one-way search from the starting point to the ending point; the third relationship direction object "INCOMING" represents a one-way search from the ending point to the starting point.
[0097] For example, the end node type "labelName" may include two types of objects, that is, the first end node object "F_CERT" indicates that the end node is an enterprise, and the first end node object "P_CERT" indicates that the end node is an individual.
[0098] For example, the relationship type "typeName" may include two types of objects. The first relationship object "SERVE" represents an executive relationship; the first relationship object "INVEST" represents an investment relationship.
[0099] After determining the basic relationship type label, the system will then check the specific object in the preset json file. The specific object defines the basic relationship information corresponding to each basic relationship type label. The system will find the corresponding basic relationship information in the specific object based on all the basic relationship type labels previously determined, and record the corresponding node type, relationship direction, and relationship type. This information will be used for subsequent query operations from the graph structure repository.
[0100] In some embodiments, it also includes:
[0101] Based on the labelMap object in the preset json file, the enterprise label is mapped to the node label used in the graph structure repository, so that the graph structure repository can query the relevant basic relationship of the first query task.
[0102] In this embodiment, the preset json file also includes a labelMap object, which is used for label mapping. This label mapping is used to convert the enterprise labels used in the query task into the node labels actually used in the graph structure repository.
[0103] In the preset json file, the labelMap object provides a mapping relationship from enterprise labels to actual node labels in the graph structure repository. That is, when the system identifies an enterprise label in a query task, it can look up the labelMap object to find the corresponding node label in the graph structure repository.
[0104] In this embodiment, a query bridge between the single-layer network plug-in and the graph structure repository is also implemented by presetting the labelMap object in the json file.
[0105] For ease of understanding, this embodiment illustrates this by example:
[0106] In this embodiment, the predefined single-layer relationship is divided into a single basic relationship and a combined basic relationship. The single basic relationship is a direct relationship between two information subjects, and the combined basic relationship is an indirect relationship between two information subjects that needs to be connected in series through one or more information subjects.
[0107] For example, when an individual (a) invests in an enterprise (A) or an enterprise (B) invests in an enterprise (A), both are considered to be single-layer relationship models defined by the business, that is, the individual (a) and the enterprise (A) are in an investment relationship or the enterprise (B) and the enterprise (A) are in an investment relationship.
[0108] For example, if an individual (d) serves as a senior executive in two companies (E and F), it is considered a single-layer relationship model defined by the business, that is, the company (E) and the company (F) are in a senior executive relationship. Among them, the individual (d) and the company (E), and the individual (d) and the company (F) are both in a position relationship, but they cannot be regarded as a single-layer relationship model alone.
[0109] In order to simplify the relationship search method, the query path of all single-layer relationship patterns is predefined by using a json file. When querying, it is only necessary to query by calling the single-layer relationship pattern predefined in the json file.
[0110] The json file content is designed according to the predefined single-layer relationship model in this embodiment, including four objects: directions, general, labelMap, and specific. For details, refer to the following Table 1:
[0111] Table 1: Part of the content in the json file
[0112]
[0113] Here, "firm" means the initiating node is an enterprise; "serve" means querying the executive relationship; if the value is "invest", it means querying the investment relationship; "asSeed" indicates whether the end node of the basic relationship of the data to be searched under this label can be used as the end node of the single-layer relationship. If the value is true, it can be used as the end node, and if the value is false, it cannot be used as the end node; "operations" indicates that the relationship is always the first-class path of the initiating node search; "modeNames" indicates that the names of the basic relationships in this label are usually consistent with the relationships stored in the graph structure repository; "control-firm" means that the control relationship needs to be searched and the end node is the enterprise. It can be flexibly changed according to different relationship types and end node types, such as: "invest-firm", "serve-person", etc. "subplan" is used to determine whether to continue searching after the "operations" search is completed. If the content under this label is empty, it means that there is no need to continue searching. If there is content, it is necessary to continue searching. Usually, the structure of the content under this tag is consistent with the content structure under the "firm" tag; "direction" indicates the direction of the relationship. If the value is "BOTH", it indicates a direction-independent search; if the value is "OUTGOING", it indicates a one-way search from the starting point to the ending point; if the value is "INCOMING", it indicates a one-way search from the ending point to the starting point; "labelName" indicates the end node type. If the value is "F_CERT", it indicates that the end node is an enterprise; if the value is "P_CERT", it indicates that the end node is an individual; "typeName" indicates the basic relationship type of the queried data. If the value is "SERVE", it indicates a query of executive relationships; if the value is "INVEST", it indicates a query of investment relationships.
[0114] In this embodiment, the query of investment relationship (B->A) and executive relationship (E<-d->F) is used as an example for explanation:
[0115] Using B and E as the starting nodes, we can query the investment relationship and executive relationship respectively:
[0116] Start reading sequentially from the first line in the JSON file, enter the directions object first, and match it according to the relationship type in the query information. The investment and executive relationships are matched to invest and serve respectively, so both can continue to be queried;
[0117] Enter the general object and determine that the starting nodes (B, E) of the relationship query are both companies, then enter the "firm" tag, which has two child objects;
[0118] Enter the first child object in "firm" in order, and determine that the value of "asSeed" is true, which means that the relationship in the "modeNames" tag in "operations" can be used as a single-layer relationship;
[0119] Enter the first "modeNames" and search for the label at the beginning of the investment and executive relationship. Since only the investment relationship is defined, only the "invest-firm" label with B as the starting node can be matched. Record the label "invest-firm";
[0120] Continue to search for the next "subplan" tag, which is empty, indicating that there is no combined basic relationship under the "operations" tag, only a single basic relationship, that is, "invest-firm";
[0121] Enter the second child object in "firm", determine that the value of "asSeed" is false, and match only the "serve-person" tag related to the executive relationship with E as the starting node in order according to the queried investment and executive relationships, and continue to search for the relationship in the next "subplan" tag for combination and use, and record the tag "serve-person";
[0122] Sequentially enter the "subplan" tag. The value of "asSeed" in this tag is true. Therefore, after the relationship under this tag is obtained, it is combined with other results to form a single-layer relationship. This layer can find the "serve-firm" tag and record the tag "serve-firm";
[0123] Enter the labelMap object and convert "firm" to "F_CERT" for subsequent graph structure repository queries;
[0124] Enter the specific object, find the corresponding object according to the previously recorded "invest-firm", "server-person", and "server-firm" labels, and record the values of the object's "direction", "labelName", and "typeName" to pass to the graph structure repository for query.
[0125] Thus, this embodiment obtains two predefined one-layer relationship patterns according to the query task, namely, the relationship pattern of the single basic relationship type label of "Enterprise B-(Investment)-Enterprise A" and the relationship pattern of the combined basic relationship type label of "Enterprise E-(Executive)-Individual D-(Executive)-Enterprise F". Through the predefined json file, the queryable relationship types are pre-set, and whether they can be used as the basic relationship after the search is made, if not, the extended relationship is continued to be searched on the basis of the relationship, so that the predefined relationship pattern is generated after the combination.
[0126] Based on any of the above embodiments, Figure 2 is a schematic diagram of the structure of the association relationship query device provided by the present invention, such as Figure 2 As shown, the device comprises:
[0127] A first association relationship query module 210 is used to determine whether there is a second query task with the same query task information as the first query task in the cache database in response to a first query task initiated by a user;
[0128] A second association relationship query module 220 is used to determine whether there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0129] The third association relationship query module 230 is used to determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database and the cache database to obtain the first query result of the first query task, and return the first query result to the user;
[0130] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0131] The device provided by the embodiment of the present invention can obtain the query result set stored in the cache database after the first query for repeated query tasks, thereby reducing the repeated calculation of the association relationship. In addition, the single-layer network plug-in formed by the single-layer derivative relationship defined by the basic association relationship path recognition business is embedded in the graph structure repository for relationship query call, thereby realizing accurate identification of the required association relationship.
[0132] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the association relationship query method, which includes:
[0133] In response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in a cache database;
[0134] Determine that there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0135] Determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and return the first query result to the user;
[0136] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0137] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0138] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the association relationship query method provided by the above methods, the method includes:
[0139] In response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in a cache database;
[0140] Determine that there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0141] Determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and return the first query result to the user;
[0142] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0143] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for querying the association relationship provided by the above methods is implemented, and the method includes:
[0144] In response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in a cache database;
[0145] Determine that there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user;
[0146] Determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and return the first query result to the user;
[0147] Among them, the single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results.
[0148] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0149] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for querying association relationships, characterized in that: The method comprises: In response to a first query task initiated by a user, determining whether there is a second query task having the same query task information as the first query task in a cache database; Determine that there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user; Determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain a first query result of the first query task, and return the first query result to the user; The single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results; The calling of the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain the first query result of the first query task includes: Identifying a relational pattern related to the first query task based on a single-layer network plug-in; Based on the relationship model, query the related basic relationships of the first query task from the graph structure repository to obtain an association relationship result set; Acquire node information and relationship information related to the association relationship result set from the cache database; Based on the node information and the relationship information, acquiring node attributes and relationship attributes related to the first query task from a relationship database; The node attributes, the relationship attributes, and the association relationship result set related to the first query task are integrated to obtain a first query result of the first query task.
2. The method for querying association relationships according to claim 1, characterized in that: The step of responding to the first query task initiated by the user further includes: Determine the request ID and query task information of the first query task; The request ID and the query task information are stored in the cache database in the form of a key-value pair.
3. The method for querying association relationships according to claim 2, characterized in that: The method further comprises: The request ID of the first query task and the first query result are stored in the cache database in the form of a key-value pair.
4. The method for querying association relationships according to claim 2, characterized in that: The identifying the relationship pattern related to the first query task based on the single-layer network plug-in includes: parsing the query task information of the first query task, and determining the task type in the query task information; Based on a preset json file, determine the target query path that matches the task type, wherein the preset json file includes predefined query paths for all single-layer relationship patterns, wherein the single-layer relationship patterns include relationship patterns with single basic relationship type labels and relationship patterns with combined basic relationship type labels, and the query path predefines the node types, relationship directions, and relationship types corresponding to all basic relationship type labels; Based on the target query path, a relationship model related to the first query task is obtained.
5. The method for querying association relationships according to claim 4, characterized in that: The step of determining the target query path matching the task type based on the preset json file includes: Determine whether the task type of the query task information has a matching preset single-layer relationship type in the directions object in the preset json file; In the case where there is a matching preset single-layer relationship type, based on the general object in the preset json file, when it is determined that the starting node type of the query task information is an enterprise, determine the basic relationship type label that matches the query task information; Based on the specific object in the preset json file, the basic relationship information corresponding to the basic relationship type label is defined, and the basic relationship information includes at least one of a node type, a relationship direction, and a relationship type.
6. The method for querying association relationships according to claim 4, characterized in that: Also includes: Based on the labelMap object in the preset json file, the enterprise label is mapped to the node label used in the graph structure repository, so that the graph structure repository can query the relevant basic relationship of the first query task.
7. A correlation relationship query device, characterized in that: The device comprises: A first association relationship query module, configured to determine, in response to a first query task initiated by a user, whether there is a second query task having the same query task information as the first query task in the cache database; A second association relationship query module is used to determine whether there is a second query task in the cache database having the same query task information as the first query task, and return a second query result associated with the second query task in the cache database to the user; A third association relationship query module is used to determine that there is no second query task with the same query task information as the first query task in the cache database, call the single-layer network plug-in, the graph structure repository, the relational database and the cache database to obtain a first query result of the first query task, and return the first query result to the user; The single-layer network plug-in is used to identify single-layer relationships, the graph structure repository is used to store basic relationships, the relationship database is used to store node attributes and relationship attributes, and the cache database is used to store query tasks and query results; The calling of the single-layer network plug-in, the graph structure repository, the relational database, and the cache database to obtain the first query result of the first query task includes: Identifying a relational pattern related to the first query task based on a single-layer network plug-in; Based on the relationship model, query the related basic relationships of the first query task from the graph structure repository to obtain an association relationship result set; Acquire node information and relationship information related to the association relationship result set from the cache database; Based on the node information and the relationship information, acquiring node attributes and relationship attributes related to the first query task from a relationship database; The node attributes, the relationship attributes, and the association relationship result set related to the first query task are integrated to obtain a first query result of the first query task.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the association relationship query method as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the association relationship query method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Query request asynchronous processing method and device, computer equipment and storage medium
CN114218267A
Batch query method, device and equipment for incidence relation
CN114625783A
Data processing method based on power grid resource data
CN115658642A
Querying one or more databases
US20140280326A1
