Data query method, device, and equipment, storage medium, and computer program product

By obtaining the target data nested representation and text string of the ElasticSearch DSL query structure through the constructor, the problem of low query efficiency caused by the complexity of nested query process in the existing technology is solved, and more efficient data query and code conciseness are achieved.

CN122240638APending Publication Date: 2026-06-19BEIJING HONGTENG INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING HONGTENG INTELLIGENT TECH CO LTD
Filing Date
2024-12-17
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In existing technologies, when generating ElasticSearch DSL query structures by manually constructing nested map structures, the complex nested query process leads to low query efficiency.

Method used

The constructor obtains the nested expression of the target data structure based on the underlying data structure of the code to be queried, retrieves the text string, and generates the data query structure, simplifying the query process.

Benefits of technology

It improves query efficiency, enhances code readability and maintainability, reduces code duplication, and improves code reusability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240638A_ABST
    Figure CN122240638A_ABST
Patent Text Reader

Abstract

This application discloses a data query method, apparatus, device, storage medium, and computer program product, relating to the field of data processing technology. The method includes: obtaining a nested expression of a target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried using a constructor; obtaining a text string from the code to be queried based on the nested expression of the target data structure; generating a data query structure corresponding to the code to be queried based on the text string; and performing a data query using the data query structure. This invention can obtain the text string from the nested expression of the target data structure corresponding to the code to be queried, and then generate a data query structure based on the text string to perform a data query. This solves the technical problem of low query efficiency caused by the complex construction process of complex nested query structures when manually constructing nested map structures to generate query structures in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to data query methods, apparatus, devices, storage media, and computer program products. Background Technology

[0002] Elasticsearch is a distributed search and analytics engine widely used in full-text search, log and event data analysis, and other fields. In practical applications, Elasticsearch can use its proprietary query language, ElasticsearchDSL (Domain Specific Language), in JSON format for data queries. While the JSON query structure offers significant advantages in flexibility and expressiveness, writing and maintaining complex query statements still presents certain challenges.

[0003] Currently, in Go, developers typically generate ElasticSearch DSL queries by building and managing nested map structures. However, while this approach is straightforward, for complex nested queries, the process of building the query structure is usually quite complicated, resulting in high time costs and ultimately low query efficiency. Summary of the Invention

[0004] The main objective of this application is to provide a data query method, apparatus, device, storage medium, and computer program product, which aims to solve the technical problem that the query efficiency is low when generating query structures by manually constructing nested map structures in the prior art, due to the complex construction process of the nested query structures.

[0005] To achieve the above objectives, this application proposes a data query method, which includes:

[0006] The constructor obtains the nested representation of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried.

[0007] The text string in the code to be queried is obtained based on the nested expression of the target data structure.

[0008] A data query structure corresponding to the code to be queried is generated based on the text string, and the data is queried through the data query structure.

[0009] In one embodiment, the step of obtaining the nested expression of the target data structure corresponding to the query code based on the underlying data structure of the query code by a constructor includes:

[0010] The constructor determines the nested data structure representation corresponding to the code to be queried based on the underlying data structure of the code to be queried.

[0011] The nested expression of the data structure is simplified to obtain the nested expression of the target data structure.

[0012] In one embodiment, the step of determining the nested data structure representation corresponding to the query code based on the underlying data structure of the query code by a constructor includes:

[0013] Determine the structure type corresponding to the underlying data structure of the code to be queried;

[0014] The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the structure type;

[0015] Generate the nested data structure representation corresponding to the code to be queried based on the nested data structure relationship.

[0016] In one embodiment, the step of determining the nesting relationship of the data structure corresponding to the code to be queried based on the structure type by the constructor includes:

[0017] Determine the target constructor corresponding to the basic data structure based on the structure type;

[0018] The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the target constructor.

[0019] In one embodiment, the step of simplifying the nested representation of the data structure to obtain the nested representation of the target data structure includes:

[0020] Identify the nested combinations to be simplified in the nested representation of the data structure;

[0021] Obtain the target syntax function corresponding to the nested combination to be simplified;

[0022] The target syntax function is used to simplify the nested combination to be simplified, thereby obtaining the nested expression of the target data structure.

[0023] In one embodiment, the step of obtaining the text string in the code to be queried based on the nested expression of the target data structure includes:

[0024] Obtain the data structure object in the nested expression of the target data structure;

[0025] Determine the object type corresponding to the data structure object;

[0026] Retrieve the text string from the code to be queried based on the object type.

[0027] In one embodiment, the object type includes: a basic type; the step of obtaining the text string in the code to be queried based on the object type includes:

