Data processing method, device, computer equipment and storage medium

By generating index classes and loading index files to process Elasticsearch operation instructions, the problems of large Elasticsearch code compilation volume and low efficiency are solved, and simplified operations and efficient data processing are achieved.

CN111666282BActive Publication Date: 2025-09-26CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010350598.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-28
Publication Date
2025-09-26
Estimated Expiration
2040-04-28

AI Technical Summary

Technical Problem

When using Elasticsearch in existing technologies, the code compilation volume is large and the efficiency is low. Developers need to write complex script codes, which has high learning and maintenance costs.

Method used

By pre-writing SQL statements based on the user's database operation habits and the index structure of Elasticsearch, an index class is generated, and an index file is generated. When an operation instruction is received, the index file is scanned and loaded, and the corresponding index class is called to execute the operation instruction to obtain the execution result.

Benefits of technology

It reduces user workload, lowers the usage threshold, improves the work efficiency of Elasticsearch, and reduces learning and financial costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111666282B_ABST
    Figure CN111666282B_ABST
Patent Text Reader

Abstract

The present invention discloses a data processing method, apparatus, computer equipment and storage medium. The method uses SQL statements written in advance according to the user's operating habits of using a database and the index structure of Elasticsearch as index classes, and writes index files. When using Elasticsearch to perform data operations, the pre-written index file is obtained, and when an operation instruction for Elasticsearch sent by the user is received, the index file is scanned and loaded; the corresponding index class in the index file is called according to the operation instruction, and the execution result corresponding to the operation instruction is obtained according to the operation instruction and the corresponding index class, and the execution result is fed back to the client; the present invention can obtain the data corresponding to Elasticsearch by writing simple SQL statements without writing complex script codes, thereby solving the problems of large workload and high user usage threshold caused by writing complex script codes, reducing user workload, reducing learning time and working time, lowering usage threshold and improving work efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a data processing method, device, computer equipment and storage medium. Background Art

[0002] As the amount of Internet data grows, it becomes increasingly difficult to process and display relevant data. Traditional databases can no longer meet the query needs, and Elasticsearch has become the choice of more and more companies.

[0003] Elasticsearch provides a distributed, multi-user, full-text search and analysis engine. Developed in Java and using Lucene at its core for all search and indexing functions, it features real-time search, stability, reliability, speed, and easy installation. Elasticsearch allows for the storage, search, and analysis of vast amounts of data in near real time. It is often used as the underlying engine and technology to power complex search capabilities and requirements.

[0004] However, existing solutions for operating Elasticsearch generally communicate with Elasticsearch through JAVA APIs or RESTful APIs, which have poor configuration flexibility and require a large amount of code compilation in the application. For example, when performing queries, it is necessary to write specific query scripts, which is a lot of work. In addition, Elasticsearch versions are constantly updated and vary greatly between versions, and the code written by developers also needs to change with them. The learning and adaptation costs are high and the efficiency is low. At the same time, there are also some Elasticsearch-related SQL encapsulations on Github, but the encapsulation is not thorough and difficult to use, which increases the cost of use and maintenance for developers. Summary of the Invention

[0005] The present invention provides a data processing method, apparatus, computer equipment and storage medium to solve the problems of large code compilation and low efficiency caused by using Elasticsearch in the prior art.

[0006] A data processing method, comprising:

[0007] Obtain an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written according to the user's database operation habits;

[0008] Receive an operation instruction for the Elasticsearch sent by the user, scan and load the index file;

[0009] Calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class;

[0010] The execution result is fed back to the client.

[0011] Furthermore, the index file is generated by:

[0012] Write an SQL statement as the index class according to the index structure of the Elasticsearch;

[0013] Each of the SQL statements is named and written as a mapper file to obtain the index file.

[0014] Furthermore, obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class includes:

[0015] Convert the operation instruction into script code corresponding to the Elasticsearch;

[0016] Executing the script code through the Elasticsearch API to operate the corresponding index data and obtain execution data;

[0017] The execution data is encapsulated to obtain the execution result.

[0018] Furthermore, the operation instruction is a query instruction, and calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the index class corresponding to the operation instruction, includes:

[0019] Calling the corresponding index class in the index file according to the query instruction;

[0020] Convert the query instruction into a query script corresponding to the Elasticsearch;

[0021] Executing the query script through the Elasticsearch API to query the corresponding index data and obtain query data;

[0022] The query data is encapsulated to obtain the execution result.

[0023] Furthermore, the operation instruction is a modification instruction, and calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the index class corresponding to the operation instruction, includes:

[0024] Calling the corresponding index class in the index file according to the modification instruction;

[0025] Convert the modification instruction into a modification script corresponding to the Elasticsearch;

[0026] Executing the modification script through the Elasticsearch API to modify the corresponding index data and obtain the modified data;

[0027] The modified data is encapsulated to obtain the execution result.

[0028] A data processing device, comprising:

[0029] An acquisition module is used to acquire an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written by a user according to his or her database operation habits;

[0030] A receiving module is used to receive an operation instruction for the Elasticsearch sent by a user, scan and load the index file;

[0031] A calling module, configured to call the corresponding index class in the index file according to the operation instruction, and obtain an execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class;

[0032] A feedback module is used to feed back the execution result to the client.

[0033] Furthermore, the acquisition module is further configured to:

[0034] Write an SQL statement as the index class according to the Elasticsearch index structure; including:

[0035] Each of the SQL statements is named and written as a mapper file to obtain the index file.

[0036] Furthermore, the calling module is specifically used to:

[0037] Convert the operation instruction into script code corresponding to the Elasticsearch;

[0038] Executing the script code through the Elasticsearch API to operate the corresponding index data and obtain execution data;

[0039] The execution data is encapsulated to obtain the execution result.

[0040] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data processing method when executing the computer program.

[0041] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above-mentioned data processing method when executed by a processor.

[0042] The above-mentioned data processing method, device, computer equipment and storage medium use SQL statements written in advance according to the user's operating habits of using the database and the index structure of Elasticsearch as index classes, and obtain index files based on the index classes. When using Elasticsearch for data operations, by obtaining the pre-written index file, when receiving the operation instructions for Elasticsearch sent by the user, the index file is scanned and loaded; the corresponding index class in the index file is called according to the operation instruction, and the execution result corresponding to the operation instruction is obtained according to the operation instruction and the corresponding index class, and the execution result is fed back to the client; the mapping relationship between the index file and ElasticSearch enables the user to obtain the corresponding data of Elasticsearch by writing simple SQL statements when using ElasticSearch, without having to write complex script codes like ordinary Elasticsearch, solving the problems of large workload and high user threshold caused by the need to write complex script codes when using Elasticsearch, reducing user workload, reducing learning time and working time, lowering the usage threshold, and improving the work efficiency of using Elasticsearch, thereby reducing the user's learning cost and financial cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0044] Figure 1 is a schematic diagram of an application environment of a data processing method according to an embodiment of the present invention;

[0045] Figure 2 is a flow chart of a data processing method in one embodiment of the present invention;

[0046] Figure 3 This is a schematic diagram of a flow chart of a data processing method index file generation process according to an embodiment of the present invention;

[0047] Figure 4 1 is a schematic diagram of the implementation flow of step S30 of the data processing method in one embodiment of the present invention;

[0048] Figure 5 is a structural diagram of a data processing device in one embodiment of the present invention;

[0049] Figure 6 It is a structural diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0051] The embodiment of the present invention provides a data processing method, which can be applied as follows: Figure 1 Specifically, the data processing method is applied in a data processing system, which includes Figure 1 The client and server shown communicate over a network, addressing the high code compilation and low efficiency issues associated with using Elasticsearch in the prior art. The client, also known as the user end, refers to a program that corresponds to the server and provides local services to clients. The client can be installed on, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented as a standalone server or a server cluster consisting of multiple servers. In the present invention, the server is an Elasticsearch server.

[0052] In one embodiment, if Figure 2 As shown, a data processing method is provided, which is applied in Figure 1 The server in the example is used as an example, and the steps are as follows:

[0053] S10: Obtain an index file. The index file includes an index class. The index class is generated by an SQL statement and an index structure of Elasticsearch. The SQL statement is an SQL statement written by the user according to the operation habits of the database.

[0054] Elasticsearch refers to a collection of interrelated documents, and Elasticsearch stores data in the form of JSON documents. During the indexing process, Elasticsearch stores documents and builds an inverted index, so that users can search for document data in near real time. The existing solutions for operating Elasticsearch generally communicate with Elasticsearch through JAVA API or RESTful API. The amount of code compilation in the application is large. For example, when querying, it is necessary to write specific query script code, which is a lot of work. Therefore, in order to reduce the workload during use, improve the work efficiency of Elasticsearch, and lower the user's usage threshold, the present invention is proposed. By using the data processing method provided by the present invention, developers can fully operate Elasticsearch proficiently according to common database development and usage experience, thereby reducing learning costs and improving work efficiency.

[0055] First, SQL statements corresponding to Elasticsearch data categories are written based on Elasticsearch data and user database operation habits. Then, the written SQL statements are used to generate index classes based on Elasticsearch's index structure. Further, index files are generated based on the index classes, so that Elasticsearch data can be added, modified, deleted, and queried based on the index files when Elasticsearch is used later.

[0056] For example, the data in Elasticsearch is a customer data table, which contains basic customer information such as age, gender, and ID. Based on the data categories of the customer data table in Elasticsearch, SQL statements corresponding to age, gender, and ID are written respectively. Then, the SQL statements corresponding to age, gender, and ID are used to generate age index class, gender index class, and ID index class according to the structure of the customer data table.

[0057] Among them, such as Figure 3 As shown, in one embodiment, the user's operation mode of using mybatis is used as the user's operation habit of using the database, and the index file is generated in the following way:

[0058] S11: Write SQL statements as index classes based on the Elasticsearch index structure.

[0059] The user's operation mode of using mybatis is used as the user's operation habit of using the database, and an SQL statement is written as the index class according to the data and index structure of Elasticsearch. When using the mybatis database, the data of the mybatis database is generally queried by writing an SQL statement.

[0060] For example, Elasticsearch's data contains a customer data table, where the attribute parameters of each column in the customer data table are: age, gender, ID, and region. At this time, SQL statements are written according to the attribute parameters and Elasticsearch's data and index structure to obtain the user's age index class, gender index class, region index class, and ID index class respectively. The index classes correspond to the attribute parameters in the customer data table.

[0061] The customer data table and its attribute parameters are shown in Table 1:

[0062] Table 1

[0063] ID area gender age 1 Shanghai female 10 2 Beijing female 20 3 Shenzhen male 30

[0064] It should be noted that the customer data table and its attribute parameters: age, gender, ID and region are for illustrative purposes. In actual applications, the data recorded in the customer data table may have other attribute parameters, and Elasticsearch data also has other types of data. Table 1 is only an example for the convenience of explanation and does not constitute a limitative description of this application.

[0065] In this embodiment, the index classes of the index file are age index class, gender index class, region index class and ID index class for exemplary purposes only. In other embodiments, the index class of the index file may also be other classes, which will not be described in detail here.

[0066] S12: Name each SQL statement and write the SQL statement into a mapper file to obtain an index file.

[0067] Name each index class obtained by writing SQL statements according to the operation mode of MyBatis, the data category and index structure of Elasticsearch, and write all named index classes as mapper files mapped to Elasticsearch data.

[0068] For example, the SQL statement about age written based on Elasticsearch data is named "queryPersonByAge" and is the age index class in the index file mapper file. The written mapper file contains an index class named "queryPersonByAge". When you need to query customer age data, you can directly enter age-related instructions to call the customer data corresponding to the "queryPersonByAge" index class.

[0069] In this embodiment, by obtaining the operation mode of mybatis, writing SQL statements as index classes according to the operation mode of mybatis and the index structure of Elasticsearch, naming each SQL statement and writing the SQL statement as a mapper file, and obtaining the index file, Elasticsearch is pre-encapsulated according to the user's commonly used database operation habits and the index structure of Elasticsearch, providing a basis for subsequent users to use Elasticsearch conveniently and efficiently, so that users can subsequently operate Elasticsearch according to database operation habits without having to write specific script code to obtain data, thereby reducing the user's workload and improving the work efficiency of using Elasticsearch.

[0070] S20: Receive the operation instructions for Elasticsearch sent by the user, scan and load the index file.

[0071] After the project is started, the user sends an operation instruction to Elasticsearch through the client. After receiving the operation instruction, the index file of Elasticsearch is automatically scanned. When the index file is found to have an index class corresponding to the operation instruction, the index file is loaded into the container so that the corresponding data can be directly obtained according to the index class corresponding to the operation instruction.

[0072] If the scanned index file does not contain an index class corresponding to the operation instruction, it means that Elasticsearch does not have data related to the operation instruction and does not load the index file into the container.

[0073] For example, the index file is a mapper file. When the user needs to query the data of a certain age group in Elasticsearch, the user enters the query instruction through the client and writes the query instruction into a related age query statement. When the user receives the age query instruction for the Elasticsearch data through the client, the mapper file of Elasticsearch is automatically scanned. When the mapper file is found to have an age index class corresponding to the age, the mapper file is loaded into the container so that the corresponding data can be directly obtained based on the age index class in the future; when there is no age index class in the mapper file, the mapper file is not loaded.

[0074] S30: calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class.

[0075] After automatically scanning the Elasticsearch index file and loading the index file into the container, the index class corresponding to the operation instruction in the index file is called according to the operation instruction sent by the user through the client, and the operation instruction is executed according to the index class corresponding to the operation instruction to obtain the execution result corresponding to the operation instruction.

[0076] For example, a user sends a query through the client for people whose age is greater than 9. The SQL statement for this query is "SELECT * FROM person where age>9". After automatically scanning the Elasticsearch mapper file and loading it into the container, a proxy object method is generated in the container based on the age index class "queryPersonByAge". Then, based on the "SELECT * FROM person where age>9" query sent by the user through the client, the method "queryPersonByAge" of the generated proxy object is directly called to query the age data in Elasticsearch and obtain the age data returned by Elasticsearch.

[0077] S40: Feedback the execution result to the client.

[0078] After obtaining the execution result corresponding to the operation instruction, the execution result is fed back to the client.

[0079] For example, after obtaining the age data returned by Elasticsearch, the age data returned by Elasticsearch is fed back to the client so that the user can quickly obtain the information.

[0080] This proposal uses SQL statements written in advance based on the user's database operating habits and Elasticsearch's index structure as index classes, and obtains index files based on the index class. When using Elasticsearch for data operations, by obtaining the pre-written index file, when receiving the user's operation instructions to Elasticsearch through the client, the index file is scanned and loaded; the corresponding index class in the index file is called according to the operation instruction, and the execution result corresponding to the operation instruction is obtained according to the operation instruction and the corresponding index class, and the execution result is fed back to the client, so that the user can operate Elasticsearch according to the database operation habits, which solves the problem of large workload and high user threshold caused by the need to write complex script code when using Elasticsearch, reduces user workload, improves work efficiency when using Elasticsearch, lowers the usage threshold, reduces workload, reduces learning time and working time, improves work efficiency when using Elasticsearch, and reduces user learning cost and financial cost.

[0081] In one embodiment, if Figure 4 As shown, after the corresponding index class in the index file is called according to the operation instruction, step S30, that is, obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class, specifically includes the following steps:

[0082] S31: Convert the operation instructions into the script code corresponding to Elasticsearch.

[0083] After calling the corresponding index class in the index file according to the operation instruction, the operation instruction is converted into the script code corresponding to Elasticsearch, wherein the operation instruction is a written SQL statement, and the written SQL statement corresponds to the SQL statement of the corresponding index class.

[0084] S32: Execute the script code through the Elasticsearch API to operate the corresponding index data and obtain the execution data.

[0085] After converting the operation instruction into the script code corresponding to Elasticsearch, the converted script code is executed through the Elasticsearch API to perform the operation corresponding to the operation instruction on the Elasticsearch data associated with the index class mapping, and the execution data is obtained according to the execution result of the script code.

[0086] For example, if the operation instruction is to query age, the query age instruction is converted into the corresponding script code for querying age in Elasticsearch, the script code for querying age is executed through the API of Elasticsearch, and age-related data is queried in Elasticsearch to obtain age-related data.

[0087] S33: Encapsulate the execution data to obtain the execution result.

[0088] After obtaining the execution data according to the execution result of the script code, the execution data is encapsulated to obtain the execution result corresponding to the operation instruction, and the encapsulated data is returned to the client so that the user can quickly obtain the execution result.

[0089] For example, after querying age-related data in Elasticsearch and obtaining the age-related data, the age-related data is packaged and returned to the client so that the user can quickly obtain the data.

[0090] In this embodiment, the user's operation instructions are converted into the corresponding script code of Elasticsearch, and then Elasticsearch executes the script code to obtain the execution result corresponding to the operation instruction, and finally the execution result is packaged. The user can simply enter the operation instruction to obtain the corresponding packaged data. The operation is simple and convenient, and the packaging is thorough. There is no need to write specific script code according to needs, which reduces workload and improves work efficiency when using Elasticsearch.

[0091] In one embodiment, after receiving an operation instruction sent by a user to Elasticsearch and scanning and loading an index file, if the operation instruction is a query instruction, the corresponding index class in the index file is called according to the operation instruction, and the execution result corresponding to the operation instruction is obtained according to the index class corresponding to the operation instruction, which specifically includes the following:

[0092] SA31: Call the corresponding index class in the index file according to the query instruction;

[0093] When receiving a query instruction to Elasticsearch sent by the user through the client, after automatically scanning the index file of Elasticsearch and loading the index file into the container, the corresponding index class in the index file is called according to the query instruction sent by the user through the client.

[0094] For example, when a user needs to query the data of users older than 9 in Elasticsearch, the user enters a query instruction for users older than 9 through the client. The SQL statement of the query instruction is "SELECT * FROM person where age>9". When the user's query instruction "SELECT * FROM person where age>9" is received from the client to Elasticsearch, the mapper file is automatically scanned to determine that the mapper file contains the index class "queryPersonByAge" corresponding to the query instruction. The mapper file is then loaded into the container. Then, a proxy object method corresponding to the index class "queryPersonByAge" is generated in the container. Then, based on the "SELECT * FROM person where age>9" sent by the user through the client, the method "queryPersonByAge" of the corresponding proxy object is directly called to query the age data in Elasticsearch and obtain the age data returned by Elasticsearch.

[0095] SA32: Convert query instructions into query scripts corresponding to Elasticsearch.

[0096] After calling the corresponding index class in the index file according to the query instruction, the query instruction is converted into the corresponding query script of Elasticsearch so that the query script can be executed through the Elasticsearch API later.

[0097] For example, when a user needs to query user data older than 9 in Elasticsearch, the user enters "SELECT * FROM person where age>9" through the client. After calling the proxy object's method "queryPersonByAge" based on "SELECT * FROM person where age>9" and the corresponding index class "queryPersonByAge", "SELECT * FROM person where age>9" is converted into the corresponding Elasticsearch query script.

[0098] SA33: Execute the query script through the Elasticsearch API to query the corresponding index data and obtain the query data.

[0099] After converting the query instruction into the corresponding query script of Elasticsearch, the query script is executed through the Elasticsearch API to query the corresponding index data and obtain the query data.

[0100] For example, convert "SELECT * FROM person where age>9" into the corresponding Elasticsearch query script. Elasticsearch executes the query script through the API to query the data of the index class "queryPersonByAge" corresponding to the proxy object method "queryPersonByAge" to obtain the user data corresponding to "SELECT * FROM person where age>9" in the index class "queryPersonByAge" data.

[0101] SA34: Encapsulate the query data to obtain the execution result.

[0102] After the query data is obtained, the query data is encapsulated to obtain an execution result, so that the encapsulated query data is returned to the client as an execution result.

[0103] In addition, when receiving the user's operation instruction for the Elasticsearch through the client, after scanning and loading the index file, if the operation instruction is a modification instruction, the corresponding index class in the index file is called according to the operation instruction, and the execution result corresponding to the operation instruction is obtained according to the index class corresponding to the operation instruction, which specifically includes the following steps:

