Searching method and device, equipment and storage medium
By converting the user's logical condition collection into a tree data structure and building elastic search query statements, the problem of low query accuracy in financial product information retrieval is solved, efficient and accurate data retrieval is achieved, and the operation process is simplified and technology is reduced. threshold.
Patent Information
- Application Number
- CN202411261534.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-27
AI Technical Summary
When the existing financial product information retrieval methods deal with large-scale, multi-dimensional, and high real-time data retrieval tasks, there are problems of low query accuracy and insufficient performance, especially in complex logic query scenarios, it is difficult to meet high-precision requirements.
By converting the user's logical condition collection into a tree data structure and building query statements using Elasticsearch, comprehensive analysis and processing of complex logical conditions are achieved and query accuracy is improved. The method includes receiving user operation instructions, determining a tree data structure, constructing an ES query statement, and accessing an ES service to obtain query results.
It improves the query accuracy and efficiency of financial product information retrieval, simplifies user operation processes, lowers technical thresholds, and allows non-technical users to easily build complex logical condition sets, reducing query errors and omissions.
Smart Images

Figure CN119201972A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and specifically to a search method, device, equipment and storage medium. Background Art
[0002] With the rapid development of information technology, especially in the financial industry, the explosive growth of data volume has brought huge challenges and opportunities. The types and number of financial products are increasing, and the labels and indicators involved are becoming more and more complex. Therefore, business personnel need to quickly and accurately screen out products that meet specific conditions from a large number of financial products to meet customer needs. At present, the retrieval of financial product information mainly relies on traditional relational databases or simple search engines. Although these technologies are quite mature, they are still insufficient when dealing with large-scale, multi-dimensional, and real-time data retrieval tasks. For example, relational databases have poor performance when performing full-text retrieval and complex logical queries, and general search engines cannot meet the needs of high-precision data queries.
[0003] As a high-performance search engine, Elasticsearch (ES) has powerful full-text search capabilities, flexible data processing features, and high real-time performance. When the search conditions are numerous and complex, how to improve the query accuracy based on the ES search method is an issue worthy of attention. Summary of the invention
[0004] Embodiments of the present application provide a search method, apparatus, device, and storage medium for improving query accuracy.
[0005] In a first aspect, the present application provides a search method, the method comprising:
[0006] Receive a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to satisfy, the set of logical conditions includes multiple logical conditions, the multiple logical conditions belong to different levels, and each logical condition includes a logical operator and description information of at least two indicators;
[0007] Determine a tree data structure according to the set of logical conditions; wherein the tree data structure includes a root node, at least one non-leaf node, and a plurality of leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to description information of indicators;
[0008] Constructing an ES query statement according to the tree data structure;
[0009] The ES service is accessed according to the ES query statement to obtain a query result, wherein the query result indicates products that meet the set of logical conditions.
[0010] In an embodiment of the present invention, a search method is provided, which converts a logical condition set indicated by a user operation instruction into a tree data structure. Multiple logical conditions in the logical condition set can belong to different levels. The above method can be applied to more complex query scenarios, and can consider multiple logical conditions at the same time. It utilizes the full-text retrieval and data analysis capabilities of ES, and can quickly query products that meet the logical condition set, thereby improving query accuracy.
[0011] In a possible embodiment, in the tree data structure, the root node has an association relationship with at least two leaf nodes, the root node is connected to at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes.
[0012] In a possible embodiment, constructing an ES query statement according to the tree data structure includes:
[0013] Determine the clause corresponding to each leaf node;
[0014] Determine a first ES query clause according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node;
[0015] Determine a second ES query clause according to the logical operator corresponding to each non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node;
[0016] The ES query statement is obtained by assembling the first ES query clause and the second ES query clauses respectively corresponding to the at least one non-leaf node in a top-down order according to the tree data structure.
[0017] In this embodiment, by parsing the tree data structure, the clause corresponding to each leaf node can be determined, and the first ES query clause is determined according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node, and the second ES query clause is determined according to the logical operator corresponding to the non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node. Assembling the first query clause and the second query clauses can not only realize a comprehensive top-down parsing of this tree data structure, but also ensure the structural integrity of the query statement and reduce errors and omissions.
[0018] In a possible embodiment, the description information of each indicator includes a name indicating the indicator, a screening method of the indicator and a corresponding screening value;
[0019] Determine the clause corresponding to each leaf node, including:
[0020] Determine the corresponding ES field information according to the name of the indicator in the description information of the indicator corresponding to each leaf node and the mapping relationship; the mapping relationship indicates that N indicator names correspond to N ES field information one by one, and N is a positive integer;
[0021] Determine the corresponding assembly rule according to the screening method and screening value in the description information of the indicator corresponding to each leaf node;
[0022] The clause corresponding to the leaf node is determined according to the obtained ES field information, the sum assembly rule and the screening value.
[0023] In this embodiment, by constructing a mapping relationship between indicator names and ES field information, users only need to flexibly select indicator names on the visual interface to directly associate them with ES field information. This not only simplifies the user's operation process, but also enables non-technical users to easily build a set of logical conditions, effectively lowering the technical threshold.
[0024] In a possible embodiment, the mapping relationship is constructed according to a product information set, and the N indicator names are determined according to the product information set.
[0025] In a possible embodiment, the screening method includes any one of the following: equal value matching, multi-value equal value matching, inequality matching, fuzzy matching, and search matching.
[0026] In a possible embodiment, it further includes:
[0027] When the logical operator corresponding to the root node is the same as the logical operator corresponding to the first non-leaf node, and the first non-leaf node is connected to the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are merged.
[0028] In this embodiment, when the server receives a complex query request, the query depth can be reduced and the query structure can be simplified through the above-mentioned merged query method, thereby improving the query efficiency.
[0029] In a second aspect, the present application further provides a search device, the device comprising: a receiving unit and a processing unit;
[0030] The receiving unit is used to receive a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to meet, the set of logical conditions includes multiple logical conditions, the multiple logical conditions belong to different levels, and each logical condition includes a logical operator and description information of at least two indicators;
[0031] The processing unit is used to determine a tree data structure according to the set of logical conditions; wherein the tree data structure includes a root node, at least one non-leaf node, and multiple leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to description information of indicators; construct an elastic search ES query statement according to the tree data structure; access the ES service according to the ES query statement to obtain a query result, and the query result indicates a product that meets the set of logical conditions.
[0032] In a possible embodiment, in the tree data structure, the root node has an association relationship with at least two leaf nodes, the root node is connected to at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes;
[0033] In a possible embodiment, when the processing unit constructs the ElasticSearch ES query statement according to the tree data structure, it is specifically used to:
[0034] Determine the clause corresponding to each leaf node;
[0035] Determine a first ES query clause according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node;
[0036] Determine a second ES query clause according to the logical operator corresponding to each non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node;
[0037] The ES query statement is obtained by assembling the first ES query clause and the second ES query clauses respectively corresponding to the at least one non-leaf node in a top-down order according to the tree data structure.
[0038] In a possible embodiment, the description information of each indicator includes the name of the indicator, the screening method of the indicator and the corresponding screening value; when determining the clause corresponding to each leaf node, the processing unit is specifically used to:
[0039] Determine the corresponding ES field information according to the name of the indicator in the description information of the indicator corresponding to each leaf node and the mapping relationship; the mapping relationship indicates that N indicator names correspond to N ES field information one by one, and N is a positive integer;
[0040] Determine the corresponding assembly rule according to the screening method in the description information of the indicator corresponding to each leaf node;
[0041] The clause corresponding to the leaf node is determined according to the obtained ES field information, the assembly rule and the screening value.
[0042] In a possible embodiment, the mapping relationship is constructed according to a product information set, and the N indicator names are determined according to the product information set.
[0043] In a possible embodiment, the screening method includes any one of the following: equal value matching, multi-value equal value matching, inequality matching, fuzzy matching, and search matching.
[0044] In a possible embodiment, the processing unit further includes:
[0045] When the logical operator corresponding to the root node is the same as the logical operator corresponding to the first non-leaf node, and the first non-leaf node is connected to the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are merged.
[0046] In a third aspect, the present application provides a search device, including:
[0047] A memory for storing program instructions;
[0048] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.
[0049] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.
[0050] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A flowchart of a search method provided in an embodiment of the present application;
[0052] Figure 2 A schematic diagram of a visual interface provided in an embodiment of the present application;
[0053] Figure 3A A possible tree data structure provided in the embodiment of the present application Figure 1 ;
[0054] Figure 3B A possible tree data structure provided in the embodiment of the present application Figure 2 ;
[0055] Figure 4 A schematic diagram of the structure of the search device provided in the embodiment of the present application Figure 1 ;
[0056] Figure 5 A schematic diagram of the structure of the search device provided in the embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0057] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0058] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0059] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0060] The acquisition, transmission, storage, and use of data in the technical solution of this application comply with the requirements of relevant national laws and regulations.
[0061] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0062] To facilitate understanding, the technical background of the embodiments of the present application is first introduced in detail below.
[0063] 1. ES, also known as elastic search, search data analysis engine, or search server, is a distributed full-text search engine that can provide real-time storage, data retrieval and analysis capabilities. It can be expanded and deployed to hundreds of servers and process tens of thousands of data. It provides a RESTful interface for users to call. RESTful generally refers to rest, and REST stands for Representational State Transfer (REST).
[0064] ES query statement: The query statement of ES is a JSON statement, which defines the index to be queried, the query method and the query conditions. JSON (JavaScript Object Notation) is a lightweight data exchange format that represents structured data in text form.
[0065] In the existing technology, the ES-based search method requires users to have a basic understanding of structured query statements and to understand the ES index structure, field types, and data organization methods. This limits the use of business personnel and non-technical users and increases the technical threshold. In addition, when the search conditions are numerous and complex, the ES-based search method also has the problems of low query accuracy and long response time.
[0066] Based on the above problems, Figure 1 A flowchart of a search method provided by an embodiment of the present invention is exemplarily shown, and the flowchart can be executed by a server for explanation.
[0067] like Figure 1 As shown in the figure, the process specifically includes:
[0068] Step 100: The server receives a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to meet. The set of logical conditions includes multiple logical conditions at different levels, and each logical condition includes a logical operator and description information of at least two indicators.
[0069] The logical operators may be AND, OR, and NOT, and their specific meanings are AND, OR, and NOT, respectively.
[0070] The description information of an indicator includes the name of the indicator, the filtering method of the indicator, and the corresponding filtering value.
[0071] There can be multiple names for an indicator, such as product number, product name, label A, label B, etc.
[0072] The screening method can be any of the following:
[0073] a) Equal value matching
[0074] The equal value match may be recorded as "=", and the equal value match may support characters, numbers, dates and other types; for example, the description information of the indicator may be: label A = '5'.
[0075] b) Multi-value equal matching
[0076] Among them, multi-value equal matching can be recorded as "IN", and "IN" contains at least two characters, indicating that one of the multiple values can be satisfied; for example, the description information of the indicator can be: label B IN('2','3'), that is, label B can be equal to 2 or 3.
[0077] c) Inequality matching
[0078] The inequality can be recorded as “>, ≥, <, ≤, BETWEEN...AND...”, and the inequality matching can support inequality filtering of numerical values and date types. For example, the description information of the indicator can be: label C≥'10'.
[0079] d) Fuzzy matching
[0080] The fuzzy match can be recorded as "LIKE", wherein the part to be fuzzy matched is defined by inputting a wildcard '*'. For example, the description information of the indicator can be: tag G LIKE '*currency*', that is, searching for tag G semantically related to 'currency'.
[0081] e) Search Match
[0082] The search can be recorded as "SEARCH", and a segmentation search can be performed by entering any value. For example, the description information of the indicator can be: product name SEARCH 'change', that is, the change is segmented and the product name of the segmented result is searched.
[0083] For example, the user can select various logical operators, the name of the indicator, the screening method of the indicator and the corresponding screening value through the visual interface, and then generate a set of logical conditions that the product requested by the user needs to meet.
[0084] Exemplarily, the visualization interface may be divided into two parts, the left part presents all optional indicator names, and the right part presents a set of logical conditions that the product requested by the user needs to satisfy.
[0085] In one embodiment, Figure 2 As shown in the figure, if each financial product has ten indicators, they correspond to product number, product name, product description, label A, label B, label C, label D, label E, label F, and label G. Users can first query the names of these indicators of the product on the visual interface to understand which indicators are available.
[0086] Assuming that the user wants to query products whose label A is equal to '5', label B is equal to '2' or '3', and label G contains the word 'currency', the user can click or drag these three indicators to the specified filter box in turn, and select the required filter method and filter value in the form of a drop-down box. Specifically, select "=" for the filter method corresponding to label A, and select the corresponding filter value as '5'; select "IN" for the filter method corresponding to label B, and select the corresponding filter values as '2' and '3'; select "LIKE" for the filter method corresponding to "label G", and the corresponding filter value can be selected as 'currency' by input or selection. Finally, the description information of these three indicators is connected with the logical operator "AND", indicating that the products that meet the description information of the three indicators are filtered at the same time.
[0087] Step 110: The server determines a tree data structure according to a set of logical conditions.
[0088] The tree data structure includes a root node, at least one non-leaf node, and multiple leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to the description information of the indicators.
[0089] If the user selects multiple logical conditions, and the multiple logical conditions belong to different levels, the logical condition set will contain multiple layers of nesting to form a tree structure. In the tree structure, the root node represents the top-level operator, and all logical conditions in the logical condition set can be included in one tree structure.
[0090] In a possible implementation, the root node is associated with at least two leaf nodes and is connected to at least one non-leaf node, and each non-leaf node is associated with at least two leaf nodes. Figure 3AAs shown, the logical operator corresponding to the root node is "AND", the description information of the indicators corresponding to the two leaf nodes connected to the root node is "label A = 'value'" and "label B = ('T1', 'T2')", and the logical operators corresponding to the two non-leaf nodes connected to the root node are "OR" and "AND", respectively, wherein the description information of the indicators corresponding to the leaf nodes connected to the logical operator "OR" corresponding to the non-leaf nodes is "label C ≥ 10" and "label D = 3", and the description information of the indicators corresponding to the leaf nodes connected to the logical operator "AND" corresponding to the non-leaf nodes is "product name SEARCH 'change'" and "label GLIKE '*currency*'". In other words, according to the different logical operators and description information of the indicators selected by the user, a two-level tree data structure can be formed.
[0091] In a possible implementation, the root node has an association relationship with at least two leaf nodes and is connected to at least one non-leaf node, each non-leaf node has an association relationship with at least two leaf nodes, and there is a non-leaf node connected to at least one non-leaf node. For example, Figure 3B As shown, except Figure 3A The structure shown above can connect another non-leaf node (corresponding to the logical operator "NOT") under the non-leaf node of the second level (corresponding to the logical operator "OR"), and is at the third level, where the description information of the indicators corresponding to the leaf nodes connected by "NOT" are "label E = '20150101'" and "label F ≤ '20231231'". In other words, this tree data structure can be three levels, and the logical conditions of the third level are nested in the logical conditions of the second level.
[0092] Therefore, the root node and at least two connected leaf nodes constitute the first level; on this basis, the non-leaf nodes connected to the root node and the leaf nodes connected to these non-leaf nodes constitute the second level; if there are other non-leaf nodes and connected leaf nodes under the second level, they constitute the third level, and so on, a tree structure of multiple levels can be formed.
[0093] Through the above tree data structure, various logical conditions are distributed on multiple levels, which can be applied to complex query scenarios that consider multiple logical conditions at the same time, thereby improving query accuracy.
[0094] Step 120: The server constructs an ElasticSearch ES query statement based on the tree data structure.
[0095] Before constructing an ES query statement, a mapping relationship is first constructed; the mapping relationship indicates that N indicator names correspond to N ES field information one by one, where N is a positive integer.
[0096] For example, as shown in Table 1, the mapping relationship can indicate the correspondence between the indicator name and the ES field information; wherein, the left column can be displayed on the user's visual interface in step 110, indicating which indicator names are available for selection. This application does not limit the number of indicator names, and the N indicator names are determined based on the product information set; the right column is used to indicate the corresponding ES field information of the indicator name mapping.
[0097] Indicator name ES field information Product Number PD_ID Product Name PD_NAME Product Description PD_DESC Tag A LABEL_A Label B LABEL_B Label C LABEL_C Tag D LABEL_D Tag E LABEL_E Tag F LABEL_F Tag G LABEL_G
[0098] Table 1
[0099] Furthermore, in order to enrich this mapping relationship, other information may be added to the mapping relationship, such as indicator number, indicator type, and ES index information, as shown in Table 2. By adding information from these columns, the mapping relationship may be richer and more complete.
[0100]
[0101]
[0102] Table 2
[0103] Furthermore, ES field description and ES field type may be added to the mapping relationship, as shown in Table 3. By adding information of these columns, the content of the ES field information may be made clearer and more complete.
[0104]
[0105] Table 3
[0106] In addition, Table 3 can also be decomposed into two tables, namely Table 2 and Table 4. Table 2 indicates the mapping relationship, and Table 4 indicates the relevant content of the ES index information, which includes four columns: index name, ES field information, ES field description, and ES field type. The indicator name selected by the user can be mapped to Table 4 to query more relevant information.
[0107] Among them, the index name indicates the index name of the ES field information, the ES field information indicates the ES field name, the ES field description indicates the ES field type, and the text and keyword in the ES field type indicate the text type and keyword type respectively, such as PD_NAME corresponds to the text type (text), and LABEL_A corresponds to the keyword type (Keyword). Among them, the text type is used for full-text search and is suitable for fields that require full-text retrieval. When executing a search query, the content of the text type field will be processed by the word segmenter, and the word segmenter will split the text into separate words or phrases for search. The Keyword type is used for exact value matching and is suitable for fields that require exact matching and will not be split into separate words.
[0108] Index Name ES field information ES field description ES field type PD_LABEL_INDEX PD_ID Product number (character type) doc_id PD_LABEL_INDEX PD_NAME Product Name (Text) text PD_LABEL_INDEX PD_DESC Product Description (Text) text PD_LABEL_INDEX LABEL_A Tag A (enumeration value) keyword PD_LABEL_INDEX LABEL_B Tag B (enumeration value) keyword PD_LABEL_INDEX LABEL_C Label C (numeric type) keyword PD_LABEL_INDEX LABEL_D Tag D (numeric type) keyword PD_LABEL_INDEX LABEL_E Label E (Date Type) keyword PD_LABEL_INDEX LABEL_F Label F (date type) keyword PD_LABEL_INDEX LABEL_G Label G (text type) text PD_LABEL_INDEX ...... ......
[0109] Table 4
[0110] Exemplarily, in combination with the above mapping relationship, the specific process of the server constructing an ES query statement according to the tree data structure is as follows:
[0111] First, determine the clause corresponding to each leaf node.
[0112] (1) Determine the corresponding ES field information according to the mapping relationship and the name of the indicator in the description information of the indicator corresponding to each leaf node.
[0113] For example, the corresponding ES field information corresponding to the indicator name can be obtained by querying Table 1 and Table 2. For example, the description information of the indicator corresponding to the leaf node is: label A = '5', then by querying Table 1, it is known that the ES field information corresponding to "label A" is "LABEL_A".
[0114] (2) Determine the corresponding assembly rules according to the screening method in the description information of the indicator corresponding to each leaf node. According to different screening methods, the assembly rules are as follows:
[0115] a) When the screening method is equal value matching, the assembly rules corresponding to this screening method are:
[0116] {"ES field information":{:"value"}}.
[0117] b) When the screening method is multi-value equal matching, the assembly rules corresponding to this screening method are:
[0118] {"terms":{"ES field information":["value1","value2","......"]}}.
[0119] c) When the screening method is inequality matching, the assembly rule corresponding to this screening method is:
[0120] {"range":{"ES field information":{"gt / gte":"value1","lt / lte":"value2"}}. Among them, ">" corresponds to "gt", "≥" corresponds to "gte", "<" corresponds to "lt", and "≤" corresponds to "lte".
[0121] d) When the screening method is fuzzy matching, the assembly rules corresponding to this screening method are:
[0122] {"wildcard":{"ES field information":{"value":"*query_text*"}}.
[0123] e) When the filtering method is search matching, the assembly rules corresponding to this filtering method are:
[0124] {"match":{"ES field information":"search term"}}.
[0125] (3) Determine the clause corresponding to the leaf node according to the obtained ES field information, assembly rules and filtering values. Specifically, the clause corresponding to the leaf node is obtained by combining the ES index information mapped to the indicator name in the description information of the indicator corresponding to the leaf node, the assembly rules of the filtering method and the filtering value selected by the user.
[0126] For example, Figure 3B As shown, the leaf nodes are:
[0127] Tag A = 'value'
[0128] Label B IN('T1','T2')
[0129] Tag C ≥ 10
[0130] Tag D = 3
[0131] Tag E = '20240101'
[0132] Tag F ≤ '20241231'
[0133] Product nameSERACH 'Change'
[0134] Tag G LIKE '*Currency*'
[0135] The clauses corresponding to the obtained leaf nodes are:
[0136] {"LABEL_A":{:"5"}}
[0137] {"LABEL_B":["T1","T2"]}
[0138] {"LABEL_C":{"gte":10}}
[0139] {"LABEL_D":3}
[0140] {"LABEL_E":"20150101"}
[0141] {"LABEL_F":{"lte":"20231231"};
[0142] Secondly, the first ES query clause is determined according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node.
[0143] Exemplarily, the assembly rule corresponding to the logical operator corresponding to the root node is determined according to the logical operator corresponding to the root node, and then the first ES query clause is determined according to the assembly rule corresponding to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node.
[0144] For example, a bool query statement can be used for assembly. For example, when the logical operator is "AND", the clauses corresponding to the logical operator "AND" and at least two leaf nodes associated with the logical operator "AND" are assembled into a must clause. The specific assembly rules are:
[0145] AND->must clause,
[0146]
[0147] For example, when the logical operator is "OR", the clauses corresponding to the logical operator "OR" and at least two leaf nodes associated with the logical operator "OR" are assembled into a should clause. The specific assembly rules are:
[0148] OR->should clause, and set the parameter minimum_should_match to 1:
[0149]
[0150]
[0151] For example, when the logical operator is "NOT", the clauses corresponding to the logical operator "NOT" and at least two leaf nodes associated with the logical operator "NOT" are assembled into a must_not clause. The specific assembly rules are:
[0152] NOT->must_not clause,
[0153]
[0154] Furthermore, combined with Figure 3B , the logical operator corresponding to the root node is "AND", and the first ES query clause obtained according to the assembly rule corresponding to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node is:
[0155]
[0156] Third, determine the second ES query clause according to the logical operator corresponding to each non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node;
[0157] Exemplarily, the assembly rule corresponding to the logical operator corresponding to the non-leaf node is determined according to the logical operator corresponding to the non-leaf node, and then the second ES query clause is determined according to the assembly rule corresponding to the logical operator corresponding to the non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node. The specific assembly rules can refer to the above rules. In addition, the non-leaf node can also be connected to other non-leaf nodes, and other second ES query clauses are determined according to the assembly rule corresponding to the logical operator corresponding to other non-leaf nodes and the clauses corresponding to at least two leaf nodes associated with other non-leaf nodes, and so on, multiple second ES query clauses can be determined.
[0158] Furthermore, combined with Figure 3B , the logical operators corresponding to non-leaf nodes are "OR", "AND" and "NOT" respectively,
[0159] When the logical operator corresponding to the non-leaf node is "OR", the second ES query clause obtained according to the assembly rule corresponding to the logical operator "OR" and the clauses corresponding to at least two leaf nodes associated with the non-leaf node is:
[0160] {"bool":{
[0161] "should":[
[0162] {"range":{"LABEL_C":{"gte":10}}},
[0163] {"term":{"LABEL_D":3}},
[0164] }
[0165] When the logical operator corresponding to the non-leaf node is "AND", the second ES query clause obtained according to the assembly rule corresponding to the logical operator "AND" and the clauses corresponding to at least two leaf nodes associated with the non-leaf node is:
[0166] {"bool":{
[0167] "must":[
[0168] {"match":{"PD_NAME":"Change"}},
[0169] {"wildcard":{"LABEL_G":{"value":"*Currency*"}}}
[0170] }
[0171] When the logical operator corresponding to the non-leaf node is "NOT", the second ES query clause obtained according to the assembly rule corresponding to the logical operator "NOT" and the clauses corresponding to at least two leaf nodes associated with the non-leaf node is:
[0172]
[0173] Fourth, an ES query statement is obtained by assembling the first ES query clause and the second ES query clauses corresponding to at least one non-leaf node in a tree data structure from top to bottom.
[0174] Furthermore, combined with Figure 3B , assembled from top to bottom, the resulting ES query statement is:
[0175]
[0176]
[0177] Furthermore, when the logical operator corresponding to the root node is the same as the logical operator corresponding to the first non-leaf node, and the first non-leaf node is connected to the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are merged.
[0178] For example, in the above Figure 3B In the obtained ES query statement, the logical operator corresponding to the root node is "AND", and there is a non-leaf node whose corresponding logical operator is also "AND", and the non-leaf node is connected to the root node. Then the first ES query clause corresponding to the root node and the second ES query clause corresponding to the non-leaf node can be merged. The result after merging is:
[0179]
[0180] {"terms":{"LABEL_B":["T1","T2"]}},
[0181] {"match":{"PD_NAME":"Change"}},
[0182] {"wildcard":{"LABEL_G":{"value":"*Currency*"}}}
[0183] }
[0184] When the server receives a complex query request, this merged query method can reduce the query depth, simplify the query structure, and thus improve query efficiency.
[0185] Step 130: The server accesses the ES service according to the ES query statement and obtains the query result, which indicates the products that meet the logical condition set. Specifically, the constructed ES query statement is sent to the application programming interface port (Application Program Interface, API) of the ES service through a HyperText Transfer Protocol (HTTP) request, which is usually a RESTful API call. After receiving the query request, the ES service searches for the information of the matching products according to the provided ES query statement, and returns the query result, which indicates the information of the products that match the ES query statement.
[0186] In summary, users can flexibly define logical conditions on the visual interface to form a set of logical conditions. Users only need to click and select, without having a technical background or understanding the ES query syntax, which simplifies the query process and lowers the technical threshold; the logical condition set is converted into a tree data structure, and assembled into corresponding ES query statements in a top-down order, thereby realizing a comprehensive top-down analysis of this tree data structure, ensuring the structural integrity of the query statement, and reducing errors and omissions; by constructing a mapping relationship between the indicator name and the ES field information, it is possible to quickly determine the clause corresponding to the leaf node, thereby constructing the first ES query clause and the second ES query clause, thereby obtaining the ES query statement, and further, according to the ES query statement, quickly and accurately search and filter results for users, which can effectively solve the problem of low query accuracy in the existing technology in complex query scenarios.
[0187] Figure 4 and Figure 5 The following is a schematic diagram of the structure of possible search devices provided in the embodiments of the present application. These search devices can be used to implement the functions of the server in the above method embodiments.
[0188] like Figure 4 As shown, the search device 400 includes a communication unit 410 and a processing unit 420 .
[0189] When the search device 400 is used to implement Figure 1 The functions of the server in the method embodiment shown are:
[0190] The communication unit 410 is used to receive a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to meet, the set of logical conditions includes multiple logical conditions, the multiple logical conditions belong to different levels, and each logical condition includes a logical operator and description information of at least two indicators;
[0191] The processing unit 420 is used to determine a tree data structure according to the set of logical conditions; wherein the tree data structure includes a root node, at least one non-leaf node, and multiple leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to description information of indicators; construct an ES query statement according to the tree data structure; access the ES service according to the ES query statement to obtain a query result, and the query result indicates a product that meets the set of logical conditions.
[0192] In a possible design, in the tree data structure, the root node has an association relationship with at least two leaf nodes, the root node is connected to at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes;
[0193] When constructing an ES query statement according to the tree data structure, the processing unit 420 is specifically used to:
[0194] Determine the clause corresponding to each leaf node;
[0195] Determine a first ES query clause according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node;
[0196] Determine a second ES query clause according to the logical operator corresponding to each non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node;
[0197] The ES query statement is obtained by assembling the first ES query clause and the second ES query clauses respectively corresponding to the at least one non-leaf node in a top-down order according to the tree data structure.
[0198] The description information of each indicator includes the name of the indicator, the screening method of the indicator and the corresponding screening value; when determining the clause corresponding to each leaf node, the processing unit 420 is specifically used to:
[0199] Determine the corresponding ES field information according to the name of the indicator in the description information of the indicator corresponding to each leaf node and the mapping relationship; the mapping relationship indicates that N indicator names correspond to N ES field information one by one, and N is a positive integer;
[0200] Determine the corresponding assembly rule according to the screening method in the description information of the indicator corresponding to each leaf node;
[0201] The clause corresponding to the leaf node is determined according to the obtained ES field information, the assembly rule and the screening value.
[0202] The mapping relationship is constructed according to a product information set, and the N indicator names are determined according to the product information set.
[0203] The screening method includes any one of the following: equal value matching, multi-value equal value matching, inequality matching, fuzzy matching, and search matching.
[0204] The processing unit 420 is further configured to:
[0205] When the logical operator corresponding to the root node is the same as the logical operator corresponding to the first non-leaf node, and the first non-leaf node is connected to the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are merged.
[0206] For a more detailed description of the communication unit 410 and the processing unit 420, please refer to Figure 1 The relevant description in the method embodiment shown is directly obtained and will not be repeated here.
[0207] like Figure 5 As shown, the search device 500 includes a processor 510 and a communication interface 520. The processor 510 and the communication interface 520 are coupled to each other. It is understandable that the communication interface 520 can be a transceiver or an input-output interface. Optionally, the search device 500 may also include a memory 530 for storing instructions executed by the processor 510 or storing input data required by the processor 510 to execute instructions or storing data generated after the processor 510 executes instructions.
[0208] When the search device 500 is used to implement Figure 1 When the method is shown, the processor 510 is used to implement the functions of the processing unit 420, and the communication interface 520 is used to implement the functions of the communication unit 410.
[0209] The division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0210] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is executed on a computer, the computer executes any of the search methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the search method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0211] Based on the same inventive concept, the embodiment of the present application further provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the search methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the search method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0212] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0213] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0214] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0215] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0216] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0217] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A search method, characterized in that: The method includes: Receive a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to satisfy, the set of logical conditions includes multiple logical conditions, the multiple logical conditions belong to different levels, and each logical condition includes a logical operator and description information of at least two indicators; Determine a tree data structure according to the set of logical conditions; wherein the tree data structure includes a root node, at least one non-leaf node, and a plurality of leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to description information of indicators; Constructing an ElasticSearch ES query statement according to the tree data structure; The ES service is accessed according to the ES query statement to obtain a query result, wherein the query result indicates products that meet the set of logical conditions.
2. The method according to claim 1, characterized in that In the tree data structure, the root node has an association relationship with at least two leaf nodes, the root node is connected to at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes.
3. The method according to claim 2, characterized in that Constructing an ES query statement according to the tree data structure includes: Determine the clause corresponding to each leaf node; Determine a first ES query clause according to the logical operator corresponding to the root node and the clauses corresponding to at least two leaf nodes associated with the root node; Determine a second ES query clause according to the logical operator corresponding to each non-leaf node and the clauses corresponding to at least two leaf nodes associated with the non-leaf node; The ES query statement is obtained by assembling the first ES query clause and the second ES query clauses respectively corresponding to the at least one non-leaf node in a top-down order according to the tree data structure.
4. The method according to claim 3, characterized in that The description information of each indicator includes the name of the indicator, the screening method of the indicator and the corresponding screening value; Determine the clause corresponding to each leaf node, including: Determine the corresponding ES field information according to the name of the indicator in the description information of the indicator corresponding to each leaf node and the mapping relationship; the mapping relationship indicates that N indicator names correspond to N ES field information one by one, and N is a positive integer; Determine the corresponding assembly rule according to the screening method in the description information of the indicator corresponding to each leaf node; The clause corresponding to the leaf node is determined according to the obtained ES field information, the assembly rule and the screening value.
5. The method according to claim 4, characterized in that The mapping relationship is constructed according to a product information set, and the N indicator names are determined according to the product information set.
6. The method according to claim 4, characterized in that The screening method includes any one of the following: equal value matching, multi-value equal value matching, inequality matching, fuzzy matching, and search matching.
7. The method according to claim 3, characterized in that Also includes: When the logical operator corresponding to the root node is the same as the logical operator corresponding to the first non-leaf node, and the first non-leaf node is connected to the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are merged.
8. A search device, characterized in that: The device comprises: a communication unit and a processing unit; The communication unit is used to receive a user operation instruction; the user operation instruction indicates a set of logical conditions that the product requested by the user needs to meet, the set of logical conditions includes multiple logical conditions, the multiple logical conditions belong to different levels, and each logical condition includes a logical operator and description information of at least two indicators; The processing unit is used to determine a tree data structure according to the set of logical conditions; wherein the tree data structure includes a root node, at least one non-leaf node, and multiple leaf nodes, wherein the root node and the non-leaf nodes correspond to logical operators, and the leaf nodes correspond to description information of indicators; construct an ES query statement according to the tree data structure; access the ES service according to the ES query statement to obtain a query result, wherein the query result indicates a product that meets the set of logical conditions.
9. A search device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of claims 1-7 according to the obtained program instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 7.
Citation Information
Cited By
Data screening method, device and product
CN120448386A
A data screening method, device and product
CN120448386B