[0028] If the object type is a basic type, then the key and key value of the key-value pairs in the data structure object are concatenated to obtain the first string;

[0029] The first string is identified as the text string in the code to be queried.

[0030] In one embodiment, the object type includes: a composite type; the step of obtaining the text string in the code to be queried based on the object type includes:

[0031] If the object type is a composite type, then determine the key value of the key-value pair in the data structure object;

[0032] The target syntax function retrieves the output string corresponding to the sub-object of the data structure object based on the key value;

[0033] The text string in the code to be queried is obtained based on the output string.

[0034] In one embodiment, the step of obtaining the text string in the code to be queried based on the output string includes:

[0035] Determine the key of the key-value pairs in the data structure object;

[0036] The output string and the key are concatenated to obtain the second string;

[0037] The second string is identified as the text string in the code to be queried.

[0038] In one embodiment, before the step of obtaining the nested expression of the target data structure corresponding to the query code based on the underlying data structure of the query code by the constructor, the method further includes:

[0039] The code to be queried is abstracted to obtain the data structure object in the code to be queried.

[0040] The underlying data structure of the code to be queried is determined based on the data structure object.

[0041] Furthermore, to achieve the above objectives, this application also proposes a data query device, the device comprising:

[0042] The nested expression acquisition module is used to obtain the nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried through a constructor.

[0043] The string retrieval module is used to retrieve the text string from the code to be queried based on the nested expression of the target data structure;

[0044] The data query module is used to generate a data query structure corresponding to the code to be queried based on the text string, and to perform data query through the data query structure.

[0045] In one embodiment, the nested expression acquisition module is further configured to determine the nested expression of the data structure corresponding to the code to be queried based on the basic data structure of the code to be queried by a constructor; and to simplify the nested expression of the data structure to obtain the target nested expression of the data structure.

[0046] In one embodiment, the nested expression acquisition module is further configured to determine the structure type corresponding to the basic data structure of the code to be queried; determine the nesting relationship of the data structure corresponding to the code to be queried based on the structure type using a constructor; and generate the nested expression of the data structure corresponding to the code to be queried based on the nesting relationship of the data structure.

[0047] In one embodiment, the nested expression acquisition module is further configured to determine the target constructor corresponding to the basic data structure based on the structure type; and determine the nesting relationship of the data structure corresponding to the code to be queried based on the target constructor through the constructor.

[0048] In one embodiment, the nested expression acquisition module is further configured to determine the nested combination to be simplified in the nested expression of the data structure; acquire the target syntax function corresponding to the nested combination to be simplified; and simplify the nested combination to be simplified through the target syntax function to obtain the target data structure nested expression.

[0049] In one embodiment, the string acquisition module is further configured to acquire a data structure object in the nested expression of the target data structure; determine the object type corresponding to the data structure object; and acquire the text string in the code to be queried based on the object type.

[0050] In one embodiment, the string acquisition module is further configured to, if the object type is a basic type, concatenate the key and key value of the key-value pairs in the data structure object to obtain a first string; and determine the first string as the text string in the code to be queried.

[0051] In addition, to achieve the above objectives, this application also proposes a data query device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the data query method as described above.

[0052] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the data query method described above.

[0053] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the data query method described above.

[0054] This application provides a data query method. It discloses a method for obtaining a nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried using a constructor; obtaining a text string from the code to be queried based on the nested expression of the target data structure; generating a data query structure corresponding to the code to be queried based on the text string; and performing data querying through the data query structure. Compared to the prior art of generating an ElasticSearch DSL by constructing and managing nested map structures for data querying, which suffers from low query efficiency due to the complex construction process of the nested query structure, this invention can obtain the text string from the nested expression of the target data structure corresponding to the code to be queried and generate a data query structure based on the text string for data querying. This solves the technical problem of low query efficiency caused by the complex construction process of the nested query structure when manually constructing a nested map structure for querying in the prior art. Attached Figure Description

[0055] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0056] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 This is a flowchart illustrating an embodiment of the data query method of this application.

[0058] Figure 2 This is an example diagram of JSON data used in the data query method of this application;

[0059] Figure 3This is a flowchart illustrating Embodiment 2 of the data query method of this application;

[0060] Figure 4 This is an example diagram illustrating the nested expression of data structures in the data query method of this application;

[0061] Figure 5 This is the entity relationship diagram in the data query method of this application;

[0062] Figure 6 This is an example diagram illustrating the nested expression of the target data structure in the data query method of this application;

[0063] Figure 7 This is a flowchart illustrating Embodiment 3 of the data query method of this application;

[0064] Figure 8 This is an example diagram of the code to be queried in the data query method of this application;

[0065] Figure 9 This is a data query structure diagram corresponding to the code to be queried in the data query method of this application;

[0066] Figure 10 This is a schematic diagram of the module structure of the data query device according to an embodiment of this application;

[0067] Figure 11 This is a schematic diagram of the device structure of the hardware operating environment involved in the data query method in this application embodiment.

[0068] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0069] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0070] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0071] The main solution of this application embodiment is: to obtain the nested expression of the target data structure corresponding to the code to be queried based on the basic data structure of the code to be queried by a constructor; to obtain the text string in the code to be queried based on the nested expression of the target data structure; to generate the data query structure corresponding to the code to be queried based on the text string; and to perform data query through the data query structure.

[0072] In existing technologies, data queries are performed by building and managing nested map structures to generate ElasticSearch DSLs. However, the complex process of building nested query structures is time-consuming, resulting in low query efficiency.

[0073] This application provides a solution that can obtain the text string from the nested expression of the target data structure corresponding to the code to be queried, and generate a data query structure based on the text string to perform data query. This solves the technical problem that the query efficiency is low when generating a query structure by manually constructing a nested map structure in the prior art, due to the complex construction process of the nested query structure.

[0074] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or data query device capable of performing the above functions. The following description uses a data query device (hereinafter referred to as the device) as an example to illustrate this embodiment and the subsequent embodiments.

[0075] Based on this, the embodiments of this application provide a data query method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the data query method of this application.

[0076] In this embodiment, the data query method includes steps S10 to S30:

[0077] Step S10: Obtain the nested expression of the target data structure corresponding to the code to be queried based on the basic data structure of the code to be queried by the constructor.

[0078] It is understandable that the code to be queried above can be any JSON code used to retrieve the required data from a database or other data source.

[0079] It should be understood that the above constructors can be tools or methods used to construct and execute database queries.

[0080] It should be noted that the aforementioned basic data structures can be the fundamental structures used to store and organize data in the code to be queried, such as String, Integer, Array, and Object. This embodiment does not impose any restrictions on these structures. These data structures can define the logical relationships and storage methods of the data. In this embodiment, the code to be queried is JSON code. JSON is a cross-language data exchange format based on key-value pairs that supports data nesting. JSON data types can include basic types (String, Integer, etc.) and composite types (Array, Object).

[0081] Furthermore, prior to step S10, the method further includes: abstracting the code to be queried to obtain a data structure object in the code to be queried; and determining the basic data structure of the code to be queried based on the data structure object.

[0082] It should be noted that the aforementioned data structure object can be an object used to construct JSON data structures, such as a Builder object. The Builder object allows developers to construct JSON data structures step by step through a series of method calls, which may include adding key-value pairs to a JSON object, adding elements to a JSON array, etc.

[0083] In practical applications, refer to Figure 2 , Figure 2 This is an example diagram of JSON data used in the data query method of this application. This embodiment demonstrates... Figure 2 The JSON data shown can be abstracted into a data structure called Builder, which contains two properties: "Type" and "Body". Type corresponds to the key of the JSON key-value pair, and Body corresponds to the value of the key-value pair. Figure 2After instantiation, the objects in the code can be converted into a Builder object with Type "query" and Body "Object" (containing a sub-object with Type "bool"), and a Builder object with Type "size" and Body 0. The sub-object with Type "bool" contains a sub-object with Type "minimum_should_match" and Body 1, and a sub-object with Type "should" and Body "Object". Furthermore, the sub-object with Type "should" contains a sub-object with Type "multi_match" and Body "Object", and the sub-object with Type "multi_match" contains sub-objects with Types "analyzer", "fields", and "query".

[0084] It should be noted that the above-mentioned nested expression of target data structure can be a data organization method that uses nested functions to express JSON data through basic data structures.

[0085] In this embodiment, the constructor can have several constructors. The constructor can use the constructors to express the JSON data (i.e. the code to be queried above) through the basic data structure in a nested manner, thereby obtaining the nested expression of the target data structure.

