Data query method and system, electronic equipment and storage medium

The data nodes are determined in the distributed database through fuzzy query method, which solves the problem of inefficient query caused by the second-level shard key, optimizes the query process, reduces resource consumption, and improves query efficiency and system performance.

CN118939704APending Publication Date: 2024-11-12JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411114433.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In distributed databases, data query efficiency and invalid performance overhead caused by secondary shard keys, especially due to the inability to directly locate data nodes, resulting in traversing all nodes that may contain data, consuming a lot of time and computing resources.

Method used

The fuzzy query method is adopted to receive data query requests, obtain fuzzy query conditions, determine the data node that meets the conditions, and send the query request to the node for data query operations, reducing large-scale secondary calculations and reducing communication and computing resource consumption.

Benefits of technology

The query process is optimized, the computing burden of data nodes is reduced, the communication and computing resource consumption of distributed systems is reduced, and the query efficiency and system performance are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939704A_ABST
    Figure CN118939704A_ABST
Patent Text Reader

Abstract

The invention relates to a data query method and system, electronic equipment and a storage medium. The method comprises the following steps: receiving a data query request; obtaining a fuzzy query condition corresponding to the data query request; based on a data query request, determining a first data node meeting the fuzzy query condition in a distributed database; the data query request is sent to a first data node, so that the first data node responds to the data query request to execute data query operation; and receiving a data query result returned by the first data node, and sorting the data query result to obtain a target query result. According to the method, the query process is optimized through fuzzy query, the issuing data nodes are selected, and then the data query operation is performed on the data nodes, so that large-scale secondary calculation on the data nodes is avoided, the calculation burden of the data nodes is reduced, and the communication overhead and the calculation resource consumption in the distributed system are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data query method, system, electronic device and storage medium. Background Art

[0002] The query operation is undoubtedly one of the most common and most frequent types of operations in a database management system. When executing a query, it is necessary to filter the data according to certain filtering conditions to obtain the required information.

[0003] However, in some specific cases, when the filter condition involves the secondary shard key, this problem becomes more complicated. The secondary shard key further disperses the data in each node group to specific nodes. When querying data based on the secondary shard key, due to the finer granularity of the secondary shard key, it is impossible to directly locate a specific data node. It is necessary to traverse all nodes that may contain the required data. The traversal process consumes a lot of time and computing resources, resulting in poor performance. In addition, since the actual data node may not contain any data, this query operation will also cause invalid performance overhead, further reducing the performance of the system.

[0004] Therefore, there is an urgent need to develop a data query method, system, electronic device and storage medium to solve one or more of the above-mentioned problems. Summary of the invention

[0005] In view of this, in order to solve the above technical problems or part of the technical problems, an embodiment of the present invention provides a data query method, system, electronic device and storage medium.

[0006] In a first aspect, the present application provides a data query method, which is applied to a distributed database, and the method comprises:

[0007] Receive a data query request, where the data query request is used to query node data in a distributed database;

[0008] Obtaining the fuzzy query condition corresponding to the data query request;

[0009] Based on the data query request, determining a first data node in the distributed database that meets the fuzzy query condition;

[0010] Sending the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request;

[0011] The data query result returned by the first data node is received, and the data query result is sorted to obtain a target query result.

[0012] In a possible implementation manner, determining the first data node in the distributed database that meets the fuzzy query condition includes:

[0013] Determine the target data shards for the distributed database;

[0014] Obtain node data of all data nodes in the target data shard;

[0015] A data node in the target data shard that meets the fuzzy query condition is selected as the first data node.

[0016] In a possible implementation, the obtaining the fuzzy query condition corresponding to the data query request includes:

[0017] Obtain the query keyword corresponding to each query dimension of the data query request, and determine the matching condition corresponding to each query keyword;

[0018] Using the matching conditions corresponding to each query dimension, construct the fuzzy query conditions corresponding to the data query request.

[0019] In a possible implementation, determining a target data shard of a distributed database includes:

[0020] Get the sharding rules of the distributed database;

[0021] Based on the sharding rule, a target data shard in the distributed database corresponding to the data query request is determined.

[0022] In a possible implementation, the sorting of the data query results to obtain target query results includes:

[0023] Using the query weight of each query dimension of the data query request, the query matching degree of the data node corresponding to the data query result is obtained;

[0024] According to the query matching degree, the data query results are sorted to obtain the target query results.

[0025] In a possible implementation, the using the query weight of each query dimension of the data query request to obtain the query matching degree of the data node corresponding to the data query result includes:

[0026] Obtaining query dimensions of data nodes corresponding to the data query result that satisfy fuzzy query conditions;

[0027] Obtaining a query weight corresponding to the query dimension;

[0028] Based on the query weight, the query matching degree of the data node is obtained.

[0029] In a possible implementation manner, before the first data node performs a data query operation in response to the data query request, the method further includes:

[0030] Obtaining a data query range corresponding to the data query request in the distributed database;

[0031] Determining whether the node data of the first data node exceeds the data query range;

[0032] When the node data of the first data node exceeds the data query range, the data query operation of the first data node is stopped.

[0033] In a second aspect, the present application provides a data query system, the system comprising:

[0034] A receiving module, used to receive a data query request, wherein the data query request is used to query node data in a distributed database;

[0035] A first acquisition module, used to acquire the fuzzy query condition corresponding to the data query request;

[0036] A second acquisition module, configured to determine, based on the data query request, a first data node in the distributed database that satisfies the fuzzy query condition;

[0037] A query module, configured to send the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request;

[0038] The sorting module is used to receive the data query result returned by the first data node, and sort the data query result to obtain the target query result.

[0039] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data query method described in any one of the embodiments of the first aspect when executing the computer program.

[0040] In a fourth aspect, the present application further provides a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the data query method described in any one of the embodiments of the first aspect are implemented.

[0041] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application first optimizes the query process through fuzzy query, selects and sends data nodes, and then performs data query operations on the data nodes, thereby avoiding large-scale secondary calculations on the data nodes, which not only reduces the computing burden of the data nodes, but also reduces the communication overhead and computing resource consumption within the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0044] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0045] Figure 1 A flowchart of a data query method provided in an embodiment of the present application;

[0046] Figure 2 A flowchart of another data query method provided in an embodiment of the present application;

[0047] Figure 3 An example query diagram provided for an embodiment of the present application;

[0048] Figure 4 A schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0049] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0051] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0052] In order to solve the problem that when the field of the filtering condition is a secondary sharding key, it is impossible to accurately locate the specific data node, resulting in low efficiency of group operations and bringing additional performance overhead, including the invalidation of data nodes, the present application proposes a data query method, system, electronic device and storage medium. The computing node will query the sub-sharding key by fuzzy routing, and send the query result to the data node, and then perform a secondary calculation on the query result, and upload the calculated result to the client, which can effectively avoid the overhead of sending the whole node, thereby realizing the query scenario performance optimization of multi-level sharding tables, and greatly improving the query efficiency of large data, reducing the consumption of resources such as CPU and memory, and further improving the performance of the query system.

[0053] Figure 1 A flow chart of a data query method provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the method specifically includes:

[0054] S101, receiving a data query request, wherein the data query request is used to query node data in a distributed database

[0055] In a distributed database, data is stored on multiple data nodes, which may be distributed in different physical locations or even on different computer networks. Therefore, in order to obtain the required data, it is necessary to send a query request to the distributed database and specify the data node to be queried; when the data query request is received, the system will query the corresponding node according to the content of the request and return the query results to the requester.

[0056] In this embodiment, a data query request sent by a client or a query end is received, and the data query request is used to instruct to obtain data information of each node in the distributed database.

[0057] S102: Obtaining the fuzzy query condition corresponding to the data query request

[0058] Fuzzy query of database is a powerful data retrieval tool that allows to retrieve data based on partial matching or uncertain query conditions. This query method is very useful when dealing with uncertain or incomplete information. For example, the keywords entered by the user may be misspelled or only remember part of the information. Using fuzzy query can obtain multiple possible matches related to the user's intention.

[0059] In this embodiment, in order to optimize the query process and reduce the computing burden of data nodes, the data query request is first parsed to extract the corresponding fuzzy query conditions, including partial keywords, range intervals, regular expressions, etc., for preliminary screening in the distributed database.

[0060] Specifically, the purpose and scope of the query can be determined by analyzing the keywords and semantics in the data request to construct fuzzy query conditions, such as keywords including nouns, verbs, and adjectives, and then the constructed fuzzy query conditions are applied to the data query request.

[0061] S103, based on the data query request, determining a first data node in the distributed database that meets the fuzzy query condition;

