CN115481145A - Data query method, device, equipment and medium based on search engine - Google Patents
Data query method, device, equipment and medium based on search engine Download PDFInfo
- Publication number
- CN115481145A CN115481145A CN202210977202.6A CN202210977202A CN115481145A CN 115481145 A CN115481145 A CN 115481145A CN 202210977202 A CN202210977202 A CN 202210977202A CN 115481145 A CN115481145 A CN 115481145A
- Authority
- CN
- China
- Prior art keywords
- query
- query statement
- database
- search engine
- preset
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000004458 analytical method Methods 0.000 claims description 25
- 239000011159 matrix material Substances 0.000 claims description 20
- 238000013145 classification model Methods 0.000 claims description 12
- 238000001914 filtration Methods 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 11
- 238000007619 statistical method Methods 0.000 claims description 6
- 238000006243 chemical reaction Methods 0.000 claims description 4
- 238000012216 screening Methods 0.000 claims description 3
- 238000013473 artificial intelligence Methods 0.000 abstract description 5
- 238000005516 engineering process Methods 0.000 abstract description 5
- 230000006870 function Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 8
- 238000007726 management method Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000007405 data analysis Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2452—Query translation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
- G06F16/2445—Data retrieval commands; View definitions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/04—Inference or reasoning models
- G06N5/041—Abduction
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Mathematical Physics (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Computation (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to an artificial intelligence technology, and discloses a data query method based on a search engine, which comprises the following steps: acquiring an input SQL query statement; extracting key words of a preset database, and deducing the type of the preset database by using the key words; converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relation corresponding table; and querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result. In addition, the invention also relates to a block chain technology, and the keyword and operation relation corresponding table can be stored in the nodes of the block chain. The invention also provides a data query device based on the search engine, electronic equipment and a storage medium. The invention can improve the complex data query efficiency.
Description
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a data query method and device based on a search engine, electronic equipment and a computer readable storage medium.
Background
With the development of computer technology, some search engines are greatly convenient for people to work and live, and users can query information by using the search engines.
When a current search engine carries out complex data query, two ways are generally available: the query method is complex and has higher requirements on the compiling capability of the inquirers; secondly, the SQL plug-in is used in the search engine to realize the query function, for example: SQL plug-ins are arranged in a server or middleware of an elastic search engine (ES for short), but the SQL plug-ins cause overlarge ES memory occupation and reduced access rate, so that the query efficiency is lowered.
In summary, current complex data queries are inefficient.
Disclosure of Invention
The invention provides a data query method and device based on a search engine and a computer readable storage medium, and mainly aims to solve the problem of low efficiency in complex data query.
In order to achieve the above object, the present invention provides a data query method based on a search engine, which includes:
acquiring an input SQL query statement;
extracting key words of a preset database, and deducing the type of the preset database by using the key words;
converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relation corresponding table;
and querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
Optionally, the extracting keywords of the preset database, and inferring a type of the preset database by using the keywords include:
segmenting words of data information in the preset database into vocabularies, screening out the vocabularies with the occurrence frequency larger than a preset threshold value from the vocabularies as a keyword information set, and converging the keyword information set to generate a vocabulary entry sequence;
constructing a keyword characteristic matrix by using the entry sequence;
and deducing the type of the preset database by utilizing a matching layer and a full connection layer in a preset matching classification model according to the keyword feature matrix.
Optionally, the inferring a type of the preset database by using a matching layer and a full connection layer in a preset matching classification model according to the keyword feature matrix includes:
performing outer product on the keyword feature matrix according to preset keyword features by using a matching layer in a preset matching classification model to obtain a keyword similarity matrix;
calculating the similarity score of the keyword similarity matrix by using a full connection layer in the preset matching classification model;
and when the similarity score is greater than or equal to a preset similarity threshold, taking the database type corresponding to the corresponding preset keyword label as the type of the preset database.
Optionally, before the root converts the SQL query statement into the ES query statement based on an abstract syntax tree structure according to the type of the database and the pre-constructed operation relationship correspondence table, the method further includes:
extracting query statement sets of each relational database and ES search engine, and clustering the query statement sets to obtain operation names corresponding to the query statement sets;
and constructing an operation relation corresponding table according to the operation name and the query statement set.
Optionally, the converting the SQL query statement into the ES query statement based on the abstract syntax tree according to the type of the database and the pre-constructed operation relationship correspondence table includes:
establishing a file related to lexical analysis and syntactic analysis, and generating a corresponding syntactic analysis class according to the file related to lexical analysis and syntactic analysis;
analyzing the SQL query statement into a syntax tree based on an abstract syntax tree structure according to the lexical analysis class and the syntax analysis class;
extracting SE keywords and symbols of corresponding ES statements according to each operation name in the pre-constructed operation relation corresponding table, extracting SQL keywords and symbols of corresponding SQL statements of various relational databases, and carrying out one-to-one correspondence on the SE keywords and the symbols and the SQL keywords and the symbols by utilizing a tree structure to construct a keyword and symbol corresponding relation table;
and analyzing the syntax tree into ES query sentences according to the type of the database and the corresponding relation table of the keywords and the symbols.
Optionally, the parsing the SQL query statement into a syntax tree based on an abstract syntax tree structure according to the lexical parsing class and the syntax parsing class includes:
extracting the query condition in the SQL query statement to generate a filtering condition;
splicing the filtering conditions to obtain a filtering condition sequence;
and calling a grammar parsing method in the grammar parsing class to construct a Walker class, calling a grammar tree constructing method in the Walker class, and parsing the filtering condition sequence into ES query statements.
Optionally, the querying according to the ES query statement, querying the preset database by using a search engine to obtain a query result, including:
querying the preset database by using the ES query statement to obtain service query result data;
matching the service query result data with parameters of a statistical and analytical method in the preset database to obtain configuration parameters;
and analyzing the service query result data by using the configuration parameters to obtain a query result.
In order to solve the above problem, the present invention further provides a data query apparatus based on a search engine, the apparatus comprising:
the query statement acquisition module is used for acquiring the input SQL query statement;
the type inference module of the database is used for extracting key words of a preset database and inferring the type of the preset database by using the key words;
the query statement conversion module is used for converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relationship corresponding table;
and the query module is used for querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and (c) a second step of,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the search engine-based data query method described above.
In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the search engine-based data query method described above.
According to the method and the device, keywords of a preset database are extracted, the type of the preset database is deduced by using the keywords, the SQL query statement is converted into the ES query statement according to the type of the database and a pre-constructed operation relation corresponding table and based on an abstract syntax tree structure, so that the syntax structure of the corresponding query statement can be mapped quickly according to the type of the database, and the pre-constructed operation relation correspondingly supports multiple relational types; according to the ES query statement query, a search engine is used for querying the preset database to obtain a query result, and the SQL query statement is directly used to obtain the corresponding query result without SQL plug-in, middleware or complex compiled query statements, so that the query operation of a user is simplified, and the data query efficiency is improved. Therefore, the data query method, the data query device, the electronic equipment and the computer readable storage medium based on the search engine can solve the problem of low efficiency in complex data query.
Drawings
Fig. 1 is a schematic flowchart of a data query method based on a search engine according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a detailed implementation of one step in the search engine-based data query method shown in FIG. 1;
FIG. 3 is a flowchart illustrating a detailed implementation of one step in the search engine-based data query method shown in FIG. 1;
FIG. 4 is a functional block diagram of a data query device based on a search engine according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device for implementing the search engine-based data query method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
The embodiment of the application provides a data query method based on a search engine. The execution subject of the search engine-based data query method includes, but is not limited to, at least one of electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiments of the present application. In other words, the search engine-based data query method may be performed by software or hardware installed in a terminal device or a server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, web service, cloud communication, middleware service, domain name service, security service, content Delivery Network (CDN), and a big data and artificial intelligence platform.
Fig. 1 is a schematic flowchart of a data query method based on a search engine according to an embodiment of the present invention. In this embodiment, the search engine elastic search (ES for short) is a distributed, high-expansion, high-real-time search and data analysis engine, and currently, complex SQL queries mainly use ES for querying.
In this embodiment, the data query method based on a search engine includes:
s1, acquiring an input SQL query statement.
In the embodiment of the invention, the input SQL query statement is obtained BY utilizing the preset buried point, wherein the SQL is a database query and programming language and is used for accessing data and querying, updating and managing a relational database system, for example, the SQL query statement comprises SELECT FROM table _001WHERE a =1 and (b =2 or b = 3) ORDER BY d desc.
And S2, extracting key words of a preset database, and deducing the type of the preset database by using the key words.
In the embodiment of the present invention, the preset database may be any relational database, such as Oracle, DB2, microsoft SQL Server, microsoft Access, mySQL, sybase, and the like.
In detail, referring to fig. 2, the S2 includes:
s21, segmenting words of data information in the preset database into vocabularies, screening out the vocabularies with the occurrence frequency larger than a preset threshold value from the vocabularies to serve as a keyword information set, and gathering the keyword information set to generate a vocabulary entry sequence;
s22, constructing a keyword feature matrix by using the entry sequence;
and S23, deducing the type of the preset database by utilizing a matching layer and a full connection layer in a preset matching classification model according to the keyword feature matrix.
In the embodiment of the invention, the preset matching classification model can be composed of a convolution layer, a matching layer and a full connection layer, wherein the convolution layer can extract a keyword feature matrix in data information in the preset database; the similarity matching layer can perform outer product on the text to be matched to obtain a similarity matrix; wherein the fully connected layer can be subjected to similarity score by normalizing the two-dimensional vector by softmax.
In one embodiment of the invention, the keyword feature matrix of the data information in the preset database is extracted from a plurality of scales by utilizing 1 × 1 convolution, 3 × 3 convolution and 5 × 5 convolution, so that the obtained features are richer and more accurate in classification judgment.
In detail, the S23 includes:
performing outer product on the keyword feature matrix according to preset keyword features by using a matching layer in a preset matching classification model to obtain a keyword similarity matrix;
calculating the similarity score of the keyword similarity matrix by using a full connection layer in the preset matching classification model;
and when the similarity score is greater than or equal to a preset similarity threshold value, taking the database type corresponding to the corresponding preset keyword label as the type of the preset database.
In the embodiment of the present invention, the preset keyword feature tag is a database keyword feature extracted from each relational database, and has a one-to-one correspondence relationship with the relational database, and the specific type of the database may be mapped by the database keyword feature.
According to the embodiment of the invention, the type of the preset database is deduced according to the key words of the preset database, so that the quick mapping of the syntactic structure of the corresponding query statement according to the type of the database is facilitated.
And S3, converting the SQL query statement into an ES query statement based on an abstract syntax tree according to the type of the database and the pre-constructed operation relation corresponding table.
In the embodiment of the invention, the ES query statement is a language corresponding to an ES search engine, and a server of the ES search engine generally does not support an SQL language. The SQL language can be converted into the DSL language, namely the SQL query statement is converted into the ES query statement, so that the problem that if the SQL plug-in is not installed at the server of the search engine or the version of the server is not matched with that of the client, the server does not support the SQL language or cannot accurately identify the SQL language, and the target method in the query request cannot be accurately executed can be avoided.
In detail, the method before S3 further includes:
extracting query statement sets of each relational database and ES search engine, and clustering the query statement sets to obtain operation names corresponding to the query statement sets;
and constructing an operation relation corresponding table according to the operation name and the query statement set.
In one embodiment of the present invention, the syntax structure of the first ten records of the relational database MySQL query is: select from table _001limit 10; the syntax structure of the first ten records of the query of the relational database SQLServer is as follows: select top 10 from student.
In the embodiment of the invention, the operation relation corresponding table can support different relational databases, and the universality of complex data query is improved.
In detail, referring to fig. 3, the S3 includes:
s31, constructing a file related to lexical analysis and grammar analysis, and generating a corresponding grammar analysis class according to the file related to the lexical analysis and the grammar analysis;
s32, according to the lexical analysis class and the syntax analysis class, analyzing the SQL query statement into a syntax tree based on an abstract syntax tree structure;
s33, extracting SE keywords and symbols of corresponding ES statements according to each operation name in the pre-constructed operation relation corresponding table, extracting SQL keywords and symbols of corresponding SQL statements of various relational databases, and carrying out one-to-one correspondence on the SE keywords and the symbols and the SQL keywords and the symbols by utilizing a tree structure to construct a keyword and symbol corresponding relation table;
and S34, analyzing the syntax tree into ES query sentences according to the type of the database and the corresponding relation table of the keywords and the symbols.
IN the embodiment of the present invention, for example, the SQL keywords AND symbols extracted from the SQL statement are DISTINCT, AND, OR, NOT, =, > = < = > < betweeen, LIKE, IN, group by, LIMIT, AND may be similar to the SE keywords AND symbols: aggs, must, should, must _ not, term, range, regexp, term, aggs and size are in one-to-one correspondence.
Further, the S32 includes:
extracting the query condition in the SQL query statement to generate a filtering condition;
splicing the filtering conditions to obtain a filtering condition sequence;
and calling a grammar parsing method in the grammar parsing class to construct a Walker class, calling a grammar tree constructing method in the Walker class, and parsing the filtering condition sequence into ES query statements.
In the embodiment of the invention, the Walker class is a self-defined Java class and is used for constructing an Antlr syntax tree, wherein the Antlr is an open source syntax analyzer which can automatically generate the syntax tree according to input and can be visually displayed.
According to the embodiment of the invention, the SQL query statement is converted, so that SQL analysis is transferred from the SQL plug-in to the client of the search engine, and the SQL can be developed or used in the search engine environment without the SQL plug-in/middleware, so that the problems of overlarge ES memory occupation and low access rate caused by the SQL plug-in can be avoided, and the efficiency of complex data query is improved.
And S4, inquiring the preset database by using a search engine according to the ES inquiry statement to obtain an inquiry result.
In detail, the S4 includes:
querying the preset database by using the ES query statement to obtain service query result data;
matching the service query result data with parameters of a statistical and analytical method in the preset database to obtain configuration parameters;
and analyzing the service query result data by using the configuration parameters to obtain a query result.
Furthermore, the embodiment of the invention also provides a parameter adjusting interface for professionals, can realize the function of manually inputting parameters to adjust configuration parameters, and realizes more accurate statistical analysis effect.
The embodiment of the invention provides a common statistical and data analysis method for processing the service query result data, wherein the data analysis is to analyze a large amount of collected data by using a proper statistical analysis method, and summarize, understand and digest the data so as to maximally develop the function of the data and play the role of the data, so that the query result is closer to the service requirement.
According to the method and the device, keywords of a preset database are extracted, the type of the preset database is deduced by using the keywords, the SQL query statement is converted into the ES query statement according to the type of the database and a pre-constructed operation relation corresponding table and based on an abstract syntax tree structure, so that the syntax structure of the corresponding query statement can be mapped quickly according to the type of the database, and the pre-constructed operation relation correspondingly supports multiple relational types; according to the ES query statement query, a search engine is used for querying the preset database to obtain a query result, and the SQL query statement is directly used to obtain the corresponding query result without SQL plug-in, middleware or complex compiled query statements, so that the query operation of a user is simplified, and the data query efficiency is improved. Therefore, the data query method based on the search engine can solve the problem of low efficiency in complex data query.
Fig. 4 is a functional block diagram of a data query apparatus based on a search engine according to an embodiment of the present invention.
The data query apparatus 100 based on the search engine according to the present invention may be installed in an electronic device. According to the implemented functions, the search engine-based data query apparatus 100 may include a query statement acquisition module 101, a database type inference module 102, a query statement conversion module 103, and a query module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and can perform a fixed function, and are stored in a memory of the electronic device.
In the present embodiment, the functions of the respective modules/units are as follows:
the query statement acquisition module 101 is configured to acquire an input SQL query statement;
the type inference module 102 of the database is configured to extract a keyword of a preset database, and infer a type of the preset database by using the keyword;
the query statement conversion module 103 is configured to convert the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relationship correspondence table;
the query module 104 is configured to query the preset database by using a search engine according to the ES query statement to obtain a query result.
In detail, when the modules in the data query device 100 based on a search engine according to the embodiment of the present invention are used, the same technical means as the data query method based on a search engine described in fig. 1 to fig. 3 are used, and the same technical effect can be produced, which is not described herein again.
Fig. 5 is a schematic structural diagram of an electronic device implementing a data query method based on a search engine according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may further comprise a computer program, such as a search engine based data query program, stored in the memory 11 and executable on the processor 10.
In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same function or different functions, and includes one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the whole electronic device by using various interfaces and lines, and executes various functions of the electronic device and processes data by running or executing programs or modules (for example, executing a search engine-based data query program, etc.) stored in the memory 11 and calling data stored in the memory 11.
The memory 11 includes at least one type of readable storage medium including flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only to store application software installed in the electronic device and various types of data, such as codes of a search engine-based data query program, but also to temporarily store data that has been output or will be output.
The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
The communication interface 13 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are typically used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
Fig. 5 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The search engine based data query program stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, which when executed in the processor 10, can realize:
acquiring an input SQL query statement;
extracting key words of a preset database, and deducing the type of the preset database by using the key words;
converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relation corresponding table;
and querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, a recording medium, a usb-disk, a removable hard disk, a magnetic diskette, an optical disk, a computer Memory, a Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium storing a computer program which, when executed by a processor of an electronic device, implements:
acquiring an input SQL query statement;
extracting key words of a preset database, and deducing the type of the preset database by using the key words;
converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relation corresponding table;
and querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the same, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
1. A data query method based on a search engine is characterized by comprising the following steps:
acquiring an input SQL query statement;
extracting key words of a preset database, and deducing the type of the preset database by using the key words;
converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relation corresponding table;
and querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
2. The search engine-based data query method of claim 1, wherein the extracting keywords of the preset database, and using the keywords to infer the type of the preset database comprises:
dividing words of data information in the preset database into vocabularies, screening out the vocabularies with the occurrence frequency larger than a preset threshold value from the vocabularies to serve as a keyword information set, and gathering the keyword information set to generate a vocabulary entry sequence;
constructing a keyword feature matrix by using the entry sequence;
and deducing the type of the preset database by utilizing a matching layer and a full connection layer in a preset matching classification model according to the keyword feature matrix.
3. The method for data query based on search engine according to claim 2, wherein said inferring the type of the predetermined database using the matching layer and the full connection layer in the predetermined matching classification model according to the keyword feature matrix comprises:
performing outer product on the keyword feature matrix according to preset keyword features by using a matching layer in a preset matching classification model to obtain a keyword similarity matrix;
calculating the similarity score of the keyword similarity matrix by using a full connection layer in the preset matching classification model;
and when the similarity score is greater than or equal to a preset similarity threshold value, taking the database type corresponding to the corresponding preset keyword label as the type of the preset database.
4. The search engine-based data query method of claim 1, wherein before the root converts the SQL query statement into the ES query statement based on an abstract syntax tree structure according to the type of the database and the pre-constructed operation relationship correspondence table, the method further comprises:
extracting query statement sets of each relational database and ES search engine, and clustering the query statement sets to obtain operation names corresponding to the query statement sets;
and constructing an operation relation corresponding table according to the operation name and the query statement set.
5. The data query method based on search engine according to claim 1, wherein the converting the SQL query statement into the ES query statement based on the abstract syntax tree according to the type of the database and the pre-constructed operation relationship correspondence table comprises:
files related to lexical analysis and grammar analysis are built, and corresponding grammar analysis classes are generated according to the files related to the lexical analysis and the grammar analysis;
analyzing the SQL query statement into a syntax tree based on an abstract syntax tree structure according to the lexical analysis class and the syntax analysis class;
extracting SE keywords and symbols of corresponding ES statements and SQL keywords and symbols of corresponding SQL statements of various relational databases according to each operation name in the pre-constructed operation relationship corresponding table, and utilizing a tree structure to make one-to-one correspondence between the SE keywords and the symbols and between the SQL keywords and the symbols so as to construct a keyword and symbol corresponding relationship table;
and analyzing the syntax tree into ES query sentences according to the type of the database and the corresponding relation table of the keywords and the symbols.
6. The search engine-based data query method of claim 5, wherein said parsing said SQL query statement into a syntax tree based on an abstract syntax tree structure according to said lexical resolution class, said syntax resolution class, comprises:
extracting the query condition in the SQL query statement to generate a filtering condition;
splicing the filtering conditions to obtain a filtering condition sequence;
and calling a grammar parsing method in the grammar parsing class to construct a Walker class, calling a grammar tree constructing method in the Walker class, and parsing the filtering condition sequence into ES query statements.
7. The search engine-based data query method of claim 1, wherein the querying the preset database with a search engine according to the ES query statement to obtain a query result comprises:
querying the preset database by using the ES query statement to obtain service query result data;
matching the service query result data with parameters of a statistical and analytical method in the preset database to obtain configuration parameters;
and analyzing the service query result data by using the configuration parameters to obtain a query result.
8. A data query device based on a search engine, the device comprising:
the query statement acquisition module is used for acquiring the input SQL query statement;
the type inference module of the database is used for extracting key words of a preset database and inferring the type of the preset database by using the key words;
the query statement conversion module is used for converting the SQL query statement into an ES query statement based on an abstract syntax tree structure according to the type of the database and a pre-constructed operation relationship corresponding table;
and the query module is used for querying the preset database by utilizing a search engine according to the ES query statement to obtain a query result.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the search engine-based data query method of any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements a search engine-based data query method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210977202.6A CN115481145A (en) | 2022-08-15 | 2022-08-15 | Data query method, device, equipment and medium based on search engine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210977202.6A CN115481145A (en) | 2022-08-15 | 2022-08-15 | Data query method, device, equipment and medium based on search engine |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115481145A true CN115481145A (en) | 2022-12-16 |
Family
ID=84422113
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210977202.6A Pending CN115481145A (en) | 2022-08-15 | 2022-08-15 | Data query method, device, equipment and medium based on search engine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115481145A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093964A (en) * | 2024-01-29 | 2024-05-28 | 北京衡石科技有限公司 | Query result information sending method and device, electronic equipment and readable medium |
-
2022
- 2022-08-15 CN CN202210977202.6A patent/CN115481145A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093964A (en) * | 2024-01-29 | 2024-05-28 | 北京衡石科技有限公司 | Query result information sending method and device, electronic equipment and readable medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111813963B (en) | Knowledge graph construction method and device, electronic equipment and storage medium | |
CN113672781A (en) | Data query method and device, electronic equipment and storage medium | |
CN112364107A (en) | System analysis visualization method and device, electronic equipment and computer readable storage medium | |
CN114979120B (en) | Data uploading method, device, equipment and storage medium | |
CN113806434B (en) | Big data processing method, device, equipment and medium | |
CN116257610B (en) | Intelligent question-answering method, device, equipment and medium based on industry knowledge graph | |
CN113887941B (en) | Business process generation method, device, electronic equipment and medium | |
CN114610747A (en) | Data query method, device, equipment and storage medium | |
CN114138784B (en) | Information tracing method and device based on storage library, electronic equipment and medium | |
CN111930963B (en) | Knowledge graph generation method and device, electronic equipment and storage medium | |
CN112231417A (en) | Data classification method and device, electronic equipment and storage medium | |
CN114416939A (en) | Intelligent question and answer method, device, equipment and storage medium | |
CN115238670A (en) | Information text extraction method, device, equipment and storage medium | |
CN115129753A (en) | Data blood relationship analysis method and device, electronic equipment and storage medium | |
CN114691782A (en) | Database table increment synchronization method and device and storage medium | |
CN112506931B (en) | Data query method, device, electronic equipment and storage medium | |
CN115481145A (en) | Data query method, device, equipment and medium based on search engine | |
CN113806492A (en) | Record generation method, device and equipment based on semantic recognition and storage medium | |
CN111538768A (en) | Data query method and device based on N-element model, electronic equipment and medium | |
CN116741358A (en) | Inquiry registration recommendation method, inquiry registration recommendation device, inquiry registration recommendation equipment and storage medium | |
CN115062023A (en) | Wide table optimization method and device, electronic equipment and computer readable storage medium | |
CN114996386A (en) | Business role identification method, device, equipment and storage medium | |
CN114490666A (en) | Chart generation method, device and equipment based on data requirements and storage medium | |
CN114518993A (en) | System performance monitoring method, device, equipment and medium based on business characteristics | |
CN113704616A (en) | Information pushing method and device, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |