CN-115438070-B - Method and device for automatic completion of query statement of graph database
Abstract
The embodiment of the specification provides a method and a device for automatically completing query sentences of a graph database, wherein in the method for automatically completing query sentences of the graph database, current input characters are acquired in the process of inputting the query sentences of the graph database based on a target query language by a user. In the case where the current input character is not a predetermined character, each of the target keywords that match is queried from among the plurality of grammatical keywords based at least on the current input character. The predetermined character here belongs to a reserved character of the target query language. Each target keyword is determined as complement content corresponding to the currently input character.
Inventors
- LI PENGFEI
Assignees
- 支付宝(杭州)信息技术有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20220926
Claims (18)
- 1. A method of automatic completion of query statements for a graph database, comprising: acquiring a current input character in the process of inputting a graph database query sentence based on a target query language by a user; Inquiring each matched target keyword from a plurality of grammar keywords based on at least the current input character when the current input character is not a preset character, wherein the preset character belongs to reserved characters of the target inquiry language; and under the condition that the current input character is a preset character and is a first symbol, acquiring the object category included in the target relation network diagram in the diagram database and taking the object category as the complement content, wherein the first symbol is used for connecting the variable name and the object category of the object represented by the graphic element defined by the variable name.
- 2. The method of claim 1, wherein the current input character is a non-first character; the method for inquiring the matched target keywords from the grammar keywords comprises the following steps: Starting from the current input character, acquiring a plurality of characters which are continuous in the current input character, and forming a target character string based on the input sequence of each character; and inquiring each matched target keyword from a plurality of grammar keywords based on the target character string.
- 3. The method of claim 1, wherein the first symbol is included in an input combination defined by a preset pair of symbols, different types of the pair of symbols indicating whether the graphical element is a node or an edge, the obtaining object categories included in a target relationship network graph in a graph database includes: Under the condition that the paired symbols are first type symbols corresponding to the nodes, acquiring each entity category of the entity represented by the nodes in the target relation network diagram, and determining the entity category as the complement content corresponding to the current input character; And under the condition that the paired symbols are the second type symbols corresponding to the edges, acquiring each relationship category of the relationship represented by the edges in the target relationship network diagram, and determining the relationship category as the complement content corresponding to the current input character.
- 4. The method of claim 1, further comprising: acquiring at least one first character continuously input after the current input character to form a first character string; And inquiring the matched target object category from the object categories based on the first character string, and determining the target object category as the complement content corresponding to the at least one first character.
- 5. The method of claim 1, wherein the graph database query statement is used to query a target relationship network graph in a graph database, the predetermined character further comprises a second symbol for connecting a variable name defined by a user and an attribute category of an object represented by a graphic element defined by the variable name, and the method further comprises: Acquiring a target variable name connected through the second symbol when the current input character is the second symbol; acquiring a target object category corresponding to the target variable name from the input query content based on the target variable name; And acquiring each attribute category corresponding to the target object category, and determining each attribute category as the complement content corresponding to the current input character.
- 6. The method of claim 5, wherein the already entered query content comprises a number of first symbols; the obtaining a target object class corresponding to the target variable name includes: querying a variable name matched with the target variable name from variable names connected with the first symbols; And determining the object category corresponding to the queried variable name as the target object category.
- 7. The method of claim 5, further comprising: acquiring at least one second character continuously input after the current input character to form a second character string; And inquiring the matched target attribute category from the attribute categories based on the second character string, and determining the target attribute category as the complement content corresponding to the at least one second character.
- 8. The method of claim 1, further comprising: at least part of the complement content is presented to the user for selection by the user.
- 9. An apparatus for automatic completion of query statements for a graph database, comprising: The acquisition unit is used for acquiring the current input character in the process of inputting the query statement of the graph database based on the target query language by the user; The query unit is used for querying each matched target keyword from a plurality of grammar keywords at least based on the current input character when the current input character is not a preset character; A determining unit configured to determine each target keyword as complement content corresponding to the currently input character; the obtaining unit is further configured to obtain, when the current input character is a predetermined character and is a first symbol, an object class included in a target relationship network graph in the graph database as complement content, where the first symbol is used to connect a variable name and an object class of an object represented by a graphic element defined by the variable name.
- 10. The apparatus of claim 9, wherein the current input character is a non-first character; The query unit is specifically configured to: Starting from the current input character, acquiring a plurality of characters which are continuous in the current input character, and forming a target character string based on the input sequence of each character; and inquiring each matched target keyword from a plurality of grammar keywords based on the target character string.
- 11. The apparatus according to claim 9, wherein the first symbol is included in an input combination defined by a preset pair of symbols, different types of the pair of symbols indicating whether the graphic element is a node or an edge, the acquisition unit comprising: the first obtaining submodule is used for obtaining each entity category of the entity represented by the node in the target relation network diagram and determining the entity category as the complement content corresponding to the current input character under the condition that the paired symbol is a first type symbol corresponding to the node; and the second acquisition sub-module is used for acquiring each relationship category of the relationship represented by the edge in the target relationship network diagram and determining the relationship category as the complement content corresponding to the current input character under the condition that the paired symbol is the second type symbol corresponding to the edge.
- 12. An apparatus according to claim 9, The acquisition unit is further used for acquiring at least one first character continuously input after the current input character to form a first character string; The query unit is further configured to query, based on the first character string, a matched target object category from the object categories, and determine the target object category as complement content corresponding to the at least one first character.
- 13. The apparatus of claim 9, wherein the graph database query statement is configured to query a target relationship network graph in a graph database, and wherein the predetermined character further comprises a second symbol for connecting a variable name defined by a user and an attribute category of an object represented by a graphic element defined by the variable name; The obtaining unit is further configured to obtain a target variable name connected through the second symbol when the current input character is the second symbol; The obtaining unit is further configured to obtain, from the query content that has been input, a target object category corresponding to the target variable name based on the target variable name; The determining unit is further configured to obtain each attribute category corresponding to the target object category, and determine each attribute category as the complement content corresponding to the current input character.
- 14. The apparatus of claim 13, wherein the already entered query content comprises a number of first symbols; the acquisition unit is specifically configured to: querying a variable name matched with the target variable name from variable names connected with the first symbols; And determining the object category corresponding to the queried variable name as the target object category.
- 15. An apparatus according to claim 13, The acquisition unit is further used for acquiring at least one second character continuously input after the current input character to form a second character string; And the query unit is further used for querying the matched target attribute category from the attribute categories based on the second character string, and determining the target attribute category as the complement content corresponding to the at least one second character.
- 16. The apparatus of claim 9, further comprising: and the presentation unit is used for presenting at least part of the complement contents to the user for selection by the user.
- 17. A computer readable storage medium having stored thereon a computer program, wherein the computer program, when executed in a computer, causes the computer to perform the method of any of claims 1-8.
- 18. A computing device comprising a memory and a processor, wherein the memory has executable code stored therein, which when executed by the processor, implements the method of any of claims 1-8.
Description
Method and device for automatic completion of query statement of graph database Technical Field One or more embodiments of the present disclosure relate to the field of databases, and in particular, to a method and apparatus for automatically completing query sentences for a graph database. Background In order to improve the query efficiency of the graph database, in the process of inputting query sentences (abbreviated as graph query sentences) of the graph database by a user, a query sentence editor (abbreviated as editor) needs to be able to associate a plurality of options for the user to select according to the query content already input by the user, wherein the plurality of options are also called as complement content. The map database may have stored therein private data. In the conventional art, an editor can only complement specific contents input by a user. Therefore, there is a need to provide a more comprehensive graph query statement completion scheme. Disclosure of Invention One or more embodiments of the present disclosure describe a method for automatically completing query sentences of a graph database, which may implement completion of multiple aspects such as grammar keywords. In a first aspect, a method for automatic completion of a query statement for a graph database is provided, including: acquiring a current input character in the process of inputting a graph database query sentence based on a target query language by a user; Inquiring each matched target keyword from a plurality of grammar keywords based on at least the current input character under the condition that the current input character is not a preset character; and determining each target keyword as the complement content corresponding to the current input character. In a second aspect, an apparatus for automatic completion of query statements for a graph database is provided, including: The acquisition unit is used for acquiring the current input character in the process of inputting the query statement of the graph database based on the target query language by the user; The query unit is used for querying each matched target keyword from a plurality of grammar keywords at least based on the current input character when the current input character is not a preset character; A determining unit for determining each target keyword as the complement content corresponding to the current input character In a third aspect, there is provided a computer storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect. In a fourth aspect, there is provided a computing device comprising a memory having executable code stored therein and a processor which, when executing the executable code, implements the method of the first aspect. In the method and the device for automatically completing query sentences of the graph database provided by one or more embodiments of the present disclosure, in the process of inputting query sentences of the graph database based on the target query language by a user, if the current input character of the user is not a predetermined character, each matched target keyword is queried from a plurality of grammar keywords as the complement content, which is helpful to improve the input efficiency of the grammar keywords, and further can improve the query efficiency of the graph database. Drawings In order to more clearly illustrate the technical solutions of the embodiments of the present description, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present description, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. FIG. 1 is a schematic illustration of an implementation scenario of an embodiment disclosed herein; FIG. 2 illustrates a method flow diagram for query statement autocompletion for a graph database, according to one embodiment; FIG. 3 illustrates an apparatus diagram for query statement autocompletion for a graph database, according to one embodiment. Detailed Description The following describes the scheme provided in the present specification with reference to the drawings. Fig. 1 is a schematic diagram of an implementation scenario of an embodiment disclosed in the present specification. In fig. 1, a user may input a graph database Query sentence (abbreviated as a graph Query sentence, which will be described in detail later) based on a target Query Language (for example, international STANDARD GRAPHIC Query Language (iso gql) or cypher Language) through a Query sentence editor to Query a target graph database. The query term editor may further include a client and a server. The server may have a number of grammar keys stored therein. For example, the target query language is iso