An elastic search method, device, equipment and medium
By performing multi-layered parsing and conversion of domain-specific languages, the problem of insufficient nested functions in elastic search is solved, enabling the use of multiple functions and improving query efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-11
- Publication Date
- 2026-03-31
AI Technical Summary
Existing elastic search technology cannot implement nested functions, resulting in a limited variety of available functions, limited functionality, and an inability to meet the needs of data query and analysis, leading to low query efficiency.
By acquiring a domain-specific language, parsing it into a syntax tree, and performing multi-level parsing on the syntax tree, including direct parsing, parsing combined with external data, and intermediate data parsing, the data is converted into intermediate code that the data engine can recognize. Nested function forests are processed, and hierarchy and compatibility checks are performed to finally obtain the search results.
It provides a variety of functions of different types and quantities, which improves the efficiency of data querying, meets the needs of complex query analysis, and enhances the accuracy and speed of queries.
Smart Images

Figure CN116910091B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of data processing technology and query analysis and computing technology, and in particular to a flexible search method, apparatus, device and medium. Background Technology
[0002] Elasticsearch (ES) is a search engine. It provides a distributed, multi-tenant full-text search engine. Typically, querying or data analysis often requires combining numerous functions for computation. However, in ES data querying scenarios, due to the limitations of ES's query capabilities, nested functions cannot be implemented; queries can only be performed using the ES query language (JSON statements with special semantics). Furthermore, the available functions are limited to a few provided by ES, resulting in a small number of functions with limited functionality, which cannot meet the demands of complex function calls, leading to low accuracy in data query and analysis. Summary of the Invention
[0003] This disclosure provides a flexible search method, apparatus, device, and medium to at least solve the problem in related technologies where the inability to implement nested functions results in a limited variety of available flexible search functions, a small number of functions with limited functionality, and an inability to meet the needs of data query and analysis, leading to low query efficiency. The technical solution of this disclosure is as follows:
[0004] According to a first aspect of the present disclosure, a flexible search method is provided, comprising:
[0005] Obtain the domain-specific language used for searching, which includes the search object;
[0006] Parse the domain-specific language to obtain the first syntax tree containing the search object;
[0007] Parse the first syntax tree to obtain the second syntax tree containing the search object;
[0008] The second syntax tree is parsed, and the search objects contained in the parsed second syntax tree are used to perform a flexible search to obtain the search results.
[0009] In one possible implementation, the method provided in this disclosure parses a first syntax tree to obtain a second syntax tree containing the search object, including:
[0010] The business characteristic functions in the first syntax tree are parsed to obtain a second syntax tree containing the search object. The first parsing includes at least one of the following: direct parsing, parsing combined with external data, and parsing to obtain intermediate data.
[0011] In one possible implementation, the method provided in this disclosure includes a second syntax tree comprising execution statements, a single-level function syntax tree, and a nested function syntax tree.
[0012] In one possible implementation, the method provided in this disclosure, when parsing the execution statements in the second syntax tree, parses the second syntax tree and uses the search objects contained in the parsed second syntax tree to perform a flexible search to obtain search results, including:
[0013] Based on the search object, the data engine processes the executed statement to obtain the first execution result.
[0014] In one possible implementation, the method provided in this disclosure, when parsing a single-level function syntax tree in a second syntax tree, parses the second syntax tree and uses the search objects contained in the parsed second syntax tree to perform a flexible search to obtain search results, including:
[0015] Transform a single-level function syntax tree into first intermediate code that can be recognized by the data engine;
[0016] Based on the search object, the first intermediate code is processed using a data engine to obtain the second execution result.
[0017] In one possible implementation, the method provided in this disclosure, when parsing the nested function syntax tree in the second syntax tree, parses the second syntax tree and uses the search objects contained in the parsed second syntax tree to perform a flexible search to obtain the search results, including:
[0018] Parse the nested function syntax tree to obtain a nested function forest;
[0019] Transform the nested function forest into a second intermediate code that can be recognized by the data engine;
[0020] Based on the search object, the data engine processes the second intermediate code to obtain the third execution result;
[0021] The first execution result, the second execution result, and the third execution result are determined as the search results.
[0022] In one possible implementation, after parsing the nested function syntax tree to obtain a nested function forest, the method further includes:
[0023] Traverse the nested function forest and perform hierarchy checks, compatibility checks, and performance checks on the functions within the forest.
[0024] According to a second aspect of the present disclosure, a flexible search device is provided, comprising:
[0025] The retrieval unit is configured to perform the retrieval of a domain-specific language for searching, the domain-specific language including the search object;
[0026] The parsing unit is configured to perform parsing of the domain-specific language to obtain a first syntax tree containing the search object;
[0027] The first processing unit is configured to parse the first syntax tree to obtain a second syntax tree containing the search object;
[0028] The second processing unit is configured to parse the second syntax tree and perform a flexible search using the search objects contained in the parsed second syntax tree to obtain the search results.
[0029] In one possible implementation, the apparatus provided in this disclosure is specifically configured to perform:
[0030] The business characteristic functions in the first syntax tree are parsed to obtain a second syntax tree containing the search object. The first parsing includes at least one of the following: direct parsing, parsing combined with external data, and parsing to obtain intermediate data.
[0031] In one possible implementation, the apparatus provided in this disclosure includes a second syntax tree comprising execution statements, a single-level function syntax tree, and a nested function syntax tree.
[0032] In one possible implementation, in the apparatus provided by this disclosure, when parsing the executable statements in the second syntax tree, the second processing unit is specifically configured to execute:
[0033] Based on the search object, the data engine processes the executed statement to obtain the first execution result.
[0034] In one possible implementation, in the apparatus provided by this disclosure, when parsing a single-level function syntax tree in a second syntax tree, the second processing unit is specifically configured to execute:
[0035] Transform a single-level function syntax tree into first intermediate code that can be recognized by the data engine;
[0036] Based on the search object, the first intermediate code is processed using a data engine to obtain the second execution result.
[0037] In one possible implementation, in the apparatus provided by this disclosure, when parsing the nested function syntax tree in the second syntax tree, the second processing unit is specifically configured to execute:
[0038] Parse the nested function syntax tree to obtain a nested function forest;
[0039] Transform the nested function forest into a second intermediate code that can be recognized by the data engine;
[0040] Based on the search object, the data engine processes the second intermediate code to obtain the third execution result;
[0041] The first execution result, the second execution result, and the third execution result are determined as the search results.
[0042] In one possible implementation, the second processing unit in the apparatus provided by this disclosure is further configured to perform:
[0043] Traverse the nested function forest and perform hierarchy checks, compatibility checks, and performance checks on the functions within the forest.
[0044] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor;
[0045] Memory used to store processor-executable instructions;
[0046] The processor is configured to execute the instructions to implement the flexible search method mentioned in the first aspect of the embodiments of this disclosure.
[0047] According to a fourth aspect of the present disclosure, a storage medium is provided such that, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is able to perform the flexible search method mentioned in the first aspect of the present disclosure.
[0048] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects:
[0049] First, the domain-specific language used for searching is obtained. Then, the domain-specific language is parsed to obtain a first syntax tree containing the search objects. The first syntax tree is then parsed again to obtain a second syntax tree containing the search objects. Finally, the second syntax tree is parsed, and the search objects contained in the parsed second syntax tree are used for elastic searching to obtain the search results. Compared with existing elastic search solutions, this method solves the problem that the inability to implement nested functions in related technologies results in a limited variety of available elastic search functions, a small number of functions, and limited functionality, which cannot meet the needs of data query and analysis, leading to low query efficiency. It provides an elastic search method that includes multiple types and reusable function types, effectively increasing the variety and number of functions used for searching. This effectively helps data analysts, programmers, and ordinary users quickly query data using Elasticsearch, obtain effective data, and improve efficiency.
[0050] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0052] Figure 1 This is a flowchart illustrating an elastic search method according to an exemplary embodiment.
[0053] Figure 2 This is a schematic diagram of the structure of an elastic search device according to an exemplary embodiment.
[0054] Figure 3 This is a schematic diagram of the structure of an elastic search device according to an exemplary embodiment.
[0055] Figure 4 This is a schematic diagram of the structure of a terminal that applies an elastic search method according to an exemplary embodiment. Detailed Implementation
[0056] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0057] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0058] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0059] The following are explanations of some of the words that appear in the text:
[0060] 1. In the embodiments of this invention, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.
[0061] 2. ElasticSearch (ES) is a search engine based on the Lucene library. It provides a distributed, multi-tenant full-text search engine.
[0062] 3. A function, also known as a subroutine, refers to a section of code within a large program, consisting of one or more blocks of statements. It is responsible for performing a specific task and is relatively independent of other code. It typically has input parameters and a return value, providing encapsulation of the process and hiding its details.
[0063] 4. Nested function: A function that, under certain circumstances, needs to be used as an argument to another function.
[0064] 5. An Abstract Syntax Tree (AST), or simply a syntax tree, is an abstract representation of the syntactic structure of source code. It represents the syntactic structure of a programming language in a tree-like form, where each node in the tree represents a structure in the source code.
[0065] Elasticsearch (ES) is a search engine. It provides a distributed, multi-tenant full-text search engine. Typically, querying or data analysis often requires combining numerous functions for computation. However, in scenarios where ES is used for data querying, due to the limitations of ES's query capabilities, queries can only be performed using the ES query language (JSON statements with special semantics). The available functions are also limited to a few provided by ES, resulting in a small number of functions with limited functionality, which cannot meet the needs of data query and analysis.
[0066] Functions are categorized into specific functions and general functions based on their usage. Specific functions are closely related to business logic, abstracting complex, high-frequency, and independent logic from business data calculations into functions to improve the usability and reusability of query calculations. General functions, on the other hand, typically meet the query calculation needs of various business processes, are independent of the business logic, and can be used across different business processes. Specific functions and general functions are both independent and interdependent. Independence refers to functional independence; their execution is unaffected by each other. Interdependence refers to function evolution. As specific functions are referenced by more and more business processes, they become more general and can eventually be transformed into general functions. Conversely, when business processes impose special requirements on the capabilities of general functions, a new specific function may be added.
[0067] However, as the number of feature functions increases, naming conflicts become more and more apparent. But if the capabilities of a general function are broken down into very fine details, a feature function can be expressed using a combination of general functions. This necessitates the ability to nest functions. Nested functions can effectively reduce naming conflicts and the number of function definitions, providing ease of use and flexibility.
[0068] Against this backdrop, there is an urgent need for a flexible search solution to address the limited variety of available flexible search functions in related technologies. Furthermore, the limited number and singular functionality of these functions fail to meet the needs of data query and analysis.
[0069] Figure 1 This is a flowchart illustrating a flexible search method according to an exemplary embodiment, such as... Figure 1 As shown, the elastic search method includes the following steps:
[0070] In step S101, the domain-specific language used for the search is obtained.
[0071] In practice, the input Domain Search Language (DSL) is obtained, which includes the search object.
[0072] In step S102, the domain-specific language is parsed to obtain a first syntax tree containing the search object.
[0073] In practice, the domain-specific language is parsed to obtain the first syntax tree, which is also the intermediate layer AST, or Old AST. This first syntax tree contains the search objects and is used to process business feature functions.
[0074] In step S103, the first syntax tree is parsed to obtain a second syntax tree containing the search object.
[0075] In practice, the business characteristic functions in the first syntax tree undergo initial parsing to obtain a second syntax tree containing the search object. This initial parsing includes at least one of the following: local computation, computation combined with external data, and intermediate data computation. Local parsing involves performing computation within the model itself without combining other data. Computation combined with external data requires introducing external data to assist in the computation, typically used for rewriting the AST (Abstract Syntax Tree) to a general AST or a nested AST. Intermediate data computation involves identifying nested functions, further processing the nested function AST to obtain a nested function forest, and finally parsing the nested function forest into intermediate code that the data engine can recognize and hand it over to the data engine for execution. Because business characteristic functions require fetching business data for processing during parsing, sometimes the same function call combination may appear multiple times in a single query condition. In this case, the parser internally caches business data to avoid repeated fetching of the same batch of business data, thus accelerating parsing.
[0076] The business characteristic functions mainly adopt the dynamic syntax tree (AST) scheme, which uses a unified function syntax for representation.
[0077] functionName=ID params=collection expression
[0078] Any function in the form `functionName(param1...param2)` will be recognized as a function by the query analyzer. The recognized function name is `functionName`, and the parameter is `collection`. Multiple business characteristic functions are defined on the business function parsing chain. All characteristic functions together form a parser chain. All query conditions must be parsed layer by layer by the parser nodes on this chain. The specific parsing process involves obtaining the query condition's `TokenExpression` from the AST, using the function name as the function entry point, processing it through the parser on the parsing chain, fetching business data based on the function's characteristics, processing the parsed result, and finally rewriting the query condition. This completes the parsing of the business characteristic function. After processing by the query analyzer, the AST is obtained, along with a `TokenExpression` containing part-of-speech tags and parameter positions. This is then passed to the business layer for further function interpretation. The result of the function interpretation is used to rewrite the query process. The rewritten result is then uniformly converted to Elasticsearch query language by the `FunctionParser`, and finally, an Elasticsearch search is initiated.
[0079] In step S104, the second syntax tree is parsed, and the search objects contained in the parsed second syntax tree are used to perform a flexible search to obtain the search results.
[0080] In practice, the second syntax tree includes execution statements, single-level function syntax trees, and nested function syntax trees. When parsing the execution statements in the second syntax tree, a data engine is used to process the execution statements and obtain the first execution result.
[0081] When parsing the single-level function syntax tree in the second syntax tree, the single-level function syntax tree is converted into first intermediate code that can be recognized by the data engine. Then, the data engine processes the first intermediate code to obtain the second execution result.
[0082] When parsing the nested function syntax tree in the second syntax tree, the nested function syntax tree is parsed to obtain a nested function forest. Then, the nested function forest is traversed, and the functions within it undergo hierarchy checks, compatibility checks, and performance checks. The nested function forest is then converted into second intermediate code that can be recognized by the data engine. The data engine then processes this second intermediate code to obtain the third execution result. The implementation of nested subquery functions involves extracting the query conditions within the function definition and reassembling them into a subquery. The result of the subquery, returned by the Elasticsearch query, is then filled back into the original query statement. A new query is initiated to obtain the final query result, thus completing the parsing of nested functions and realizing join queries and nested queries.
[0083] The syntax of nested functions is defined by using a static AST. After analysis, nested functions mainly address the following key issues:
[0084] Compatibility handling for function parameter calculations, arrangement of function calculation order, and performance handling for nested functions.
[0085] The implementation of nested functions is achieved through a depth-first traversal of a nested function forest, where each tree is a nested abstract syntax tree (Syntax Tree). The Syntax Tree uses the parent function as the root node and the parameter functions (child functions) as relative leaf nodes. During the traversal from the parent function to the child function node, checkpoints are encountered, primarily for three types of checks: hierarchy, compatibility, and performance.
[0086] The nesting check examines the current nesting level of functions and records the number of nested levels. The compatibility check checks if the parent function is compatible with its child functions and modifies incompatible child functions to be compatible with the parent function, such as ensuring the child function's return type matches the parent function's parameter type requirements. The performance check tracks the computation time of the child functions. After a checkpoint, the computation return value of the child function is further used in the parent function's computation. To accelerate computation, the results returned by the child function are created as local variables and stored in the variable pool, which serves three purposes.
[0087] 1. Distinguishing Ambiguities Between Variables with the Same Name: The naming rules for variables are based on function names. For example, the result of function A will generate a local variable named var_A and store the mapping rule between the parameter function A(C) and var_A, i.e., A(C)->var_A. If there is also a function A(D), then a local variable named var_A_1 will be generated and the mapping rule between the parameter function A(D) and var_A_1 will be stored, i.e., A(D)->var_A_1. The above processing is also performed when dealing with multiple levels of nesting.
[0088] 2. Input parameter variable compatibility: The compatibility handling here mainly targets time-related data, because time-related values can exist in multiple formats, such as long-type timestamps, times, and dates. The compatibility handling here will perform compatibility processing on the time results of local variables in the child function according to the time parameter requirements of the parent function, so as to achieve compatibility conversion of data between multiple time formats.
[0089] 3. Local variable assignment: Local variable assignment here is mainly to reduce redundant calculations and speed up the calculation process. For example, if the function A(C) exists multiple times in the entire nested function operation, when A(C) is encountered again, it will be checked whether it exists in the variable pool mapping rules. If it exists, the result of the mapped var_A will directly replace A(C), avoiding secondary calculation.
[0090] In this step, the second syntax tree, or metafunction, is processed. All functions on the metafunction parsing chain together form a parser chain, and all query conditions need to be parsed layer by layer by the parser nodes on the chain. The entire parsing process involves obtaining the TokenExpression of the query condition from the AST, using the part-of-speech tagging of a specific function as the parser entry point, and then processing it through the function parser. The parser converts the function logic into Elasticsearch query language and stores it in the ParserResultContext, completing the parsing. The query engine's metafunctions (general functions) mainly adopt a static AST scheme. Under this scheme, each added function needs to be defined in the query analyzer's lexical file, and the function syntax definition needs to be defined in the query analyzer's syntax file. Each new function must have a corresponding parser in the syntax parsing chain for parsing and Elasticsearch query language conversion.
[0091] Common functions include general functions such as query by, multiMatch, functionScore, and disMax;
[0092] Script query functions, such as is, isNot, timeDiff, timeDiffMix; nested subquery functions, such as subTaskOf, linkedTaskOf, linkedDefectOf; free sorting functions, such as customSort; relational query functions, such as has_parent, has_child; nested query functions, such as nested; aggregate functions, such as max, min, group, subAggreagte, aggregate, nestedAggregate.
[0093] After layers of calculations using depth-first traversal, the final result of the nested function is obtained, and the result of each nested function will further participate in the calculation of the entire nested function forest.
[0094] After the execution statement, single-level function syntax tree, and nested function syntax tree are processed, the first execution result, the second execution result, and the third execution result are determined as the search results.
[0095] Figure 2 This is a block diagram illustrating a flexible search device according to an exemplary embodiment. (Refer to...) Figure 2 The device includes an acquisition unit 201, an analysis unit 202, a first processing unit 203, and a second processing unit 204.
[0096] The acquisition unit 201 is configured to perform the acquisition of a domain-specific language for searching, the domain-specific language including the search object;
[0097] Parsing unit 202 is configured to perform parsing of a domain-specific language to obtain a first syntax tree containing the search object;
[0098] The first processing unit 203 is configured to parse the first syntax tree to obtain a second syntax tree containing the search object;
[0099] The second processing unit 204 is configured to parse the second syntax tree and perform a flexible search using the search objects contained in the parsed second syntax tree to obtain the search results.
[0100] In one possible implementation, the first processing unit 203 in the apparatus provided in this disclosure is specifically configured to perform:
[0101] The business characteristic functions in the first syntax tree are parsed to obtain a second syntax tree containing the search object. The first parsing includes at least one of the following: direct parsing, parsing combined with external data, and parsing to obtain intermediate data.
[0102] In one possible implementation, the apparatus provided in this disclosure includes a second syntax tree comprising execution statements, a single-level function syntax tree, and a nested function syntax tree.
[0103] In one possible implementation, in the apparatus provided by this disclosure, when parsing the executable statements in the second syntax tree, the second processing unit 204 is specifically configured to execute:
[0104] Based on the search object, the data engine processes the executed statement to obtain the first execution result.
[0105] In one possible implementation, in the apparatus provided by this disclosure, when parsing a single-level function syntax tree in the second syntax tree, the second processing unit 204 is specifically configured to execute:
[0106] Transform a single-level function syntax tree into first intermediate code that can be recognized by the data engine;
[0107] Based on the search object, the first intermediate code is processed using a data engine to obtain the second execution result.
[0108] In one possible implementation, in the apparatus provided by this disclosure, when parsing the nested function syntax tree in the second syntax tree, the second processing unit 204 is specifically configured to execute:
[0109] Parse the nested function syntax tree to obtain a nested function forest;
[0110] Transform the nested function forest into a second intermediate code that can be recognized by the data engine;
[0111] Based on the search object, the data engine processes the second intermediate code to obtain the third execution result;
[0112] The first execution result, the second execution result, and the third execution result are determined as the search results.
[0113] In one possible implementation, the second processing unit 204 in the apparatus provided by this disclosure is further configured to perform:
[0114] Traverse the nested function forest and perform hierarchy checks, compatibility checks, and performance checks on the functions within the forest.
[0115] Figure 3 This is a block diagram illustrating an electronic device 300 according to an exemplary embodiment.
[0116] Processor 310;
[0117] Memory 330 for storing executable instructions of the processor 310;
[0118] The processor 310 is configured to execute the instructions to implement the flexible search method in this embodiment of the present disclosure.
[0119] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 330 including instructions, which can be executed by a processor 310 of the device 300 to perform the above-described method. Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0120] In the embodiments disclosed herein, such as Figure 4 As shown, this disclosure provides a terminal 400 applying the flexible search method provided in this disclosure, including: a radio frequency (RF) circuit 410, a power supply 430, a processor 430, a memory 440, an input unit 450, a display unit 460, a camera 470, a communication interface 480, and a wireless Fidelity (Wi-Fi) module 490, etc. Those skilled in the art will understand that... Figure 4 The structure of the terminal shown in the figure does not constitute a limitation on the terminal. The terminal provided in the embodiments of this application may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0121] The following is combined Figure 4 The various components of the terminal 400 are described in detail below:
[0122] The RF circuit 410 can be used for receiving and transmitting data during communication or a call. Specifically, after receiving downlink data from the base station, the RF circuit 410 sends it to the processor 430 for processing; additionally, it sends uplink data to be transmitted to the base station. Typically, the RF circuit 410 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc.
[0123] Furthermore, the RF circuit 410 can also communicate wirelessly with networks and other terminals. The wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).
[0124] Wi-Fi technology is a short-range wireless transmission technology. The terminal 400 can connect to an access point (AP) via the Wi-Fi module 490, thereby enabling access to the data network. The Wi-Fi module 490 can be used for receiving and sending data during communication.
[0125] The terminal 400 can physically connect to other terminals through the communication interface 480. Optionally, the communication interface 480 can be connected to the communication interfaces of other terminals via a cable to enable data transmission between the terminal 400 and other terminals.
[0126] Since the terminal 400 in this embodiment of the application is capable of communication services and sending information to other contacts, the terminal 400 needs to have data transmission capabilities, that is, the terminal 400 needs to include a communication module. Although Figure 4 The RF circuit 410, the Wi-Fi module 490, and the communication interface 480 are shown, but it is understood that the terminal 400 contains at least one of the above-mentioned components or other communication modules (such as a Bluetooth module) for data transmission.
[0127] For example, when the terminal 400 is a mobile phone, the terminal 400 may include the RF circuit 410 and the Wi-Fi module 490; when the terminal 400 is a computer, the terminal 400 may include the communication interface 480 and the Wi-Fi module 440; when the terminal 400 is a tablet computer, the terminal 400 may include the Wi-Fi module.
[0128] The memory 440 can be used to store software programs and modules. The processor 430 executes various functional applications and data processing of the terminal 400 by running the software programs and modules stored in the memory 440. Furthermore, when the processor 430 executes the program code in the memory 440, it can implement the embodiments of this disclosure. Figure 4 Part or all of the process.
[0129] Optionally, the memory 440 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, various applications (such as communication applications), and pop-up window modules; the data storage area may store data created based on the use of the terminal (such as various images, video files, and other multimedia files, as well as pop-up window information templates).
[0130] In addition, the memory 440 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0131] The input unit 450 can be used to receive numerical or character information input by the user, and to generate key signal inputs related to user settings and function control of the terminal 400.
[0132] Optionally, the input unit 450 may include a touch panel 451 and other input devices 452.
[0133] The touch panel 451, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 451), and drive corresponding connection devices according to a pre-set program. Optionally, the touch panel 451 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 430, and can also receive and execute commands from the processor 430. Furthermore, the touch panel 451 can be implemented using various types of touch technologies, such as resistive, capacitive, infrared, and surface acoustic wave.
[0134] Optionally, the other input device 452 may include, but is not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0135] The display unit 460 can be used to display information input by the user or information provided to the user, as well as various menus of the terminal 400. The display unit 460 is the display system of the terminal 400, used to present the interface and realize human-computer interaction.
[0136] The display unit 460 may include a display panel 461. Optionally, the display panel 461 may be configured as a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0137] Furthermore, the touch panel 451 may cover the display panel 461. When the touch panel 451 detects a touch operation on or near it, it transmits the information to the processor 430 to determine the type of touch event. Subsequently, the processor 430 provides corresponding visual output on the display panel 461 according to the type of touch event.
[0138] Although Figure 4 In this embodiment, the touch panel 451 and the display panel 461 are two independent components to realize the input and output functions of the terminal 400. However, in some embodiments, the touch panel 451 and the display panel 461 can be integrated to realize the input and output functions of the terminal 400.
[0139] The processor 430 is the control center of the terminal 400. It connects various components through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 440, and calling data stored in the memory 440, it performs various functions of the terminal 400 and processes data, thereby realizing various services based on the terminal.
[0140] Optionally, the processor 430 may include one or more processing units. Optionally, the processor 430 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 430.
[0141] The camera 470 is used to enable the terminal 400 to capture images or videos. The camera 470 can also be used to enable the terminal 400 to scan objects (QR codes / barcodes).
[0142] The terminal 400 also includes a power supply 420 (such as a battery) for supplying power to various components. Optionally, the power supply 430 can be logically connected to the processor 430 through a power management system, thereby enabling the power management system to manage functions such as charging, discharging, and power consumption.
[0143] It should be noted that the processor 430 in this embodiment can execute... Figure 3 The processor 310 has functions, and the memory 440 stores the contents of the processor 310.
[0144] In addition, in an exemplary embodiment, this disclosure also provides a storage medium that, when the instructions in the storage medium are executed by the processor of the aforementioned flexible search device, enables the aforementioned flexible search device to implement the flexible search method in the embodiments of this disclosure.
[0145] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0146] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An elastic search method, characterized by, The method comprises: obtaining a domain-specific language for searching, the domain-specific language comprising a search object; parsing the domain-specific language to obtain a first syntax tree comprising the search object; parsing the first syntax tree to obtain a second syntax tree comprising the search object, comprising: performing first parsing on a business characteristic function in the first syntax tree to obtain the second syntax tree comprising the search object, the first parsing comprising at least one of the following parsing: direct parsing, parsing combined with external data, and parsing to obtain intermediate data; parsing the second syntax tree and performing flexible search using the search object contained in the parsed second syntax tree to obtain a search result.
2. The method of claim 1, wherein, The second syntax tree comprises an execution statement, a single-layer function syntax tree, and a nested function syntax tree.
3. The method of claim 2, wherein, When parsing the execution statement in the second syntax tree, the parsing the second syntax tree and performing flexible search using the search object contained in the parsed second syntax tree to obtain a search result comprises: processing the execution statement based on the search object using a data engine to obtain a first execution result.
4. The method of claim 3, wherein, When parsing the single-layer function syntax tree in the second syntax tree, the parsing the second syntax tree and performing flexible search using the search object contained in the parsed second syntax tree to obtain a search result comprises: converting the single-layer function syntax tree into a first intermediate code that can be recognized by the data engine; processing the first intermediate code based on the search object using the data engine to obtain a second execution result.
5. The method of claim 4, wherein, When parsing the nested function syntax tree in the second syntax tree, the parsing the second syntax tree and performing flexible search using the search object contained in the parsed second syntax tree to obtain a search result comprises: parsing the nested function syntax tree to obtain a nested function forest; converting the nested function forest into a second intermediate code that can be recognized by the data engine; processing the second intermediate code based on the search object using the data engine to obtain a third execution result; determining the first execution result, the second execution result, and the third execution result as the search result.
6. The method of claim 5, wherein, After the parsing the nested function syntax tree to obtain a nested function forest, the method further comprises: traversing the nested function forest and performing hierarchical checking, compatibility checking, and performance checking on the functions in the nested function forest.
7. An elastic search apparatus, characterized by, The method comprises: an obtaining unit configured to obtain a domain-specific language for searching, the domain-specific language comprising a search object; a parsing unit configured to parse the domain-specific language to obtain a first syntax tree comprising the search object; The first processing unit is configured to perform parsing on the first syntax tree to obtain a second syntax tree containing the search object, including: performing first parsing on a service characteristic function in the first syntax tree to obtain the second syntax tree containing the search object, and the first parsing includes at least one of the following parsing: direct parsing, parsing combined with external data, and parsing to obtain intermediate data; The second processing unit is configured to perform parsing on the second syntax tree, and perform flexible search on the search object contained in the parsed second syntax tree to obtain a search result.
8. An electronic device, comprising: Comprise: A processor; A memory for storing instructions executable by the processor; Wherein the processor is configured to execute the instructions to implement the flexible search method according to any one of claims 1 to 6.
9. A storage medium, when instructions in the storage medium are executed by a processor of a flexible search electronic device, the flexible search electronic device is enabled to perform the flexible search method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data query method and device based on domain-specific language
CN114168622A