# US 2024/0202192 A1 · Data query method and apparatus, storage medium, and device

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0202192 A1
- Document ID: US20240202192A1
- Status: Published application
- Kind: A1
- Application number: 18/541,587
- Filed: 2023-12-15
- Published: 2024-06-20
- Earliest claimed: 2022-12-19
- Assignees: Alipay (Hangzhou) Information Technology Co., Ltd.
- Applicants: Alipay (Hangzhou) Information Technology Co., Ltd.
- Inventors: Jingru LIANG; Tao WANG
- Web page: https://patentgrep.com/patent/US20240202192A1

## CPC

- G06F 16/24542: {Plan optimisation}
- G06F 16/9024: {Graphs; Linked lists (G06F16/9027 takes precedence)}
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

This specification discloses a method. The method includes: when a received match statement includes a filtering condition of a path pattern, a node that matches a path in the path pattern is queried from all nodes in the graph database based on the path, to obtain a first node set. A node that meets a matching condition in the match statement is determined from all the nodes in the graph database based on the matching condition. For each node that meets the matching condition, whether the node falls within the first node set is determined. Whether the node belongs to a query result of the match statement is determined based on a determining result. Traversing, based on the path pattern, a path of a node that matches the match statement can be simplified as matching between a node and a node set.

## Claims

### Claim 1

A data query method, wherein the data query method is applied to a graph database, and the method comprises:
receiving a match statement, and when the match statement comprises a filtering condition of a path pattern, querying a node that matches a path in the filtering condition of the path pattern from all nodes in the graph database based on the path, to obtain a first node set;
determining a node that meets a matching condition in the match statement from all the nodes in the graph database based on the matching condition;
for each node that meets the matching condition, determining whether the node falls within the first node set; and
determining, based on a determining result, whether the node belongs to a query result of the match statement.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the querying a node that matches a path in the filtering condition of the path pattern from all nodes in the graph database based on the path, to obtain a first node set specifically comprises:
using the filtering condition of the path pattern as a target condition, and determining another filtering condition in the match statement;
determining another condition associated with the target condition from the another filtering condition based on a node identifier in the filtering condition of the path pattern and a node identifier in the another filtering condition;
fusing the filtering condition of the path pattern and the another condition based on the node identifier in the filtering condition of the path pattern and the node identifier in the another condition associated with the target condition, to obtain a fused filtering condition of the path pattern; and
querying a node that matches a path in the fused filtering condition of the path pattern from all the nodes in the graph database based on the path, to obtain the first node set.

### Claim 3 (depends on 2)

The method according to claim 2, wherein the fusing the filtering condition of the path pattern and the another condition based on the node identifier in the filtering condition of the path pattern and the node identifier in the another condition associated with the target condition, to obtain a fused filtering condition of the path pattern specifically comprises:
determining an attribute value of an attribute corresponding to the node identifier in the another condition associated with the target condition;
determining, as a target identifier from the node identifier in the filtering condition of the path pattern, a node identifier the same as a node identifier corresponding to the attribute value;
assigning a value to an attribute of the target identifier based on the attribute value; and
using, as the fused filtering condition of the path pattern, a filtering condition of the path pattern after a value is assigned to the attribute of the target identifier.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the determining, based on a determining result, whether the node belongs to a query result of the match statement specifically comprises:
when the filtering condition of the path pattern corresponds to positive semantics and the node falls within the first node set, determining that the node belongs to the query result of the match statement; or
when the filtering condition of the path pattern corresponds to positive semantics and the node does not fall within the first node set, determining that the node does not belong to the query result of the match statement; or
when the filtering condition of the path pattern corresponds to negative semantics and the node falls within the first node set, determining that the node does not belong to the query result of the match statement; or
when the filtering condition of the path pattern corresponds to negative semantics and the node does not fall within the first node set, determining that the node belongs to the query result of the match statement.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
when the match statement comprises the filtering condition of the path pattern, determining a first matching condition as a first statement segment based on the filtering condition of the path pattern;
determining a set identifier of a node set obtained through matching based on the first statement segment;
using an original matching condition in the match statement as a second matching condition, and updating the filtering condition based on the set identifier and a node identifier of a node queried based on the match statement, to obtain an updated filtering condition;
generating a second statement segment based on the second matching condition and the updated filtering condition;
generating an optimized match statement based on the first statement segment and the second statement segment; and
executing the optimized match statement, to determine a query result.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the generating an optimized match statement based on the first statement segment and the second statement segment specifically comprises:
obtaining a preset statement template, wherein the statement template comprises an aggregation function template;
determining a node identifier corresponding to a node obtained through matching based on the first statement segment;
determining an aggregation function based on the node identifier corresponding to a node obtained through matching based on the first statement segment, the set identifier, and the aggregation function template, wherein the aggregation function is used to store, in the node set, the node obtained through matching based on the first statement segment;
determining a connection clause based on the statement template and the aggregation function; and
generating the optimized match statement based on the first statement segment, the connection clause, and the second statement segment, wherein
the connection clause is used to input an output of the first statement segment into the second statement segment determined based on the match statement.

### Claim 7

A non-transitory computer-readable storage medium, having stored therein instructions that, when executed by a processor of a computing device, cause the processor to:
receive a match statement, and when the match statement comprises a filtering condition of a path pattern, querying a node that matches a path in the filtering condition of the path pattern from all nodes in a graph database based on the path, to obtain a first node set;
determine a node that meets a matching condition in the match statement from all the nodes in the graph database based on the matching condition;
for each node that meets the matching condition, determine whether the node falls within the first node set; and
determine, based on a determining result, whether the node belongs to a query result of the match statement.

### Claim 8

An electronic device, comprising a memory, a processor, wherein the memory stores executable instructions that, in response to execution by the processor, cause the processor to:
receive a match statement, and when the match statement comprises a filtering condition of a path pattern, querying a node that matches a path in the filtering condition of the path pattern from all nodes in a graph database based on the path, to obtain a first node set;
determine a node that meets a matching condition in the match statement from all the nodes in the graph database based on the matching condition;
for each node that meets the matching condition, determine whether the node falls within the first node set; and
determine, based on a determining result, whether the node belongs to a query result of the match statement.
