CN119201972A - A search method, device, equipment and storage medium - Google Patents
A search method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN119201972A CN119201972A CN202411261534.XA CN202411261534A CN119201972A CN 119201972 A CN119201972 A CN 119201972A CN 202411261534 A CN202411261534 A CN 202411261534A CN 119201972 A CN119201972 A CN 119201972A
- Authority
- CN
- China
- Prior art keywords
- query
- logic
- leaf node
- leaf
- node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2246—Trees, e.g. B+trees
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to the field of data processing, in particular to a searching method, a searching device, searching equipment and a storage medium, wherein the searching method comprises the steps of receiving a user operation instruction; the method comprises the steps of indicating a logic condition set which is required to be met by a product which is required to be queried by a user through a user operation instruction, determining a tree data structure according to the logic condition set, wherein a plurality of logic conditions in the logic condition set belong to different levels, each logic condition comprises a logic operator and description information of at least two indexes, the tree data structure comprises a root node, at least one non-leaf node and a plurality of leaf nodes, the root node corresponds to the logic operator with the non-leaf node, the leaf nodes correspond to the description information of the indexes, constructing an ES query statement according to the tree data structure, accessing an ES service according to the ES query statement to obtain a query result, and the query result indicates the product which meets the logic condition set. The method is suitable for the scene of complex query, and effectively solves the problem of low complex query precision.
Description
Technical Field
The present application relates to the field of data processing, and in particular, to a search method, apparatus, device, and storage medium.
Background
With the rapid development of information technology, particularly in the financial industry, the explosive growth of data volume has created great challenges and opportunities. The variety and number of financial products are increasing, and the labels and indexes involved are becoming more complex. Therefore, business personnel need to rapidly and accurately screen out products meeting specific conditions from massive financial products so as to meet customer requirements. At present, the retrieval of the information of the financial products mainly depends on a traditional relational database or a simple search engine, and although the technologies are quite mature, the technology still has the defects when processing large-scale, multi-dimensional and real-time data retrieval tasks with high requirements. For example, relational databases perform poorly when performing full-text searches and complex logical queries, while general search engines cannot meet the high-precision requirements of data queries.
Elastic Search (ES) is a high-performance search engine, and has strong full-text retrieval capability, flexible data processing characteristics and high real-time performance. How to improve query accuracy based on the ES search method is a concern when the search conditions are numerous and complex.
Disclosure of Invention
The embodiment of the application provides a searching method, device, equipment and storage medium, which are used for improving query precision.
In a first aspect, the present application provides a search method, the method comprising:
Receiving a user operation instruction, wherein the user operation instruction indicates a logic condition set which is required to be met by a product which is requested to be queried by a user, the logic condition set comprises a plurality of logic conditions, the logic conditions belong to different levels, and each logic condition comprises a logic operator and descriptive information of at least two indexes;
Determining a tree data structure according to the logic condition set, wherein the tree data structure comprises a root node, at least one non-leaf node and a plurality of leaf nodes, wherein the root node and the non-leaf node correspond to logic operators, and the leaf nodes correspond to description information of indexes;
Constructing an ES query statement according to the tree data structure;
And accessing an ES service according to the ES query statement to obtain a query result, wherein the query result indicates products meeting the logic condition set.
In the embodiment of the invention, a searching method is provided, a logic condition set indicated by a user operation instruction is converted into a tree data structure, a plurality of logic conditions in the logic condition set can belong to different levels, the method can be applied to a relatively complex query scene, a plurality of logic conditions can be considered simultaneously, full text retrieval and data analysis capability of an ES are utilized, products meeting the logic condition set can be queried rapidly, and query precision is improved.
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 with at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes.
In one possible embodiment, constructing an ES query statement from the tree data structure includes:
Determining clauses corresponding to each leaf node;
determining a first ES query clause according to a logical operator corresponding to the root node and clauses respectively corresponding to at least two leaf nodes associated with the root node;
determining a second ES query clause according to a logical operator corresponding to each non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node;
And assembling according to the tree data structure from top to bottom according to the first ES query clause and the second ES query clause corresponding to the at least one non-leaf node respectively to obtain the ES query statement.
In this embodiment, by parsing the tree data structure, it is possible to determine the clause corresponding to each leaf node, determine the 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, and determine the second ES query clause 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, and assemble the first query clause and each second query clause, so that not only can the overall parsing of the tree data structure from top to bottom be realized, but also the structural integrity of the query clause is ensured, and errors and omissions are reduced.
In a possible embodiment, the description information of each index includes a name indicating the index, a screening mode of the index and a corresponding screening value;
Determining clauses corresponding to each leaf node, including:
Determining corresponding ES field information according to a mapping relation and names of indexes in description information of indexes corresponding to each leaf node, wherein the mapping relation indicates that N index names are in one-to-one correspondence with N ES field information, and N is a positive integer;
Determining corresponding assembly rules according to screening modes and screening values in the description information of the indexes corresponding to each leaf node;
And determining a clause corresponding to the leaf node according to the obtained ES field information, the assembly rule and the screening value.
In this embodiment, by constructing the mapping relationship between the index name and the ES field information, the user only needs to flexibly select the index name on the visual interface, so that the field information of the ES can be directly associated with the index name, which not only simplifies the operation flow of the user, but also enables non-technical users to easily construct the logic condition set, and effectively reduces the technical threshold.
In a possible embodiment, the mapping relation is constructed according to a product information set, and the N index names are determined according to the product information set.
In one possible embodiment, the screening mode comprises any one of equivalent matching, multi-value equivalent matching, inequality matching, fuzzy matching and searching matching.
In one possible embodiment, the method further comprises:
and 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 with the root node, merging the first ES query clause with the second ES query clause corresponding to the first non-leaf node.
In this embodiment, when the server receives the transmitted complex query request, the depth of the query can be reduced and the query structure can be simplified by the above-mentioned query merging method, thereby improving the query efficiency.
In a second aspect, the present application also provides a search apparatus, the apparatus including a receiving unit and a processing unit;
The receiving unit is used for receiving a user operation instruction, wherein the user operation instruction indicates a logic condition set which is required to be met by a product which is requested to be queried by a user, the logic condition set comprises a plurality of logic conditions, the logic conditions belong to different levels, and each logic condition comprises a logic operator and descriptive information of at least two indexes;
The processing unit is used for determining a tree data structure according to the logic condition set, wherein the tree data structure comprises a root node, at least one non-leaf node and a plurality of leaf nodes, the root node and the non-leaf nodes correspond to logic operators, the leaf nodes correspond to description information of indexes, an elastic search ES query statement is constructed according to the tree data structure, ES service is accessed according to the ES query statement, and a query result is obtained, wherein the query result indicates products meeting the logic condition set.
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 with at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes;
In a possible embodiment, the processing unit is specifically configured to, when constructing the elastic search ES query statement according to the tree data structure:
Determining clauses corresponding to each leaf node;
determining a first ES query clause according to a logical operator corresponding to the root node and clauses respectively corresponding to at least two leaf nodes associated with the root node;
determining a second ES query clause according to a logical operator corresponding to each non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node;
And assembling according to the tree data structure from top to bottom according to the first ES query clause and the second ES query clause corresponding to the at least one non-leaf node respectively to obtain the ES query statement.
In one possible embodiment, the description information of each index includes the name of the index, the screening mode of the index and the corresponding screening value, and the processing unit is specifically configured to, when determining the clause corresponding to each leaf node:
Determining corresponding ES field information according to a mapping relation and names of indexes in description information of indexes corresponding to each leaf node, wherein the mapping relation indicates that N index names are in one-to-one correspondence with N ES field information, and N is a positive integer;
determining corresponding assembly rules according to screening modes in the description information of indexes corresponding to each leaf node;
And determining clauses corresponding to the leaf nodes according to the obtained ES field information, the assembly rule and the screening value.
In a possible embodiment, the mapping relation is constructed according to a product information set, and the N index names are determined according to the product information set.
In one possible embodiment, the screening mode comprises any one of equivalent matching, multi-value equivalent matching, inequality matching, fuzzy matching and searching matching.
In a possible embodiment, the processing unit further comprises:
and 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 with the root node, merging the first ES query clause with the second ES query clause corresponding to the first non-leaf node.
In a third aspect, the present application provides a search apparatus comprising:
a memory for storing program instructions;
A processor for invoking program instructions stored in the memory and executing the steps comprised by the method according to any of the first aspects in accordance with the obtained program instructions.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program comprising program instructions which, when executed by a computer, cause the computer to perform the method of any one of the first aspects.
In a fifth aspect, the present application provides a computer program product comprising computer program code which, when run on a computer, causes the computer to perform the method of any of the first aspects.
Drawings
FIG. 1 is a flowchart of a searching method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a visual interface according to an embodiment of the present application;
FIG. 3A is a diagram illustrating a possible tree data structure according to an embodiment of the present application;
FIG. 3B is a diagram II of a possible tree data structure according to an embodiment of the present application;
Fig. 4 is a schematic structural diagram of a search device according to an embodiment of the present application;
Fig. 5 is a schematic diagram of a search device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application. Embodiments of the application and features of the embodiments may be combined with one another arbitrarily without conflict. Also, while a logical order of illustration is depicted in the flowchart, in some cases the steps shown or described may be performed in a different order than presented.
The terms first and second in the description and claims of the application and in the above-mentioned figures are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover non-exclusive protection. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The term "plurality" in the present application may mean at least two, for example, two, three or more, and embodiments of the present application are not limited.
Exemplary embodiments of the present application will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present application are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness. It should be noted that, in the embodiments of the present application, some existing solutions in the industry such as software, components, models, etc. may be mentioned, and they should be regarded as exemplary, only for illustrating the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or must not use the solution.
The technical scheme of the application obtains, transmits, stores, uses and the like the data, and meets the requirements of national related laws and regulations.
It should be noted that, in the embodiments of the present application, some existing solutions in the industry such as software, components, models, etc. may be mentioned, and they should be regarded as exemplary, only for illustrating the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or must not use the solution.
For easy understanding, the following description will first be given in detail of the technical background of the embodiments of the present application.
1. ES, which may also be referred to as elastic search, or search data analysis engine, or search server, etc. The ES is a distributed full-text search engine, can provide real-time storage, data retrieval and analysis capability, and can be expanded and deployed to hundreds of servers to process ten thousand levels of data. He provides a RESTful interface for the user to call, where RESTful generally refers to REST, representational state transfer (Representational STATE TRANSFER, REST).
ES query statement is JSON statement, in which the index to be queried, the query mode and the query condition are defined, JSON (JavaScript Object Notation) is a lightweight data exchange format, and the structured data is expressed in text form.
In the prior art, the retrieval method based on the ES requires users to have a structured query statement basis, and needs to know the ES index structure, the field type and the data organization mode, so that the use of business personnel and non-technical users is limited, and the technical threshold is increased. In addition, when the search conditions are numerous and complex, the ES-based search method also has problems of low query accuracy and long response time.
Based on the above-mentioned problems, fig. 1 exemplarily shows a flowchart of a search method provided by an embodiment of the present invention, and the flowchart may be described as an example by a server.
As shown in fig. 1, the process specifically includes:
Step 100, the server receives a user operation instruction, wherein the user operation instruction indicates a logic condition set which is required to be met by a product which is requested to be queried by a user. The logic condition set comprises a plurality of logic conditions and belongs to different levels, and each logic condition comprises a logic operator and descriptive information of at least two indexes.
Wherein, the logical operator can be AND, OR, NOT, and the specific meaning is AND, OR and NOT respectively.
The description information of the index comprises the name of the index, the screening mode of the index and the corresponding screening value.
The index name may be a plurality of, for example, a product number, a product name, a label a, a label B, and the like.
The screening mode can be any one of the following:
a) Equivalent matching
The equivalence matching may be recorded as "=", wherein the equivalence matching may support types of characters, values, dates, etc., and for example, the description information of the index may be a tag a= '5'.
B) Multi-value equivalent matching
The multi-value equivalent matching may be denoted as "IN", where "IN" includes at least two characters, and represents that one of a plurality of values may be satisfied, and for example, the description information of the index may be a tag B IN ('2', '3'), that is, the tag B may be equal to 2 or 3.
C) Inequality matching
Wherein, the inequality can be recorded as ">,. Gtoreq,. Ltoreq.BETWEEN..AND..wherein, the inequality matching can support numerical and date type screening of inequality. For example, the description information of the index can be that the label C is equal to or more than 10'.
D) Fuzzy matching
The fuzzy matching may be denoted as "LIKE", wherein the part requiring fuzzy matching is defined by an input wild card'. Times.. For example, the index may be described as a tag G list 'currency', i.e. searching for tags G that are semantically related to 'currency'.
E) Searching for matches
The SEARCH may be referred to as "SEARCH", and the word segmentation SEARCH is performed by inputting an arbitrary value. For example, the description information of the index can be the product name SEARCH 'change', namely, the change is subjected to word segmentation, and the product name of the segmented result is searched.
Illustratively, the user can select each logic operator, the name of the index, the screening mode of the index and the corresponding screening value through the visual interface, so as to generate a logic condition set which is required to be met by the product which the user requests to inquire.
For example, the visual interface may be divided into left and right portions, with the left portion presenting all selectable index names and the right portion presenting the set of logical conditions that the user needs to satisfy for the product being queried.
In one embodiment, as shown in fig. 2, if there are ten indexes for each financial product, the product number, the product name, the product description, the label a, the label B, the label C, the label D, the label E, the label F, and the label G are respectively corresponding. The user can first inquire the index names of the products on the visual interface to know which indexes are available for selection.
Assuming that the user wants to query a product with label a equal to '5', label B equal to '2' or '3', and label G containing two words of 'currency', the user can click or drag these three indexes into the designated screening box IN turn, and select the required screening method and screening value IN a drop-down box manner, specifically, select the screening method corresponding to label a as "=", select the corresponding screening value as '5', select the screening method corresponding to label B as "IN", select the corresponding screening value as '2' and '3', select the screening method corresponding to "label G" as "lie", and select the corresponding screening value as 'currency' through an input or selection manner. AND finally, connecting the description information of the three indexes by using a logic operator 'AND', AND representing screening products which simultaneously meet the description information of the three indexes.
Step 110, the server determines a tree data structure according to the logic condition set.
The tree data structure comprises 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 indexes.
Wherein, if the user selects a plurality of logic conditions and the plurality of logic conditions belong to different levels, the set of logic conditions may comprise a multi-level nest, forming a tree structure. In the tree structure, the root node represents the top-level operator, and all the logic conditions in the logic condition set can be contained in one tree structure.
In one possible implementation, the root node has an association with at least two leaf nodes while being connected to at least one non-leaf node, each non-leaf node having an association with at least two leaf nodes. For example, as shown in fig. 3A, the logical operators corresponding to the root node are "AND", the descriptors of the indexes corresponding to the two leaf nodes connected to the root node are "tag a= ' value '" AND "tag b= (' T1', ' T2 ')", the logical operators corresponding to the two non-leaf nodes connected to the root node are "OR" AND ", respectively, wherein the descriptors of the indexes corresponding to the leaf nodes connected to the logical operator" OR "corresponding to the non-leaf node are" tag c≡10 "AND" tag d=3 ", AND the descriptors of the indexes corresponding to the leaf nodes connected to the logical operator" AND "corresponding to the non-leaf node are" product name SEARCH ' change ' "AND" tag G LIKE ' "currency". That is, two levels of tree data structures may be formed based on the description information of the different logical operators and indexes selected by the user.
In one possible implementation, the root node has an association with at least two leaf nodes, while being connected to at least one non-leaf node, each non-leaf node has an association with at least two leaf nodes, and there is a non-leaf node connected to at least one non-leaf node. For example, as shown in fig. 3B, in addition to the structure shown in fig. 3A, a non-leaf node (corresponding to the logical operator "OR") may be further connected under the non-leaf node of the second hierarchy (corresponding to the logical operator "NOT") and in the third hierarchy, wherein the description information of the index corresponding to the leaf node connected by "NOT" is "tag e= '20150101'" and "tag f+ '20231231'", respectively. That is, this tree data structure may be three levels, with the logic conditions of the third level nested within the logic conditions of the second level.
Thus, the root node and at least two leaf nodes connected thereto form a first hierarchy, on the basis of which the non-leaf nodes connected to the root node and the leaf nodes connected to these non-leaf nodes form a second hierarchy, and if there are other non-leaf nodes and connected leaf nodes below the second hierarchy, a third hierarchy is formed, and so on, a tree structure of multiple hierarchies can be formed.
Through the tree data structure, each logic condition is distributed on a plurality of levels, so that the method is applicable to complex query scenes which simultaneously consider a plurality of logic conditions, and the query precision is improved.
Step 120, the server constructs an elastic search ES query statement according to the tree data structure.
Before the ES query statement is constructed, a mapping relation is constructed, wherein the mapping relation indicates that N index names are in one-to-one correspondence with N ES field information, and N is a positive integer.
For example, as shown in table 1, the mapping relationship may indicate the correspondence between the index names and the ES field information, where the left column may be displayed on the visual interface of the user in step 110 to indicate which of the index names are available for selection, the present application is not limited to the number of index names, N index names are determined according to the product information set, and the right column is used to indicate the corresponding ES field information mapped by the index names.
| Index name | ES field information |
| Product numbering | PD_ID |
| Product name | PD_NAME |
| Description of the product | PD_DESC |
| Label A | LABEL_A |
| Label B | LABEL_B |
| Label C | LABEL_C |
| Label D | LABEL_D |
| Label E | LABEL_E |
| Label F | LABEL_F |
| Label G | LABEL_G |
TABLE 1
Further, in order to enrich the mapping relationship, other information such as index number, index type, ES index information, etc. may be added to the mapping relationship, and by adding the information of these columns, the mapping relationship may be richer and more complete, as shown in table 2.
TABLE 2
Further, the ES field description and the ES field type may be added to the mapping relationship, as shown in table 3, and by adding these columns of information, the content of the ES field information may be more explicit and more complete.
TABLE 3 Table 3
In addition, table 3 may be divided into two tables, i.e., table 2 and table 4, respectively, table 2 indicates a mapping relationship, table 4 indicates a related content of the ES index information, and includes four columns of index name, ES field information, ES field description, and ES field type, and the index name selected by the user may be mapped to table 4 to query more related information.
The index NAME indicates an index NAME of ES field information, the ES field information indicates an ES field NAME, the ES field description indicates an ES field type, text and Keyword in the ES field type indicate a text type and a Keyword type, respectively, such as pd_name corresponds to a text type (text), and label_a corresponds to a Keyword type (Keyword). The text type is used for full text search and is suitable for fields needing full text search, when search query is executed, the content of the text type field is processed by a word segmentation device, and the word segmentation device can divide the text into individual words or phrases so as to search. The Keyword type is used for accurate value matching, is suitable for fields needing accurate matching, and cannot be divided into independent words.
| 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 type) | text |
| PD_LABEL_INDEX | PD_DESC | Product description (text type) | text |
| PD_LABEL_INDEX | LABEL_A | Label A (enumeration value) | keyword |
| PD_LABEL_INDEX | LABEL_B | Label B (enumeration value) | keyword |
| PD_LABEL_INDEX | LABEL_C | Label C (numerical value type) | keyword |
| PD_LABEL_INDEX | LABEL_D | Label D (numerical 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 | ...... | ...... |
TABLE 4 Table 4
By way of example, in combination with the above mapping relationship, the specific process of constructing the ES query statement by the server according to the tree data structure is:
First, the clause corresponding to each leaf node is determined.
(1) And determining corresponding ES field information according to the mapping relation and the names of the indexes in the description information of the indexes corresponding to each leaf node.
For example, by referring to tables 1 and 2, the corresponding ES field information corresponding to the index name can be obtained. For example, if the description information of the index corresponding to the leaf node is tag a= '5', the ES field information corresponding to "tag a" is known to be "label_a" by looking up table 1.
(2) And determining corresponding assembly rules according to screening modes in the description information of the indexes corresponding to each leaf node. Wherein, according to the difference of screening mode, the assembly rule specifically is as follows:
a) When the screening mode is equivalent matching, the assembly rule corresponding to the screening mode is as follows:
{ "ES field info" {: value "}.
B) When the screening mode is multi-value equivalent matching, the assembly rule corresponding to the screening mode is as follows:
{ "terms": { "ES field information": [ "value1", "value2", ".
C) When the screening mode is inequality matching, the assembly rule corresponding to the screening mode is as follows:
{ "range": { "ES field information": { "gt/gte": "value1", "lt/te": "value2" }. Wherein ">" corresponds to "gt", "> corresponds to" gte "," < "corresponds to" lt ",".
D) When the screening mode is fuzzy matching, the assembly rule corresponding to the screening mode is as follows:
{ "wildcard" { "ES field information": { "value": ". Query_text" }.
E) When the screening mode is search matching, the assembly rule corresponding to the screening mode is as follows:
{ "match": { "ES field information": "search term" }.
(3) And determining the clause corresponding to the leaf node according to the obtained ES field information, the assembly rule and the screening value. Specifically, the clause corresponding to the leaf node is obtained by combining the ES index information mapped by the index name in the description information of the index corresponding to the leaf node, the assembly rule of the screening mode and the screening value selected by the user.
Illustratively, as shown in fig. 3B, the leaf nodes are respectively:
Tag a= 'value'
Tag B IN ('T1', 'T2')
Label C is greater than or equal to 10
Label d=3
Tag e= '20240101'
Label F is less than or equal to '20241231'
Product name SERACH 'Change'
Label G lie 'currency'
The clauses corresponding to the obtained leaf nodes are respectively:
{"LABEL_A":{:"5"}}
{"LABEL_B":["T1","T2"]}
{"LABEL_C":{"gte":10}}
{"LABEL_D":3}
{"LABEL_E":"20150101"}
{"LABEL_F":{"lte":"20231231"};
and secondly, determining a first ES query clause according to a logical operator corresponding to the root node and clauses respectively corresponding to at least two leaf nodes associated with the root node.
Illustratively, 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 clauses corresponding to at least two leaf nodes associated with the root node.
For example, the assembling may be performed by using a bol query sentence, for example, when the logical operator is "AND", assembling the logical operator "AND clauses corresponding to at least two leaf nodes associated with the logical operator" AND "into a multi clause, where a specific assembling rule is:
AND- > the must clause,
For example, when the logical operator is "OR", the logical operator "OR" and clauses corresponding to at least two leaf nodes associated with the logical operator "OR" are assembled into should clauses, and the specific assembly rule is:
OR- > should clauses, and set the parameter minimum_ should _match to 1:
For example, when the logical operator is "NOT", the logical operator "NOT" and clauses corresponding to at least two leaf nodes associated with the logical operator "NOT" are assembled into a multiple_not clause, and the specific assembly rule is:
NOT- > must _ NOT clause,
Further, with reference to fig. 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 respectively is:
Thirdly, determining a second ES query clause according to a logical operator corresponding to each non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node;
Illustratively, the logical operator corresponding assembly rule 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 logical operator corresponding assembly rule corresponding to the non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node. Specific assembly rules may be referred to above. In addition, the non-leaf nodes can also be connected with other non-leaf nodes, other second ES query clauses are determined according to the logical operator corresponding assembly rule corresponding to the other non-leaf nodes and clauses corresponding to at least two leaf nodes associated with the other non-leaf nodes, and the like, and a plurality of second ES query clauses can be determined.
Further, with reference to fig. 3B, the logical operators corresponding to the non-leaf nodes are "OR", "AND" NOT "respectively,
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 clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node is:
{"bool":{
"should":[
{"range":{"LABEL_C":{"gte":10}}},
{"term":{"LABEL_D":3}},
}
When the logical operator corresponding to the non-leaf node is 'AND', the second ES query clause obtained according to the logical operator 'AND' corresponding assembly rule AND clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node is:
{"bool":{
"must":[
{ "match": { "PD_NAME": "change" },
{ "Wildcard" { "LABEL_G" { "value": "
}
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 respectively corresponding to at least two leaf nodes associated with the non-leaf node is:
Fourth, according to the first ES inquiry clause and the second ES inquiry clause corresponding to at least one non-leaf node, the ES inquiry clauses are assembled in a top-down order according to the tree data structure.
Further, with reference to fig. 3B, the ES query sentences obtained are assembled in top-down order:
Further, 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 with the root node, the first ES query clause and the second ES query clause corresponding to the first non-leaf node are combined.
For example, in the ES query sentence obtained according to fig. 3B, the logical operator corresponding to the root node is "AND", there is a logical operator corresponding to a non-leaf node that is also "AND", AND the non-leaf node is connected to the root node, so that the first ES query clause corresponding to the root node AND the second ES query clause corresponding to the non-leaf node may be combined, where the combined result is:
{"terms":{"LABEL_B":["T1","T2"]}},
{ "match": { "PD_NAME": "change" },
{ "Wildcard" { "LABEL_G" { "value": "
}
When the server receives the transmitted complex query request, the combined query mode can reduce the depth of query and simplify the query structure, thereby improving the query efficiency.
And 130, accessing the ES service by the server according to the ES query statement to obtain a query result, wherein the query result indicates products meeting the logic condition set. Specifically, the constructed ES query statement is sent to an application programming interface port (Application Program Interface, API), typically a RESTful API call, of the ES service via a hypertext transfer protocol (HyperText Transfer Protocol, HTTP) request. After receiving the query request, the ES service searches for the information of the matched product according to the provided ES query statement, returns the queried result, and returns the information of the product of the result indicating the matched ES query statement.
In summary, the user can flexibly define logic conditions on the visual interface to form a logic condition set, the user only needs to click and select operation, the technical background is not needed or the ES query grammar is not needed to be known, the query flow is simplified, the technical threshold is reduced, the logic condition set is converted into a tree data structure and is sequentially assembled into corresponding ES query sentences according to the sequence from top to bottom, the comprehensive analysis of the tree data structure from top to bottom is realized, the structural integrity of the query sentences is ensured, the errors and omission are reduced, the clauses corresponding to leaf nodes can be quickly determined by constructing the mapping relation between index names and ES field information, the first ES query clause and the second ES query clause are constructed, the ES query sentences are obtained, and further, the problem of low query accuracy in the prior art in complex query scenes can be effectively solved according to the ES query sentences for the user.
Fig. 4 and fig. 5 are schematic structural diagrams of a possible searching apparatus according to an embodiment of the present application. These search means may be used to implement the functions of the server in the method embodiments described above.
As shown in fig. 4, the search apparatus 400 includes a communication unit 410 and a processing unit 420.
When the search apparatus 400 is used to implement the functionality of the server in the method embodiment shown in fig. 1:
The communication unit 410 is configured to receive a user operation instruction, where the user operation instruction indicates a set of logic conditions that needs to be satisfied by a product that is requested to be queried by a user, where the set of logic conditions includes a plurality of logic conditions, where the plurality of logic conditions belong to different levels, and each logic condition includes a logic operator and description information of at least two indexes;
The processing unit 420 is configured to determine a tree data structure according to the set of logic conditions, where the tree data structure includes a root node, at least one non-leaf node, and a plurality of leaf nodes, where the root node and the non-leaf node correspond to logic operators, the leaf nodes correspond to description information of indexes, construct an ES query statement according to the tree data structure, access ES service according to the ES query statement, and obtain a query result, where the query result indicates a product meeting the set of logic conditions.
In one 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 with at least one non-leaf node, and each non-leaf node has an association relationship with at least two leaf nodes;
The processing unit 420 is specifically configured to, when constructing an ES query statement according to the tree data structure:
Determining clauses corresponding to each leaf node;
determining a first ES query clause according to a logical operator corresponding to the root node and clauses respectively corresponding to at least two leaf nodes associated with the root node;
determining a second ES query clause according to a logical operator corresponding to each non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node;
And assembling according to the tree data structure from top to bottom according to the first ES query clause and the second ES query clause corresponding to the at least one non-leaf node respectively to obtain the ES query statement.
The description information of each index includes the name of the index, the screening mode of the index and the corresponding screening value, and the processing unit 420 is specifically configured to, when determining the clause corresponding to each leaf node:
Determining corresponding ES field information according to a mapping relation and names of indexes in description information of indexes corresponding to each leaf node, wherein the mapping relation indicates that N index names are in one-to-one correspondence with N ES field information, and N is a positive integer;
determining corresponding assembly rules according to screening modes in the description information of indexes corresponding to each leaf node;
And determining clauses corresponding to the leaf nodes according to the obtained ES field information, the assembly rule and the screening value.
The mapping relation is constructed according to a product information set, and the N index names are determined according to the product information set.
The screening mode comprises any one of equivalent matching, multi-value equivalent matching, inequality matching, fuzzy matching and searching matching.
The processing unit 420 is further configured to:
and 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 with the root node, merging the first ES query clause with the second ES query clause corresponding to the first non-leaf node.
The more detailed description about the communication unit 410 and the processing unit 420 can be directly obtained by referring to the related description in the method embodiment shown in fig. 1, and will not be repeated here.
As shown in fig. 5, the search apparatus 500 includes a processor 510 and a communication interface 520. Processor 510 and communication interface 520 are coupled to each other. It is understood that the communication interface 520 may be a transceiver or an input-output interface. Optionally, the search device 500 may further include a memory 530 for storing instructions executed by the processor 510 or for storing input data required by the processor 510 to execute the instructions or for storing data generated after the processor 510 executes the instructions.
When the search apparatus 500 is used to implement the method shown in fig. 1, 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.
The division of the units in the embodiments of the present application is schematically shown, which is merely a logic function division, and may have another division manner when actually implemented, and in addition, each functional unit in each embodiment of the present application may be integrated in one processor, or may exist separately and physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
Based on the same inventive concept, embodiments of the present application provide a computer-readable storage medium, a computer program product comprising computer program code which, when run on a computer, causes the computer to perform a search method as any one of the preceding discussion. Since the principle of solving the problem by the computer readable storage medium is similar to that of the searching method, the implementation of the computer readable storage medium can refer to the implementation of the method, and the repetition is omitted.
Based on the same inventive concept, embodiments of the present application also provide a computer program product comprising computer program code which, when run on a computer, causes the computer to perform a search method as any of the preceding discussion. Since the principle of solving the problem by the computer program product is similar to that of the search method, the implementation of the computer program product can be referred to as implementation of the method, and the repetition is omitted.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of user operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.
Claims (11)
1. A search method, the method comprising:
Receiving a user operation instruction, wherein the user operation instruction indicates a logic condition set which is required to be met by a product which is requested to be queried by a user, the logic condition set comprises a plurality of logic conditions, the logic conditions belong to different levels, and each logic condition comprises a logic operator and descriptive information of at least two indexes;
Determining a tree data structure according to the logic condition set, wherein the tree data structure comprises a root node, at least one non-leaf node and a plurality of leaf nodes, wherein the root node and the non-leaf node correspond to logic operators, and the leaf nodes correspond to description information of indexes;
Constructing an elastic search ES query statement according to the tree data structure;
And accessing an ES service according to the ES query statement to obtain a query result, wherein the query result indicates products meeting the logic condition set.
2. The method of claim 1, wherein in the tree data structure, the root node has an association with at least two leaf nodes, the root node is connected with at least one non-leaf node, and each non-leaf node has an association with at least two leaf nodes.
3. The method of claim 2, wherein constructing an ES query statement from the tree data structure comprises:
Determining clauses corresponding to each leaf node;
determining a first ES query clause according to a logical operator corresponding to the root node and clauses respectively corresponding to at least two leaf nodes associated with the root node;
determining a second ES query clause according to a logical operator corresponding to each non-leaf node and clauses respectively corresponding to at least two leaf nodes associated with the non-leaf node;
And assembling according to the tree data structure from top to bottom according to the first ES query clause and the second ES query clause corresponding to the at least one non-leaf node respectively to obtain the ES query statement.
4. A method according to claim 3, wherein the description information of each index includes the name of the index, the screening mode of the index and the corresponding screening value;
Determining clauses corresponding to each leaf node, including:
Determining corresponding ES field information according to a mapping relation and names of indexes in description information of indexes corresponding to each leaf node, wherein the mapping relation indicates that N index names are in one-to-one correspondence with N ES field information, and N is a positive integer;
determining corresponding assembly rules according to screening modes in the description information of indexes corresponding to each leaf node;
And determining clauses corresponding to the leaf nodes according to the obtained ES field information, the assembly rule and the screening value.
5. The method of claim 4, wherein the mapping relationship is constructed from a set of product information, and the N index names are determined from the set of product information.
6. The method of claim 4, wherein the screening method comprises any one of equivalent matching, multi-valued equivalent matching, inequality matching, fuzzy matching, search matching.
7. A method as recited in claim 3, further comprising:
and 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 with the root node, merging the first ES query clause with the second ES query clause corresponding to the first non-leaf node.
8. A search device is characterized by comprising a communication unit and a processing unit;
The communication unit is used for receiving a user operation instruction, wherein the user operation instruction indicates a logic condition set which is required to be met by a product which is requested to be queried by a user, the logic condition set comprises a plurality of logic conditions, the logic conditions belong to different levels, and each logic condition comprises a logic operator and descriptive information of at least two indexes;
The processing unit is used for determining a tree data structure according to the logic condition set, wherein the tree data structure comprises a root node, at least one non-leaf node and a plurality of leaf nodes, the root node and the non-leaf nodes correspond to logic operators, the leaf nodes correspond to description information of indexes, an ES query statement is constructed according to the tree data structure, ES service is accessed according to the ES query statement, and a query result is obtained, wherein the query result indicates a product meeting the logic condition set.
9. A search apparatus, comprising:
a memory for storing program instructions;
a processor for invoking program instructions stored in the memory and for performing the steps comprised in the method according to any of claims 1-7 in accordance with the obtained program instructions.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions which, when executed by a computer, cause the computer to perform the method of any of claims 1-7.
11. Computer program product, characterized in that it comprises computer program code which, when run on a computer, causes the computer to carry out the method according to any of the preceding claims 1-7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411261534.XA CN119201972A (en) | 2024-09-10 | 2024-09-10 | A search method, device, equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411261534.XA CN119201972A (en) | 2024-09-10 | 2024-09-10 | A search method, device, equipment and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN119201972A true CN119201972A (en) | 2024-12-27 |
Family
ID=94075024
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411261534.XA Pending CN119201972A (en) | 2024-09-10 | 2024-09-10 | A search method, device, equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN119201972A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120448386A (en) * | 2025-04-28 | 2025-08-08 | 襄阳求己则赢软件技术有限公司 | Data screening method, device and product |
-
2024
- 2024-09-10 CN CN202411261534.XA patent/CN119201972A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120448386A (en) * | 2025-04-28 | 2025-08-08 | 襄阳求己则赢软件技术有限公司 | Data screening method, device and product |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11615143B2 (en) | System and method for querying a graph model | |
| CN114461603A (en) | Multi-source heterogeneous data fusion method and device | |
| US8825621B2 (en) | Transformation of complex data source result sets to normalized sets for manipulation and presentation | |
| CN111506621B (en) | Data statistical method and device | |
| US20170357653A1 (en) | Unsupervised method for enriching rdf data sources from denormalized data | |
| US20130124545A1 (en) | System and method implementing a text analysis repository | |
| CN114218472A (en) | Intelligent search system based on knowledge graph | |
| WO2014169265A1 (en) | Storing and querying graph data in a key-value store | |
| CN103646032A (en) | Database query method based on body and restricted natural language processing | |
| US12271698B1 (en) | Schema and cell value aware named entity recognition model for executing natural language queries | |
| CN102360367A (en) | XBRL (Extensible Business Reporting Language) data search method and search engine | |
| US20230350899A1 (en) | Query engine for recursive searches in a self-describing data system | |
| CN119025552A (en) | A natural language intelligent number asking method, device and storage medium | |
| WO2023278154A1 (en) | Apparatus and method for transforming unstructured data sources into both relational entities and machine learning models that support structured query language queries | |
| CN118708704A (en) | Data query method and device based on text processing model | |
| CN119166740A (en) | Knowledge base construction method, data processing method, device, storage medium and program product | |
| CN119201972A (en) | A search method, device, equipment and storage medium | |
| CN116975098A (en) | Query plan construction method, device, electronic device and storage medium | |
| CN119760113B (en) | A Legal Concept Interpretation Method Based on Multi-Perspective Clustering and Hybrid Retrieval | |
| CN113434654B (en) | A data processing method, device, equipment, and storage medium | |
| Izquierdo et al. | Busca360: A search application in the context of top-side asset integrity management in the oil & gas industry | |
| US11775513B2 (en) | Database management for sound-based identifiers | |
| CN110716994A (en) | Retrieval method and device supporting heterogeneous geographic data resource retrieval | |
| CN116089636A (en) | Frequency class diagram query method, related device, electronic equipment and storage medium | |
| CN119536988A (en) | A text file processing method and device, electronic device, and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |