WO2021189195A1 - 数据查询方法、装置、服务器及存储介质 - Google Patents
数据查询方法、装置、服务器及存储介质 Download PDFInfo
- Publication number
- WO2021189195A1 WO2021189195A1 PCT/CN2020/080690 CN2020080690W WO2021189195A1 WO 2021189195 A1 WO2021189195 A1 WO 2021189195A1 CN 2020080690 W CN2020080690 W CN 2020080690W WO 2021189195 A1 WO2021189195 A1 WO 2021189195A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- query
- label
- logical
- tree
- data
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 78
- 230000014509 gene expression Effects 0.000 claims abstract description 120
- 239000010410 layer Substances 0.000 claims abstract description 19
- 239000002356 single layer Substances 0.000 claims abstract description 17
- 230000002194 synthesizing effect Effects 0.000 claims description 3
- 230000015572 biosynthetic process Effects 0.000 description 8
- 230000008569 process Effects 0.000 description 8
- 238000012545 processing Methods 0.000 description 8
- 238000003786 synthesis reaction Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 5
- 101100264195 Caenorhabditis elegans app-1 gene Proteins 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 230000008901 benefit Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000007619 statistical method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
Definitions
- This application relates to the field of data processing technology, and more specifically, to a data query method, device, server, and storage medium.
- Information recommendation technology mainly recommends related information based on user tag data.
- information recommendation there is usually a business party that queries the tag data to perform corresponding services based on the tag data.
- this application proposes a data query method, device, server and storage medium.
- an embodiment of the present application provides a data query device.
- the device includes: an expression generation module, a tree generation module, a sentence generation module, and a tag query module.
- Query condition obtain a logical expression corresponding to the tag query condition, the logical expression includes a single layer or multiple layers of logic, the tag query condition includes a plurality of tag conditions;
- the tree generation module is used for Logical expressions to generate a logical tree;
- the sentence generation module is used to generate a query sentence for querying label data according to the logic tree;
- the label query module is used to query conditions from the label according to the query sentence Query label data in the corresponding database.
- an embodiment of the present application provides a server, including: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and are It is configured to be executed by the one or more processors, and the one or more programs are configured to execute the data query method provided in the above-mentioned first aspect.
- the solution provided in this application obtains the logical expression corresponding to the label query condition according to the label query condition.
- the logical expression includes single-layer or multi-layer logic, and the label query condition includes multiple label conditions, and then according to the logical expression Generate a logic tree, generate a query statement for querying label data according to the logic tree, and finally query the label data from the database corresponding to the label query condition according to the query statement.
- the label query conditions composed of multiple label conditions are parsed into logical expressions, and the logical tree generated by the logical expressions is used to generate query statements and perform label data queries. Since logical expressions can support multiple levels of logic, Therefore, it can meet complex query requirements and improve the accuracy of data query.
- Fig. 1 shows a flowchart of a data query method according to an embodiment of the present application.
- Fig. 2 shows a schematic diagram of a logic tree provided by an embodiment of the present application.
- Fig. 3 shows another schematic diagram of a logic tree provided by an embodiment of the present application.
- Fig. 4 shows a flowchart of a data query method according to another embodiment of the present application.
- Fig. 5 shows a flowchart of a data query method according to another embodiment of the present application.
- Fig. 6 shows a flowchart of a data query method according to still another embodiment of the present application.
- Fig. 7 shows a block diagram of a data query device according to an embodiment of the present application.
- FIG. 8 is a block diagram of a server for executing the data query method according to the embodiment of the present application according to an embodiment of the present application.
- Fig. 9 is a storage unit for storing or carrying program code for implementing the data query method according to the embodiment of the present application according to an embodiment of the present application.
- the business party queries the label data, and the business party can determine the user, content, etc. to be pushed through the queried label data.
- the business side uses multiple label conditions to query the corresponding user when encircling users.
- the inventor proposed the data query method, device, server, and storage medium provided by the embodiments of the present application.
- the label query conditions including multiple label conditions
- a logical expression supporting multi-layer logic is obtained, and then according to the logic
- the expression generates a logic tree, and generates a query statement based on the logic tree, and finally uses the query statement to query label data, which can meet the needs of complex business scenarios.
- the specific data query method will be described in detail in the subsequent embodiments.
- FIG. 1 shows a schematic flowchart of a data query method provided by an embodiment of the present application.
- the data query method is applied to the data query device 400 shown in FIG. 7 and the server 100 equipped with the data query device 400 (FIG. 8).
- the following will take a server as an example to describe the specific process of this embodiment.
- the server applied in this embodiment may be a traditional server, a cloud server, etc., which is not limited here.
- the process shown in FIG. 1 will be described in detail below, and the data query method may specifically include the following steps:
- Step S110 Obtain a logical expression corresponding to the label query condition according to the label query condition, the logical expression includes a single layer or multiple layers of logic, and the label query condition includes a plurality of label conditions.
- the server parses the label query condition to obtain the logical expression corresponding to the label query condition.
- the label query condition is a condition for constraining label data
- the label query condition includes multiple label conditions.
- the tag query conditions also include relationships between multiple tag conditions, such as parallel relationships.
- the label condition is a single condition that limits the label data.
- the business side wants to advertise for users who have installed both App 1 and App 2, but not App 3, and set the label query condition as users who have installed App 1 and App 2, but not App 3; and For example, if a game company wants to increase the retention rate of recent active game players, and wants to offer game rewards to recent active game players, the label query conditions set are that the game duration exceeds 24 hours or the number of logins exceeds 10 times in the last week. User.
- the specific label query condition may not be used as a limitation.
- the label query condition may be sent by the business party to the server, and the server will receive it accordingly. It is understandable that when the business party needs to query label data, the business party's electronic device can send the label query condition to the server, so that the server can query the label data and obtain the label data obtained by the query from the server.
- the label query condition may also be pre-stored in the server, and when the server needs to query the label data, the label query condition can be read to perform the label data query.
- the server can periodically return label data to the business side according to the business side’s needs for label data. Therefore, the server can store the label query conditions, and then periodically query the latest label data according to the label query conditions, and then return the label data to the business. square.
- the label query condition may also be set locally by the server, and the server may perform corresponding push based on the label data after the label data is obtained by query.
- the server parses the label query conditions, and parses out multiple label conditions and logical relationships between the multiple label conditions. Then, according to the multiple label conditions and the logical relationship between the multiple label conditions, a logical expression is generated.
- the logical relationship can be and, or, etc.
- a logical expression is a formula composed of operators and label conditions corresponding to the logical relationship. For example, if the label query condition is a user who has installed application A or B and installed application C, the logical expression can be (application A or application B) and application C.
- the way the server specifically generates the logical expression and the form of the logical expression are not limited.
- the logic expression may include a single layer of logic or multiple layers of logic.
- single-layer logic refers to logic that can get a result through only one logical operation, for example, A and B;
- multi-layer logic refers to logic that requires multiple logical operations to get the result, for example, (A or B) and C.
- Multi-layered logic can include explicit multi-layered logic with parentheses and implicit hierarchical logic without parentheses.
- the display multi-layer logic is (((A and B) and C) and D), and the implicit layer logic is A and B or C and D.
- Step S120 Generate a logic tree according to the logic expression.
- the server may generate a logical tree according to the logical expression.
- the logical tree is used to represent the logical relationship of the label conditions in the logical expression, and the logical relationship between the label conditions is expressed in the form of text.
- the server when the server generates a logical tree based on a logical expression, if the logical expression includes a single layer of logic, it can use each label condition as the tree according to the logical characteristics between the various label conditions in the logical expression.
- the nodes are connected in sequence to obtain the generated logical tree.
- the logical features can be logical connectives, logical relational characters, logical operators, etc., which are not limited here.
- the server When the server generates a logical tree based on a logical expression, if the logical expression includes multiple levels of logic, it can generate a logical subtree according to each level of logic in the multilevel logic, and then merge all the logical subtrees. Obtain the logical tree corresponding to the logical expression.
- the logical features can also be logical connectives, logical relational symbols, logical operators, etc., which are not limited here.
- the way the server generates the logical subtree of each level of logic can refer to the way of generating the logical tree when the logical expression includes a single level of logic.
- the server When the server merges all the logical subtrees to obtain the logical tree corresponding to the logical expression, it can use the logical subtree corresponding to each level of logic as the next level of logic according to the order in which each level of logic appears in the logical expression.
- the tree node in the corresponding logical subtree is merged with the logical subtree, so that the logical tree corresponding to the logical expression can be obtained.
- the server first generates (A and B) logical subtree 1, (E and C) logical subtree 2, (F and D) logical subtree 3, A and B are the tree nodes of logical subtree 1, E and C are the tree nodes of logical subtree 2, F and D are the tree nodes of logical subtree 3.
- a and B are the tree nodes of logical subtree 1
- E and C are the tree nodes of logical subtree 2
- F and D are the tree nodes of logical subtree 3.
- the logic of the first level is (A and B)
- logical subtree 1 is taken as the tree node E in logical subtree 2
- E is replaced and added to logical subtree 2.
- the logical subtree 2 after adding the logical subtree 1 is used as the tree node F in the logical subtree 3, so that the final synthesized logical tree can be obtained.
- the server when the server generates the logic tree based on the logic expression, if the logic expression includes multiple levels of logic, the server can also generate the connections in sequence according to the order in which each level of logic appears in the logic expression. Of the tree nodes to form a logical tree.
- the server when the logical expression is (((A and B) and C) and D), at this time, after the server first generates the tree nodes of the first level of logic (A and B), according to the logic of the next level, it generates C The tree node, and the tree node of (A and B) is connected with the tree node of C with and, and then according to the logic of the next layer, the tree node of D is generated, and the previously connected tree node is connected with D with and , So as to obtain the final logic tree.
- the logical tree may be a binary tree, where the binary tree is a tree structure in which each node has at most two subtrees.
- the logical expression is (((A and B) and C) and D), and the generated logical tree is shown in Figure 2.
- the generated logical tree is shown in Figure 3.
- the above is only an example, and does not represent a limitation on a specific logic tree.
- Step S130 According to the logic tree, a query sentence for querying label data is generated.
- the server may generate a query statement for querying cousin data according to the logical tree.
- the server can traverse the logic tree to complete the synthesis of the query statement. Specifically, the server may traverse the logic tree according to the query engine adopted by the corresponding database, and then generate the query statement corresponding to the database.
- the query statement can be a query code, which can be used to query data from a corresponding database.
- the server may send the query sentence to the database corresponding to the label query condition to query the corresponding label data from the database.
- the database may also be local to the server, and the server may directly query the label data from the database according to the query statement.
- the data query method provided by the embodiment of the present application obtains the logical expression corresponding to the label query condition according to the label query condition, the logical expression includes single-layer or multi-layer logic, and the label query condition includes multiple label conditions, and then A logic tree is generated according to the logic expression, a query statement for querying label data is generated according to the logic tree, and finally the label data is queried from the database corresponding to the label query condition according to the query statement.
- the label query conditions composed of multiple label conditions are parsed into logical expressions, and the logical tree generated by the logical expressions is used to generate query statements and perform label data queries. Since multi-layer logical logical expressions can be generated, Therefore, it can meet complex query requirements and improve the accuracy of data query. When used for crowd trapping, it can improve the flexibility of trapping crowds and position the crowd more accurately.
- Step S210 Obtain logical features among multiple label conditions in the label query conditions according to label query conditions, where the label query conditions include multiple label conditions.
- the server can provide a page of label data selection to the business side, and the page can include various filterable label condition options, as well as the relationship between the various options. Logical relationship selection, so that users on the business end can quickly and conveniently determine the label query conditions through operations on the page.
- the server After receiving the label query condition returned by the business end, the server can generate a logical expression according to the label query condition.
- step S230 can refer to the content of the foregoing embodiment, and will not be repeated here.
- the logic tree can have a clear and reasonable expression of the multi-layer complex logic combination, and is very convenient for subsequent use, and supports various query languages. After the logic tree is parsed successfully, the query condition synthesis can be completed quickly and clearly, saving labor costs. Specifically, after the logic tree is generated, for subsequent sentence synthesis, the front-end expression and back-end synthesis query sentences are already well completed Decoupling, the server uses the logic tree to flexibly cooperate with most query engines to synthesize query statements.
- Step S240 Invoke the query engine.
- the server can call the corresponding query engine.
- the query engine may be a query engine corresponding to the database. It is understandable that different databases may correspond to different query engines and can recognize different query statements. Therefore, the query engine needs to be used to synthesize query statements corresponding to the database.
- the obtained query sentence is a query code corresponding to the database, and the query code can be identified by the database.
- the query statement is shown in the following code:
- the data query method obtains logical characteristics between multiple label conditions in the label query conditions, generates logical expressions composed of multiple label conditions according to the logical characteristics, and then generates logic according to the logical expressions Tree, then determine the database where the tag data corresponding to the tag query condition is located, call the query engine corresponding to the database, and use the query engine to traverse the logic tree to obtain the query statement used to query the tag data, and finally query the tag based on the query statement Query label data in the corresponding database.
- the label query conditions composed of multiple label conditions are parsed into logical expressions, and the logical tree generated by the logical expressions is used to generate query statements and perform label data queries. Since multi-layer logical logical expressions can be generated, Therefore, it can meet complex query requirements and improve the accuracy of data query. When used for crowd trapping, the flexibility of trapping crowds can be improved, and the positioning of crowds can be more accurate.
- Step S310 Obtain a logical expression corresponding to the label query condition according to the label query condition, the logical expression includes a single layer or multiple layers of logic, and the label query condition includes multiple label conditions.
- steps S310 to S340 can refer to the content of the foregoing embodiment, and details are not described herein again.
- Step S350 Store the query sentence.
- Step S360 Generate a sentence identifier of the query sentence.
- Step S370 Send the corresponding relationship between the label query condition and the sentence identifier to the service end.
- the server may send the corresponding relationship between the label query condition and the sentence identifier to the service end.
- the server can issue the corresponding relationship so that the business end generates a query request according to the corresponding sentence identifier.
- the business end can determine the corresponding sentence identifier according to the input label query condition, and generate a query request according to the sentence identifier.
- the server may issue the corresponding relationship between the label query condition and the sentence identifier when accessing the query page of the label data.
- the business end accesses the query page of the tag data, it can generate an access request for the page, and when the server receives the access request, it sends the above corresponding relationship to the business end.
- the server when the server receives the query request corresponding to the above query sentence, it indicates that the business end needs to use the query sentence to query the label data, that is, to query the label data according to the above label query conditions. Therefore, the server can directly read the stored query statement, so as to use the query statement to query the label data from the database.
- Step S390 According to the query condition, query label data from the database corresponding to the label query condition.
- the server when the server queries the label data from the database corresponding to the label query condition according to the query condition, it may send the query sentence to the database corresponding to the label query condition, and then receive the label data returned by the database.
- the server sends the query sentence to the hive of the database corresponding to the label query condition through the query interface.
- hive is a data warehouse tool based on Hadoop, which can map structured data files to a database table and provide simple SQL query functions.
- the advantage of Hive lies in the low cost of learning. Simple MapReduce statistics can be quickly implemented through SQL-like statements without the need to develop specialized MapReduce applications. It is very suitable for statistical analysis in data warehouses.
- the data query method analyzes the label query conditions composed of multiple label conditions into logical expressions, and generates the query statement from the logical tree generated by the logical expressions, and performs the query of the label data. Generate multi-layer logical logical expressions, so it can meet complex query requirements and improve the accuracy of data query. When used for crowd trapping, the flexibility of trapping crowds can be improved, and the positioning of crowds can be more accurate.
- the query statement is stored, and the statement identifier corresponding to the query statement is generated, and the corresponding relationship between the statement identifier and the label query condition is sent to the business side, so that the business side can generate query requests based on the statement identification, and the server can generate query requests based on the query Request, directly use the stored query statement to query the label data, which improves the query speed of the label data.
- FIG. 6 shows a schematic flowchart of a data query method provided by another embodiment of the present application.
- the data query method can be applied to the above-mentioned server. The process shown in FIG. 6 will be described in detail below.
- the data query method may specifically include the following steps:
- Step S400 Obtain a logical expression corresponding to the label query condition according to the label query condition, the logical expression includes a single layer or multiple layers of logic, and the label query condition includes a plurality of label conditions.
- Step S401 Generate a logic tree according to the logic expression.
- Step S402 According to the logic tree, a query sentence for querying label data is generated.
- Step S403 According to the query sentence, query label data from the database corresponding to the label query condition.
- steps S400 to S403 can refer to the content of the foregoing embodiment, which will not be repeated here.
- Step S404 Store the corresponding relationship between the logical tree and the tag query condition.
- the server may also store the corresponding relationship between the generated logic tree and the above tag query conditions. It is understandable that the server stores the corresponding relationship between the logical tree and the above tag query conditions, then when subsequent data queries are performed according to the new query conditions including the tag query conditions, the logical tree and other logical trees can be directly used for data query Synthesize, effectively save the time of data query and improve the speed of data query.
- Step S405 Obtain the first query condition.
- Step S406 If the first query condition includes the tag query condition and at least one second query condition, generate a first logic tree according to the at least one second query condition.
- Step S407 The logical tree corresponding to the tag query condition is synthesized with the first logical tree to obtain a second logical tree.
- the server may synthesize the logical tree corresponding to the above label query condition with the first logical tree to obtain the second logical tree. Specifically, the server may identify the logical relationship between the above tag query condition and the second tag query condition in the first query condition, and then use the logical relationship to synthesize the logical tree corresponding to the tag query condition and the first logical tree.
- the server may also determine whether the database corresponding to the label query condition is the same as the database corresponding to the second query condition before synthesizing the logic tree corresponding to the label query condition with the first logic tree to obtain the second logic tree. . If the database corresponding to the label query condition is the same as the database corresponding to the second query condition, it means that when the data corresponding to the first query condition all exist in the same database, it means that the label data query can be performed in the same database, and the database can be used directly in the future The query engine is used to synthesize the query statement, so the server can synthesize the logical tree corresponding to the label query condition with the first logical tree to obtain the second logical tree.
- the server may generate a target query statement according to the first logic tree, and the target query statement is used to query the label data from the database corresponding to the second query condition. After the server generates the target query statement, it can query the label data from the database corresponding to the second query condition according to the target query statement. In addition, the server can query the label data from the data corresponding to the label query condition according to the query sentence corresponding to the above label query condition. After completing the label data query, the server filters, combines, de-duplicates, etc., the label data according to the logical relationship between the label query condition and the second query condition, so as to obtain the finally queried label data.
- Step S408 According to the second logic tree, a query sentence corresponding to the first query condition is generated.
- Step S409 According to the query sentence corresponding to the first query condition, query the label data from the database.
- step S408 and step S409 can refer to the content of the foregoing embodiment, and will not be repeated here.
- the logical tree generated by the logical expressions By parsing the label query conditions composed of multiple label conditions into logical expressions, the logical tree generated by the logical expressions generates the query statement, and performs the query of the label data, because the logical expression of multi-layer logic can be generated, so It can meet complex query requirements and improve the accuracy of data query.
- the flexibility of trapping crowds can be improved, and the positioning of crowds can be more accurate.
- the corresponding relationship between the logical tree and the above tag query conditions is stored, and then when the subsequent data query is performed according to the new query conditions including the tag query conditions, the logical tree can be directly used to synthesize with other logical trees, which is effective Save data query time and improve data query speed.
- FIG. 7 shows a structural block diagram of a data query device 400 provided by an embodiment of the present application.
- the data query device 400 uses the aforementioned server.
- the data query device 400 includes: an expression generation module 410, a tree generation module 420, a sentence generation module 430, and a tag query module 440.
- the expression generating module 410 is configured to obtain a logical expression corresponding to the label query condition according to the label query condition, the logical expression includes single-layer or multi-layer logic, and the label query condition includes multiple Label conditions; the tree generation module 420 is used to generate a logic tree according to the logical expression; the sentence generation module 430 is used to generate a query sentence for querying label data according to the logic tree; the label query The module 440 is used for querying tag data from the database corresponding to the tag query condition according to the query sentence.
- the sentence generation module 430 includes: an engine invocation unit for invoking a query engine; and a traversal unit for traversing the logic tree by using the query engine to obtain a query sentence for querying tag data.
- the engine invoking unit may be specifically configured to: determine the database where the tag data corresponding to the tag query condition is located; call the query engine corresponding to the database.
- the traversal unit may be specifically configured to: use the query engine to traverse the logic tree in a recursive manner to obtain query statements for querying label data.
- the expression generation module 410 may include: a feature acquiring unit, configured to acquire logical features among multiple tag conditions in the tag query condition; a generating unit, configured to generate A logical expression composed of the multiple label conditions.
- the generating unit may be specifically configured to: determine a corresponding logical relation symbol according to the logical characteristic; and generate a logical expression composed of the multiple label conditions according to the logical relation symbol.
- the feature acquisition unit may be specifically configured to: identify connective words between multiple label conditions in the label query condition, and use the connective words as logical features between the multiple label conditions.
- the data query device 400 may further include: a first sending module and a first receiving module.
- the first sending module is configured to send the keyword set corresponding to the currently existing label to the business end before obtaining the logical expression corresponding to the label query condition according to the label query condition, and the keyword set is used for all
- the service terminal generates a label query condition; the first receiving module is used to receive the label query condition returned by the service terminal.
- the data query device 400 may further include: a first storage module.
- the first storage module is configured to store the query statement after the query statement for querying label data is generated according to the logic tree.
- the data query device 400 may further include: a sentence reading module.
- the sentence reading module is used for reading the query sentence when the query request corresponding to the query sentence is obtained.
- the tag query module 440 may also be used to query tag data from the database corresponding to the tag query condition according to the query condition after reading the query sentence.
- the data query device 400 may further include: a sentence identification generating module and a second sending module.
- the sentence identifier generation module is used to generate the sentence identifier of the query sentence before the query sentence is read when the query request corresponding to the query sentence is obtained; the second sending module is used to query the label The corresponding relationship between the condition and the sentence identifier is sent to the service end.
- the sentence reading module may be specifically configured to: receive a query request sent by the business end; if the query request carries the sentence identifier, read the query sentence.
- the tag query module 440 may include a sentence sending unit and a data receiving unit.
- the sentence sending unit is used for sending the query sentence to the database corresponding to the label query condition;
- the data receiving unit is used for receiving the label data returned by the database.
- the sentence sending unit may be specifically configured to send the query sentence to the hive of the database corresponding to the label query condition through a query interface.
- the data query device 400 may further include: a second storage module.
- the second storage module is configured to store the corresponding relationship between the logical tree and the tag query condition after the logical tree is generated according to the logical expression.
- the data query device 400 may further include: a condition acquisition module and a tree synthesis module.
- the condition obtaining module is used to obtain the first query condition;
- the tree generation module 420 is also used to generate the first query condition according to the at least one second query condition if the first query condition includes the tag query condition and at least one second query condition The first logic tree;
- the tree synthesis module is used to synthesize the logic tree corresponding to the tag query condition with the first logic tree to obtain a second logic tree;
- the sentence generation module 430 is also used to generate a second logic tree according to the To generate a query sentence corresponding to the first query condition.
- the data query device 400 may further include: a database judgment module.
- the database judgment module is configured to judge that the database corresponding to the label query condition corresponds to the second query condition before synthesizing the logic tree corresponding to the label query condition with the first logic tree to obtain the second logic tree Are the databases the same. If they are the same, the tree synthesis module synthesizes the logical tree corresponding to the tag query condition with the first logical tree to obtain a second logical tree.
- the sentence generation module 430 is also configured to, after determining whether the database corresponding to the tag query condition and the database corresponding to the second query condition are the same, if they are not the same, generate according to the first logic tree
- the target query sentence is used to query label data from the database corresponding to the second query condition.
- the coupling between the modules may be electrical, mechanical or other forms of coupling.
- each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
- the above-mentioned integrated modules can be implemented in the form of hardware or software function modules.
- the solution provided by this application obtains the logical expression corresponding to the label query condition according to the label query condition.
- the logical expression includes single-layer or multi-layer logic, and the label query condition includes multiple label conditions.
- a logic tree is generated according to the logic expression, a query statement for querying label data is generated according to the logic tree, and finally the label data is queried from the database corresponding to the label query condition according to the query statement.
- the label query conditions composed of multiple label conditions are parsed into logical expressions, and the logical tree generated by the logical expressions is used to generate query statements and perform label data queries. Since logical expressions can support multiple levels of logic, Therefore, it can meet complex query requirements and improve the accuracy of data query.
- the server 100 may be a server capable of running application programs, such as a traditional server or a cloud server.
- the server 100 in this application may include one or more of the following components: a processor 110, a memory 120, a touch screen 130, and one or more application programs, where one or more application programs may be stored in the memory 120 and configured as Executed by one or more processors 110, one or more programs are configured to execute the methods described in the foregoing method embodiments.
- the processor 110 may include one or more processing cores.
- the processor 110 uses various interfaces and lines to connect various parts of the entire server 100, and executes the server by running or executing instructions, programs, code sets, or instruction sets stored in the memory 120, and calling data stored in the memory 120. 100's various functions and processing data.
- the processor 110 may adopt at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA).
- DSP Digital Signal Processing
- FPGA Field-Programmable Gate Array
- PDA Programmable Logic Array
- the processor 110 may be integrated with one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like.
- the CPU mainly processes the operating system, user interface, and application programs; the GPU is used for rendering and drawing of display content; the modem is used for processing wireless communication. It is understandable that the above-mentioned modem may not be integrated into the processor 110, but may be implemented by a communication chip alone.
- the memory 120 may include random access memory (RAM) or read-only memory (Read-Only Memory).
- the memory 120 may be used to store instructions, programs, codes, code sets or instruction sets.
- the memory 120 may include a program storage area and a data storage area, where the program storage area may store instructions for implementing the operating system and instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.) , Instructions used to implement the following various method embodiments, etc.
- the storage data area can also store data (such as phone book, audio and video data, chat record data) created by the server 100 during use.
- FIG. 9 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
- the computer-readable medium 800 stores program code, and the program code can be invoked by a processor to execute the method described in the foregoing method embodiment.
- the computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
- the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium.
- the computer-readable storage medium 800 has storage space for the program code 810 for executing any method steps in the above-mentioned methods. These program codes can be read from or written into one or more computer program products.
- the program code 810 may be compressed in a suitable form, for example.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请公开了一种数据查询方法、装置、服务器及存储介质,该数据查询方法包括:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;根据所述逻辑表达式,生成逻辑树;根据所述逻辑树,生成用于查询标签数据的查询语句;根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。本方法可以实现复杂场景的数据查询。
Description
本申请涉及数据处理技术领域,更具体地,涉及一种数据查询方法、装置、服务器及存储介质。
随着网络信息技术的快速发展,基于大数据技术的信息推荐技术也应运而生。信息推荐技术中主要依据用户的标签数据而进行相关信息的推荐,在信息推荐中通常会存在业务方对标签数据进行查询,以根据标签数据进行相应的业务。
发明内容
鉴于上述问题,本申请提出了一种数据查询方法、装置、服务器及存储介质。
第一方面,本申请实施例提供了一种数据查询方法,,所述方法包括:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;根据所述逻辑表达式,生成逻辑树;根据所述逻辑树,生成用于查询标签数据的查询语句;根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
第二方面,本申请实施例提供了一种数据查询装置,所述装置包括:表达式生成模块、树生成模块、语句生成模块以及标签查询模块,其中,所述表达式生成模块用于根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;所述树生成模块用于根据所述逻辑表达式,生成逻辑树;所述语句生成模块用于根据所述逻辑树,生成用于查询标签数据的查询语句;所述标签查询模块用于根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
第三方面,本申请实施例提供了一种服务器,包括:一个或多个处理器;存储器;一个或多个应用程序,其中所述一个或多个应用程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行上述第一方面提供的数据查询方法。
第四方面,本申请实施例提供了一种计算机可读取存储介质,所述计算机可读取存储介质中存储有程序代码,所述程序代码可被处理器调用执行上述第一方面提供的数据查询方法。
本申请提供的方案,通过根据标签查询条件,获取标签查询条件对应的逻辑表达式,该逻辑表达式包括单层或多层的逻辑,且标签查询条件包括多个标签条件,然后根据逻辑表达式生成逻辑树,根据逻辑树生成用于查询标签数据的查询语句,最后根据查询语句,从标签查询条件对应的数据库中查询标签数据。从而实现将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于逻辑表达式能够支持多层的逻辑,因此能满足复杂的查询需求,提升数据查询的准确性。
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得 其他的附图。
图1示出了根据本申请一个实施例的数据查询方法流程图。
图2示出了本申请一个实施例提供的逻辑树的一种示意图。
图3示出了本申请一个实施例提供的逻辑树的另一种示意图。
图4示出了根据本申请另一个实施例的数据查询方法流程图。
图5示出了根据本申请又一个实施例的数据查询方法流程图。
图6示出了根据本申请再一个实施例的数据查询方法流程图。
图7示出了根据本申请一个实施例的数据查询装置的一种框图。
图8是本申请实施例的用于执行根据本申请实施例的数据查询方法的服务器的框图。
图9是本申请实施例的用于保存或者携带实现根据本申请实施例的数据查询方法的程序代码的存储单元。
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。
在信息推送中,通常存在业务方对标签数据进行查询的情况,业务方通过查询到的标签数据,可以确定待推送的用户、内容等。例如,业务方在对用户进行圈取时,利用多个标签条件查询相应的用户。
在传统的标签查询的方案中,通常将多个标签条件限制为同一层级,各个标签条件之间的组合逻辑限制为全且逻辑或者全或逻辑,后端合成查询逻辑时先合成各自标签的条件,再将它们组合在同一层,用“且”或者“或”连接,例如,条件1+条件2,条件3/条件4。
发明人经过长期研究发现,随着业务方数量和需求的持续增长,需要圈取的用户群越来越多,业务方在实际使用中的需求点也越来越细致复杂,单层条件组合的逻辑条件已经很难继续满足业务方的用户群圈取需求。例如:某业务方需要对同时安装了应用A和应用B,但是没有安装应用C的用户群进行广告投放,全且全或逻辑将难以实现。
针对上述问题,发明人提出了本申请实施例提供的数据查询方法、装置、服务器以及存储介质,通过根据包括多个标签条件的标签查询条件,获取支持多层逻辑的逻辑表达式,然后根据逻辑表达式生成逻辑树,并根据逻辑树生成查询语句,最后利用查询语句进行标签数据的查询,从而可以满足复杂的业务场景的需求。其中,具体的数据查询方法在后续的实施例中进行详细的说明。
请参阅图1,图1示出了本申请一个实施例提供的数据查询方法的流程示意图。在具体的实施例中,所述数据查询方法应用于如图7所示的数据查询装置400以及配置有所述数据查询装置400的服务器100(图8)。下面将以服务器为例,说明本实施例的具体流程,当然,可以理解的,本实施例所应用的服务器可以为传统服务器、云服务器等,在此不做限定。下面将针对图1所示的流程进行详细的阐述,所述数据查询方法具体可以包括以下步骤:
步骤S110:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件。
在本申请实施例中,服务器对标签查询条件进行解析,以获取标签查询条件对应的逻辑表达式。其中,标签查询条件为约束标签数据的条件,标签查询条件中包括有多个标签条件。当然,标签查询条件中还包括有多个标签条件之间的关系,例如并列关系等。标签条件为对标签数据进行限定的单个条件。例如,业务方想对同时安装了应用1和应用2,但未安装应用3的用户进行广告投放,设置的标签查询条件为同时安 装了应用1和应用2,但未安装应用3的用户;又例如,游戏公司向提升近期的比较活跃的游戏玩家的留存率,想要对近期比较活跃的游戏玩家投放游戏奖励,设置的标签查询条件为最近一周内游戏时长超过24小时或者登陆次数超过10次的用户。当然,具体的标签查询条件可以不作为限定。
在一些实施方式中,标签查询条件可以为业务方发送至服务器,服务器对应接收获得。可以理解的,业务方在需要查询标签数据时,可以通过业务方的电子设备将标签查询条件发送至服务器,以便服务器进行标签数据的查询,并从服务器获取查询得到的标签数据。
在一些实施方式中,标签查询条件也可以预先存储于服务器,服务器在需要查询标签数据时,可以读取该标签查询条件,以进行标签数据的查询。例如,服务器可以针对业务方对标签数据的需求定期返回标签数据至业务方,因此服务器可以将标签查询条件进行存储,然后定期的按照标签查询条件,查询最新的标签数据后,返回标签数据给业务方。又例如,该标签查询条件也可以为服务器本地设置的,服务器可以在查询获得标签数据后,根据标签数据,来进行相应的推送。
在一些实施方式中,服务器对标签查询条件进行解析,解析出其中的多个标签条件以及多个标签条件之间的逻辑关系。然后根据多个标签条件以及多个标签条件之间的逻辑关系,生成逻辑表达式。其中,逻辑关系可以为且、或等。逻辑表达式为逻辑关系对应的运算符与标签条件组成的公式。例如,标签查询条件为安装有应用A或B,且安装有应用C的用户,则逻辑表达式可以为(应用A or应用B)and应用C。当然,服务器具体生成逻辑表达式的方式,以及逻辑表达式的形式可以不作为限定。
在一些实施方式中,逻辑表达式中可以包括单层的逻辑或者多层的逻辑。其中,单层的逻辑指的是仅通过一次逻辑运算即可得到结果的逻辑,例如,A and B;多层的逻辑则指的是需要通过多次的逻辑运算才能得到结果的逻辑,例如,(A or B)and C。多层逻辑可以包括括号分层的显式多层逻辑和无括号的隐式分层逻辑。例如,显示多层逻辑为(((A and B)and C)and D),隐式分层逻辑为A and B or C and D。
步骤S120:根据所述逻辑表达式,生成逻辑树。
在本申请实施例中,服务器在生成逻辑表达式之后,可以根据逻辑表达式,生成逻辑树。其中,逻辑树用于表示逻辑表达式中的标签条件的逻辑关系,标签条件之间的逻辑关系以文本的形式表达。
在一些实施方式中,服务器在根据逻辑表达式生成逻辑树时,如果逻辑表达式中包括单层的逻辑,则可以根据逻辑表达式中各个标签条件之间的逻辑特征,将各个标签条件作为树节点依次进行连接,获得到生成的逻辑树。其中,逻辑特征可以为逻辑连接词、逻辑关系符、逻辑运算符等,在此不做限定。
服务器在根据逻辑表达式生成逻辑树时,如果逻辑表达式中包括多层的逻辑,则可以根据多层的逻辑中的每层逻辑,生成逻辑子树,然后将所有的逻辑子树进行合并,获得逻辑表达式对应的逻辑树。其中,逻辑特征同样可以为逻辑连接词、逻辑关系符、逻辑运算符等,在此不做限定。服务器生成每层逻辑的逻辑子树的方式,可以参考逻辑表达式包括单层的逻辑时,生成逻辑树的方式。
服务器在将所有的逻辑子树进行合并,获得逻辑表达式对应的逻辑树时,可以按照每层逻辑在逻辑表达式中出现的先后顺序,依次将每层逻辑对应逻辑子树作为下一层逻辑对应的逻辑子树中的树节点,进行逻辑子树的合并,从而可以获得该逻辑表达式对应的逻辑树。
其中,每个逻辑子树中均包括至少两个树节点,每个树节点可以为一个标签条件,也可以为某层逻辑的逻辑子树,这样的话,按照以上先后顺序,依次将逻辑子树作为下一层逻辑对应的逻辑子树中的树节点,添加于逻辑子树中,然后再将添加逻辑子树后的逻辑子树添加于下一逻辑子树,直至添加至最后一层逻辑的逻辑子树。例如,逻 辑表达式为(((A and B)and C)and D)时,此时服务器先生成(A and B)的逻辑子树1,(E and C)的逻辑子树2,(F and D)的逻辑子树3,A和B为逻辑子树1的树节点,E和C为逻辑子树2的树结点,F和D为逻辑子树3的树节点,在进行逻辑子树的合成时,将由于第一层逻辑为(A and B),因此,将逻辑子树1作为逻辑子树2中的树节点E,对E进行替代,而添加于逻辑子树2中,然后再将添加了逻辑子树1后的逻辑子树2作为逻辑子树3中的树节点F,从而可以获得最终合成的逻辑树。
在另一些实施方式中,服务器在根据逻辑表达式生成逻辑树时,如果逻辑表达式中包括多层的逻辑,服务器也可以按照每层逻辑在逻辑表达式中出现的先后顺序,依次生成相连接的树节点,从而形成逻辑树。例如,逻辑表达式为(((A and B)and C)and D)时,此时服务器先生成第一层逻辑(A and B)的树节点之后,根据下一层的逻辑,生成C的树节点,并(A and B)的树节点与C的树节点用and进行连接,再根据下一层的逻辑,生成D的树节点,并将此前连接完成的树节点与D用and进行连接,从而获得最终的逻辑树。
在一些实施方式中,逻辑树可以为二叉树,其中,二叉树是每个节点最多有两个子树的树结构。示例性的,逻辑表达式为(((A and B)and C)and D),生成的逻辑树如图2所示。逻辑表达式为A and B or C and D时,生成的逻辑树如图3所示。当然,以上仅为示例,并不代表对具体逻辑树的限定。
通过以上方式生成逻辑树,可以实现对多层复杂逻辑组合有一个既清晰又合理的表达,逻辑树解析成功后,查询条件合成即可迅速清晰的完成,节约人力成本。
步骤S130:根据所述逻辑树,生成用于查询标签数据的查询语句。
在本申请实施例中,服务器在生成逻辑树之后,则可以根据逻辑树,生成用于查询表亲数据的查询语句。在一些实施方式中,服务器可以对逻辑树进行遍历,完成查询语句的合成。具体地,服务器可以根据相应的数据库所采用的查询引擎,来对逻辑树进行遍历,进而生成与该数据库相对应的查询语句。其中,查询语句可以为查询代码,可以用于从相应的数据库中查询数据。
步骤S140:根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
在本申请实施例中,服务器在生成查询语句之后,则可以利用查询语句,从标签查询条件对应的数据库中查询标签数据。其中,标签查询条件对应的数据库为标签查询条件对应的标签数据所在的数据库,例如标签查询条件拥有查询用户帐号的标签数据,则数据库为存储用户帐号的标签数据的数据库。
在一些实施方式中,服务器可以将查询语句发送至标签查询条件对应的数据库,以从该数据库查询相应的标签数据。在另一些实施方式中,数据库也可以在服务器本地,服务器可以直接根据查询语句,从数据库中查询标签数据。
服务器查询获得的标签数据,可以用于发送至业务方,从而满足业务方的标签数据的查询需求。服务器查询获得的标签数据,也可以用于服务器根据标签数据,来进行相应的推送,例如,标签数据为查询到的用户,服务器可以将待推送内容推送至用户,又例如,标签数据为与用户个人习惯相关的数据,服务器可以根据标签数据来确定待推送内容,并将待推送内容推送至用户。当然,具体的使用场景可以不作为限定。
本申请实施例提供的数据查询方法,通过根据标签查询条件,获取标签查询条件对应的逻辑表达式,该逻辑表达式包括单层或多层的逻辑,且标签查询条件包括多个标签条件,然后根据逻辑表达式生成逻辑树,根据逻辑树生成用于查询标签数据的查询语句,最后根据查询语句,从标签查询条件对应的数据库中查询标签数据。从而实现将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于可以生成多层逻辑的逻辑表达式,因此能满足复杂的查询需求,提升数据查询的准确性。当用于人群的圈取时,可以提 高圈取人群的灵活性,对人群的定位更加精准。
请参阅图4,图4示出了本申请另一个实施例提供的数据查询方法的流程示意图。该数据查询方法可应用于上述服务器,下面将针对图4所示的流程进行详细的阐述,所述数据查询方法具体可以包括以下步骤:
步骤S210:根据标签查询条件,获取所述标签查询条件中多个标签条件之间的逻辑特征,所述标签查询条件包括多个标签条件。
在本申请实施例中,服务器在根据标签查询条件,生成逻辑表达式时,可以获取多个标签条件之间的逻辑特征。其中,逻辑特征可以通过对标签查询条件进行特征提取的方式,从标签查询条件中获取逻辑特征。
在一些实施方式中,服务器可以识别标签查询条件中多个标签条件之间的连接词,将连接词作为多个标签条件之间的逻辑特征。具体地,服务器可以识别标签查询条件中的关键词,并从识别的关键词中确定出连接词。其中,服务器可以通过语义识别,识别出标签查询条件中的多个关键词,并从关键词中确定出多个标签条件以及标签条件之间的连接词。例如,标签查询条件为:安装有应用A、应用B或应用C,且安装有D,则可以识别到应用A、应用B、应用C、应用D、或、且,“或”和“且”即为连接词。
在一些实施方式中,服务器在根据标签查询条件,获取标签查询条件对应的逻辑表达式之前,还可以将标签数据的一些信息发送至业务方对应的业务端,以便业务方根据标签数据的信息,来确定标签查询条件。具体地,服务器可以将当前存在的标签对应的关键词集合发送至业务端,关键词集合用于业务端生成标签查询条件;接收业务端返回的标签查询条件。其中,标签对应的关键词集合,可以为反映标签数据的特征的关键词,以供用户知晓有哪些类型的标签数据、标签数据有哪些内容等。
当然,服务器具体发送至业务端的标签数据的信息可以不作为限定,例如,服务器可以提供标签数据选择的页面至业务端,页面中可以包括各个可筛选的标签条件的选项,以及各个选项之间的逻辑关系选择,从而业务端的用户可以通过于页面的操作,而快捷方便的进行标签查询条件的确定。服务器在接收到业务端返回的标签查询条件之后,则可以根据标签查询条件来生成逻辑表达式。
步骤S220:根据所述逻辑特征,生成由所述多个标签条件构成的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑。
在本申请实施例中,服务器在获得标签查询条件中的逻辑特征之后,则可以根据识别到的逻辑特征,来生成由以上多个标签条件构成的逻辑表达式。可以理解的,逻辑特征反映了标签条件之间的逻辑关系,因此可以利用逻辑关系来将标签条件进行组合,从而构成逻辑表达式。
在一些实施方式中,服务器可以根据逻辑特征,确定对应的逻辑关系符,然后根据逻辑关系符,生成由多个标签条件构成的逻辑表达式。其中,逻辑关系符可以为且(and)、或(or)等。由逻辑关系符来对各个逻辑条件进行组合,从而可形成标签查询条件对应的逻辑表达式。
步骤S230:根据所述逻辑表达式,生成逻辑树。
在本申请实施例中,步骤S230可以参阅前述实施例的内容,在此不再赘述。逻辑树可以对多层复杂逻辑组合有一个既清晰又合理的表达,同时非常方便后续使用,对各种查询语言的支持都很好。逻辑树解析成功后,查询条件合成即可迅速清晰的完成,节约人力成本,具体地,逻辑树生成后,对后续的语句合成来说,前端表达和后端合成查询语句就已经很好地完成了解耦,服务器用逻辑树灵活得配合大多数查询引擎合成查询语句。
步骤S240:调用查询引擎。
在本申请实施例中,服务器可以调用相应的查询引擎。其中,查询引擎可以为数 据库对应的查询引擎,可以理解的,不同数据库可能对应的查询引擎不同,其可以识别的查询语句也不同,因此,需要利用查询引擎来合成与数据库相对应的查询语句。
在一些实施方式中,服务器可以确定标签查询条件对应的标签数据所在的数据库。其中,服务器可以根据标签查询条件,确定需要查询的标签数据存储于何个数据库。作为一种方式,服务器可以存储有各个类型的标签数据与数据库的对应关系,服务器根据标签查询条件,可以确定需要查询的标签数据的类型,然后根据以上对应关系,即可确定标签数据所存在的数据库,例如,查询的标签数据类型为移动终端的国际移动设备识别码(IMEI,International Mobile Equipment Identity),则可以确定数据库为存储IMEI的标签数据库。作为另一种实施方式,服务器也可以确定需要查询的标签数据的类型之后,将标签数据的类型发送至各个数据库,并根据各个数据库返回的结果,确定标签数据所存在的数据库,例如,数据库1返回的结果为当前存储有该类型的标签数据,则确定标签数据所存在的数据库为数据库1。
服务器在确定出数据库之后,则可以调用数据库对应的查询引擎。作为一种方式,服务器中可以存储有各个数据与查询引擎的对应关系,并且设置有各个查询引擎,从而服务器可以根据确定出的数据库,确定查询引擎,并调用确定出的查询引擎。
在一些实施方式中,服务器在调用查询引擎之前,还可以确定标签查询条件对应的数据是否都存在于同一数据库,如果标签查询条件对应的数据是存在于同一数据库,则可以使用同一查询引擎来合成查询语句;如果标签查询条件对应的数据不存在于同一数据库,则不可以使用同一查询引擎来合成查询语句。
可以理解的,对于标签查询条件对应的数据存在于同一数据库时,则表示可以于同一数据库进行标签数据查询,因此,可以直接使用该数据库的查询引擎来进行查询语句的合成;而对于标签查询条件对应的数据不存在于同一数据库时,则表示需要从多个数据库中查询标签数据。
进一步地,如果标签查询条件对应的数据不存在于同一数据库时,可以确定标签查询条件中各个标签条件所对应的数据所在数据库,再根据各个标签条件,分别从相应的数据库中查询标签数据,最后再根据以上确定的逻辑特征,对各个标签条件对应的标签数据进行筛选、组合、去重等。
步骤S250:利用所述查询引擎对所述逻辑树进行遍历,获得用于查询标签数据的查询语句。
在本申请实施例中,服务器可以利用查询引擎,对逻辑树进行遍历,获得用于查询标签数据的查询语句。其中,数据库的查询引擎均能实现逻辑树的遍历。具体地,查询引擎可以通过递归的方式对逻辑树进行遍历,根据遍历的结果,将所有标签条件结合在一起,合成为最终的查询语句。
在一些实施方式中,获得的查询语句为数据库对应的查询代码,该查询代码能够被数据库所识别。示例性的,查询语句如以下代码所示:
Select imei
From xxxTable
Where
(abc.bcd.cde.value in(1,2,3)and abc.bcd.edf.weight in(2,3,4))or
(abc.bcd.cde.value in(11,12,13)and abc.bcd.edf.weight in(22,23,24))
步骤S260:根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
在本申请实施例中,步骤S260可以参阅前述实施例的内容,在此不再赘述。
本申请实施例提供的数据查询方法,通过获取标签查询条件中多个标签条件之间的逻辑特征,根据逻辑特征,生成由多个标签条件构成的逻辑表达式,然后根据逻辑 表达式,生成逻辑树,再确定标签查询条件对应的标签数据所在的数据库,调用数据库对应的查询引擎,并利用查询引擎对逻辑树进行遍历,获得用于查询标签数据的查询语句,最后根据查询语句从标签查询条件对应的数据库中查询标签数据。从而实现将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于可以生成多层逻辑的逻辑表达式,因此能满足复杂的查询需求,提升数据查询的准确性。当用于人群的圈取时,可以提高圈取人群的灵活性,对人群的定位更加精准。
请参阅图5,图5示出了本申请又一个实施例提供的数据查询方法的流程示意图。该数据查询方法可应用于上述服务器,下面将针对图5所示的流程进行详细的阐述,所述数据查询方法具体可以包括以下步骤:
步骤S310:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件。
步骤S320:根据所述逻辑表达式,生成逻辑树。
步骤S330:根据所述逻辑树,生成用于查询标签数据的查询语句。
步骤S340:根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
在本申请实施例中,步骤S310至步骤S340可以参阅前述实施例的内容,在此不再赘述。
步骤S350:将所述查询语句进行存储。
在本申请实施例中,服务器可以将以上查询语句进行存储。具体地,服务器可以将以上标签查询条件与获得的查询语句对应起来进行存储。可以理解的,服务器将查询语句进行存储,则后续在根据相同的标签查询条件进行数据查询时,则可以直接利用该查询语句进行查询,提升标签数据的查询速度。
步骤S360:生成所述查询语句的语句标识。
在本申请实施例中,服务器可以生成查询语句的语句标识。语句标识用于作为查询语句的身份标识,语句标识的形式可以不作为限定,可以为任意的字段内容。
步骤S370:将所述标签查询条件与所述语句标识的对应关系发送至业务端。
在本申请实施例中,服务器可以将标签查询条件与语句标识的对应关系发送至业务端。具体地,业务端在需要进行标签数据的查询时,服务器可以该对应关系进行下发,以便业务端根据相应的语句标识来生成查询请求。其中,业务端可以根据输入的标签查询条件,来确定相应的语句标识,并根据语句标识来生成查询请求。
在一些实施方式中,业务端可以在访问标签数据的查询页面时,服务器将标签查询条件与语句标识的对应关系进行下发。其中,业务端在访问标签数据的查询页面时,可以生成该页面的访问请求,当服务器接收到该访问请求时,将以上对应关系发送至业务端。
在一些实施方式中,服务器也可以预先将标签查询条件与语句标识的对应关系发送至业务端,业务端可以对该对应关系进行存储。当业务端的用户需要进行标签查询时,则业务端可以根据输入的标签查询条件,来确定相应的语句标识,并根据语句标识来生成查询请求。
步骤S380:当获取到所述查询语句对应的查询请求时,读取所述查询语句。
在本申请实施例中,服务器在接收到以上查询语句对应的查询请求时,则表示业务端需要以该查询语句来进行标签数据的查询,也就是根据以上标签查询条件来进行标签数据的查询,因此服务器可以直接读取存储的该查询语句,以便利用该查询语句从数据库中查询标签数据。
具体地,服务器可以接收业务端发送的查询请求,然后确定查询请求中是否携带有以上语句标识,如果查询请求中携带有该语句标识,则表示查询请求为该查询语句 对应的查询请求,此时,服务器可以读取查询语句;如果查询请求中携带有该语句标识,则表示查询请求为该查询语句对应的查询请求,此时,服务器可以读取查询语句;如果查询请求中未携带有该语句标识,则表示查询请求不为该查询语句对应的查询请求,此时,服务器根据查询请求中携带的标签查询条件,按照步骤S310至步骤S340的方式来进行标签数据的查询。可以理解的,当业务端根据输入的标签查询条件,确定不存在标签查询条件对应的语句标识,则业务端可以根据标签查询条件来生成查询请求,此时,查询请求中可以携带有标签查询条件。
步骤S390:根据所述查询条件,从所述标签查询条件对应的数据库中查询标签数据。
在本申请实施例中,服务器根据查询条件,从标签查询条件对应的数据库中查询标签数据时,可以将查询语句发送至标签查询条件对应的数据库,然后接收数据库返回的标签数据。在一些实施方式中,服务器通过查询接口将所述查询语句发送至标签查询条件对应的数据库的hive。其中,hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的sql查询功能。Hive的优势在于学习成本低,可以通过类SQL语句快速实现简单的MapReduce统计,不必开发专门的MapReduce应用,十分适合数据仓库的统计分析。数据库的hive接收到所述服务器发送的查询语句后,可以根据查询语句对数据库hive中存储的标签数据进行查询,获取满足标签查询条件的标签数据,并将查找的标签数据返回到服务器。
本申请实施例提供的数据查询方法,通过将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于可以生成多层逻辑的逻辑表达式,因此能满足复杂的查询需求,提升数据查询的准确性。当用于人群的圈取时,可以提高圈取人群的灵活性,对人群的定位更加精准。另外,将查询语句进行存储,并生成查询语句对应的语句标识,将语句标识与标签查询条件的对应关系发送至业务端,方便业务端能够根据语句标识来生成查询请求,而服务器则可以根据查询请求,直接利用存储的查询语句进行标签数据的查询,提升了标签数据的查询速度。
请参阅图6,图6示出了本申请再一个实施例提供的数据查询方法的流程示意图。该数据查询方法可应用于上述服务器,下面将针对图6所示的流程进行详细的阐述,所述数据查询方法具体可以包括以下步骤:
步骤S400:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件。
步骤S401:根据所述逻辑表达式,生成逻辑树。
步骤S402:根据所述逻辑树,生成用于查询标签数据的查询语句。
步骤S403:根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
在本申请实施例中,步骤S400至步骤S403可以参阅前述实施例的内容,在此不再赘述。
步骤S404:将所述逻辑树与所述标签查询条件的对应关系进行存储。
在本申请实施例中,服务器还可以将生成的逻辑树与以上标签查询条件的对应关系进行存储。可以理解的,服务器将逻辑树与以上标签查询条件的对应关系进行存储,则后续在根据包括有该标签查询条件的新的查询条件进行数据查询时,可以直接利用该逻辑树与其他逻辑树进行合成,有效节省数据查询的时间,提升数据查询速度。
步骤S405:获取第一查询条件。
步骤S406:如果所述第一查询条件包括所述标签查询条件以及至少一个第二查询条件,根据所述至少一个第二查询条件,生成第一逻辑树。
在本申请实施例中,服务器在获取到第一查询条件后,可以判断第一查询条件中 是否包括以上标签查询条件以及至少一个第二标签查询条件。如果第一查询条件中包括以上标签查询条件以及至少一个第二标签查询条件,则服务器可以根据标签查询条件的逻辑树,与第二标签查询条件的逻辑树进行合成,来形成新的逻辑树;如果第一查询条件中不包括以上标签查询条件,则服务器可以根据第一标签查询条件来生成逻辑树,并根据逻辑树来生成新的查询语句,根据查询语句从数据库查询标签数据。
在一些实施方式中,如果服务器确定出第一查询条件中包括以上标签查询条件以及至少一个第二标签查询条件,则服务器可以读取该标签查询条件对应的逻辑树,并且根据第二标签查询条件,生成第二标签查询条件对应的第一逻辑树。具体生成第一逻辑树的方式可以参阅前述实施例的内容,在此不再赘述。
步骤S407:将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树。
在本申请实施例中,服务器在生成第一逻辑树之后,则可以根据以上标签查询条件对应的逻辑树与第一逻辑树进行合成,获得第二逻辑树。具体地,服务器可以识别第一查询条件中以上标签查询条件与第二标签查询条件的逻辑关系,然后利用该逻辑关系,来对标签查询条件对应的逻辑树与第一逻辑树进行合成。
在一些实施方式中,服务器在将标签查询条件对应的逻辑树与第一逻辑树进行合成,获得第二逻辑树之前,还可以判断标签查询条件对应的数据库与第二查询条件对应的数据库是否相同。如果标签查询条件对应的数据库与第二查询条件对应的数据库相同,则表示第一查询条件对应的数据均存在于同一数据库时,则表示可以于同一数据库进行标签数据查询,后续可以直接使用该数据库的查询引擎来进行查询语句的合成,因此服务器可以将标签查询条件对应的逻辑树与第一逻辑树进行合成,获得第二逻辑树。
如果标签查询条件对应的数据库与第二查询条件对应的数据库不相同时,则表示第一查询条件对应的数据不存在于同一数据库,此时不能从同一数据库中查询标签数据。该情况下,服务器可以根据第一逻辑树,生成目标查询语句,目标查询语句用于从第二查询条件对应的数据库中查询标签数据。服务器在生成目标查询语句之后,则可以根据目标查询语句,从第二查询条件对应的数据库中查询标签数据。另外,服务器可以根据以上标签查询条件对应的查询语句,从该标签查询条件对应的数据中查询标签数据。在完成标签数据的查询之后,服务器根据根据该标签查询条件与第二查询条件之间的逻辑关系,对标签数据进行筛选、组合、去重等,从而获得最终查询到的标签数据。
步骤S408:根据所述第二逻辑树,生成所述第一查询条件对应的查询语句。
步骤S409:根据所述第一查询条件对应的查询语句,从数据库查询标签数据。
在本申请实施例中,步骤S408以及步骤S409可以参阅前述实施例的内容,在此不再赘述。
通过将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于可以生成多层逻辑的逻辑表达式,因此能满足复杂的查询需求,提升数据查询的准确性。当用于人群的圈取时,可以提高圈取人群的灵活性,对人群的定位更加精准。另外,将逻辑树与以上标签查询条件的对应关系进行存储,则后续在根据包括有该标签查询条件的新的查询条件进行数据查询时,可以直接利用该逻辑树与其他逻辑树进行合成,有效节省数据查询的时间,提升数据查询速度。
请参阅图7,其示出了本申请实施例提供的一种数据查询装置400的结构框图。该数据查询装置400应用上述的服务器,该数据查询装置400包括:表达式生成模块410、树生成模块420、语句生成模块430以及标签查询模块440。其中,所述表达式生成模块410用于根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑 表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;所述树生成模块420用于根据所述逻辑表达式,生成逻辑树;所述语句生成模块430用于根据所述逻辑树,生成用于查询标签数据的查询语句;所述标签查询模块440用于根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
在一些实施方式中,语句生成模块430包括:引擎调用单元,用于调用查询引擎;遍历单元,用于利用所述查询引擎对所述逻辑树进行遍历,获得用于查询标签数据的查询语句。
在该实施方式中,引擎调用单元可以具体用于:确定所述标签查询条件对应的标签数据所在的数据库;调用所述数据库对应的查询引擎。
在该实施方式中,遍历单元可以具体用于:利用所述查询引擎,通过递归的方式对所述逻辑树进行遍历,获得用于查询标签数据的查询语句。
在一些实施方式中,表达式生成模块410可以包括:特征获取单元,用于获取所述标签查询条件中多个标签条件之间的逻辑特征;生成单元,用于根据所述逻辑特征,生成由所述多个标签条件构成的逻辑表达式。
在该实施方式中,生成单元可以具体用于:根据所述逻辑特征,确定对应的逻辑关系符;根据所述逻辑关系符,生成由所述多个标签条件构成的逻辑表达式。
在该实施方式中,特征获取单元可以具体用于:识别所述标签查询条件中多个标签条件之间的连接词,将所述连接词作为所述多个标签条件之间的逻辑特征。
在一些实施方式中,该数据查询装置400还可以包括:第一发送模块以及第一接收模块。第一发送模块用于在所述根据标签查询条件,获取所述标签查询条件对应的逻辑表达式之前,将当前存在的标签对应的关键词集合发送至业务端,所述关键词集合用于所述业务端生成标签查询条件;第一接收模块用于接收业务端返回的标签查询条件。
在一些实施方式中,该数据查询装置400还可以包括:第一存储模块。第一存储模块用于在所述根据所述逻辑树,生成用于查询标签数据的查询语句之后,将所述查询语句进行存储。
在该实施方式中,该数据查询装置400还可以包括:语句读取模块。语句读取模块用于当获取到所述查询语句对应的查询请求时,读取所述查询语句。标签查询模块440还可以用于在读取所述查询语句之后,根据所述查询条件,从所述标签查询条件对应的数据库中查询标签数据。
进一步地,该数据查询装置400还可以包括:语句标识生成模块以及第二发送模块。语句标识生成模块用于在所述当获取到所述查询语句对应的查询请求时,读取所述查询语句之前,生成所述查询语句的语句标识;第二发送模块用于将所述标签查询条件与所述语句标识的对应关系发送至业务端。语句读取模块可以具体用于:接收所述业务端发送的查询请求;如果所述查询请求中携带有所述语句标识,读取所述查询语句。
在一些实施方式中,标签查询模块440可以包括:语句发送单元以及数据接收单元。语句发送单元用于将所述查询语句发送至所述标签查询条件对应的数据库;数据接收单元用于接收所述数据库返回的标签数据。
在该实施方式中,语句发送单元可以具体用于:通过查询接口将所述查询语句发送至所述标签查询条件对应的数据库的hive。
在一些实施方式中,该数据查询装置400还可以包括:第二存储模块。第二存储模块用于在所述根据所述逻辑表达式,生成逻辑树之后,将所述逻辑树与所述标签查询条件的对应关系进行存储。
在一些实施方式中,该数据查询装置400还可以包括:条件获取模块以及树合成模块。条件获取模块用于获取第一查询条件;树生成模块420还用于如果所述第一查 询条件包括所述标签查询条件以及至少一个第二查询条件,根据所述至少一个第二查询条件,生成第一逻辑树;树合成模块用于将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树;语句生成模块430还用于根据所述第二逻辑树,生成所述第一查询条件对应的查询语句。
在该实施方式中,该数据查询装置400还可以包括:数据库判断模块。数据库判断模块用于在将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树之前,判断所述标签查询条件对应的数据库与所述第二查询条件对应的数据库是否相同。如果相同,树合成模块将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树。
进一步地,语句生成模块430还用于在所述判断所述标签查询条件对应的数据库与所述第二查询条件对应的数据库是否相同之后,如果不相同,则根据所述第一逻辑树,生成目标查询语句,所述目标查询语句用于从所述第二查询条件对应的数据库中查询标签数据。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述装置和模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,模块相互之间的耦合可以是电性,机械或其它形式的耦合。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
综上所述,本申请提供的方案,通过根据标签查询条件,获取标签查询条件对应的逻辑表达式,该逻辑表达式包括单层或多层的逻辑,且标签查询条件包括多个标签条件,然后根据逻辑表达式生成逻辑树,根据逻辑树生成用于查询标签数据的查询语句,最后根据查询语句,从标签查询条件对应的数据库中查询标签数据。从而实现将多个标签条件构成的标签查询条件,解析为逻辑表达式,由逻辑表达式生成的逻辑树来生成查询语句,并进行标签数据的查询,由于逻辑表达式能够支持多层的逻辑,因此能满足复杂的查询需求,提升数据查询的准确性。
请参考图8,其示出了本申请实施例提供的一种服务器的结构框图。该服务器100可以是传统服务器、云服务器等能够运行应用程序的服务器。本申请中的服务器100可以包括一个或多个如下部件:处理器110、存储器120、触摸屏130以及一个或多个应用程序,其中一个或多个应用程序可以被存储在存储器120中并被配置为由一个或多个处理器110执行,一个或多个程序配置用于执行如前述方法实施例所描述的方法。
处理器110可以包括一个或者多个处理核。处理器110利用各种接口和线路连接整个服务器100内的各个部分,通过运行或执行存储在存储器120内的指令、程序、代码集或指令集,以及调用存储在存储器120内的数据,执行服务器100的各种功能和处理数据。可选地,处理器110可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器110可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作***、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器110中,单独通过一块通信芯片进行实现。
存储器120可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。存储器120可用于存储指令、程序、代码、代码集或指令集。存储器120可包括存储程序区和存储数据区,其中,存储程序区可存储 用于实现操作***的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储服务器100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
请参考图9,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读介质800中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质800可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质800包括非易失性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质800具有执行上述方法中的任何方法步骤的程序代码810的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码810可以例如以适当形式进行压缩。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。
Claims (20)
- 一种数据查询方法,其特征在于,所述方法包括:根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;根据所述逻辑表达式,生成逻辑树;根据所述逻辑树,生成用于查询标签数据的查询语句;根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
- 根据权利要求1所述的方法,其特征在于,所述根据所述逻辑树,生成用于查询标签数据的查询语句,包括:调用查询引擎;利用所述查询引擎对所述逻辑树进行遍历,获得用于查询标签数据的查询语句。
- 根据权利要求2所述的方法,其特征在于,所述调用目标查询引擎,包括:确定所述标签查询条件对应的标签数据所在的数据库;调用所述数据库对应的查询引擎。
- 根据权利要求2或3所述的方法,其特征在于,所述利用所述查询引擎对所述逻辑树进行遍历,获得用于查询标签数据的查询语句,包括:利用所述查询引擎,通过递归的方式对所述逻辑树进行遍历,获得用于查询标签数据的查询语句。
- 根据权利要求1-4任一项所述的方法,其特征在于,所述逻辑表达式包括多层的逻辑,所述根据所述逻辑表达式,生成逻辑树,包括:根据所述多层的逻辑中的每层逻辑,生成逻辑子树;将所有的逻辑子树进行合并,获得所述逻辑表达式对应的逻辑树。
- 根据权利要求5所述的方法,其特征在于,所述将所有的逻辑子树进行合并,获得所述逻辑表达式对应的逻辑树,包括:按照所述逻辑表达式中每层逻辑的先后顺序,依次将每层逻辑对应逻辑子树作为下一层逻辑对应的逻辑子树中的树节点,进行逻辑子树的合并,获得所述逻辑表达式对应的逻辑树。
- 根据权利要求1-6任一项所述的方法,其特征在于,所述根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,包括:获取所述标签查询条件中多个标签条件之间的逻辑特征;根据所述逻辑特征,生成由所述多个标签条件构成的逻辑表达式。
- 根据权利要求7所述的方法,其特征在于,所述根据所述逻辑特征,生成由所述多个标签条件构成的逻辑表达式,包括:根据所述逻辑特征,确定对应的逻辑关系符;根据所述逻辑关系符,生成由所述多个标签条件构成的逻辑表达式。
- 根据权利要求7或8所述的方法,其特征在于,所述获取所述标签查询条件中多个标签条件之间的逻辑特征,包括:识别所述标签查询条件中多个标签条件之间的连接词,将所述连接词作为所述多个标签条件之间的逻辑特征。
- 根据权利要求1-9任一项所述的方法,其特征在于,在所述根据标签查询条件,获取所述标签查询条件对应的逻辑表达式之前,所述方法还包括:将当前存在的标签对应的关键词集合发送至业务端,所述关键词集合用于所述业务端生成标签查询条件;接收业务端返回的标签查询条件。
- 根据权利要求1-10任一项所述的方法,其特征在于,在所述根据所述逻辑树,生成用于查询标签数据的查询语句之后,所述方法还包括:将所述查询语句进行存储;当获取到所述查询语句对应的查询请求时,读取所述查询语句;根据所述查询条件,从所述标签查询条件对应的数据库中查询标签数据。
- 根据权利要求11所述的方法,其特征在于,在所述当获取到所述查询语句对应的查询请求时,读取所述查询语句之前,所述方法还包括:生成所述查询语句的语句标识;将所述标签查询条件与所述语句标识的对应关系发送至业务端;所述当获取到所述查询语句对应的查询请求时,读取所述查询语句,包括:接收所述业务端发送的查询请求;如果所述查询请求中携带有所述语句标识,读取所述查询语句。
- 根据权利要求1-12任一项所述的方法,其特征在于,所述根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据,包括:将所述查询语句发送至所述标签查询条件对应的数据库;接收所述数据库返回的标签数据。
- 根据权利要求1-13任一项所述的方法,其特征在于,在所述根据所述逻辑表达式,生成逻辑树之后,所述方法还包括:将所述逻辑树与所述标签查询条件的对应关系进行存储。
- 根据权利要求14所述的方法,其特征在于,所述方法还包括:获取第一查询条件;如果所述第一查询条件包括所述标签查询条件以及至少一个第二查询条件,根据所述至少一个第二查询条件,生成第一逻辑树;将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树;根据所述第二逻辑树,生成所述第一查询条件对应的查询语句。
- 根据权利要求15所述的方法,其特征在于,在将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树之前,所述方法还包括:判断所述标签查询条件对应的数据库与所述第二查询条件对应的数据库是否相同;如果相同,执行将所述标签查询条件对应的逻辑树与所述第一逻辑树进行合成,获得第二逻辑树。
- 根据权利要求16所述的方法,其特征在于,在所述判断所述标签查询条件对应的数据库与所述第二查询条件对应的数据库是否相同之后,所述方法还包括:如果不相同,则根据所述第一逻辑树,生成目标查询语句,所述目标查询语句用于从所述第二查询条件对应的数据库中查询标签数据。
- 一种数据查询装置,其特征在于,所述装置包括:表达式生成模块、树生成模块、语句生成模块以及标签查询模块,其中,所述表达式生成模块用于根据标签查询条件,获取所述标签查询条件对应的逻辑表达式,所述逻辑表达式包括单层或多层的逻辑,所述标签查询条件包括多个标签条件;所述树生成模块用于根据所述逻辑表达式,生成逻辑树;所述语句生成模块用于根据所述逻辑树,生成用于查询标签数据的查询语句;所述标签查询模块用于根据所述查询语句,从所述标签查询条件对应的数据库中查询标签数据。
- 一种服务器,其特征在于,包括:一个或多个处理器;存储器;一个或多个应用程序,其中所述一个或多个应用程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行如权利要求1-17任一项所述的方法。
- 一种计算机可读取存储介质,其特征在于,所述计算机可读取存储介质中存储有程序代码,所述程序代码可被处理器调用执行如权利要求1-17任一项所述的方法。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202080094497.1A CN115039090A (zh) | 2020-03-23 | 2020-03-23 | 数据查询方法、装置、服务器及存储介质 |
PCT/CN2020/080690 WO2021189195A1 (zh) | 2020-03-23 | 2020-03-23 | 数据查询方法、装置、服务器及存储介质 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2020/080690 WO2021189195A1 (zh) | 2020-03-23 | 2020-03-23 | 数据查询方法、装置、服务器及存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021189195A1 true WO2021189195A1 (zh) | 2021-09-30 |
Family
ID=77890830
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/080690 WO2021189195A1 (zh) | 2020-03-23 | 2020-03-23 | 数据查询方法、装置、服务器及存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115039090A (zh) |
WO (1) | WO2021189195A1 (zh) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114090627A (zh) * | 2022-01-19 | 2022-02-25 | 支付宝(杭州)信息技术有限公司 | 一种数据查询方法及装置 |
CN114185929A (zh) * | 2022-02-15 | 2022-03-15 | 支付宝(杭州)信息技术有限公司 | 一种获取用于数据查询的可视化配置的方法及装置 |
CN115563385A (zh) * | 2022-10-12 | 2023-01-03 | 中电金信软件有限公司 | 一种组合标签的生成方法及生成装置 |
CN117951281A (zh) * | 2024-03-26 | 2024-04-30 | 上海森亿医疗科技有限公司 | 基于知识图谱的数据库查询语句生成方法、***以及终端 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110099190A1 (en) * | 2009-10-28 | 2011-04-28 | Sap Ag. | Methods and systems for querying a tag database |
CN109766353A (zh) * | 2018-11-30 | 2019-05-17 | 成都四方伟业软件股份有限公司 | 一种基于大数据多维属性动态生成标签的***及工作方法 |
CN109871393A (zh) * | 2019-03-05 | 2019-06-11 | 云南电网有限责任公司信息中心 | 一种基于标签体系的取数方法 |
CN109947788A (zh) * | 2017-10-30 | 2019-06-28 | 北京京东尚科信息技术有限公司 | 数据查询方法和装置 |
US10394823B2 (en) * | 2017-01-04 | 2019-08-27 | International Business Machines Corporation | Detection and utilization of attributes |
-
2020
- 2020-03-23 CN CN202080094497.1A patent/CN115039090A/zh active Pending
- 2020-03-23 WO PCT/CN2020/080690 patent/WO2021189195A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110099190A1 (en) * | 2009-10-28 | 2011-04-28 | Sap Ag. | Methods and systems for querying a tag database |
US10394823B2 (en) * | 2017-01-04 | 2019-08-27 | International Business Machines Corporation | Detection and utilization of attributes |
CN109947788A (zh) * | 2017-10-30 | 2019-06-28 | 北京京东尚科信息技术有限公司 | 数据查询方法和装置 |
CN109766353A (zh) * | 2018-11-30 | 2019-05-17 | 成都四方伟业软件股份有限公司 | 一种基于大数据多维属性动态生成标签的***及工作方法 |
CN109871393A (zh) * | 2019-03-05 | 2019-06-11 | 云南电网有限责任公司信息中心 | 一种基于标签体系的取数方法 |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114090627A (zh) * | 2022-01-19 | 2022-02-25 | 支付宝(杭州)信息技术有限公司 | 一种数据查询方法及装置 |
CN114090627B (zh) * | 2022-01-19 | 2022-05-31 | 支付宝(杭州)信息技术有限公司 | 一种数据查询方法及装置 |
CN114185929A (zh) * | 2022-02-15 | 2022-03-15 | 支付宝(杭州)信息技术有限公司 | 一种获取用于数据查询的可视化配置的方法及装置 |
CN114185929B (zh) * | 2022-02-15 | 2022-11-22 | 支付宝(杭州)信息技术有限公司 | 一种获取用于数据查询的可视化配置的方法及装置 |
CN115563385A (zh) * | 2022-10-12 | 2023-01-03 | 中电金信软件有限公司 | 一种组合标签的生成方法及生成装置 |
CN115563385B (zh) * | 2022-10-12 | 2023-07-28 | 中电金信软件有限公司 | 一种组合标签的生成方法及生成装置 |
CN117951281A (zh) * | 2024-03-26 | 2024-04-30 | 上海森亿医疗科技有限公司 | 基于知识图谱的数据库查询语句生成方法、***以及终端 |
Also Published As
Publication number | Publication date |
---|---|
CN115039090A (zh) | 2022-09-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021189195A1 (zh) | 数据查询方法、装置、服务器及存储介质 | |
WO2021218144A1 (zh) | 数据处理方法、装置、计算机设备及存储介质 | |
US10983815B1 (en) | System and method for implementing a generic parser module | |
CN104252536A (zh) | 一种基于hbase的上网日志数据查询方法及装置 | |
US11494395B2 (en) | Creating dashboards for viewing data in a data storage system based on natural language requests | |
CN111221791A (zh) | 一种多源异构数据导入数据湖的方法 | |
CN108363741B (zh) | 大数据统一接口方法、装置、设备及存储介质 | |
US10901811B2 (en) | Creating alerts associated with a data storage system based on natural language requests | |
CN114356971A (zh) | 数据处理方法、装置以及*** | |
CN111258978A (zh) | 一种数据存储的方法 | |
CN107636655B (zh) | 实时提供数据即服务(DaaS)的***和方法 | |
CN111367873A (zh) | 日志数据的存储方法、装置、终端及计算机存储介质 | |
CN111435376A (zh) | 信息处理方法及***、计算机***和计算机可读存储介质 | |
CN111694866A (zh) | 数据搜索及存储方法、数据搜索***、装置、设备及介质 | |
CN115905630A (zh) | 一种图数据库查询方法、装置、设备及存储介质 | |
CN113220710B (zh) | 数据查询方法、装置、电子设备以及存储介质 | |
CN109597825B (zh) | 规则引擎调用方法、装置、设备及计算机可读存储介质 | |
CN110888672A (zh) | 一种基于元数据架构的表达式引擎实现方法及*** | |
CN114741570A (zh) | 图数据库的查询方法、索引创建方法及相关设备 | |
CN108959294B (zh) | 一种访问搜索引擎的方法和装置 | |
CN112835929A (zh) | 用户管理方法、***及存储介质 | |
CN117171108A (zh) | 一种虚拟模型映射方法和*** | |
CN113761016A (zh) | 数据查询方法、装置、设备及存储介质 | |
CN112307264A (zh) | 数据查询方法和装置、以及存储介质和电子设备 | |
CN107153674B (zh) | 一种直播房间信息展示方法及*** |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20926690 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 28/02/2023) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20926690 Country of ref document: EP Kind code of ref document: A1 |