[0086] In practical applications, when querying data based on the code to be queried using Elasticsearch, Elasticsearch can use its proprietary query language, Elasticsearch DSL, to represent the code as a JSON-formatted query structure before querying the data. Currently, a JSON-formatted query structure can be generated by manually constructing nested map structures. However, while this method is convenient for simple queries, it becomes verbose and difficult to understand when dealing with complex nested queries, resulting in low query efficiency. Furthermore, manually constructing JSON queries requires numerous nested maps and interface type conversions, significantly reducing code readability and maintainability. This is especially problematic when the query structure needs frequent modification, as developers are prone to introducing errors, impacting system stability and reliability. In addition, manually constructing query structures typically lacks modularity and abstraction, making it difficult to reuse code between different queries. Therefore, each query construction requires rewriting similar logic, leading to significant code duplication and increased maintenance costs. The data query method proposed in this solution interprets the Elasticsearch DSL query structure through function nesting, simplifying the query structure construction process, making the code more intuitive and concise, enhancing readability and maintainability, improving code reusability, and reducing code duplication.

[0087] Step S20: Obtain the text string in the code to be queried based on the nested expression of the target data structure.

[0088] It should be noted that the aforementioned text string can be a JSON string representing the data and nesting relationships in the code to be queried. In this embodiment, an interpreter can be defined, which can be used to recursively interpret functions, converting the data and nesting relationships defined in the function into JSON strings. That is, the interpreter can serialize the Builder object in the JSON data into a JSON string.

[0089] Step S30: Generate a data query structure corresponding to the code to be queried based on the text string, and perform data query through the data query structure.

[0090] It should be understood that the above data query structure can be the data structure used when obtaining, processing and storing data through the code to be queried. In this embodiment, the data query structure can be a JSON format query structure.

[0091] In practical applications, when Elasticsearch performs data queries on the query statements in the code to be queried, it first abstracts the code to obtain Builder objects, thereby determining all the basic data structures in the code. Then, it uses constructors to express the nesting relationships between the basic data structures in the code, obtaining the nested expression of the target data structure. An interpreter is then defined to recursively interpret the functions, converting the data and nesting relationships defined in the functions into JSON strings. Finally, these JSON strings can be combined to form the complete data query structure of the code, which can then be used for subsequent data queries.

[0092] This embodiment provides a data query method. The method discloses obtaining a nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried using a constructor; obtaining a text string from the code to be queried based on the nested expression of the target data structure; generating a data query structure corresponding to the code to be queried based on the text string; and performing data querying through the data query structure. Compared to the prior art of generating an ElasticSearch DSL by constructing and managing nested map structures for data querying, which suffers from low query efficiency due to the complex construction process of the nested query structure, this embodiment solves the technical problem of low query efficiency caused by the complex construction process of the nested query structure when manually constructing nested map structures for querying. This method obtains the text string from the nested expression of the target data structure corresponding to the code to be queried and generates a data query structure based on the text string.

[0093] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the data query method in this application.

[0094] In this embodiment, step S10 includes steps S101 to S102:

[0095] Step S101: Determine the nested data structure representation corresponding to the code to be queried based on the underlying data structure of the code to be queried by using a constructor.

[0096] It should be noted that the above nested data structure expression can be a data organization method that uses constructors to express JSON data through basic data structures in a nested manner.

[0097] Further, step S101 includes:

[0098] Step S101a: Determine the structure type corresponding to the basic data structure of the code to be queried.

[0099] It is understandable that the above structure type refers to the data type corresponding to the JSON data in the code to be queried, including basic types (such as String, Integer, etc.) and composite types (such as Array, Object, etc.). Among them, composite type data can express more complex data formats through hierarchical nesting.

[0100] Step S101b: Determine the nesting relationship of the data structure corresponding to the code to be queried based on the structure type using the constructor.

[0101] Specifically, step S101b includes: determining the target constructor corresponding to the basic data structure according to the structure type; and determining the nesting relationship of the data structure corresponding to the code to be queried based on the target constructor through the constructor.

[0102] It should be noted that the target constructor described above can be a function used to express the nested relationship between data structures in JSON data. The constructor designed in this embodiment can provide three constructors: Key(), KeyArray(), and KeyAny(). In this embodiment, if the structure type corresponding to the basic data structure is Object (array), then its corresponding target constructor can be Key(); if the structure type corresponding to the basic data structure is Array (object), then its corresponding target constructor can be KeyArray(); if the structure type corresponding to the basic data structure is another basic type, then its corresponding target constructor can be KeyAny().

[0103] Step S101c: Generate the nested data structure representation corresponding to the code to be queried based on the nested data structure relationship.

[0104] In practical applications, after determining all the basic data structures in the code to be queried, these data structures can be expressed in corresponding ways. Since functions have parameters and return values, and the return value of a function can be used as a parameter of another function, this characteristic is naturally beneficial for expressing the nested relationships between data structures. Therefore, this embodiment designs a constructor that provides three constructors: Key(), KeyArray(), and KeyAny(), corresponding to Object (array), Array (object), and other basic types of JSON data, respectively. The nested relationships between data structures in the JSON data can then be expressed through these constructors. (Refer to...) Figure 4 , Figure 4 This is an example diagram illustrating the nested expression of data structures in the data query method of this application. For example... Figure 4 As shown, for other basic JSON data types: "analyzer":"ik_smart", it can be expressed using the constructor KeyAny() as: analyzerBuilder:=KeyAny("analyzer", "ik_smart"); for other basic JSON data types: "fields":["name", "description"], it can be expressed using the constructor KeyAny() as: fieldBuilder:=KeyAny("fields",[]string{"name","description"}); for array-type data structures: "multi_match":{"analyzer":"ik_smart","fields":["name","description"],"query":"APT"}, it can be expressed using the constructor Key() as multiMatchBuilder:=Key("multi_match",analyzerBuilder,fieldBuilder,KeyAny("query","APT")); other expressions are as follows. Figure 4 As shown, they are not all listed here.

[0105] Step S102: Simplify the nested expression of the data structure to obtain the nested expression of the target data structure.

[0106] In this embodiment, after the constructor expresses the nesting relationship between the basic data structures in the code to be queried through the constructor, in order to achieve a simpler call, a syntax function can be introduced, and the nesting relationship of data objects can be expressed by nesting the syntax function, thereby simplifying the nested expression of data structures and obtaining the nested expression of the target data structure.

[0107] Further, step S102 includes: determining the nested combination to be simplified in the nested expression of the data structure; obtaining the target syntax function corresponding to the nested combination to be simplified; and simplifying the nested combination to be simplified through the target syntax function to obtain the target nested expression of the data structure.

[0108] It should be noted that the aforementioned nested combinations to be simplified can be nested combinations of specific keywords in the nested expression of data structures, such as the combination of boolean values ​​in query. In this embodiment, corresponding syntax functions can be provided according to different syntaxes of the DSL to achieve simpler calls. Here, DSL is a JSON query language. Since some query structures of DSL are relatively fixed, specific syntax functions can be provided for nested combinations of specific keywords (such as the combination of boolean values ​​in query) to achieve simpler calls.

[0109] It should be noted that the target syntax function mentioned above can be a function used to call nested combinations of specific keywords in nested expressions of data structures, such as Query, Match, Filter, Aggs, etc. This embodiment does not limit this.

[0110] In this embodiment, refer to Figure 5 , Figure 5 This is the entity relationship diagram in the data query method of this application. For example... Figure 5 As shown, in this embodiment, the data abstracted from JSON data is divided into basic types (String, Integer, etc.) and composite types (Array, Object, etc.). The abstracted data structure can also include properties such as Type, Body, and ToString. Furthermore, the constructor designed in this embodiment can express the nesting relationship of JSON data objects by nesting constructor calls (including Key, KeyArray, KeyAny, etc.). Simultaneously, simpler calls can be achieved through nested combinations of specific keywords using syntax functions (Query, Match, Filter, Aggs, etc.). An interpreter is defined to convert the data and nesting relationships defined by the syntax functions into JSON strings.

[0111] In the specific implementation, refer to Figure 6 , Figure 6 This is an example diagram illustrating the nested expression of the target data structure in the data query method of this application. Figure 6 In this context, KeyAny("size",val) can be simplified to Size(val) which matches the keyword name in the DSL. Figure 4 In the code, KeyAny("size",1) is converted to Size(1), and then... Figure 4In the code, KeyAny("analyzer","ik_smart") is converted to Analyzer("ik_smart"); Additionally, it can also be used to convert KeyAny("analyzer","ik_smart") to Analyzer("ik_smart"); Figure 4 Fixed nested functions like Key("query", Key("bool", shouldBuilder)) are simplified to QueryBool(shouldBuilder)), etc., which will not be listed here.

[0112] This embodiment discloses a method for determining the nested expression of the data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried using a constructor; simplifying the nested expression of the data structure to obtain the target nested expression of the data structure. Since this embodiment can use a constructor to express the nested expression relationship between the underlying data structures in the JSON data, obtain the nested expression of the data structure corresponding to the code to be queried, and simplify the nested expression of the data structure using a syntax function to obtain the target nested expression of the data structure, the constructed data query structure can be more intuitive and concise, further improving the data query efficiency.

[0113] Based on the first and / or second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 7 , Figure 7 This is a flowchart illustrating the data query method of this application in Embodiment 3.

[0114] In this embodiment, step S20 includes steps S201 to S203:

[0115] Step S201: Obtain the data structure object in the nested expression of the target data structure.

[0116] Step S202: Determine the object type corresponding to the data structure object.

[0117] It is understandable that the above object type is the type corresponding to the data structure of the JSON data in the code to be queried, which can include basic types and composite types.

[0118] Step S203: Obtain the text string in the code to be queried based on the object type.

[0119] In this embodiment, the data in the nested expression of the target data structure has been expressed as Builder objects through syntax functions and constructors. At this point, an interpreter can be defined that can accept multiple Builder objects as parameters. During execution, the interpreter can traverse these Builder objects and determine the type of Builder.Body in the Builder object, i.e., the object type mentioned above, and then generate a JSON string based on the object type.

[0120] Further, the object type includes: a basic type; step S203 includes: if the object type is a basic type, then concatenating the key and key value of the key-value pairs in the data structure object to obtain a first string; and determining the first string as the text string in the code to be queried.

[0121] It should be noted that the first string mentioned above can be a string obtained by concatenating the key and value of key-value pairs in a data structure object. In this embodiment, if the type of Builder.Body in the Builder object is the aforementioned basic type (such as String, Integer, etc.), then the key and value of the Builder object can be concatenated into a JSON format string, that is, Builder.Type and Builder.Body can be concatenated into a JSON format string, and the first string can be obtained and returned. The first string obtained at this time is the text string in the code to be queried.

[0122] Further, the object type includes: composite type; step S203 includes:

[0123] Step S203a: If the object type is a composite type, then determine the key value of the key-value pair in the data structure object.

[0124] Step S203b: Obtain the output string corresponding to the sub-object of the data structure object based on the key value using the target syntax function.

[0125] It should be understood that the above output string can be a JSON string output by a sub-object of the data structure object.

[0126] Step S203c: Obtain the text string from the code to be queried based on the output string.

[0127] Specifically, step S203c includes: determining the key of the key-value pair in the data structure object; concatenating the output string and the key to obtain a second string; and determining the second string as the text string in the code to be queried.

[0128] It should be noted that the second string mentioned above can be a JSON string obtained by concatenating the string output by the child object of the data structure object with the key of its corresponding parent object. In this embodiment, if Builder.Body in the Builder object is also a Builder object, it means that the Builder object is a composite type (such as Array, Object, etc.). In this case, the interpreter function can be recursively applied to Builder.Body to obtain the JSON string output by the child object of Builder.Body. Then, the string output by the child object is concatenated with the Builder.Type of its corresponding parent object to obtain and return the second string. The second string obtained at this time is the text string in the code to be queried.

[0129] In the specific implementation, refer to Figure 8 , Figure 8 This is an example diagram of the code to be queried in the data query method of this application. Figure 8 In a bucket query example, when querying data, the dynamically generated parts (such as MultiMacth, Filter, etc.) can first be extracted and stored in variables. The nesting relationships of syntax keywords are expressed through nested constructors and syntax functions, ultimately generating data like... Figure 9 The JSON structure shown is as follows, in which, Figure 9 This is a data query structure diagram corresponding to the code to be queried in the data query method of this application.

[0130] This embodiment discloses the following steps: obtaining the data structure object in the nested expression of the target data structure; determining the object type corresponding to the data structure object; and obtaining the text string in the code to be queried based on the object type. Since this embodiment can obtain the text string in the code to be queried based on the object type of the data structure object, a complete JSON string can be returned to construct the data query structure, thereby improving the accuracy of data query.

[0131] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the data query method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0132] This application also provides a data query device, please refer to... Figure 10 The data query device includes:

[0133] Nested Representation Acquisition Module 10 is used to acquire the nested representation of the target data structure corresponding to the code to be queried based on the basic data structure of the code to be queried by a constructor.

[0134] String acquisition module 20 is used to acquire the text string in the code to be queried based on the nested expression of the target data structure;

[0135] The data query module 30 is used to generate a data query structure corresponding to the code to be queried based on the text string, and to perform data query through the data query structure.

[0136] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problem in the prior art where, when generating a query structure by manually constructing a nested map structure, the complex process of constructing the nested query structure leads to low query efficiency. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features in the data query device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0137] This application provides a data query device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the data query method in Embodiment 1 above.

[0138] The following is for reference. Figure 11 The diagram illustrates a structural schematic of a data query device suitable for implementing embodiments of this application. The data query device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 11 The data query device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0139] like Figure 11As shown, the data query device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the data query device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the data query device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show data query devices with various systems, it should be understood that it is not required to implement or possess all of the systems shown. More or fewer systems may be implemented alternatively.

[0140] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0141] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problem of data query. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features of this data query device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0142] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0143] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0144] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the data query method described in the above embodiments.

[0145] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0146] The aforementioned computer-readable storage medium may be included in the data query device; or it may exist independently and not assembled into the data query device.

[0147] The aforementioned computer-readable storage medium carries one or more programs. When the one or more programs are executed by a data query device, the data query device: obtains a nested expression of a target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried by a constructor; obtains a text string in the code to be queried based on the nested expression of the target data structure; generates a data query structure corresponding to the code to be queried based on the text string; and performs a data query through the data query structure.

[0148] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0149] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0150] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0151] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described data query method. This solves the technical problem in the prior art where, when generating a query structure by manually constructing a nested map structure, the complex construction process of the nested query structure leads to low query efficiency. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.

[0152] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the data query method described above.

[0153] The computer program product provided in this application can solve the technical problem of low query efficiency in the prior art when generating query structures by manually constructing nested map structures, due to the complex construction process of the complex nested query structures. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.

[0154] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

[0155] This invention discloses A1, a data query method, the method comprising:

[0156] The constructor obtains the nested representation of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried.

[0157] The text string in the code to be queried is obtained based on the nested expression of the target data structure.

[0158] A data query structure corresponding to the code to be queried is generated based on the text string, and the data is queried through the data query structure.

[0159] A2. As described in A1, the step of obtaining the nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried by the constructor includes:

[0160] The constructor determines the nested data structure representation corresponding to the code to be queried based on the underlying data structure of the code to be queried.

[0161] The nested expression of the data structure is simplified to obtain the nested expression of the target data structure.

[0162] A3. As described in A2, the step of determining the nested data structure representation corresponding to the code to be queried based on the underlying data structure of the code to be queried by the constructor includes:

[0163] Determine the structure type corresponding to the underlying data structure of the code to be queried;

[0164] The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the structure type;

[0165] Generate the nested data structure representation corresponding to the code to be queried based on the nested data structure relationship.

[0166] A4. As described in A3, the step of determining the nesting relationship of the data structure corresponding to the code to be queried based on the structure type using a constructor includes:

[0167] Determine the target constructor corresponding to the basic data structure based on the structure type;

[0168] The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the target constructor.

[0169] A5. As described in A2, the step of simplifying the nested expression of the data structure to obtain the nested expression of the target data structure includes:

[0170] Identify the nested combinations to be simplified in the nested representation of the data structure;

[0171] Obtain the target syntax function corresponding to the nested combination to be simplified;

[0172] The target syntax function is used to simplify the nested combination to be simplified, thereby obtaining the nested expression of the target data structure.

[0173] A6. As described in A1, the step of obtaining the text string in the code to be queried based on the nested expression of the target data structure includes:

[0174] Obtain the data structure object in the nested expression of the target data structure;

[0175] Determine the object type corresponding to the data structure object;

[0176] Retrieve the text string from the code to be queried based on the object type.

[0177] A7. As described in A6, the object type includes: basic types; the step of obtaining the text string in the code to be queried based on the object type includes:

[0178] If the object type is a basic type, then the key and key value of the key-value pairs in the data structure object are concatenated to obtain the first string;

[0179] The first string is identified as the text string in the code to be queried.

[0180] A8. As described in A6, the object type includes: composite type; the step of obtaining the text string in the code to be queried based on the object type includes:

[0181] If the object type is a composite type, then determine the key value of the key-value pair in the data structure object;

[0182] The target syntax function retrieves the output string corresponding to the sub-object of the data structure object based on the key value;

[0183] The text string in the code to be queried is obtained based on the output string.

[0184] A9. As described in A8, the step of obtaining the text string in the code to be queried based on the output string includes:

[0185] Determine the key of the key-value pairs in the data structure object;

[0186] The output string and the key are concatenated to obtain the second string;

[0187] The second string is identified as the text string in the code to be queried.

[0188] A10. The method as described in any one of A1 to A9, prior to the step of obtaining the nested expression of the target data structure corresponding to the query code through the constructor based on the underlying data structure of the query code, further includes:

[0189] The code to be queried is abstracted to obtain the data structure object in the code to be queried.

[0190] The underlying data structure of the code to be queried is determined based on the data structure object.

[0191] The present invention also discloses B11, a data query device, the device comprising:

[0192] The nested expression acquisition module is used to obtain the nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried through a constructor.

[0193] The string retrieval module is used to retrieve the text string from the code to be queried based on the nested expression of the target data structure;

