Method and device for query statement automatic completion of graph database
By automatically completing syntax keywords, object categories, and attribute categories in the graph database query statement editor, the problem of incomplete completion in traditional editors is solved, thus improving query efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2022-09-26
- Publication Date
- 2026-05-05
AI Technical Summary
Traditional graph database query editors can only complete specific content, lacking comprehensiveness and resulting in low query efficiency.
A method and apparatus are provided to automatically complete input from grammatical keywords, object categories, and attribute categories by acquiring characters input by a user, including querying matching target keywords when the currently input character is not a predetermined character, thereby improving input efficiency.
This improves the input efficiency of graph database query statements, thereby enhancing query efficiency.
Smart Images

Figure CN115438070B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of databases, and more particularly to a method and apparatus for automatically completing query statements for graph databases. Background Technology
[0002] To improve the efficiency of querying graph databases, during the user's input of a graph database query statement (hereinafter referred to as a graph query statement), the query statement editor (hereinafter referred to as the editor) needs to be able to suggest several options for the user to choose from based on the query content already entered. These options are also called completion options. This graph database may store private data.
[0003] In traditional technologies, editors can only complete specific user-inputted content. Therefore, a more comprehensive graph query completion solution is needed. Summary of the Invention
[0004] This specification describes one or more embodiments of a method for automatically completing query statements for graph databases, which can complete various aspects such as syntax and keywords.
[0005] Firstly, a method for automatically completing query statements in graph databases is provided, including:
[0006] During the process of the user entering a graph database query statement based on the target query language, obtain the currently input character;
[0007] If the current input character is not a predetermined character, at least based on the current input character, query each matching target keyword from a number of grammatical keywords; the predetermined character is a reserved character of the target query language;
[0008] Each target keyword is determined as the completion content corresponding to the currently input character.
[0009] Secondly, an apparatus for automatically completing query statements in graph databases is provided, comprising:
[0010] The acquisition unit is used to acquire the currently input characters during the process of the user inputting a graph database query statement based on the target query language;
[0011] A query unit is configured to, when the current input character is not a predetermined character, at least based on the current input character, query a plurality of syntactic keywords for matching target keywords; the predetermined character is a reserved character of the target query language;
[0012] The determining unit is used to determine each target keyword as the completion content corresponding to the currently input character.
[0013] Thirdly, a computer storage medium is provided that stores a computer program thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.
[0014] Fourthly, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.
[0015] The method and apparatus for automatic completion of query statements for graph databases provided in one or more embodiments of this specification, when a user is inputting a graph database query statement based on a target query language, if the currently input character is not a predetermined character, then the matching target keywords are queried from a number of grammatical keywords as the completion content. This helps to improve the input efficiency of grammatical keywords, and thus can improve the query efficiency of graph databases. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram illustrating an implementation scenario of one embodiment disclosed in this specification;
[0018] Figure 2 A flowchart illustrating a method for automatically completing query statements for a graph database according to one embodiment is shown.
[0019] Figure 3 A schematic diagram of an apparatus for automatically completing query statements for a graph database according to one embodiment is shown. Detailed Implementation
[0020] The solution provided in this specification will now be described with reference to the accompanying drawings.
[0021] Figure 1 This is a schematic diagram illustrating an implementation scenario of one of the embodiments disclosed in this specification. Figure 1 In the system, users can enter graph database query statements (hereinafter referred to as graph query statements, which will be explained in detail later) based on the target query language (such as the International Standard Graphic Query Language (iso gql) or Cypher language) through the query statement editor to query the target graph database.
[0022] The query editor described above may further include a client and a server. The server may store several syntax keywords. Taking the target query language as iso gql or cypher as an example, the syntax keywords could be "MATCH", "RETURN", or "LIMIT", etc.
[0023] The aforementioned target graph database can store several relational network graphs, each of which includes several nodes and edges between them. These nodes and edges are collectively referred to as the graphical elements of the relational network graph. Each graphical element possesses the following relevant information: the object category, attribute category, and element identifier of the object it represents (including entities or relationships). Of course, when the graphical element is an edge, the edge's relevant information may also include its start and end points.
[0024] In one example, the query editor client can pre-retrieve several syntax keywords stored on the server. Then, the client can complete the syntax keywords for the graph query entered by the user.
[0025] Specifically, during the user's input of a graph database query statement based on the target query language, the currently input character is obtained. If the currently input character is not a predefined character, at least based on the currently input character, matching target keywords are retrieved from a pool of syntactic keywords. The predefined characters are reserved characters in the target query language. Each target keyword is then determined as the completion content corresponding to the currently input character.
[0026] Of course, in practical applications, the server can also perform syntax keyword completion on the graph query statement entered by the user. It should be understood that when the server performs syntax keyword completion, the client needs to send the characters entered by the user to the server in real time. Afterwards, once the server determines the completed content, it returns the completed content to the client, so that the client can present at least a portion of the completed content to the user.
[0027] In addition, the query statement editor client or server can also complete the query statement with content such as object category or attribute category, and the corresponding completion methods will be explained in detail later.
[0028] The following is a detailed explanation of the graph query statements mentioned above.
[0029] The above graph query statement must include at least the MATCH clause and the RETURN clause.
[0030] For example, a graph query statement can be: MATCH(n: person)-[r: rate]-(m: movie)RETURNn.name,r.starts,m.title.
[0031] The MATCH clause in the graph query statement above can include a matching expression (also called a path), which consists of nodes and / or edges.
[0032] In one example, the matching expression can be represented as: "(n)-[r]-(m)", where "()" is a pairwise symbol corresponding to the first type of node (referred to as first-type symbol), and the letters n and m are user-defined variable names used to define two nodes, which can represent entities of two different entity categories. "[]" is a pairwise symbol corresponding to the second type of edge (referred to as second-type symbol), and the letters within it are user-defined variable names used to define edges, which can represent relationships between entities. Furthermore, "-[r]-" indicates that the edge between nodes is an undirected edge or a bidirectional edge, which can also be replaced by "-[r]->" and "<-[r]-", representing incoming and outgoing edges respectively. It should be understood that incoming and outgoing edges here are relative to node n.
[0033] Of course, in practical applications, the corresponding object category can also be set for the objects represented by nodes or edges. For example, the matching expression can also be: "(n:person)-[r:rate]-(m:movie)", where "person" is the entity category of the entity represented by node n, "movie" is the entity category of the entity represented by node m, and "rate" is the relationship category of the relationship represented by edge r.
[0034] It should be understood that, based on the above matching expression, several network subgraphs can be matched from the relational network graph to be queried.
[0035] The RETURN clause above can include several query fields, each of which can be any of the following: path, node, connection edge, attribute category, and objective function, where the objective function can be, for example, an aggregate function, etc.
[0036] Taking the graph query statement above as an example, the query fields in the RETURN clause include: n.name, r.starts, m.title. Here, "name" is the entity category of the entity represented by node n: the attribute category of "person"; "title" is the entity category of the entity represented by node m: the attribute category of "movie"; "starts" is the relation category of the relationship represented by edge r: the attribute category of "rate".
[0037] It should be noted that the above graph query statement may also include other clauses, such as the LIMIT clause, which is used to limit the number of query results returned. This specification will not elaborate on this further.
[0038] Figure 2 This diagram illustrates a method for auto-completion of query statements for a graph database according to one embodiment. This method can be executed by any system, device, platform, or cluster of devices with computing and processing capabilities. For example, through... Figure 1 The query statement editor in the program is executed on the client or server. For example... Figure 2 As shown, the method may include the following steps.
[0039] Step 202: During the process of the user inputting a graph database query statement based on the target query language, obtain the currently input character.
[0040] Optionally, before obtaining the current input character, a user selection instruction can be received. This selection instruction is used to select the target relational network graph from the target graph database. Afterwards, the query editor's client or server can send a data retrieval request to the target graph database. This data retrieval request is used to request the object categories and attribute categories of the objects represented by the graphical elements in the target relational network graph.
[0041] The graphical elements here include nodes and / or edges. For nodes, the object they represent is an entity; for edges, the object they represent is a relationship. Thus, the above object categories include entity categories and / or relationship categories. Taking a person-relationship network diagram as an example, the entity category represented by a node could be, for example, person, movie, job, etc. The relationship category represented by a node could be, for example, acted-in or rate, etc.
[0042] Furthermore, the objects represented by graphic elements can have several attribute categories, and objects belonging to different object categories will have different attribute categories. For example, for the entity category "person," its attribute categories could be identity, occupation (job), hobby, etc. For the entity category "movie," its attribute categories could be lead actor, director, and running time, etc. For the relationship category "performance," its attribute category could be "role," and for the entity category "rating," its attribute category could be "stars."
[0043] After obtaining the object and attribute categories, the client or server of the query editor can cache them locally. Then, the server can complete the query by providing syntax keywords, object categories, or attribute categories based on the user's input.
[0044] Furthermore, the query statement editor client can retrieve several syntax keywords stored on the server. This allows the client to complete the query statement entered by the user, including syntax keywords, object categories, and attribute categories.
[0045] Returning to step 202, if step 202 is executed by the query statement editor's client, then the client can directly obtain the currently input character. If step 202 is executed by the query statement editor's server, then the server can receive the currently input character obtained by the client from the client.
[0046] Step 204: If the current input character is not a predetermined character, at least based on the current input character, query each target keyword that matches from several grammatical keywords.
[0047] The aforementioned reserved characters belong to the reserved characters of the target query language. Taking ISO GQL or Cypher as examples, the reserved characters here can be, for example, ":" and ".".
[0048] Taking the target query language as an example, which is iso gql or cypher, the syntax keywords here can be, for example, "MATCH", "RETURN" or "LIMIT", etc.
[0049] In one example, the current input character is the first character, and the target keywords that the query matches may include: performing a header match between the current input character and several pre-stored syntactic keywords to obtain the target keywords.
[0050] In another example, where the current input character is not the first character, the target keywords that match the query can include: starting from the current input character, obtaining several consecutive characters including the current input character, and forming a target string based on the input order of these characters. Based on the target string, querying for matching target keywords from several syntax keywords.
[0051] It should be noted that "continuous" as mentioned above means there are no spaces in between. Therefore, the cutoff condition for retrieving several characters forward is reaching the nearest space or reaching the beginning of the query statement.
[0052] For example, suppose the user has entered the query "MAT", that is, the current input character is "T". Then the characters obtained above are "T", "A" and "M". After concatenating them according to the input order of each character, the target string "MAT" is obtained.
[0053] Step 206: Determine the completion content corresponding to each target keyword for the currently input character.
[0054] If step 206 is executed by the query statement editor's client, then the client can present at least part of the completed content to the user for the user to select.
[0055] If step 206 is executed by the query statement editor's server, the server can first return the finalized content to the client, and then the client can present at least part of the finalized content to the user for the user to select.
[0056] It should be noted that user-inputted grammatical keywords can also be highlighted.
[0057] The above explains the methods for completing grammatical keywords. The following explains the methods for completing object categories.
[0058] Specifically, when the current input character is the first symbol, the object categories included in the target relational network graph are obtained and determined as the completion content corresponding to the current input character.
[0059] The first symbol here connects the user-defined variable name to the object category of the graphical element represented by that variable name, which is contained in the input combination qualified by preset pairs of symbols. The different types of these pairs of symbols indicate whether the graphical element is a node or an edge.
[0060] Taking the target query language as iso gql or cypher as an example, the first symbol above can be, for example, ":".
[0061] Taking the aforementioned graph query statement as an example, the variable names and object categories connected by the first symbol are "n" and "person", "m" and "movie", and "r" and "rate", respectively. Furthermore, the first symbol is enclosed in either the input combination "()" or "[]". Here, "()" indicates that the graph element is a node, and "[]" indicates that the graph element is an edge.
[0062] In one example, obtaining the object categories included in the target relational network graph may include: when the paired symbols are first-type symbols corresponding to nodes, obtaining the entity categories of the entities represented by the nodes in the target relational network graph and determining them as the completion content corresponding to the current input character; when the paired symbols are second-type symbols corresponding to edges, obtaining the relation categories of the relations represented by the edges in the target relational network graph and determining them as the completion content corresponding to the current input character.
[0063] Taking the graph query statement mentioned above as an example, assuming that the user has entered the query content as "MATCH(n:)", that is, the current input character is ":", then the entity categories included in the target relational network graph, such as "person" and "movie", can all be determined as the completion content of ":".
[0064] It should be noted that in the query statement editor, paired symbols are usually entered at the same time. For example, when the user enters "(", the editor will automatically complete ")"; and when the user enters "[", the editor will automatically complete "]".
[0065] Since paired symbols are entered simultaneously, when the user enters the above query content, the current input character can be ":".
[0066] Taking the graph query statement mentioned above as an example, assuming that the user has entered the query content as "MATCH(n:person)-[r:]", that is, the current input character is ":", then the various relation categories included in the target relation network graph, such as "acted_in" and "rate", can all be determined as the completion content of ":".
[0067] It should be noted that after presenting at least part of the completed content of the colon to the user, the user can select an object category from it, or continue to enter characters (hereinafter referred to as the first character). If the user continues to enter characters, this solution may also include the following steps:
[0068] Retrieve at least one first character consecutively entered after the current input character to form a first string. Based on the first string, query the target object category from each object category to find the matching target object category, and determine the target object category as the completion content corresponding to at least one first character.
[0069] For example, in the previous example, after presenting "person" and "movie" as completion content to the user, if the user continues to enter the first character "p", that is, the already entered query content is updated to "MATCH(n:p)", and the current input character is updated to "p", then "person" can be used as the completion content corresponding to "p" for the user to choose from.
[0070] In one example, forming the first string as described above may include: starting from the current input character, retrieving each character backward up to the first symbol as at least one first character. It should be understood that the characters retrieved here include the current input character, but not the first symbol. Then, concatenating these first characters in the order they were input yields the first string.
[0071] The above explains the completion methods for object categories. The following explains the completion methods for attribute categories.
[0072] Specifically, if the current input character is the second symbol, obtain the target variable name connected by the second symbol. Based on the target variable name, obtain the target object category corresponding to the target variable name from the already entered query content. Obtain the attribute categories corresponding to the target object category, and determine each attribute category as the completion content corresponding to the current input character.
[0073] The second symbol here connects the user-defined variable name to the attribute category of the object represented by the graphical element defined by that variable name. Furthermore, this second symbol is typically entered after the first symbol mentioned above; that is, the first symbol is entered before the second symbol.
[0074] Taking the target query language as an example, which is iso gql or cypher, the second symbol mentioned above can be, for example, "·".
[0075] Taking the aforementioned graph query statement as an example, the variable names and attribute categories connected by the second symbol are "n" and "name", "r" and "starts", and "m" and "title", respectively.
[0076] As mentioned earlier, objects belonging to different object categories have different attribute categories. Therefore, to complete attribute categories, the object category needs to be determined first. And as previously mentioned, the first symbol is used to connect the variable name and the object category, and the first symbol is usually entered before the second symbol. Therefore, attribute category completion can be achieved based on the connection content of the first symbol (including the variable name and object category).
[0077] In one example, assuming the entered query contains several first symbols, obtaining the target object category corresponding to the target variable name includes: querying the variable names connected by each first symbol that match the target variable name; and determining the object category corresponding to the matched variable name as the target object category.
[0078] Taking the graph query statement above as an example, suppose the user has entered the query: "MATCH(n:person)-[r:rate]-(m:movie)RETURN n.", that is, the current input character is ".". Then, we can match "n" with the variable names "n" and "m" connected by the colon in the entered query. Since the match with "n" is successful, "person" can be identified as the target object category. Afterwards, the attribute categories of "person," such as "job" and "hobby," can be identified as the completion content for ".".
[0079] Similarly, after presenting at least part of the completed content of "." to the user, the user can select an attribute category or continue entering characters (hereinafter referred to as the second character). If the user continues to enter characters, this solution may further include the following steps:
[0080] Retrieve at least one second character that is entered consecutively after the current input character to form a second string. Based on the second string, query the target attribute category from each attribute category to find the matching target attribute category, and determine the target attribute category as the completion content corresponding to at least one second character.
[0081] For example, in the previous example, after presenting "job" and "hobby" as completion content to the user, if the user continues to enter the second character "j", that is, the already entered query content is updated to "MATCH(n:person)-[r:rate]-(m:movie)RETURN nj", and the current input character is updated to "j", then "job" can be used as the completion content corresponding to "j" for the user to choose from.
[0082] In one example, forming the second string as described above may include: starting from the current input character, retrieving each character backward up to the second symbol as at least one second character. It should be understood that the characters retrieved here include the current input character, but not the second symbol. Then, concatenating these second characters in the order they were input yields the second string.
[0083] The above is the method for automatic completion of query statements for graph databases provided in the embodiments of this specification. This solution can complete multiple aspects such as grammatical keywords, object categories, and attribute categories, which helps to improve the input efficiency of graph query statements and thus improve the query efficiency of graph databases.
[0084] Corresponding to the method for automatically completing query statements for graph databases, one embodiment of this specification also provides an apparatus for automatically completing query statements for graph databases, such as... Figure 3 As shown, the device may include:
[0085] The acquisition unit 302 is used to acquire the currently input characters during the process of the user inputting a graph database query statement based on the target query language.
[0086] Query unit 304 is used to query, at least based on the current input character, from a number of syntactic keywords to find matching target keywords when the current input character is not a predetermined character. The predetermined character is a reserved character of the target query language.
[0087] The currently input character is not the first character;
[0088] Query unit 304 is specifically used for:
[0089] Starting from the current input character, retrieve several consecutive characters, including the current input character, and form the target string based on the input order of each character;
[0090] Based on the target string, search for matching target keywords from a number of syntactic keywords.
[0091] The determination unit 306 is used to determine each target keyword as the completion content corresponding to the currently input character.
[0092] Optionally, the above graph database query statement is used to query the target relational network graph in the graph database, and the above-mentioned predetermined characters include a first symbol, which is used to connect the user-defined variable name and the object category of the object represented by the graphical element defined by the variable name;
[0093] The acquisition unit 302 is also used to acquire the object categories included in the target relational network graph when the current input character is the first symbol, and determine them as the completion content corresponding to the current input character.
[0094] The first symbol mentioned above is included in the input combination defined by preset pairs of symbols, and the different types of the pairs of symbols indicate whether the graphic element is a node or an edge; the acquisition unit 302 includes:
[0095] The first acquisition submodule 3022 is used to acquire the entity categories of the entities represented by the nodes in the target relational network graph when the paired symbols are the first type symbols corresponding to the nodes, and determine them as the completion content corresponding to the current input character.
[0096] The second acquisition submodule 3024 is used to acquire each relation category represented by the edge in the target relation network graph when the paired symbols are second type symbols corresponding to the edge, and determine them as the completion content corresponding to the current input character.
[0097] Optionally, the acquisition unit 302 is also used to acquire at least one first character that is continuously input after the current input character to form a first string;
[0098] The query unit 304 is further configured to query a matching target object category from each object category based on the first string, and determine the target object category as the completion content corresponding to the at least one first character.
[0099] Optionally, the above graph database query statement is used to query the target relational network graph in the graph database, and the above-mentioned predetermined characters include a second symbol, which is used to connect the user-defined variable name and the attribute category of the object represented by the graphical element defined by the variable name;
[0100] The acquisition unit 302 is also used to acquire the target variable name connected by the second symbol when the current input character is the second symbol;
[0101] The acquisition unit 302 is also used to obtain the target object category corresponding to the target variable name from the input query content based on the target variable name;
[0102] The determining unit 306 is also used to obtain the attribute categories corresponding to the target object category, and determine each attribute category as the completion content corresponding to the currently input character.
[0103] The entered query content contains several first symbols, each of which is used to connect the user-defined variable name and the object category represented by the graphic element defined by that variable name;
[0104] The acquisition unit 302 is specifically used for:
[0105] From the variable names connected by each first symbol, query the variable name that matches the target variable name;
[0106] The object category corresponding to the queried variable name is determined as the target object category.
[0107] Optionally, the acquisition unit 302 is also used to acquire at least one second character that is continuously input after the current input character, forming a second string;
[0108] The query unit 304 is also used to query the target attribute category that matches from each attribute category based on the second string, and to determine the target attribute category as the completion content corresponding to at least one second character.
[0109] Optionally, the device further includes:
[0110] Presentation unit 308 is used to present at least a portion of the completed content to the user for the user to select.
[0111] The functions of each functional module of the apparatus in the above embodiments of this specification can be implemented through the steps of the above method embodiments. Therefore, the specific working process of the apparatus provided in one embodiment of this specification will not be repeated here.
[0112] This specification provides an embodiment of an apparatus for automatically completing query statements for graph databases. This apparatus can complete various aspects such as grammatical keywords, object categories, and attribute categories, which helps improve the input efficiency of graph query statements and thus improves the query efficiency of graph databases.
[0113] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform a combination Figure 2 The method described in [the document / article].
[0114] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements a combination... Figure 2 The method described.
[0115] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0116] The steps of the methods or algorithms described in conjunction with the disclosure in this specification can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, external hard disk, CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in a server. Of course, the processor and storage medium can also exist as discrete components in the server.
[0117] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium accessible to a general-purpose or special-purpose computer.
[0118] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0119] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this specification. It should be understood that the above description is only a specific embodiment of this specification and is not intended to limit the scope of protection of this specification. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of this specification should be included within the scope of protection of this specification.
Claims
1. A method for automatically completing query statements in graph databases, comprising: During the process of the user entering a graph database query statement based on the target query language, obtain the currently input character; If the current input character is not a predetermined character, at least based on the current input character, query each matching target keyword from several grammatical keywords; the predetermined character is a reserved character of the target query language; and each target keyword is determined as the completion content corresponding to the current input character. If the current input character is a predetermined character and is a first symbol, the object categories included in the target relational network graph in the graph database are obtained and used as the completion content; The first symbol is used to connect the variable name with the object category of the graphic element defined by that variable name.
2. The method according to claim 1, wherein, The currently input character is not the first character; The process of querying matching target keywords from a set of grammatical keywords includes: Starting from the current input character, retrieve several consecutive characters including the current input character, and form the target string based on the input order of each character; Based on the target string, search for matching target keywords from a number of syntactic keywords.
3. The method according to claim 1, wherein, The first symbol is contained in an input combination defined by a preset pair of symbols, the different types of which indicate whether the graphical element is a node or an edge; The object categories included in the target relational network graph obtained from the graph database include: When the paired symbols are first type symbols corresponding to the nodes, obtain the entity categories of the entities represented by the nodes in the target relational network graph, and determine them as the completion content corresponding to the current input character; When the paired symbols are second-type symbols corresponding to edges, obtain the relationship categories of the relationships represented by the edges in the target relationship network graph, and determine them as the completion content corresponding to the current input character.
4. The method according to claim 1, further comprising: Obtain at least one first character that is continuously input after the current input character to form a first string; Based on the first string, a matching target object category is queried from each object category, and the target object category is determined as the completion content corresponding to the at least one first character.
5. The method according to claim 1, wherein, The graph database query statement is used to query the target relational network graph in the graph database; the predefined characters also include a second symbol, which is used to connect the user-defined variable name and the attribute category of the object represented by the graphical element defined by the variable name; the method further includes: If the current input character is the second symbol, obtain the target variable name connected by the second symbol; Based on the target variable name, obtain the target object category corresponding to the target variable name from the input query content; Obtain the attribute categories corresponding to the target object category, and determine the attribute categories as the completion content corresponding to the current input character.
6. The method according to claim 5, wherein, The entered query content contains several first symbols; The step of obtaining the target object category corresponding to the target variable name includes: From the variable names connected by each first symbol, query the variable name that matches the target variable name; The object category corresponding to the queried variable name is determined as the target object category.
7. The method according to claim 5, further comprising: Obtain at least one second character that is continuously input after the current input character to form a second string; Based on the second string, a matching target attribute category is queried from each attribute category, and the target attribute category is determined as the completion content corresponding to the at least one second character.
8. The method according to claim 1, further comprising: Present at least a portion of the completed content to the user for selection.
9. An apparatus for automatically completing query statements in a graph database, comprising: The acquisition unit is used to acquire the currently input characters during the process of the user inputting a graph database query statement based on the target query language; A query unit is configured to, when the current input character is not a predetermined character, at least based on the current input character, query a plurality of syntactic keywords for matching target keywords; the predetermined character is a reserved character of the target query language; The determining unit is used to determine each target keyword as the completion content corresponding to the currently input character; The acquisition unit is further configured to acquire the object categories included in the target relational network graph in the graph database as completion content when the current input character is a predetermined character and is a first symbol; wherein the first symbol is used to connect the variable name with the object category of the object represented by the graphical element defined by the variable name.
10. The apparatus according to claim 9, wherein, The currently input character is not the first character; The query unit is specifically used for: Starting from the current input character, retrieve several consecutive characters including the current input character, and form the target string based on the input order of each character; Based on the target string, search for matching target keywords from a number of syntactic keywords.
11. The apparatus according to claim 9, wherein, The first symbol is contained in an input combination defined by a preset pair of symbols, the different types of which indicate whether the graphical element is a node or an edge; The acquisition unit includes: The first acquisition submodule is used to acquire the entity categories of the entities represented by the nodes in the target relational network graph when the paired symbols are first type symbols corresponding to the nodes, and determine them as the completion content corresponding to the current input character. The second acquisition submodule is used to acquire each relation category of the relation represented by the edge in the target relation network graph when the paired symbols are second type symbols corresponding to the edge, and determine them as the completion content corresponding to the current input character.
12. The apparatus according to claim 9, The acquisition unit is further configured to acquire at least one first character that is continuously input after the current input character, forming a first string; The query unit is further configured to query a matching target object category from the object categories based on the first string, and determine the target object category as the completion content corresponding to the at least one first character.
13. The apparatus according to claim 9, wherein, The graph database query statement is used to query the target relational network graph in the graph database; the predefined characters also include a second symbol, which is used to connect the user-defined variable name and the attribute category of the object represented by the graphical element defined by the variable name; The acquisition unit is further configured to acquire the target variable name connected by the second symbol when the current input character is the second symbol; The acquisition unit is further configured to, based on the target variable name, obtain the target object category corresponding to the target variable name from the input query content; The determining unit is further configured to obtain each attribute category corresponding to the target object category, and determine each attribute category as the completion content corresponding to the current input character.
14. The apparatus according to claim 13, wherein, The entered query content contains several first symbols; The acquisition unit is specifically used for: From the variable names connected by each first symbol, query the variable name that matches the target variable name; The object category corresponding to the queried variable name is determined as the target object category.
15. The apparatus according to claim 13, The acquisition unit is further configured to acquire at least one second character that is continuously input after the current input character, forming a second string; The query unit is further configured to query a matching target attribute category from the attribute categories based on the second string, and determine the target attribute category as the completion content corresponding to the at least one second character.
16. The apparatus of claim 9, further comprising: A presentation unit is used to present at least a portion of the completed content to the user for selection.
17. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed in the computer, it causes the computer to perform the method of any one of claims 1-8.
18. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-8.
Citation Information
Patent Citations
Continuous keyword based code complementing method and device
CN106873956A
Code completion method and device, computing equipment and storage medium
CN110673836A