[0062] In order to respond to data query requests, after obtaining the fuzzy query conditions, the fuzzy query conditions will be further analyzed, and the sharding strategy of the distributed database (such as hash sharding, range sharding, or list sharding, etc.) will be used to determine which data nodes may contain data that meets these conditions.

[0063] Specifically, the keywords in the query request are analyzed to extract key words that can represent the query conditions, such as time range, geographic location, specific attributes, etc. Subsequently, these keywords are compared with the data of each data node in the distributed database to determine whether the data of each data node meets the requirements of the fuzzy query. During the comparison process, the system will take into account the characteristics of fuzzy queries, that is, the query conditions may have certain uncertainties. It will not only check whether the data in the data node completely matches the query conditions, but also perform certain fuzzy processing on the data, such as expanding the context of the time range, considering the surrounding areas of the geographic location, and similarity analysis of specific attributes. Through the above methods, data nodes that meet the fuzzy query conditions can be identified more accurately; the query range can be narrowed by screening data nodes to avoid unnecessary data nodes from being queried, thereby improving query efficiency.

[0064] S104: Send the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request;

[0065] In this embodiment, after determining the first data node, the data query request is sent to the first data node. After receiving the query request, the first data node will search and query the data in the data node according to its own storage structure and index mechanism, quickly locate and retrieve data records that meet the query conditions, so that the data query is more accurate, the overall data retrieval efficiency is optimized, and it is ensured that the data query task can be completed accurately and effectively in a shorter time.

[0066] S105: Receive the data query result returned by the first data node, and sort the data query result to obtain a target query result.

[0067] In this embodiment, when each data node completes the query task, it will return the query results to the computing node. After receiving the query results from the data node, the computing node uses a merge and sort algorithm to centrally process and organize the scattered query results, merge them into an ordered query result list through a merge and sort processing method, and report the final query results obtained through processing to the client application.

[0068] The data query method provided in this embodiment, when the system receives a data query request, first identifies and obtains the fuzzy query condition corresponding to the request, then locates the data node that meets the condition in the distributed database according to the fuzzy query condition, and sends the data query request to the data node. After receiving the query request, the data node searches the data stored thereon to find the record that matches the query condition, and feeds back the matching record to the computing node. After receiving the query result returned by the first data node, the computing node further sorts the results, ensuring that the query results can be presented in a specific order, so that the user can understand the query result more intuitively and easily. The data query process first determines the data node that meets the fuzzy query condition, and then performs a data query operation on the data node, thereby avoiding large-scale secondary calculations on the data node, which not only reduces the computing burden of the data node, but also reduces the communication overhead and computing resource consumption within the distributed system.

[0069] Figure 2 A flowchart of another data query method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the method specifically includes:

[0070] S201, determining the target data shard of the distributed database;

[0071] Distributed databases distribute data to different data shards in a reasonable manner, so as to achieve efficient data storage, query and management in a distributed environment. By distributing data on multiple nodes, the access speed of data can be effectively improved, and the database can also be easily expanded. When performing data sharding, multiple factors need to be considered, including data distribution strategy, shard size, load balancing of data access, etc.

[0072] In this embodiment, a sharding strategy of a distributed database is first determined, and then a target data shard of the distributed database is determined according to the sharding strategy and a target query object of the data query.

[0073] S202, obtaining node data of all data nodes in the target data shard;

[0074] Data sharding is a technology that distributes and stores large data sets across multiple nodes, which improves data reading and writing efficiency and system scalability.

[0075] In this embodiment, after determining the target data shard, it is necessary to further identify the data nodes contained in the shard; the data node is the basic unit for storing data, and each data node is responsible for storing and processing a part of the data. In a distributed database, the data nodes may be distributed in different physical locations, and communicate and work together through the network; obtain node data from each data node.

[0076] S203: Select a data node in the target data shard that meets the fuzzy query condition as the first data node.

[0077] In this embodiment, data nodes that meet the fuzzy query conditions are selected from the target data shards, and such data nodes are defined as first data nodes. Accurate data query results are obtained by performing in-depth data queries on the first data nodes.

[0078] Specifically, we first analyze the keywords in the fuzzy query conditions and determine the fuzzy matching rules for these keywords. We then traverse the data nodes in the data shards according to the matching rules, compare the similarity between the data content of each data node and the query conditions, and screen out the data nodes that meet the fuzzy query conditions. After screening out the data nodes that preliminarily meet the conditions, the system can also ensure the integrity and consistency of the node data through a data verification algorithm.