[0194] The data query module is used to generate a data query structure corresponding to the code to be queried based on the text string, and to perform data query through the data query structure.

[0195] B12. In the apparatus described in B11, the nested expression acquisition module is further configured to determine the nested expression of the data structure corresponding to the code to be queried based on the basic data structure of the code to be queried by a constructor; and to simplify the nested expression of the data structure to obtain the target nested expression of the data structure.

[0196] B13. In the apparatus described in B12, the nested expression acquisition module is further configured to determine the structure type corresponding to the basic data structure of the code to be queried; determine the nesting relationship of the data structure corresponding to the code to be queried based on the structure type by a constructor; and generate the nested expression of the data structure corresponding to the code to be queried according to the nesting relationship of the data structure.

[0197] B14. In the apparatus described in B12, the nested expression acquisition module is further configured to determine the target constructor corresponding to the basic data structure according to the structure type; and to determine the nested relationship of the data structure corresponding to the code to be queried based on the target constructor by the constructor.

[0198] B15. In the apparatus described in B12, the nested expression acquisition module is further configured to determine the nested combination to be simplified in the nested expression of the data structure; acquire the target syntax function corresponding to the nested combination to be simplified; and simplify the nested combination to be simplified through the target syntax function to obtain the target data structure nested expression.

[0199] B16. In the apparatus described in B11, the string acquisition module is further configured to acquire a data structure object in the nested expression of the target data structure; determine the object type corresponding to the data structure object; and acquire the text string in the code to be queried based on the object type.

[0200] B17. In the apparatus described in B16, the string acquisition module is further configured to, if the object type is a basic type, concatenate the key and key value of the key-value pair in the data structure object to obtain a first string; and determine the first string as the text string in the code to be queried.

[0201] The present invention also discloses C18, a data query device, the device comprising: a memory, a processor, and a data query program stored in the memory and executable on the processor, the data query program being configured to implement the steps of the data query method described above.

[0202] The present invention also discloses D19, a storage medium storing a data query program, wherein the data query program, when executed by a processor, implements the steps of the data query method described above.

[0203] The present invention also discloses E20, a computer program product comprising a computer program that, when executed by a processor, implements the steps of the data query method described above.

Claims

1. A data query method, characterized in that, The method includes: The constructor obtains the nested representation of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried. The text string in the code to be queried is obtained based on the nested expression of the target data structure. A data query structure corresponding to the code to be queried is generated based on the text string, and the data is queried through the data query structure.

2. The method as described in claim 1, characterized in that, The step of obtaining the nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried by the constructor includes: The constructor determines the nested data structure representation corresponding to the code to be queried based on the underlying data structure of the code to be queried. The nested expression of the data structure is simplified to obtain the nested expression of the target data structure.

3. The method as described in claim 2, characterized in that, The step of determining the nested data structure representation corresponding to the query code based on the underlying data structure of the query code by using a constructor includes: Determine the structure type corresponding to the underlying data structure of the code to be queried; The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the structure type; Generate the nested data structure representation corresponding to the code to be queried based on the nested data structure relationship.

4. The method as described in claim 3, characterized in that, The step of determining the nesting relationship of the data structure corresponding to the code to be queried based on the structure type by the constructor includes: Determine the target constructor corresponding to the basic data structure based on the structure type; The constructor determines the nesting relationship of the data structure corresponding to the code to be queried based on the target constructor.

5. The method as described in claim 2, characterized in that, The step of simplifying the nested representation of the data structure to obtain the nested representation of the target data structure includes: Identify the nested combinations to be simplified in the nested representation of the data structure; Obtain the target syntax function corresponding to the nested combination to be simplified; The target syntax function is used to simplify the nested combination to be simplified, thereby obtaining the nested expression of the target data structure.

6. The method as described in claim 1, characterized in that, The step of obtaining the text string in the code to be queried based on the nested expression of the target data structure includes: Obtain the data structure object in the nested expression of the target data structure; Determine the object type corresponding to the data structure object; Retrieve the text string from the code to be queried based on the object type.

7. A data query device, characterized in that, The device includes: The nested expression acquisition module is used to obtain the nested expression of the target data structure corresponding to the code to be queried based on the underlying data structure of the code to be queried through a constructor. The string retrieval module is used to retrieve the text string from the code to be queried based on the nested expression of the target data structure; The data query module is used to generate a data query structure corresponding to the code to be queried based on the text string, and to perform data query through the data query structure.

8. A data query device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the data query method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the data query method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the data query method as described in any one of claims 1 to 6.