[0104] SB31: Call the corresponding index class in the index file according to the modification instruction.

[0105] When receiving the modification instruction of Elasticsearch from the user through the client, after automatically scanning the index file of Elasticsearch and loading the index file into the container, the corresponding index class in the index file is called according to the modification instruction sent by the user through the client.

[0106] SB32: Convert modification instructions into modification scripts corresponding to Elasticsearch.

[0107] After calling the corresponding index class in the index file according to the modification instruction, the query instruction is converted into the corresponding modification script of Elasticsearch so that the modification script can be executed through the Elasticsearch API later.

[0108] SB33: Execute modification scripts through the Elasticsearch API to modify the corresponding index data and obtain the modified data;

[0109] After converting the modification instructions into the corresponding modification script of Elasticsearch, the modification script is executed through the Elasticsearch API to modify the corresponding index data and obtain the modified data.

[0110] SB34: Encapsulate the modified data to obtain the execution result.

[0111] After obtaining the modified data, the modified data is encapsulated to obtain an execution result, so that the encapsulated data is returned to the client as the execution result.

[0112] In this embodiment, the operation instruction is a query instruction or a modification instruction for exemplary purposes only. In other embodiments, the operation instruction may be a query instruction, an add instruction, a delete instruction, a modification instruction, etc., which will not be repeated here.

[0113] In this embodiment, the user's operation instructions are converted into the corresponding script code of Elasticsearch, and then Elasticsearch executes the script code to obtain the execution result corresponding to the operation instruction, and finally the execution result is packaged. The user can simply enter the operation instruction to obtain the corresponding packaged data. The operation is simple and convenient, and the packaging is thorough. There is no need to write specific script code according to needs, which reduces workload and improves work efficiency when using Elasticsearch.

[0114] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0115] In one embodiment, a data processing device is provided, which corresponds one-to-one to the data processing method in the above embodiment. Figure 5 As shown, the data processing device includes an acquisition module 501, a receiving module 502, a calling module 503 and a feedback module 504. The functional modules are described in detail as follows:

[0116] Acquisition module 501 is used to acquire an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an Elasticsearch index structure, and the SQL statement is an SQL statement written by a user according to his or her database operation habits;

[0117] The receiving module 502 is configured to receive an operation instruction for the Elasticsearch sent by a user, and scan and load the index file;

[0118] A calling module 503 is configured to call the corresponding index class in the index file according to the operation instruction, and obtain an execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class;

[0119] The feedback module 504 is configured to feed back the execution result to the client.

[0120] The acquisition module 501 is further configured to:

[0121] Write an SQL statement as the index class according to the Elasticsearch index structure; including:

[0122] Each of the SQL statements is named and written as a mapper file to obtain the index file.

[0123] The calling module 503 is specifically used for:

[0124] Convert the operation instruction into script code corresponding to the Elasticsearch;

[0125] Executing the script code through the Elasticsearch API to operate the corresponding index data and obtain execution data;

[0126] The execution data is encapsulated to obtain the execution result.

[0127] Wherein, the operation instruction is a query instruction, and the calling module 503 is specifically used to:

[0128] Calling the corresponding index class in the index file according to the query instruction;

[0129] Convert the query instruction into a query script corresponding to the Elasticsearch;

[0130] Executing the query script through the Elasticsearch API to query the corresponding index data and obtain query data;

[0131] The query data is encapsulated to obtain the execution result.

[0132] Wherein, the operation instruction is a modification instruction, and the calling module 503 is specifically used to:

[0133] Calling the corresponding index class in the index file according to the modification instruction;

[0134] Convert the modification instruction into a modification script corresponding to the Elasticsearch;

[0135] Executing the modification script through the Elasticsearch API to modify the corresponding index data and obtain the modified data;

[0136] The modified data is encapsulated to obtain the execution result.

[0137] For the specific definition of the data processing device, please refer to the definition of the data processing method above and will not be repeated here. Each module in the above-mentioned data processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software so that the processor can call and execute the operations corresponding to each of the above modules.

[0138] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, memory, a network interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements a data processing method.

[0139] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed:

[0140] Obtain an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written according to the user's database operation habits;

[0141] Receive an operation instruction for the Elasticsearch sent by the user, scan and load the index file;

[0142] Calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class;

[0143] The execution result is fed back to the client.

[0144] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0145] Obtain an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written according to the user's database operation habits;

[0146] Receive an operation instruction for the Elasticsearch sent by the user, scan and load the index file;

[0147] Calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class;

[0148] The execution result is fed back to the client.

[0149] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0150] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0151] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.

Claims

1. A data processing method, characterized in that: include: Obtain an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written according to the user's database operation habits; Receive an operation instruction for the Elasticsearch sent by the user, scan and load the index file; Calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class; Feedback the execution result to the client; The method for generating the index file includes: writing an SQL statement as the index class according to the index structure of the Elasticsearch, wherein the SQL statement is written according to the attribute parameters of the customer data table and the index structure of the Elasticsearch to obtain an age index class, a gender index class, a region index class and an ID index class respectively, and the attribute parameters of each column in the customer data table include age, gender, ID and region; naming each of the SQL statements and writing the SQL statements as a mapper file to obtain the index file; After calling the corresponding index class in the index file according to the operation instruction, the operation instruction is converted into a script code corresponding to Elasticsearch, wherein the operation instruction is a written SQL statement, and the written SQL statement corresponds to the SQL statement of the corresponding index class.

2. The data processing method according to claim 1, wherein: Obtaining an execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class includes: Convert the operation instruction into script code corresponding to the Elasticsearch; Executing the script code through the Elasticsearch API to operate the corresponding index class and obtain execution data; The execution data is encapsulated to obtain the execution result.

3. The data processing method according to any one of claims 1 to 2, characterized in that: The operation instruction is a query instruction, calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class, including: Calling the corresponding index class in the index file according to the query instruction; Convert the query instruction into a query script corresponding to the Elasticsearch; Executing the query script through the Elasticsearch API to query the corresponding index class and obtain query data; The query data is encapsulated to obtain the execution result.

4. The data processing method according to any one of claims 1 to 2, characterized in that: The operation instruction is a modification instruction, calling the corresponding index class in the index file according to the operation instruction, and obtaining the execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class, including: Calling the corresponding index class in the index file according to the modification instruction; Convert the modification instruction into a modification script corresponding to the Elasticsearch; Executing the modification script through the Elasticsearch API to modify the corresponding index class and obtain the modified data; The modified data is encapsulated to obtain the execution result.

5. A data processing device, characterized in that: include: An acquisition module is used to acquire an index file, wherein the index file includes an index class, wherein the index class is generated by an SQL statement and an index structure of Elasticsearch, and the SQL statement is an SQL statement written by a user according to his or her database operation habits; A receiving module is used to receive an operation instruction for the Elasticsearch sent by a user, scan and load the index file; A calling module, configured to call the corresponding index class in the index file according to the operation instruction, and obtain an execution result corresponding to the operation instruction according to the operation instruction and the corresponding index class; A feedback module, configured to feed back the execution result to the client; The acquisition module is further configured to: compile an SQL statement as the index class according to the index structure of Elasticsearch, wherein the SQL statement is compiled according to the attribute parameters of the customer data table and the index structure of Elasticsearch to obtain an age index class, a gender index class, a region index class, and an ID index class, respectively, wherein the attribute parameters of each column in the customer data table include age, gender, ID, and region; name each of the SQL statements and compile the SQL statements into a mapper file to obtain the index file; After calling the corresponding index class in the index file according to the operation instruction, the operation instruction is converted into a script code corresponding to Elasticsearch, wherein the operation instruction is a written SQL statement, and the written SQL statement corresponds to the SQL statement of the corresponding index class.

6. The data processing device according to claim 5, wherein: The calling module is specifically used for: Convert the operation instruction into script code corresponding to the Elasticsearch; Executing the script code through the Elasticsearch API to operate the corresponding index class and obtain execution data; The execution data is encapsulated to obtain the execution result.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the data processing method according to any one of claims 1 to 4 are implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Realization method and system for querying elasticsearch

    CN106934062A

  • Statement execution method, device and equipment based on multi-file management and medium

    CN110046170A