[0079] In another optional solution of the embodiment of the present invention, after determining the first data node, performing node data verification includes but is not limited to the following steps:

[0080] Step 1: Perform data integrity check on the selected data nodes. Ensure that there are no missing data records in each data node and that the necessary fields of each record are correctly filled.

[0081] Step 2: Perform consistency check on data nodes. Compare the records of the same data in different data nodes to ensure that they are consistent in key fields, such as timestamps, IDs, etc., to avoid data redundancy or inconsistency.

[0082] Step 3: Optimize the data verification algorithm. Improve the efficiency of the data verification process and reduce the impact on system performance by establishing indexes, caching mechanisms, or preprocessing data.

[0083] Step 4: During the data verification process, if a data node is found to have integrity or consistency issues, the system will automatically trigger the data repair process, which may include copying data from other data nodes, restoring using historical backup data, or performing data inference according to preset rules.

[0084] Step 5: Record data verification results and repair operation logs. These logs will be used for subsequent data audits and analysis to help system administrators understand the problems and repair measures in the data verification process for further optimization and adjustment.

[0085] Through the above data verification steps, the data query method can not only ensure the accuracy of the query results, but also ensure the integrity and consistency of the data, thereby providing users with more reliable and high-quality data query services.

[0086] The data query method provided in this embodiment first determines the target data shard from the distributed database, then obtains the node data of all data nodes in the target data shard, obtains the matching status of the data node and the fuzzy query condition through keyword matching processing of the node data and the fuzzy query condition, selects the data node that meets the fuzzy query condition as the first data node, and after selecting the first data node, performs in-depth query processing on the node data in these nodes; while ensuring the accuracy of the query results, it helps to further narrow the query scope involved in the data query operation, thereby greatly improving the efficiency of data query; it can also quickly find the required data in the distributed database, improving the overall query speed and system performance.

[0087] Figure 3 The query example diagram provided in the embodiment of the present application is as follows: Figure 3 As shown, the hierarchical sharding table includes the first-level partition data: city, and the second-level hierarchical data: region; the corresponding first-level sharding key city; the second-level sharding key district.

[0088] Distributed database T1 {id, city, district}

[0089] (case when city = "Nanjing" then

[0090] (case when district = "Gulou District" then g1

[0091] case when district = "Yuhuatai District" then g2

[0092] case when district = "Jianye District" then g3)

[0093] case when city = "Nanjing" then

[0094] (case when district = "Tianxin District" then g4

[0095] case when district = "Yuhuatai District" then g5

[0096] case when district = "Furong District" then g6)

[0097] case when city = "Nanjing" then

[0098] (case when district = "Weiyang District" then g7

[0099] case when district = "Chang'an District" then g8

[0100] case when district = "Xincheng District" then g9 end)

[0101] end)

[0102] That is, the data nodes are as follows:

[0103] Nanjing Gulou District: g1; Nanjing Yuhuatai District: g2; Nanjing Jianye District: g3;

[0104] Changsha Tianxin District: g4; Changsha Yuhuatai District: g5; Changsha Furong District: g6;

[0105] Xi'an Weiyang District: g7; Xi'an Chang'an District: g8; Xi'an Xincheng District: g9.

[0106] Parse the query statement type: select id from T1 where district = Yuhuatai District order by 1;

[0107] The sample steps for data query are as follows:

[0108] Step 1: Obtain the sharding rules of T1. The present invention focuses on processing multi-level sharding rules, and the sharding rules include but are not limited to city and district fields.

[0109] Step 2: Match the data node list (g2, g5) that meets the fuzzy query conditions based on the secondary shards of T1.

[0110] Step 3: Send the query syntax select id from T1 where district = Yuhua District order by 1 to the g2 and g5 data nodes in parallel.

[0111] Step 4: After receiving the query results returned by each data node, the computing node uses merge sort to process the results returned by the G2 / G5 data node.

[0112] Step 5: Report the query results obtained by the computing node to the client application.

[0113] In an optional solution of the embodiment of the present invention, the obtaining of the fuzzy query condition corresponding to the data query request includes:

[0114] Obtain the query keyword corresponding to each query dimension of the data query request, and determine the matching condition corresponding to each query keyword;

[0115] In this embodiment, in order to effectively process the data query request, it is first necessary to obtain the query keywords corresponding to each query dimension, that is, the specific content that the user wants to query in each specific dimension. For example, if the query dimensions include time, place, and product category, the time range, specific location, and product category keywords that the user wants to query must be determined accordingly. Then clarify the matching conditions corresponding to each query keyword, that is, the rules followed when searching for data matching the query keyword in a database or data set. The matching conditions may include multiple types such as exact matching, fuzzy matching, and range matching. For example, if the query keyword is "2023", then the matching condition may be to find all data records within 2023; if the query keyword is "Beijing", then the matching condition may be to find all data records related to Beijing.

[0116] By clarifying the query keywords and their corresponding matching conditions for each query dimension, the accuracy and efficiency of data query requests can be ensured, thereby providing users with more accurate and faster data query results.

[0117] Using the matching conditions corresponding to each query dimension, construct the fuzzy query conditions corresponding to the data query request.

[0118] In this embodiment, by analyzing the matching conditions corresponding to each query dimension, a corresponding data query request is further constructed, and appropriate fuzzy query conditions are set for each dimension so that various query requirements can be flexibly handled. The fuzzy query conditions are used to ensure greater flexibility and adaptability in the data retrieval process, thereby ensuring the accuracy and comprehensiveness of the query results.

[0119] Exemplarily, constructing the fuzzy query condition corresponding to the data query request includes the following steps:

[0120] Step 1: Analyze the keywords in the query request and determine the semantic meaning of the keywords and their role in the query. For example, keywords may be specific values, text strings, date ranges, etc., and may be used as filtering conditions, sorting criteria, or grouping criteria in the query.

[0121] Step 2: Based on the analysis results, map the keywords to the fields in the database to determine the fields that each keyword needs to match. For example, if the keyword is "2023", it may need to be mapped to the date field; if the keyword is "Beijing", it may need to be mapped to the location field.

[0122] Step 3: When constructing fuzzy query conditions, consider the query priority and logical relationship. For example, if the user queries "2023" and "Beijing" at the same time, construct a query statement containing the two conditions and determine the logical relationship between them (such as AND or OR) according to user needs.

[0123] Step 4: Generate a query statement suitable for distributed database query using the constructed fuzzy query condition. The query statement generation process includes query statement optimization to ensure efficient execution of the query in a distributed environment.

[0124] Step 5: Send the generated query statement to the corresponding data node for processing. In a distributed database, the query statement may need to be executed in parallel on multiple nodes to make full use of distributed computing resources and improve query efficiency.

[0125] Step 6: Aggregate and process the results returned by each data node to generate the final query results, including sorting, filtering, and aggregating the results to meet the specific needs of users.

[0126] Through the above steps, data query requests containing fuzzy query conditions can be effectively processed, which not only improves the flexibility and adaptability of the query, but also ensures the accuracy and comprehensiveness of the query results. At the same time, by reasonably allocating query tasks in the distributed database, the efficiency of data query and the performance of the system are significantly improved.

[0127] In an optional solution of the embodiment of the present invention, determining the target data shard of the distributed database includes:

[0128] Get the sharding rules of the distributed database;

[0129] In a distributed database system, the sharding rules determine how data is distributed among multiple nodes. In the process of obtaining data distribution rules, it is usually necessary to have a deep understanding of the database architecture and configuration;

[0130] Specifically, you need to access the database management interface or use the API it provides to query the sharding strategy. This process involves executing specific commands or calling specific interfaces to obtain key information such as sharding keys, sharding methods, and sharding mappings.

[0131] In addition, after obtaining the sharding rules of the database, you need to ensure that the data sharding rules are compatible with the query program. Specifically, you need to properly handle the sharding logic in the application code to ensure that data requests can be correctly routed to the corresponding nodes. This process involves modifying the database connection string, writing sharding key generation logic, or using specific database driver functions.

[0132] Based on the sharding rule, a target data shard in the distributed database corresponding to the data query request is determined.

[0133] In this embodiment, the target data shard corresponding to a specific data query request in the distributed database system is identified and determined according to the upper sharding rule, and the specific data fragment stored in the distributed database is accurately located, thereby efficiently responding to the user's query needs.

[0134] Through the above steps, the target data shard corresponding to the specific data query request in the distributed database is determined based on the distributed database sharding rule, ensuring that the query request is sent to the correct node or node set containing the required data, thereby improving query efficiency and reducing unnecessary data retrieval operations.

[0135] In an optional solution of the embodiment of the present invention, the step of sorting the data query results to obtain target query results includes:

[0136] Using the query weight of each query dimension of the data query request, the query matching degree of the data node corresponding to the data query result is obtained;

[0137] In this embodiment, the data query results are processed by analyzing the query weight of each query dimension to determine the data nodes that match the query conditions. This process includes evaluating the degree of match between each data node and the query conditions, thereby screening out the results that best meet the query requirements. In this way, the accuracy and relevance of the query results can be ensured, and the efficiency and quality of data retrieval can be improved.

[0138] Exemplarily, obtaining the query matching degree of the data node includes the following steps:

[0139] Step 1: Assign a weight value to each query dimension, which reflects the importance of each dimension in the query. For example, if the query keyword is "2023" and this time range is the core condition of the query, a higher weight value can be assigned to it.

[0140] Step 2: Based on the results returned by each data node, calculate the comprehensive matching degree of each node. For example, this can be achieved by multiplying the matching degree of each dimension by the corresponding weight value and then adding the weighted matching degrees of all dimensions.

[0141] Step 3: Sort the data nodes according to the calculated comprehensive matching degree so that the data nodes with the highest matching degree are placed at the front, thereby ensuring that the final query results first display the data that best meets the user's needs.

[0142] Step 4: The sorted results may be further processed, for example, filtering or adjusting the display order of the results according to specific business logic or user preferences.

[0143] Step 5: Return the sorted and processed results to the user to ensure that the user can intuitively see the data that best matches the query conditions, thereby improving user experience and data retrieval efficiency.

[0144] Through the above steps, it can be ensured that the sorting processing of data query results not only takes into account the weight of each query dimension, but also can effectively sort according to the matching degree of data nodes, so as to obtain target query results that are both accurate and meet user needs, which can significantly improve the efficiency and quality of data retrieval.

[0145] According to the query matching degree, the data query results are sorted to obtain the target query results.

[0146] In this embodiment, each data item is sorted according to the degree of match between it and the query conditions, and data items that highly match the query conditions are displayed first, while data items with lower matching degrees are placed at the end. This not only improves the relevance of the query results, but also helps users find the information they need more quickly, thereby improving the overall query experience.

[0147] Exemplarily, sorting the data query results to obtain the target query results includes the following steps:

[0148] Step 1: Assign a dimension score to each data item, which reflects the query weight of the query dimension of the data item. The higher the query weight, the higher its dimension score, indicating that its information is more likely to meet the user's current needs.

[0149] Step 2: Combine the importance scores of the data items to generate a comprehensive score for each data item. The importance score can be determined based on factors such as the business impact of the data item, user preferences, or historical query behavior. The higher the comprehensive score, the more important the data item is in meeting user needs.

[0150] Step 3: Weighted combination of the dimension score and comprehensive score of the data item to generate the final ranking score. In this way, it can be ensured that users can not only obtain data items that highly match the query conditions, but also these data items are the query results with the most important dimensions and the most important requirements.

[0151] Step 4: Sort the data query results according to the final ranking score to ensure that users see the most important query results first, which helps users quickly capture key information and improve decision-making efficiency.

[0152] In addition, an adjustable sorting option is provided in the user interface, allowing users to adjust the weight of the query dimension importance according to personal needs, so that users can flexibly obtain the query results that best meet their expectations based on different usage scenarios and needs.

[0153] Through the above steps, this embodiment not only considers the matching degree between the data items and the query conditions, but also comprehensively considers the importance of the data, thereby providing users with a more comprehensive and personalized query result sorting scheme, which not only improves the relevance and accuracy of the query results, but also enhances the user experience, allowing users to obtain the required data query results more efficiently.

[0154] In an optional solution of the embodiment of the present invention, the query weight of each query dimension of the data query request is used to obtain the query matching degree of the data node corresponding to the data query result, including:

[0155] Obtaining query dimensions of data nodes corresponding to the data query result that satisfy fuzzy query conditions;

[0156] Obtaining a query weight corresponding to the query dimension;

[0157] Based on the query weight, the query matching degree of the data node is obtained.

[0158] In this embodiment, the data query results are first analyzed to determine which data nodes meet the set fuzzy query conditions, where the query dimensions may include but are not limited to keywords, attributes, tags or other relevant features. After the data nodes that meet the fuzzy query conditions are determined, the query weights corresponding to these query dimensions are further obtained, and the importance of each query dimension when matching data is obtained through the query weights; finally, based on the obtained query weights, the query matching degree of each data node is calculated.

[0159] It should be noted that the query weight can be pre-set or dynamically adjusted according to the actual situation of the query process. The query weight will directly affect the final query matching degree. In the process of query matching degree calculation, the weight of each query dimension and the performance of the data nodes in these dimensions are comprehensively considered to obtain a relatively objective evaluation, so as to determine which data nodes meet the query requirements and ensure that the matching degree evaluation of the data nodes is based on comprehensive considerations of multiple dimensions, thereby providing more comprehensive and accurate query results.

[0160] In an optional solution of the embodiment of the present invention, before the first data node performs a data query operation in response to the data query request, the method further includes:

[0161] Obtaining a data query range corresponding to the data query request in the distributed database;

[0162] Determining whether the node data of the first data node exceeds the data query range;

[0163] When the node data of the first data node exceeds the data query range, the data query operation of the first data node is stopped.

[0164] In this embodiment, the specific data query range corresponding to the data query request is determined in the distributed database system, including the time range, spatial range and other possible screening conditions of the data, and then the node data in the first data node is checked to determine whether the data exceeds the previously determined data query range. If it is found through judgment that the node data in the first data node does exceed the data query range, further data query operations are stopped on the data node to avoid obtaining irrelevant or inaccurate data, ensure the accuracy and reliability of the query results, and effectively optimize the query efficiency and reduce unnecessary calculations and resource consumption.

[0165] Figure 4 A schematic diagram of a data query device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the device specifically includes:

[0166] The receiving module 401 is used to receive a data query request, where the data query request is used to query node data in a distributed database;

[0167] A first acquisition module 402 is used to acquire a fuzzy query condition corresponding to the data query request;

[0168] A second acquisition module 403 is used to determine a first data node in the distributed database that meets the fuzzy query condition based on the data query request;

[0169] A query module 404, configured to send the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request;

[0170] The sorting module 405 is used to receive the data query result returned by the first data node, and sort the data query result to obtain a target query result.

[0171] In a possible implementation, the second acquisition module 403 is further used to determine a target data shard of the distributed database; obtain node data of all data nodes in the target data shard, and select a data node in the target data shard that meets the fuzzy query condition as the first data node.

[0172] In a possible implementation, the first acquisition module 402 is further used to acquire the query keyword corresponding to each query dimension of the data query request, and determine the matching condition corresponding to each query keyword; and construct the fuzzy query condition corresponding to the data query request using the matching condition corresponding to each query dimension.

[0173] In a possible implementation, the second acquisition module 403 is further configured to acquire a sharding rule of a distributed database; and based on the sharding rule, determine a target data shard in the distributed database corresponding to the data query request.

[0174] In a possible implementation, the sorting module 405 is also used to utilize the query weight of each query dimension of the data query request to obtain the query matching degree of the data node corresponding to the data query result; and sort the data query result according to the query matching degree to obtain the target query result.

[0175] In a possible implementation, the sorting module 405 is further used to obtain the query dimension of the data node corresponding to the data query result that satisfies the fuzzy query condition; obtain the query weight corresponding to the query dimension; and obtain the query matching degree of the data node based on the query weight.

[0176] In one possible implementation, the query module 404 is also used to obtain the data query range corresponding to the data query request in the distributed database; determine whether the node data of the first data node exceeds the data query range; and stop executing the data query operation of the first data node when the node data of the first data node exceeds the data query range.

[0177] The data query device provided in this embodiment can be as follows Figure 4 The data query device shown in can be executed as follows Figure 1-3 All steps of data query in Figure 1-3 For details, please refer to the technical effect of the data query shown. Figure 1-3 For the sake of brevity, the relevant description is not repeated here.

[0178] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, an embodiment of the present application provides an electronic device, including a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504; the memory 503 is used to store computer programs; the processor 501 is used to execute the program stored in the memory 503, and implement the steps of the data query method provided by any of the above method embodiments:

[0180] Receive a data query request, the data query request is used to query node data in a distributed database; obtain a fuzzy query condition corresponding to the data query request; based on the data query request, determine a first data node in the distributed database that meets the fuzzy query condition; send the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request; receive a data query result returned by the first data node, and sort the data query result to obtain a target query result.

[0181] In one possible implementation, a target data shard of a distributed database is determined; node data of all data nodes in the target data shard is obtained, and a data node in the target data shard that meets a fuzzy query condition is selected as a first data node.

[0182] In one possible implementation, query keywords corresponding to each query dimension of the data query request are obtained, and matching conditions corresponding to each query keyword are determined; and fuzzy query conditions corresponding to the data query request are constructed using the matching conditions corresponding to each query dimension.

[0183] In a possible implementation, a sharding rule of a distributed database is obtained; and based on the sharding rule, a target data shard corresponding to a data query request in the distributed database is determined.

[0184] In a possible implementation, the query weight of each query dimension of the data query request is used to obtain the query matching degree of the data node corresponding to the data query result; and the data query result is sorted according to the query matching degree to obtain the target query result.

[0185] In a possible implementation, the query dimension of the data node corresponding to the data query result that satisfies the fuzzy query condition is obtained; the query weight corresponding to the query dimension is obtained; and based on the query weight, the query matching degree of the data node is obtained.

[0186] In one possible implementation, obtain a data query range corresponding to the data query request in the distributed database; determine whether the node data of the first data node exceeds the data query range; and stop executing the data query operation of the first data node if the node data of the first data node exceeds the data query range.

[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0188] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0189] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A data query method, characterized in that: Applied to a distributed database, the method comprises: Receive a data query request, where the data query request is used to query node data in a distributed database; Obtaining the fuzzy query condition corresponding to the data query request; Based on the data query request, determining a first data node in the distributed database that meets the fuzzy query condition; Sending the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request; The data query result returned by the first data node is received, and the data query result is sorted to obtain a target query result.

2. The method according to claim 1, characterized in that The determining of the first data node in the distributed database that meets the fuzzy query condition comprises: Determine the target data shards for the distributed database; Obtain node data of all data nodes in the target data shard; A data node in the target data shard that meets the fuzzy query condition is selected as the first data node.

3. The method according to claim 1, characterized in that The obtaining of the fuzzy query condition corresponding to the data query request includes: Obtain the query keyword corresponding to each query dimension of the data query request, and determine the matching condition corresponding to each query keyword; Using the matching conditions corresponding to each query dimension, construct the fuzzy query conditions corresponding to the data query request.

4. The method according to claim 2, characterized in that: The step of determining a target data shard of a distributed database includes: Get the sharding rules of the distributed database; Based on the sharding rule, a target data shard in the distributed database corresponding to the data query request is determined.

5. The method according to claim 1, characterized in that The step of sorting the data query results to obtain target query results includes: Using the query weight of each query dimension of the data query request, the query matching degree of the data node corresponding to the data query result is obtained; According to the query matching degree, the data query results are sorted to obtain the target query results.

6. The method according to claim 5, characterized in that The method of utilizing the query weight of each query dimension of the data query request to obtain the query matching degree of the data node corresponding to the data query result includes: Obtaining query dimensions of data nodes corresponding to the data query result that satisfy fuzzy query conditions; Obtaining a query weight corresponding to the query dimension; Based on the query weight, the query matching degree of the data node is obtained.

7. The method according to claim 1, characterized in that Before the first data node performs a data query operation in response to the data query request, the method further includes: Obtaining a data query range corresponding to the data query request in the distributed database; Determining whether the node data of the first data node exceeds the data query range; When the node data of the first data node exceeds the data query range, the data query operation of the first data node is stopped.

8. A data query system, characterized in that: include: A receiving module, used to receive a data query request, wherein the data query request is used to query node data in a distributed database; A first acquisition module, used to acquire the fuzzy query condition corresponding to the data query request; A second acquisition module, configured to determine, based on the data query request, a first data node in the distributed database that satisfies the fuzzy query condition; A query module, configured to send the data query request to the first data node, so that the first data node performs a data query operation in response to the data query request; The sorting module is used to receive the data query result returned by the first data node, and sort the data query result to obtain the target query result.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data query method according to any one of claims 1 to 7 are implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data query method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Data space-oriented data retrieval enhancement generation method, device and equipment

    CN119988697A

  • Method, device and equipment for auditing SQL (Structured Query Language) of distributed database and medium

    CN121434254A