Data query method based on label definition rule
By configuring tag definition rules and dynamically splicing to generate SQL and NoSQL query statements, the problem of inflexible tag definition rules in the existing technology is solved, flexible and scalable data query is realized, query performance is improved and code duplication is reduced.
Patent Information
- Application Number
- CN202410764689.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-15
AI Technical Summary
Existing tag definition rules are not flexible enough in the context of big data and cannot be customized according to specific application scenarios, resulting in low data query efficiency and poor scalability.
Provide a data query method based on tag definition rules. By configuring string, number and time query rules, dynamically splicing to generate SQL and NoSQL query statements, and querying in different database storage systems, using different design patterns and data visualization methods Display data.
It improves the flexibility and scalability of tag rules, realizes flexible data query, dynamically generates query statements, improves query performance, reduces code duplication, and reduces development and maintenance costs.
Smart Images

Figure CN118779333A_ABST
Abstract
Description
Technical Field
[0001] The invention discloses a method, which relates to the technical field of big data application, and in particular to a data query method based on tag definition rules. Background Art
[0002] With the development of the Internet, the amount of data is constantly growing, and data storage and governance are also constantly changing. In the label system with custom rules in the context of big data, labels are usually used for data query, but the existing label definition rules are not flexible enough and cannot implement custom rules according to specific application scenarios. Therefore, the scalability is poor, which affects the efficiency of data query. Summary of the invention
[0003] In view of the problems of the prior art, the present invention provides a data query method based on tag definition rules, which improves the flexibility and scalability of tag rules and facilitates data query and management.
[0004] The specific scheme proposed by the present invention is:
[0005] The present invention provides a data query method based on tag definition rules, comprising:
[0006] Step 1: Configure tag definition rules:
[0007] Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules,
[0008] Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships;
[0009] Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship;
[0010] Step 2: Dynamically generate the corresponding SQL and NoSQL query statements based on the configured tag definition rules.
[0011] Step 3: Use SQL and NoSQL query statements to query data in different database storage systems.
[0012] Furthermore, in step 13 of the data query method based on tag definition rules, the absolute time day in the query time range is to filter the time day for a certain time field.
[0013] Relative time days use the current time as a reference to filter time days for a certain time in the past or a certain time in the future.
[0014] The relative time day interval uses the current time as a reference to filter predefined conditions for a certain time period in the past or in the future.
[0015] Relative time month uses the current time as a reference to filter the time month for a certain period in the past or a certain period in the future.
[0016] Furthermore, in step 2 of the data query method based on tag definition rules, different design patterns are used to dynamically splice SQL and NoSQL query statements, wherein for the SQL database storage system, the WHERE clause is used to connect multiple query conditions, and the corresponding operator is selected according to the operation type of the tag, and for the NoSQL database storage system, the corresponding query syntax is used according to the characteristics of the database.
[0017] Furthermore, the data query method based on label definition rules also includes step 4, which uses a data visualization method to display data and presents data labels in different colors, graphics and annotations.
[0018] The present invention provides a data query device based on tag definition rules, comprising a configuration module, a query statement generation module and a data query module.
[0019] Configuration module configuration tag definition rules:
[0020] Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules,
[0021] Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships;
[0022] Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship;
[0023] The query statement generation module dynamically generates corresponding SQL and NoSQL query statements based on the configured tag definition rules.
[0024] The data query module uses SQL and NoSQL query statements to query data in different database storage systems.
[0025] Further, in the data query device based on tag definition rules, when the configuration module defines the query time range in step 13, the absolute time day is to filter the time day for a certain time field.
[0026] Relative time days use the current time as a reference to filter time days for a certain time in the past or a certain time in the future.
[0027] The relative time day interval uses the current time as a reference to filter predefined conditions for a certain time period in the past or in the future.
[0028] Relative time month uses the current time as a reference to filter the time month for a certain period in the past or a certain period in the future.
[0029] Furthermore, in the data query device based on label definition rules, a query statement generation module uses different design patterns to dynamically splice SQL and NoSQL query statements. For the SQL database storage system, a WHERE clause is used to connect multiple query conditions, and the corresponding operator is selected according to the operation type of the label. For the NoSQL database storage system, the corresponding query syntax is used according to the characteristics of the database.
[0030] Furthermore, the data query device based on label definition rules also includes a data visualization module, which uses a data visualization method to display data and presents data labels in different colors, graphics and annotations.
[0031] The benefits of the present invention are:
[0032] The present invention provides a data query method based on tag definition rules, which has the following advantages compared with the prior art:
[0033] Flexibility and scalability: This technical solution allows developers to customize tags and query rules according to actual business needs, thereby achieving flexible data query. This flexibility enables the system to adapt to changing needs without the need to frequently modify the code, improving the scalability of the system.
[0034] Dynamically generate query statements: This solution can dynamically convert the query rules defined by tags into SQL and NoSQL query statements. This dynamism allows us to build query statements at runtime and splice the final query statements according to different query conditions, thus achieving highly flexible data query functions.
[0035] Improve query performance: Since this technical solution can dynamically splice query statements and optimize according to actual query conditions, it can avoid unnecessary queries and improve query performance. By accurately defining query rules, the amount of data scanned in the database can be reduced, thereby speeding up the query speed.
[0036] Reduce code duplication: The tag definition rule technology solution allows query logic to be reused in multiple places, avoiding the need to write a large amount of redundant query code. This code reusability reduces the development workload and maintenance costs, making the code easier to maintain and upgrade. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0038] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0039] The present invention provides a data query method based on tag definition rules, comprising:
[0040] Step 1: Configure tag definition rules:
[0041] Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules,
[0042] Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships;
[0043] Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship;
[0044] Step 2: Dynamically generate the corresponding SQL and NoSQL query statements based on the configured tag definition rules.
[0045] Step 3: Use SQL and NoSQL query statements to query data in different database storage systems.
[0046] The method of the present invention improves the flexibility and scalability of label rules, facilitates data governance, etc.: improves the flexibility of label calculation rule definition, and can customize rules according to specific application scenarios. Improves the scalability of labels: the configuration and maintenance of rules can be more convenient, and at the same time has high scalability and maintainability. The present invention can be widely used in many application scenarios, such as label calculation, search engine optimization and other fields.
[0047] In some embodiments of the method of the present invention, the process may be as follows:
[0048] Step 1: Configure tag definition rules:
[0049] Step 11: define the fields to be queried for each query condition, and configure string query rules, wherein string operations are defined, and the string operations include equal, not equal, and fuzzy matching; string connection relationships are defined, and the connection relationships include [and] and [or]; and different string query rules are configured using the string operations and the connection relationships.
[0050] For example, if field1 is equal to value1, or field2 is not equal to value2, or field3 fuzzily matches value3, multiple rules can be configured. Multiple string query conditions can be flexibly combined according to actual needs to make the query more accurate and efficient.
[0051] Step 12: Define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and use the digital operations and the connection relationships to configure different digital query rules.
[0052] For example, if field1 is equal to 1 or field2 is not equal to 2 or field3 is greater than 3 or field4 is less than 4 or field5 is greater than or equal to 5 or field6 is less than or equal to 6 and field7 is in list 3, 4, 5, 6, 7, you can include multiple numeric query conditions in one query to achieve more flexible data filtering.
[0053] Step 13: Define the fields to be queried for each query condition, and configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; different time query rules are configured using the query time range and the connection relationship.
[0054] For example, field1 absolute time day 2023-07-20 or field2 relative time day past / future 3 days within / before / after or field3 relative time day range past / future 3 days to 5 days within / before / after or field4 relative time month past / future 1 month within / before / after In this way, users can easily query data within a specified date range, or query data within a recent period of time.
[0055] Among them, Absolute Time Day is used to filter the time day for a certain time field. For example, if the user wants to count the employees who joined the company on December 1, 2022, he can configure it as [Joining Time][Absolute Time Day][2022-12-01].
[0056] The relative time interval is based on the current time. You can perform advanced filtering on the past or future. For example, if you define a label as a highly active user and require that the user's check-in times from the previous 14 to the previous 7 days are greater than 3 days, then the user will be labeled as [highly active]. You can configure it as follows:
[0057] [Time] [Relative time interval] [Past] [7 days] [to] [14 days] [within] and
[0058] [Sign in][Count][Greater than][3]
[0059] The above rule configuration can calculate and query highly active users and label them as [Highly Active].
[0060] Relative time month is based on the current time. You can filter the time month by [past] or [future]. For example, the platform needs to count the users whose total order transaction amount is greater than 3,000 yuan last month and label them as [Gold Member]. You can configure as follows:
[0061] [Payment time] [Relative time month] [Past] [1 month] [Within] and
[0062] [Order transaction amount][Count][Greater than]
[3000]
[0063] The above rule configuration can calculate and query highly active users and label them as [Gold Member].
[0064] The relative time month is the period from the beginning of the previous month (1st) to the end of the month (30th / 31st).
[0065] Step 2: Dynamically generate the corresponding SQL and NoSQL query statements based on the configured tag definition rules.
[0066] In order to dynamically and efficiently combine SQL and NoSQL statements, the code uses a variety of design patterns, such as factory pattern, strategy pattern, singleton pattern, etc. For SQL databases, you can use the WHERE clause to connect multiple query conditions and select the corresponding operator (such as =, !=, LIKE, >, <, etc.) according to the operation type of the tag. For NoSQL databases, you can use the corresponding query syntax according to the characteristics of the database, such as MongoDB's query operators $eq, $ne, $regex, $gt, $lt, etc.
[0067] Step 3: Use SQL and NoSQL query statements to query data in different database storage systems.
[0068] It may also include step 4, using data visualization methods to display the data, and presenting the data labels in different colors, graphics and annotations.
[0069] It also provides a unified data query interface: By using tags to define rules, different types of query conditions can be unified. Whether it is for strings, numbers or time, they can be defined through the same tags and operations. This can simplify the code implementation of data queries, reduce development complexity, and enhance code readability and maintainability.
[0070] The present invention also provides a data query device based on tag definition rules, including a configuration module, a query statement generation module and a data query module.
[0071] Configuration module configuration tag definition rules:
[0072] Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules,
[0073] Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships;
[0074] Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship;
[0075] The query statement generation module dynamically generates corresponding SQL and NoSQL query statements based on the configured tag definition rules.
[0076] The data query module uses SQL and NoSQL query statements to query data in different database storage systems.
[0077] As the information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.
[0078] Similarly, compared with the prior art, the device of the present invention has the following advantages:
[0079] Flexibility and scalability: This technical solution allows developers to customize tags and query rules according to actual business needs, thereby achieving flexible data query. This flexibility enables the system to adapt to changing needs without the need to frequently modify the code, improving the scalability of the system.
[0080] Dynamically generate query statements: This solution can dynamically convert the query rules defined by tags into SQL and NoSQL query statements. This dynamism allows us to build query statements at runtime and splice the final query statements according to different query conditions, thus achieving highly flexible data query functions.
[0081] Improve query performance: Since this technical solution can dynamically splice query statements and optimize according to actual query conditions, it can avoid unnecessary queries and improve query performance. By accurately defining query rules, the amount of data scanned in the database can be reduced, thereby speeding up the query speed.
[0082] Reduce code duplication: The tag definition rule technology solution allows query logic to be reused in multiple places, avoiding the need to write a large amount of redundant query code. This code reusability reduces the development workload and maintenance costs, making the code easier to maintain and upgrade.
[0083] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0084] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A data query method based on tag definition rules, characterized in that include: Step 1: Configure tag definition rules: Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules, Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships; Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship; Step 2: Dynamically generate the corresponding SQL and NoSQL query statements based on the configured tag definition rules. Step 3: Use SQL and NoSQL query statements to query data in different database storage systems.
2. According to the data query method based on tag definition rules of claim 1, it is characterized in that in step 13, the absolute time day in the query time range is a time day screening for a certain time field, Relative time days use the current time as a reference to filter time days for a certain time in the past or a certain time in the future. The relative time day interval uses the current time as a reference to filter predefined conditions for a certain time period in the past or in the future. Relative time month uses the current time as a reference to filter the time month for a certain period in the past or a certain period in the future.
3. The data query method based on tag definition rules according to claim 1 is characterized in that In step 2, different design patterns are used to dynamically concatenate SQL and NoSQL query statements. For SQL database storage systems, the WHERE clause is used to connect multiple query conditions, and the corresponding operator is selected according to the operation type of the label. For NoSQL database storage systems, the corresponding query syntax is used according to the characteristics of the database.
4. The data query method based on tag definition rules according to claim 1 is characterized in that It also includes step 4, using data visualization methods to display data, and presenting data labels through different colors, graphics and annotations.
5. A data query device based on tag definition rules, characterized in that Including configuration module, query statement generation module and data query module, Configuration module configuration tag definition rules: Step 11: define the fields to be queried for each query condition, configure string query rules, define string operations, the string operations include equal, not equal and fuzzy matching; define string connection relationships, the connection relationships include [and] and [or]; use the string operations and the connection relationships to configure different string query rules, Step 12: define the fields to be queried for each query condition, and configure digital query rules, wherein digital operations are defined, and the digital operations include equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, and in a list; define connection relationships for digital queries, and the connection relationships include [and] and [or]; and configure different digital query rules using the digital operations and the connection relationships; Step 13: define the fields to be queried for each query condition, configure time query rules, wherein the query time range is defined, including absolute time day, relative time day, relative time day interval and relative time month, and the connection relationship of the time query is defined, wherein the connection relationship includes [or]; configure different time query rules using the query time range and the connection relationship; The query statement generation module dynamically generates corresponding SQL and NoSQL query statements based on the configured tag definition rules. The data query module uses SQL and NoSQL query statements to query data in different database storage systems.
6. The data query device based on tag definition rules according to claim 5, characterized in that When the configuration module defines the query time range in step 13, the absolute time day is to filter the time day for a certain time field. Relative time days use the current time as a reference to filter time days for a certain time in the past or a certain time in the future. The relative time day interval uses the current time as a reference to filter predefined conditions for a certain time period in the past or in the future. Relative time month uses the current time as a reference to filter the time month for a certain period in the past or a certain period in the future.
7. The data query device based on tag definition rules according to claim 5 is characterized in that The query statement generation module uses different design patterns to dynamically splice SQL and NoSQL query statements. For SQL database storage systems, the WHERE clause is used to connect multiple query conditions, and the corresponding operator is selected according to the operation type of the label. For NoSQL database storage systems, the corresponding query syntax is used according to the characteristics of the database.
8. The data query device based on tag definition rules according to claim 5 is characterized in that It also includes a data visualization module, which uses data visualization methods to display data and presents data labels through different colors, graphics and annotations.
Citation Information
Patent Citations
Data query method and system thereof
CN101446965A
Data query method and device
CN109947788A
Json key value-based universal method for analyzing sql and nosql
CN112667662A
Configurable label processing system, method and device
CN112989142A
Data acquisition method and device based on visual configuration
CN115168482A
