Data operation method and device and related equipment
By defining operation classes and configuring attribute information within the ORM framework, the simplified data operation code is converted into DSL statements, which solves the problem of low efficiency of ES data operation and realizes efficient data operations by non-code writers.
Patent Information
- Application Number
- CN202510369900.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-07-11
AI Technical Summary
The existing data operation methods based on Elasticsearch (ES) are less efficient, mainly due to the difficulty of learning DSL, which makes it difficult for non-code writers to use efficiently.
Define operation classes within the object relational mapping (ORM) framework, and configure attribute information to map data operation codes and DSL statements, control ORM framework initialization, simplify the user input data operation codes into DSL statements, and send them to Elasticsearch for execution through the ORM framework.
It reduces the cost of users learning DSL, improves the efficiency of data operations, and enables non-code writers to perform data operations efficiently.
Smart Images

Figure CN120295608A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data query, and in particular, to a data operation method, apparatus, and related equipment. Background Art
[0002] In the prior art, as an open-source professional search engine, ES (Elasticsearch) can store a large amount of data of various enterprises and institutions and provide data operation functions such as data query, data addition, and data analysis for professional users in the above units.
[0003] In actual operation, ES does not directly support data operation instructions in the form of natural language. It supports data operation statements written in DSL (Domain Specific Language) to execute corresponding functions. In actual applications, many users of ES are code writers. Due to the disadvantages of DSL such as high learning difficulty and high learning cost, an automatic parser can be written based on the ORM (Object-Relational Mapping) framework. This parser is used to parse the JSON (JavaScript Object Notation) - structured code for requesting data operations into an abstract syntax tree of DSL through steps such as lexical analysis, syntax analysis, and semantic analysis, and then generate corresponding DSL statements for executing data operations.
[0004] In actual applications, although the above method can avoid learning DSL, not all users of ES are code writers. That is to say, not all users of ES can write complex code for data operations, resulting in only some users of ES being able to use ES to search for data. Eventually, the existing ES - based data operation method still has the problem of low operation efficiency. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a data operation method, apparatus, and related equipment to solve the problem of low operation efficiency existing in the existing ES - based data operation method in the prior art.
[0006] In a first aspect, this application provides a data operation method, which is applied to a terminal device. An Object - Relational Mapping (ORM) framework and an application program are configured in the terminal device. The method includes:
[0007] Define an operation class within the ORM framework; wherein, the operation class is used to perform data operations on the search engine Elasticsearch.
[0008] Configure attribute information for the operation class based on the ORM framework; wherein, the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold;
[0009] Control the initialization of the ORM framework for configuring a data operation environment for the application;
[0010] In the data operation environment, convert the code of the data operation input by the user in the application into a DSL statement;
[0011] Send the DSL statement to the Elasticsearch so that the Elasticsearch executes the data operation according to the DSL statement.
[0012] In a second aspect, the present application provides a data operation device applied to a terminal device, where the terminal device is configured with an object-relational mapping (ORM) framework and an application; the device includes: a definition module, a configuration module, an initialization module, an input module, and a connection module;
[0013] The definition module is used to define an operation class within the ORM framework; wherein, the operation class is used to perform data operations on the search engine Elasticsearch;
[0014] The configuration module is used to configure attribute information for the operation class based on the ORM framework; wherein, the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold;
[0015] The initialization module is used to control the initialization of the ORM framework for configuring a data operation environment for the application;
[0016] The input module is used to convert the code of the data operation input by the user in the application into a DSL statement in the data operation environment;
[0017] The connection module is used to send the DSL statement to the Elasticsearch so that the Elasticsearch executes the data operation according to the DSL statement.
[0018] In a third aspect, the present application provides an electronic device, which includes a processor and a memory. The memory is used to store an application, and the processor runs or executes the software program stored in the memory so that the electronic device implements the above data operation method.
[0019] In a fourth aspect, the present application provides a computer-readable storage medium for storing program code executed by a processor, and the program code is used to implement the above data operation method.
[0020] In a fifth aspect, the present application provides a computer program product, which includes computer instructions. When the computer instructions run on an electronic device, the electronic device implements the above data operation method.
[0021] Beneficial effects:
[0022] The present application provides a data operation method applied to a terminal device, in which an object-relational mapping (ORM) framework and an application program are configured. The method includes: defining an operation class within the ORM framework, where the operation class is used to perform data operations on an Elasticsearch search engine; configuring attribute information for the operation class based on the ORM framework, where the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold; controlling the ORM framework to be initialized for configuring a data operation environment for the application program; in the data operation environment, converting the code of the data operation input by the user in the application program into a DSL statement; and sending the DSL statement to Elasticsearch so that Elasticsearch performs data operations according to the DSL statement.
[0023] In summary, it can be seen that in the present application, by defining an operation class within the ORM framework and configuring attribute information for the operation class based on the ORM framework, after initializing the data environment, the code of the data operation input by the user in the application program that does not exceed the preset threshold can be converted into a DSL statement. In this process, the user only needs to input a simplified code of the data operation, and then the simplified code can be converted into a DSL statement. Subsequently, after sending the DSL statement to ES, the corresponding query result can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. The following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0025] Figure 1 It is a schematic flowchart of the data operation method provided by the embodiment of the present application;
[0026] Figure 2An example diagram of the code for data operations provided by an embodiment of this application;
[0027] Figure 3 A structural schematic diagram of a data operation device provided by an embodiment of this application. Detailed implementation manners
[0028] In the existing big data environment, Elasticsearch, as a high-performance distributed search and analysis engine, is widely favored for its powerful full-text search ability and real-time data analysis ability. In actual operations, ES does not directly support data operation instructions in natural language form. It supports data operation statements written in DSL to perform corresponding functions, and its complex query syntax poses a significant challenge to users.
[0029] In practical applications, many users who need to use ES are code writers. Due to the disadvantages of DSL such as high learning difficulty and high learning cost, an automatic parser can be written based on the ORM framework. This parser is used to parse the code for requesting data operations in JSON structure into an abstract syntax tree of DSL through steps such as lexical analysis, syntax analysis, and semantic analysis, and then generate corresponding DSL statements for performing data operations.
[0030] In actual operations, although ES provides a REST (Representational State Transfer) API (Application Programming Interface) to simplify interactions, for large-scale and complex data query and management, directly operating the API or JSON queries still requires relatively high skills and experience.
[0031] Therefore, this application provides a data operation solution to solve the above problems. To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some, rather than all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.
[0032] First, this application provides a data operation method, which is applied to a terminal device. The terminal device is configured with an object-relational mapping (ORM) framework and an application program; as Figure 1 shown, Figure 1 A flowchart of the data operation method provided by an embodiment of this application. The method includes: S110 to S150, details are as follows:
[0033] S110: Define an operation class within the ORM framework.
[0034] Among them, the operation class is used to perform data operations on the search engine Elasticsearch.
[0035] Specifically, an operation class is created in the ORM framework configured in the terminal device. This operation class is specifically used to perform data operations on the search engine ES. The operation class encapsulates various methods and logics for interacting with ES, enabling developers to avoid directly dealing with complex DSL statements.
[0036] In the embodiments of this application, the class definition is to define an operation class in the ORM framework using a programming language (such as Java, Python, etc.). The name of the class should have a clear meaning, such as ESOperation, so that developers can clearly understand its purpose.
[0037] Among them, a series of methods can be defined in the operation class. Each method corresponds to a specific data operation, such as query, insert, update, delete, etc. For example, define a search method to perform a query operation and an insert method to insert data; when defining methods, appropriate parameters need to be set for each method so that developers can pass in the necessary information to perform data operations. For example, the search method can accept parameters such as query conditions, sorting rules, and pagination information.
[0038] In actual operations, the ORM framework encapsulates the underlying complexity, abstracting the query language and API calls of ES into a higher-level object-oriented API. This encapsulation hides the details of ES queries, enabling users to focus on business logic rather than technical details, thereby reducing the learning cost and improving the readability of the code; in addition, the ORM framework provides a consistent interface to handle different data sources, indicating that users can use the same programming model to access ES data. Even if the data storage method changes in the future, it can be adapted by adjusting the ORM framework without having to modify the application layer code; furthermore, the ORM framework is usually designed to be extensible, allowing users to customize query logic and data mapping rules according to their own needs. This flexibility enables the ORM framework to adapt to various complex application scenarios.
[0039] S120: Configure attribute information for the operation class based on the ORM framework; among them, the attribute information characterizes the mapping between the code of the data operation and the domain-specific language DSL statement; the number of characters included in the code of the data operation does not exceed a preset threshold.
[0040] Specifically, in the embodiments of the present application, after defining the operation class, it is necessary to configure attribute information for the defined operation class above. The above attribute information characterizes the mapping relationship between the code of data operation and the DSL statement. At the same time, it is required that the number of characters included in the code of data operation does not exceed a preset threshold to ensure the simplicity of the code.
[0041] In actual operation, define attributes in the operation class to store the mapping rules between the data operation code and the DSL statement. For example, a dictionary (or hash table) can be used to store the DSL statement templates corresponding to different data operation codes.
[0042] Subsequently, according to the DSL syntax of ES, corresponding mapping rules are formulated for each data operation code. For example, for a query operation, a simple query condition code (such as name = 'John') can be mapped to an ES DSL query statement (such as {"query": {"match": {"name": "John"}}}).
[0043] In the embodiments of the present application, the meaning of the preset threshold is that the user only needs to fill in the simplified code in the application program. This simplified code can be recognized by the ORM framework and directly converted into a DSL statement through the mapping characterized by the attribute information, without the user filling in complex code in the application program to perform ES queries. Therefore, it can significantly reduce the cost of code learning, reduce unnecessary I / O operations and calculations, and thus improve the efficiency of ES queries; among them, the preset threshold can be determined according to actual needs, and the present application does not make specific limitations on this.
[0044] For example, in the prior art, if you want to retrieve all articles whose titles contain the keyword "innovation" from ES, a complex JSON statement needs to be constructed, such as Figure 2 shown Figure 2 is a schematic diagram of the code of data operation provided by the embodiments of the present application. In the embodiments of the present application, only the code shown in Figure 1 needs to be filled in to achieve queries through ES.
[0045] According to Figure 2 it can be seen that the data operation method provided by the embodiments of the present application demonstrates how the framework simplifies the query construction and execution process, while maintaining the readability and simplicity of the code. Through the object-oriented API design, even developers who are not familiar with ES can quickly get started. The newly invented framework aims to provide users with a powerful and easy-to-use tool to meet the growing data query and analysis needs by enhancing the native functions of ES while maintaining lightweight and high performance.
[0046] In one implementation, before S110, the method further includes: Step (1), and S120 includes: Step (2), details are as follows:
[0047] Step (1): Construct a configuration file for attribute information.
[0048] Specifically, in the embodiments of the present application, the ORM framework defines the relationship between entity classes and ES fields through a configuration file. For example, you can use the @Document annotation to specify the index and type to which the operation class belongs, and the @Field annotation to map specific fields; the ORM framework allows users to define the mapping rules for indexes and fields, including the data type of the field, whether it is stored, whether it is tokenized, etc. It is usually implemented through annotations or configuration classes to ensure that ES understands how to store and index data. The ORM framework usually includes a DSL generator that can convert object-oriented query construction into ES DSL query language.
[0049] Users can use a more natural programming method to construct complex query logic without having to deeply understand the query syntax of ES. The framework provides a series of advanced query methods, such as full-text search, aggregation query, sorting, pagination, etc. These functions can be directly used through API calls without manually constructing complex query strings. When interacting with ES, data needs to be serialized into JSON format and sent, and the data received from ES needs to be deserialized back into Java objects. The ORM framework will handle this process, hiding the details of serialization / deserialization. At the same time, Spring's post-processor (BeanPostProcessor) and automatic scanning (@ComponentScan) mechanisms can automatically detect and register entity classes and related Repository interfaces. For example, classPathMapperScanner can scan all entity classes under the specified package and register them as bean definitions in the Spring framework.
[0050] Step (2): Assemble the configuration file based on the ORM framework for configuring attribute information for the operation class.
[0051] Specifically, in the embodiments of the present application, before the ORM framework is initialized or the operation class is instantiated, the content of the configuration file is read; in actual operation, a corresponding configuration file parsing library (such as Python's json module, yaml library, etc.) can be used to read and parse the configuration file, and then the content of the read configuration file is parsed into a data structure available to the program, such as a dictionary or an object. Finally, the parsed configuration information is assembled into the attributes of the operation class. The configuration information can be passed to the operation class through constructor injection, property injection, or method injection, etc.
[0052] S130: Control the initialization of the ORM framework, which is used to configure the data operation environment for the application.
[0053] Specifically, in the embodiments of the present application, the initialization process of the ORM framework is started to configure the data operation environment for the application. The initialization process includes loading configuration information, establishing a connection with ES, etc.
[0054] In actual operation, when initializing, the ORM framework needs to load a pre-defined configuration file, which contains information related to the connection with ES, such as server address, port number, username, password, etc.; according to the information in the configuration file, the ORM framework establishes a connection with ES. The connection can be implemented using the client libraries provided by ES (such as ESJavaClient, ESPythonClient, etc.); during the initialization process, the ORM framework also performs some environment configurations, such as setting the default index name, initializing the cache, etc., so that subsequent data operations can proceed smoothly.
[0055] S140: In the data operation environment, convert the code of the data operation input by the user in the application into a DSL statement.
[0056] Specifically, in the embodiments of the present application, in the configured data operation environment, when the user inputs the code of the data operation in the application, the ORM framework converts the input code into the corresponding DSL statement according to the previously configured attribute information.
[0057] In actual applications, the application receives the code of the data operation input by the user and passes it to the ORM framework; the ORM framework parses the input code of the user, according to the previously defined mapping rules, parses the data operation type and parameters represented by the code, and then according to the parsing result, the ORM framework obtains the corresponding DSL statement template from the attribute information and fills the parsed parameters into the template to generate a complete DSL statement; for example, if the input code of the user is searchname='John', the ORM framework will generate the corresponding DSL query statement according to the mapping rules.
[0058] In one implementation, the operation class includes multiple methods, each method is used to perform a data operation of a data operation type, and each method has corresponding attribute information; S140 includes: step (3) to step (5), the details are as follows:
[0059] Step (3): Receive the code of the data operation input by the user in the interface displayed by the application; where the code includes a first field indicating the data operation type.
[0060] Specifically, in the embodiments of the present application, the application program provides a user interface, such as a command-line interface, which allows the user to input the code for data operations; in this command-line interface, there may be elements such as input boxes and drop-down menus to facilitate the user to input and select relevant information for data operations; in this command-line interface, there may be prompt information for guiding the user on how to input the code for data operations. For example, the user is prompted to input a code like searchname='John' to perform a search operation.
[0061] In actual operation, the application program listens for the user's input operations on the interface. When the user finishes inputting and submits, the application program obtains the code for data operations input by the user; after receiving the user's input, some simple validations can be performed to ensure that the format of the input code is basically correct. For example, check whether the code contains the necessary fields and correct syntax structures (such as whether the quotation marks match, etc.). If the format of the input code is incorrect, an error message can be displayed to the user, prompting the user to re-enter.
[0062] Step (4): Determine the target method corresponding to the data operation type in the operation class according to the first field in the code for data operations.
[0063] Specifically, in the embodiments of the present application, the code for data operations input by the user contains a first field indicating the data operation type. For example, in the code searchname='John', search is the first field, which indicates that this is a search operation; the application program parses the code input by the user and extracts the first field. String operation methods (such as the split method) can be used to achieve field extraction. For example, in Python, code.split()[0] can be used to obtain the first word in the code as the first field.
[0064] In actual operation, the mapping relationship between the first field and each method is predefined in the operation class. For example, a dictionary can be used to store this mapping, where the keys of the dictionary are the first fields and the values are the corresponding method names. For example, {'search':'search_data', 'insert': 'insert_data'}; according to the extracted first field, search for the corresponding target method in the mapping relationship of the operation class. If the corresponding method is found, determine this method as the target method to be executed; if not found, it means that the data operation type indicated by the code input by the user is invalid, and an error message can be displayed to the user.
[0065] Step (5): Convert the code for data operations into a DSL statement for executing the target method according to the attribute information corresponding to the target method.
[0066] Specifically, in the embodiments of the present application, after determining the target method, according to the name or other identifiers of the target method, the corresponding attribute information of the method is obtained. These attribute information are stored in the corresponding data structure of the operation class, such as the dictionary mentioned above.
[0067] In actual operation, the DSL statement template related to the current data operation code is extracted from the attribute information. For example, if the target method is search_data and the code input by the user is searchname='John', then the DSL statement template related to the search operation is found from the attribute information, such as '{"query":{"match":{"name":"%s"}}}' ; Analyze the data operation code input by the user, and extract the parameter information therein. For example, in the code searchname='John', name='John' is the parameter information, and then the extracted parameter information is parsed and converted into a format suitable for filling into the DSL statement template. For example, name='John' is parsed into a key-value pair form for subsequent filling into the template.
[0068] Furthermore, the extracted parameter information is filled into the DSL statement template to generate a complete DSL statement. For example, using the string formatting method in Python (such as the % operator or the format method), name='John' is filled into the template '{"query":{"match":{"name":"%s"}}}' to generate a DSL statement like '{"query":{"match":{"name":"John"}}}'.
[0069] In actual operation, some simple validations can be performed on the generated DSL statement to ensure its syntax is correct. For example, a JSON validation tool can be used to check whether the generated DSL statement conforms to the JSON format (because the DSL statements of ES are usually in JSON format).
[0070] In summary, it can be realized that the data operation code input by the user in the application program is converted into a DSL statement executable by ES, thereby completing the corresponding data operation.
[0071] In one implementation, the data operation code further includes a second field indicating the data storage location; step (5) includes: step (5.1), the details are as follows:
[0072] Step (5.1): Convert the data operation code into a DSL statement according to the second field and the attribute information corresponding to the target method;
[0073] Among them, the DSL statement is a statement used to execute the target method for the data corresponding to the second field.
[0074] Specifically, in the embodiments of the present application, the second field indicates the data storage location, usually the index name in ES. For example, users represents the index where user data is located.
[0075] Determine the specific DSL statement template according to the attribute information of the second field and the target method. In some cases, different indexes may correspond to different query templates or more appropriate templates can be selected according to the characteristics of the index. If there is no template for a specific index in the attribute information, the default template is used.
[0076] In actual operation, other parameter information except the first field and the second field can be extracted from the data operation code. The subsequent generated DSL statement should include the information for executing the target method for the data corresponding to the second field (i.e., the specified index). For example, if the target method is a search operation, the DSL statement should clearly specify the index to be searched.
[0077] S150: Send the DSL statement to Elasticsearch so that Elasticsearch performs data operations according to the DSL statement.
[0078] Specifically, in the embodiments of the present application, the application program sends the generated DSL statement to the ES server. After receiving the DSL statement, the ES server executes the corresponding data operation according to its syntax rules and returns the operation result to the application program.
[0079] In practical applications, the ORM framework sends the generated DSL statement to the ES server through the previously established connection with ES. An HTTP request (such as a POST request) can be used to send the DSL statement. After receiving the DSL statement, the ES server parses the statement and executes the corresponding data operation. For example, if the DSL statement is a query statement, ES will search for data that meets the conditions in the index. Subsequently, ES returns the operation result to the ORM framework in JSON format, and the ORM framework then passes the result to the application program for the application program to further process or display the result.
[0080] In one implementation, before S110, the method further includes: step (6), the details are as follows:
[0081] Step (6): Define a connection class within the ORM framework; among them, the connection class is used to connect with Elasticsearch.
[0082] Specifically, in the embodiments of the present application, the main purpose of defining a connection class within the ORM framework is to encapsulate the logic for connecting and communicating with ES. By creating a dedicated connection class, the details of interacting with ES can be separated from the business logic, improving the maintainability and reusability of the code. The connection class is responsible for handling operations such as establishing, maintaining, and closing connections, as well as sending requests and receiving responses.
[0083] S150 includes: step (7), details are as follows:
[0084] Step (7): Send the DSL statement to Elasticsearch through the connection class.
[0085] Specifically, in the embodiments of the present application, after obtaining the DSL statement, the constructed DSL statement can be sent to the ES server through the method provided by the connection class.
[0086] In a second aspect, the present application provides a data operation device, which is applied to a terminal device. The terminal device is configured with an object-relational mapping (ORM) framework and an application; as Figure 3 shown, Figure 3 is a schematic structural diagram of the data operation device provided by the embodiments of the present application. The device includes: a definition module 310, a configuration module 320, an initialization module 330, an input module 340, and a connection module 350;
[0087] The definition module 310 is used to define an operation class within the ORM framework; wherein, the operation class is used to perform data operations on the search engine Elasticsearch;
[0088] The configuration module 320 is used to configure attribute information for the operation class based on the ORM framework; wherein, the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold;
[0089] The initialization module 330 is used to control the initialization of the ORM framework and configure a data operation environment for the application;
[0090] The input module 340 is used to convert the code of the data operation input by the user in the application into a DSL statement in the data operation environment;
[0091] The connection module 350 is used to send the DSL statement to Elasticsearch so that Elasticsearch performs data operations according to the DSL statement.
[0092] Preferably, the definition module 310 is further used to construct a configuration file regarding the attribute information;
[0093] The configuration module 320 is further configured to assemble a configuration file based on an ORM framework for configuring attribute information for an operation class.
[0094] Preferably, the definition module 310 is further configured to define a connection class within the ORM framework; wherein the connection class is used to connect to Elasticsearch;
[0095] The connection module 350 is further configured to send a DSL statement to Elasticsearch through the connection class.
[0096] In one implementation, the operation class includes multiple methods, each method is used to perform a data operation of a data operation type, and each method has corresponding attribute information; the input module 340 is further configured to receive the code of the data operation input by the user in the interface displayed by the application program; wherein the code includes a first field indicating the data operation type;
[0097] The input module 340 is further configured to determine a target method corresponding to the data operation type in the operation class according to the first field in the code of the data operation;
[0098] The input module 340 is further configured to convert the code of the data operation into a DSL statement for executing the target method according to the attribute information corresponding to the target method.
[0099] In one implementation, the code of the data operation further includes a second field indicating the data storage location; the input module 340 is further configured to convert the code of the data operation into the DSL statement according to the second field and the attribute information corresponding to the target method;
[0100] Wherein, the DSL statement is a statement for executing the target method for the data corresponding to the second field.
[0101] Third, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the steps of S110 - S150 provided in the above embodiment are implemented.
[0102] Fourth, the present application further provides a computer - readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of S110 - S150 in the above embodiment are executed.
[0103] Fifth, the computer program product provided by this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods in the foregoing method embodiments. For the specific implementation, reference can be made to the steps S110 to S150 in the method embodiments, which will not be elaborated herein.
[0104] In the embodiments provided by this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0105] In addition, the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0106] Furthermore, in each embodiment of this application, the various functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0107] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of this application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program code.
[0108] In this document, relational terms such as first and second are used solely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0109] The above description is only for the embodiments of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A data operation method, characterized in that, Applied to a terminal device, an object-relational mapping (ORM) framework and an application program are configured in the terminal device; the method includes: Defining an operation class within the ORM framework; wherein, the operation class is used to perform data operations on the search engine Elasticsearch; Configuring attribute information for the operation class based on the ORM framework; wherein, the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold; Controlling the ORM framework to initialize for configuring a data operation environment for the application program; In the data operation environment, converting the code of the data operation input by the user in the application program into a DSL statement; Sending the DSL statement to the Elasticsearch so that the Elasticsearch performs the data operation according to the DSL statement.
2. The method according to claim 1, characterized in that, Before defining the operation class within the ORM framework, the method further includes: Constructing a configuration file for the attribute information; The configuring the attribute information for the operation class based on the ORM framework includes: Assembling the configuration file based on the ORM framework for configuring the attribute information for the operation class.
3. The method according to claim 1, characterized in that, Before configuring the attribute information for the operation class based on the ORM framework, the method further includes: Defining a connection class within the ORM framework; wherein, the connection class is used to connect to the Elasticsearch; The sending the DSL statement to the Elasticsearch includes: Sending the DSL statement to the Elasticsearch through the connection class.
4. The method according to claim 1, wherein The operation class includes multiple methods, each of the methods is used to perform the data operation of a data operation type, and each of the methods has corresponding attribute information; The converting the code of the data operation input by the user in the application program into a DSL statement includes: Receiving the code of the data operation input by the user in the interface displayed by the application program; wherein, the code includes a first field indicating the data operation type; Determining a target method corresponding to the data operation type in the operation class according to the first field in the code of the data operation; Converting the code of the data operation into the DSL statement for executing the target method according to the attribute information corresponding to the target method.
5. The method according to claim 4, characterized in that, The code of the data operation further includes a second field indicating the data storage location; the converting the code of the data operation into the DSL statement for executing the target method according to the attribute information corresponding to the target method includes: Converting the code of the data operation into the DSL statement according to the second field and the attribute information corresponding to the target method; Wherein, the DSL statement is a statement for performing the target method on the data corresponding to the second field.
6. A data operation device, characterized in that, Applied to a terminal device, an object-relational mapping (ORM) framework and an application program are configured in the terminal device; the apparatus includes: a definition module, a configuration module, an initialization module, an input module, and a connection module; The definition module is configured to define an operation class within the ORM framework; wherein, the operation class is used to perform data operations on the search engine Elasticsearch; The configuration module is configured to configure attribute information for the operation class based on the ORM framework; wherein, the attribute information represents the mapping between the code of the data operation and the domain-specific language (DSL) statement; the number of characters included in the code of the data operation does not exceed a preset threshold; The initialization module is configured to control the initialization of the ORM framework and configure a data operation environment for the application program; The input module is configured to convert the code of the data operation input by the user in the application program into a DSL statement in the data operation environment; The connection module is configured to send the DSL statement to the Elasticsearch so that the Elasticsearch performs the data operation according to the DSL statement.
7. The device according to claim 6, characterized in that The definition module is further configured to construct a configuration file regarding the attribute information; The configuration module is further configured to assemble the configuration file based on the ORM framework and configure the attribute information for the operation class.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory is used to store the application program, and the processor runs or executes the software program stored in the memory to enable the electronic device to implement the data operation method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store the program code executed by the processor, and the program code is used to implement the data operation method according to any one of claims 1 to 5.
10. A computer program product, characterized in that, The computer program product includes computer instructions, and when the computer instructions run on the electronic device, the electronic device is enabled to implement the data operation method according to any one of claims 1 to 5.