Data query method and device, computer device, readable storage medium and program product
By generating a request for identification information in the terminal's local database, the amount of data queried directly from the target database is reduced, solving the problems of slow fuzzy search speed and high server load, and achieving efficient data query.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KINGDEE DEEKING CLOUDCOMPUTING CO LTD
- Filing Date
- 2025-04-25
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies for fuzzy data queries in relational databases often fail to hit indexes, resulting in slow query speeds, especially when dealing with large amounts of data, which puts significant pressure on the server and leads to low query efficiency.
By storing a portion of the target database's data in the terminal's local database as configuration data, a request message carrying identification information is generated. The server then queries based on this identification information, reducing the amount of data retrieved directly from the target database.
It improves the efficiency of data querying, reduces the query pressure on the server, and controls the amount of data stored on the terminal, ensuring the speed and efficiency of the query.
Smart Images

Figure CN120429339B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data query method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] With the development of computer technology, database technology has emerged. Database technology enables the storage, organization, management, and retrieval of data, ensuring data consistency, security, and efficient access, and supporting various data processing and decision support functions. The required data can be obtained by performing query operations on the database.
[0003] In the current process of querying a database, it is often necessary to retrieve data that matches the fuzzy information from the database.
[0004] In existing technologies, indexes can be set up in relational databases to improve data query speed. However, when performing fuzzy data queries based on these databases, if the query cannot hit the index, the query speed may be slow, resulting in low query efficiency. When the number of databases is large, the amount of data that needs to be matched with fuzzy information is also large, which can also lead to high database operating pressure. Summary of the Invention
[0005] Therefore, it is necessary to provide a data query method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can reduce the operational pressure on the server and improve the efficiency of data query, in order to address the above-mentioned technical problems.
[0006] Firstly, this application provides a data query method, including:
[0007] Get search information;
[0008] From the configuration data stored in the local database, query the reference information corresponding to the search information, and generate request information based on the identification information corresponding to the reference information;
[0009] The request information is sent to the server so that the server can retrieve the corresponding query results from the target database based on the identification information. The configuration data includes the target data in the target database that is received in advance from the server. The configuration data is used to store the data in the local database in advance.
[0010] Receive and display the query results sent by the server.
[0011] In one embodiment, reference information corresponding to the search information is queried from configuration data stored in a local database, and request information is generated based on the identification information corresponding to the reference information. This includes: determining the search item and search value corresponding to the search information; determining searchable items from the search items, wherein the searchable items belong to the configuration fields corresponding to the configuration data; determining target field data matching the search value from the searchable field data corresponding to the searchable items in the local database; and generating request information based on the identification information corresponding to the target field data.
[0012] In one embodiment, the process involves determining target field data matching a search value from searchable field data corresponding to searchable items in a local database, and generating request information based on the identifier information corresponding to the target field data. This includes: determining searchable fields corresponding to searchable items; dividing the searchable fields into at least one set of searchable fields based on the identifier fields corresponding to the searchable fields; determining target field data matching a set of search values corresponding to the set of searchable fields from searchable field data corresponding to searchable items in the local database; and generating request information based on at least one identifier field corresponding to the target field data.
[0013] In one embodiment, based on the identifier field corresponding to the searchable field, the searchable field is divided into at least one set of searchable fields, including: determining the parent field to which the searchable field belongs; dividing the searchable field into at least one set of searchable fields based on the parent field; each set of searchable fields includes at least one field; different sets of searchable fields correspond to parent fields of different types.
[0014] In one embodiment, after determining the search terms and search values corresponding to the search information, the method further includes: determining unsearchable terms and corresponding search data from the search terms, wherein the unsearchable terms do not belong to the configuration fields; generating request information based on the identification information corresponding to the search data and the target field data; sending the request information to the server, so that the server performs a first type of query on the target database based on the search data to obtain a first query result, and the server performs a second type of query on the target database based on the field data corresponding to the searchable fields in the target field data to obtain a second query result; determining the query result based on the first query result and the second query result; and receiving and displaying the query result sent by the server.
[0015] In one embodiment, before generating request information based on the identification information corresponding to the reference information, the method further includes: if the reference information obtained by query exceeds a preset amount of information, generating request information based on the search information and sending the request information to the server so that the server can perform a first type of query on the target database.
[0016] Secondly, this application also provides a data query device, comprising:
[0017] The acquisition module is used to obtain search information;
[0018] The query module is used to query reference information corresponding to the search information from the configuration data stored in the local database, and generate request information based on the identification information corresponding to the reference information;
[0019] A communication module is used to send the request information to the server so that the server can retrieve the corresponding query results from the target database based on the identification information. The configuration data includes target data from the target database that has been received in advance from the server. The configuration data is used to be stored in the local database in advance.
[0020] The display module is used to receive and display the query results sent by the server.
[0021] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps described in the above method.
[0022] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps described in the above method.
[0023] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps described in the above method.
[0024] The aforementioned data query method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire search information, query reference information corresponding to the search information from configuration data stored in the terminal's local database, and then generate request information based on the identification information corresponding to the reference information. That is, the request information carries the identification information. After receiving the identification information, the server retrieves the corresponding query results based on the identification information and sends the query results to the terminal for display. This method, which utilizes the terminal's operational capabilities to convert search information into identification information, improves query efficiency and reduces the operational burden on the server when querying the target database compared to directly querying data from the target database based on search information. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a diagram illustrating the application environment of a data query method in one embodiment.
[0027] Figure 2 This is a flowchart illustrating a data query method in one embodiment;
[0028] Figure 3 This is a schematic diagram of the query results display page in one embodiment;
[0029] Figure 4 This is a flowchart illustrating the steps for determining identification information in one embodiment;
[0030] Figure 5 This is a flowchart illustrating the data query method in another embodiment;
[0031] Figure 6 This is a schematic diagram of a page displayed on a user's terminal in one embodiment;
[0032] Figure 7 This is a schematic diagram of the first page displayed on the terminal of another user in one embodiment;
[0033] Figure 8 This is a schematic diagram of a second page displayed on the terminal of another user in one embodiment;
[0034] Figure 9 This is a schematic diagram of a third page displayed on the terminal of another user in one embodiment;
[0035] Figure 10 This is a schematic diagram illustrating the interaction between a terminal and a server in one embodiment;
[0036] Figure 11 This is a structural block diagram of a data query device in one embodiment;
[0037] Figure 12 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0039] The data query method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Target data from the target database is sent to the terminal in advance. Target data is a portion of the data stored in the target database. The terminal receives this target data and stores it as configuration data in its local database. In response to changes in the target data, the server sends changed data to the terminal to update the locally stored configuration data. The terminal obtains search information, queries the configuration data for reference information corresponding to the search information, and generates request information based on the identification information corresponding to the reference information. The terminal sends the request information to the server. After receiving the request information, the server obtains the corresponding query result from the target database based on the identification information carried in the request information. After the server sends the query result to the terminal, the terminal displays the query result. The data storage system stores the target database. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.
[0040] In one exemplary embodiment, such as Figure 2 As shown, a data query method is provided, which can be applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps S202 to S208. Wherein:
[0041] Step S202: Obtain search information.
[0042] The search information is text, numbers, or other forms of information used to match data recorded in the local database.
[0043] For example, the search information can be incomplete information entered by the user in an input box displayed on the terminal's page. Incomplete information refers to information that cannot be completely matched with any data in the database. For example, the database stores data such as: "AAA", "AAB", "BAB", "BAA", and "AB". It can be understood that "AAA" matches "AAA" completely, "AAB" matches "AAB" completely, and so on. When the search information is "AA", it cannot be completely matched with the above five data, but it partially matches "AAA" and "AAB".
[0044] Optionally, refer to Figure 3 The page is configured with fixed and variable areas. Fixed information is displayed in the fixed area. Variable areas are used to enter search information. A fixed area can be associated with at least one variable area. The page can also include a display area. This display area shows the query results that match the search information. For example, entering the search term "device" in the variable area associated with the fixed information "products" will display all records in the target database whose field value for the "products" field includes "devices". (Reference) Figure 3 The display area shows the data corresponding to "AA device", "AB device", etc.
[0045] Specifically, the search information includes at least one search data set. Each search data set consists of a search term and a search value. The search term corresponds to the fixed information mentioned above, and the search value corresponds to the variable information entered in the variable area mentioned above.
[0046] It is understandable that the data types displayed in the display area can be pre-configured. For example, in addition to displaying the product name, it can also display the product number, the product's expiration date, etc.
[0047] Step S204: Query the reference information corresponding to the search information from the configuration data stored in the local database, and generate request information based on the identification information corresponding to the reference information.
[0048] The local database is a database stored on the terminal. The configuration data stored in the local database is a subset of the data stored in the target database (i.e., the target data). The local database could be, for example, an IndexDB database. In other words, the configuration data includes the target data from the target database that has been pre-received from the server. The configuration data is pre-stored in the local database before any data query is performed. For example, the terminal maintains a persistent connection with the server. When the target data in the target database changes, the changed data can be sent to the terminal via the persistent connection to update the corresponding data in the configuration data. Optionally, all fields in the local database can be indexed to improve query efficiency within the local database.
[0049] The reference information includes at least one record in the local database. Each record includes at least one data item. Each record in the reference information has one data item that matches the search information. Specifically, for a given record, the field value corresponding to the field matching the search term matches the search value in the search information.
[0050] For example, the fields corresponding to the configuration data include at least one identifier field. The identifier field is a field in the database table used to uniquely identify each record. Identification information includes the field values corresponding to each identifier field in each record. After retrieving reference information corresponding to the search information, the identifier information corresponding to that reference information can be determined. Then, request information is generated based on this identifier information. The server can then determine the data matching the search information based on the identifier information.
[0051] Optionally, in addition to storing the identifier field, the configuration data also stores the index corresponding to the identifier field. In this case, the identifier information includes the field value and index value corresponding to each identifier field in each record. Based on the identifier field and its corresponding field value and index value, matching data is retrieved from the target database. Combining indexing techniques can improve the speed of database queries.
[0052] It's understandable that, to reduce the pressure on the terminal for querying data, the local database doesn't store field data for all field types. In this case, if a search term in the search information doesn't belong to a field type stored in the local database, it's impossible to match that search term and its corresponding search value in the local database. In this situation, the search information is directly sent to the target database for querying.
[0053] Step S206: Send the request information to the server so that the server can retrieve the corresponding query results from the target database based on the identification information.
[0054] The request information carries identification information. When performing a fuzzy search, the request information carries at least one set of identification data. Each set of identification data includes at least one field value and index value corresponding to an identification field. After receiving the field value and index value corresponding to the identification field, the server can quickly determine the matching record in the target database based on the field value and index value corresponding to the identification field.
[0055] It is understandable that when the received identifier data group includes field values corresponding to multiple identifier fields, the field value corresponding to the identifier field in each record of the query results retrieved from the target database is the same as the field value corresponding to the identifier field in the identifier data group.
[0056] Step S208: Receive and display the query results sent by the server.
[0057] For example, the server sends the query results to the terminal, and after receiving the query results, the terminal displays the results on the page. The query results can be displayed in the form of a list.
[0058] In the aforementioned data query method, by acquiring search information, reference information corresponding to the search information is retrieved from the configuration data stored in the terminal's local database. Then, based on the identifier information corresponding to the reference information, request information is generated, meaning the request information carries the identifier information. After receiving the identifier information, the server retrieves the corresponding query results based on the identifier information and sends the query results to the terminal for display. This method leverages the terminal's processing capabilities to convert search information into identifier information. The process of querying data from the target database based on the identifier information improves query efficiency and reduces the server's workload in querying the target database compared to directly querying data from the target database based on the search information. Furthermore, the configuration data stored on the terminal is related to the identifier information; data unrelated to the identifier information is not stored on the terminal. This also helps control the data stored on the terminal within a certain range, thereby ensuring the efficiency of the terminal's database queries.
[0059] In one exemplary embodiment, the local database stores a portion of the target database's data. Therefore, the search information may include search terms not stored in the local database. For example, the local database stores personal information or job-related information. If a search term is for searching for company-related data in the database, then that data will not be found in the local database. Therefore, before performing a query on the local database, it is possible to first determine the search terms and corresponding search values that can be searched in the local database. Figure 4 As shown, the process involves retrieving reference information corresponding to the search information from the configuration data stored in the local database, and generating request information based on the identifier information corresponding to the reference information, including steps S402 to S408. Wherein:
[0060] Step S402: Determine the search terms and search values corresponding to the search information.
[0061] It is understood that search information includes at least one search term and the search value corresponding to that search term. For example, the search information is "(Name: Zhou) (Position: Technical) (Note: Honorary Title A)". The corresponding search terms are: Name, Position, and Notes. The search value corresponding to the search term "Name" is: Zhou. The search value corresponding to the search term "Position" is: Technical. The search value corresponding to the search term "Notes" is: Honorary Title A.
[0062] Step S404: Determine searchable items from the search items.
[0063] Among these, searchable items belong to the configuration fields corresponding to the configuration data. As mentioned earlier, some data is stored in the local database. For example, the terminal compares the search items corresponding to the search information with the configuration fields to determine the searchable items in the search information that belong to the configuration fields.
[0064] For example, if the configuration fields include "Name" and "Position", then the searchable items determined from the search information "(Name: Zhou)(Position: Technical)(Remarks: Honorary Title A)" will be "Name" and "Position".
[0065] Optionally, after building the local database, you can establish an association between the names of search terms on the page and the names of configuration fields in the local database. For example, the search terms are "Name", "Job", and "Remarks", and the configuration field names include "name" and "job". In this case, the pre-stored association can determine that "Name" corresponds to the "name" field, and "Job" corresponds to the "job" field.
[0066] Step S406: Determine the target field data that matches the search value from the searchable field data corresponding to the searchable items in the local database.
[0067] The searchable field data corresponding to a searchable item is data stored in the local database. In other words, the searchable item corresponds to search information, and the searchable field corresponds to the database. Essentially, the searchable field data is a column of field values corresponding to the searchable item.
[0068] For example, determining the target field data that matches the search value includes: comparing searchable field data with the search value, and determining the target field data based on the searchable field data including the search value. For instance, the searchable field data includes "AAA", "AAB", "BAB", "BAA", and "AB". The search value is "AA". Comparing "AA" with "AAA", "AAB", "BAB", "BAA", and "AB", the searchable field data including "AA" is determined to be "AAA" and "AAB". Therefore, the target field data is "AAA", "AAB", and "BAA".
[0069] Step S408: Generate request information based on the identifier information corresponding to the target field data.
[0070] The identifier information is the information that uniquely identifies a record in the database. In the target database, corresponding identifier fields are set for certain fields. For example, an identifier field (e.g., the nameid field) corresponding to "name" will be set in the target database. The field values corresponding to the identifier fields are also stored in the local database.
[0071] For example, generating request information based on the identifier information corresponding to the target field data includes: retrieving the field value of the identifier field corresponding to the target field data from the local database, and generating request information based on the field value of the identifier field. Optionally, the request information includes the field value of the identifier field.
[0072] For example, the configuration data stored in the local database is: (001, AAA, job1), (002, AAB, job1), (003, ABA, job2). Here, "001", "002", and "003" are the data items corresponding to the identifier fields in the records. The determined target field data are "AAA" and "AAB". The corresponding identified identifier information is "001" and "002". The generated request information then carries "001" and "002".
[0073] In this embodiment, by determining the search terms and search values corresponding to the search information, searchable terms belonging to the configuration fields corresponding to the configuration data are identified from the search terms. From the field data corresponding to the searchable terms in the local database, target field data matching the search value is determined. Based on the identification information corresponding to the target field data, request information carrying the identification information can be generated. In this way, the terminal can query the identification information corresponding to the search information, facilitating subsequent queries to the target database based on the identification information, thereby reducing the query pressure on the server. Furthermore, since the volume of configuration data on the terminal is relatively small, querying the local database will not cause the terminal to run slowly.
[0074] In practical applications, databases store various types of fields. To better distinguish each record and reduce the amount of data stored in the database, fields can be categorized based on their type. For example, fields belonging to personal information can be grouped into basic information fields, and the values of these fields differ for different individuals. Basic information fields uniquely identify a record in the database. This improves query speed by eliminating the need to set every field in the database as a primary key, reducing storage pressure. In some embodiments, to address this, the process involves determining target field data matching the search value from the searchable field data corresponding to searchable items in the local database. This includes: determining the searchable fields corresponding to the searchable items; dividing the searchable fields into at least one set of searchable fields based on the identifier fields corresponding to the searchable fields; determining the target field data set matching the search value set corresponding to the searchable field set from the searchable field data corresponding to the searchable items in the local database; and generating request information based on at least one identifier field corresponding to the target field data set.
[0075] In this system, an identifier field is associated with at least one configuration field. When the search information includes multiple searchable fields, and some searchable fields correspond to different identifier fields, these searchable fields can be divided into at least one set of searchable fields. Each set of searchable fields corresponds to one identifier field. A set of searchable fields includes at least one searchable field, and these searchable fields are associated with the same identifier field. The field value of the identifier field is uniquely identifying the corresponding record; for example, the field value is a string of numbers, similar to an ID card number.
[0076] After obtaining at least one set of searchable fields, a corresponding set of search values can be derived. The set of search terms corresponding to the set of search values matches the set of searchable fields. Then, based on the set of search values, a matching set of target field data is queried from the local database. After determining the set of target field data, the corresponding identifier fields can be identified. For a single target field data entry, the corresponding request information is generated based on the field value combinations formed by the corresponding identifier fields.
[0077] For example, the search terms for the search information include: name, gender, age, department, and years of service. The corresponding search values are: week, male, 2, technical, 1. Name, gender, and age belong to the same category, as do years of service and department. The searchable fields match the names of the search terms. Therefore, two sets of searchable fields can be obtained: {name, gender, age} and {years of service, department}. From the field data corresponding to the fields "name, gender, age, department, years of service" in the local database, the target field data matching {week, male, 2} and {technical, 1} is determined. In other words, when performing data queries, the matching unit is the set of search values. It can be understood that in each record of the retrieved target field data, the value of the name field includes week, the value of the gender field includes male, the value of the age field includes 2, the value of the department field includes technical, and the value of the years of service includes 1. Furthermore, each record corresponds to two identifier fields. For each record, the corresponding identification information consists of the values of two identification fields. Therefore, the obtained identification information includes multiple data sets composed of the values of the two identification fields. For example: {(1001, 6789), (1002, 6790), ...}.
[0078] In this embodiment, by dividing the searchable fields into at least one set of searchable fields, and determining the target field data that matches the corresponding set of search values based on the set of searchable fields, each record in the database can be matched with multiple search values. Compared with matching on a single field basis, this reduces the number of matching operations and improves the efficiency of determining the target field data from the local database.
[0079] It is understandable that when the set of searchable fields corresponding to a searchable field includes only one searchable field, at least one target field data that matches the search value of the search term corresponding to that searchable field can be determined from the field data corresponding to that searchable field in the local database. Then, based on the field value of the identifier field corresponding to each target field data, request information is generated.
[0080] It is understandable that, in addition to storing the field data corresponding to the searchable fields, the local database will also store the field data corresponding to the identifier fields associated with these searchable fields.
[0081] Furthermore, an index can be created on the identifier field in the target database. The index-related information can also be sent from the server to the terminal for storage in the local database. In this case, request information can be generated based on the identifier field value and the corresponding index value, thus improving the speed of querying the target database.
[0082] In some embodiments, the identifier field associated with a searchable field can be a parent field to which the searchable field belongs. That is, during the process of obtaining configuration data, in addition to the data corresponding to the selected configuration field, the data corresponding to the parent field to which the configuration field belongs must also be added. For example, based on the identifier field corresponding to the searchable field, dividing the searchable field into at least one set of searchable fields includes: determining the parent field to which the searchable field belongs; dividing the searchable field into at least one set of searchable fields based on the parent field; each set of searchable fields includes at least one field; different sets of searchable fields correspond to parent fields of different types.
[0083] In this embodiment, by using the parent field to which the field belongs as the identifier field, the query operation can be simplified by associating each parent field in subsequent queries, without having to construct complex query statements, thereby improving query efficiency.
[0084] The above describes the query process for searchable items identified from the search terms. In practical applications, some search terms are not stored in the local database. For these non-searchable items, the search data corresponding to the non-searchable items can be directly sent to the server for related searches. In some embodiments, search terms include both searchable and non-searchable items. Therefore, after determining the search terms and search values corresponding to the search information, non-searchable items and their corresponding search data are determined from the search terms. Non-searchable items do not belong to configuration fields. Request information is generated based on the identification information corresponding to the search data and the target field data. The request information is sent to the server so that the server performs a first type of query on the target database based on the search data to obtain a first query result, and performs a second type of query on the target database based on the field data corresponding to the searchable fields in the target field data to obtain a second query result. The query result is determined based on the first and second query results. The query result sent by the server is received and displayed.
[0085] The first type of query can be a fuzzy query. For example, using the `like` operator in conjunction with search data. The second type of query can be a set query. Since there may be multiple records matching the fuzzy information, the field values corresponding to the identifier field sent to the server will also be multiple. In this case, the `in` operator can be used for querying. The query result can be understood as the union of the first and second query results. In the actual query process, the query statement is constructed directly by combining the unsearchable items and their corresponding search data and identifier information to obtain the query results.
[0086] In this embodiment, by performing fuzzy queries on unsearchable items in the search information and precise queries on searchable items, the query speed can be improved and the query pressure on the server can be reduced compared to performing fuzzy queries directly based on the search information.
[0087] In practical applications, while it's beneficial for the server to pre-determine the corresponding identification information from the local database to retrieve results matching the search information from the target database, if the amount of identification information sent from the terminal to the server exceeds a preset value, it may affect the communication efficiency between the two ends, resulting in slow query speeds. Therefore, before generating request information based on the identification information corresponding to the reference information, if the retrieved reference information exceeds a preset amount, request information is generated based on the search information and sent to the server so that the server can perform a first-type query on the target database.
[0088] For example, the retrieved reference information corresponding to the search information includes 1001 records. The preset information limit is set to 1000 records for each reference record. In this case, it is determined that the retrieved reference information exceeds the preset information limit. To ensure normal communication between the terminal and the server and reduce slow interaction caused by transmitting too much data, a request message is directly generated based on the search information and sent to the server, enabling the server to perform a fuzzy search on the target database based on the search information.
[0089] In this embodiment, by making a relevant judgment on the amount of information in the reference information, when there is too much information, it is converted into sending fuzzy information to perform fuzzy search on the server side. This can reduce the phenomenon of slow query speed caused by transmitting too much data.
[0090] In one exemplary embodiment, to alleviate the pressure on the server-side data querying and improve the efficiency of data querying, combined with Figure 5 As shown, the following steps can be performed:
[0091] First, the terminal can obtain search information. For example, after a user enters search keywords on a page and clicks the search button, search information can be obtained. Optionally, refer to... Figure 5 If the front-end search function is enabled in the terminal, front-end searches can be performed. If the front-end search function is disabled in the terminal, only back-end searches are possible. By setting this switch, the operability of the data query system can be improved.
[0092] Next, the terminal determines the search terms and search values corresponding to the search information, identifies searchable items from the search terms, and determines the searchable fields corresponding to the searchable items. The searchable items are configuration fields corresponding to the configuration data.
[0093] If the search term belongs to a configuration field, then determine the parent field to which the searchable field belongs. Based on the parent field, the searchable field is divided into at least one set of searchable fields. From the searchable field data corresponding to the searchable term in the local database, determine the target field data that matches the set of search values corresponding to the set of searchable fields. Based on at least one identifier field corresponding to the target field data, generate request information.
[0094] In practical applications, the number of search terms in the search information can be determined first. If there is only one search term, a single-field search branch can be executed. The basic data field (i.e., the parent field) corresponding to the search term is queried to retrieve the field information and the unique identifier ID of the basic data, which are then combined to form new data to match the user-input keywords, obtaining the IDs of all basic data that match the search value of the search term. The relevant index query identifiers can then be sent to the server. If there are multiple search terms, a full-field search branch can be executed. Essentially, the difference between a single-field search branch and a full-field search branch is that the full-field search branch additionally categorizes the searchable fields corresponding to the search terms, so that search values corresponding to search terms belonging to the same category are queried as a whole in the local database. That is, the fields searched on the terminal side need to be distinguished as belonging to the same basic data field; searchable fields belonging to the same basic data field are combined into one set of data. Finally, the search results (i.e., identifier information) of the full search contain IDs of one or more basic data types. This reduces the number of local matches, thereby improving the speed of local queries.
[0095] Optionally, after querying the local database and obtaining reference information, if the amount of reference information obtained exceeds a preset limit, a request is generated based on the search information and sent to the server so that the server can perform a first-type query on the target database, i.e., a LIKE search. If the amount of reference information does not exceed the preset limit, an IN search can be performed.
[0096] Additionally, in the all-field search branch, search terms may include search terms that do not belong to the configured fields. In this case, unsearchable terms and their corresponding search data can be identified from the search terms. Unsearchable terms do not belong to the configured fields. Based on the identification information corresponding to the search data and the target field data, request information is generated. The request information is sent to the server, so that the server performs a first type of query on the target database based on the search data to obtain a first query result, and performs a second type of query on the target database based on the field data corresponding to the searchable fields in the target field data to obtain a second query result. The query result is determined based on the first and second query results. The query result sent by the server is received and displayed. In other words, the request parameters for all searches can be composed of several cases: no client-side search fields, all fields use fuzzy search; client-side search fields and cloud search fields coexist, the original request parameters are split into two parts: client-side fields are divided into basic data types and index query identifiers are added, while fuzzy search remains unchanged; all are client-side search fields, then index query identifiers are directly added for basic data types.
[0097] Taking the procurement field as an example, sub-user A adds a product named test112002 in the browser of terminal A and clicks save (see reference). Figure 6 After saving, the information for product test112002 will be sent to the server via terminal A, creating a new record matching product test112002 in the server's database. Terminal B of the main user B maintains a persistent connection with the server. When configuration data on the server changes, the corresponding changed data is sent to terminal B and stored in terminal B's database to ensure data consistency and accuracy. (Reference) Figure 7 After user A adds product test112002, terminal B will receive a push notification indicating the addition of product test112002. Once user B confirms, terminal B will store the relevant data for product test112002 (see reference). Figure 8 After adding product "test112002", user A can continue to add purchase request records for this product. The primary user B queries and approves the purchase request records submitted by each sub-user on their terminal B. When primary user B enters a search query containing "test112002" into the purchase order list displayed on terminal B, terminal B will query the local database for the identifier information corresponding to "test112002" and send a request message carrying this identifier information to the server, enabling the server to perform a query based on the identifier information. (Reference) Figure 9 In the request information, the value corresponding to "frontValue" is the identifier information, and the value corresponding to "Compare" is the query type. Figure 9 (This is the second type of query)
[0098] Optionally, such as Figure 5 As shown in this embodiment, after determining that a search item is unsearchable, it can also be determined whether the unsearchable item is a document code. If it is a document code, a second type of query can be executed. If it is not a document code, a first type of query can be executed.
[0099] In short, for example, refer to Figure 10 After the user enters search keywords on the terminal, the terminal checks the browser cache and converts the search keywords into an index ID on the server. Then, based on the index ID, it constructs request parameters and requests the server to perform a search based on the index ID. The server constructs a related search statement based on the index ID and obtains the query results from the data server. The terminal receives the query results returned by the server and displays them.
[0100] In this embodiment, the user inputs search keywords, and the browser obtains some basic information IDs by querying the local database. These IDs are then used as parameters to request a search from the cloud database, allowing the cloud database to use the IDs as indexes for information retrieval. This utilizes the terminal's resources, pre-organizing the searched information into an index for the cloud database on the terminal, greatly reducing the pressure on the cloud database and improving query speed.
[0101] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0102] Based on the same inventive concept, this application also provides a data query apparatus for implementing the data query method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more data query apparatus embodiments provided below can be found in the limitations of the data query method described above, and will not be repeated here.
[0103] In one exemplary embodiment, such as Figure 11 As shown, a data query device 1100 is provided, including: an acquisition module 1101, a query module 1102, a communication module 1103, and a display module 1104, wherein:
[0104] Module 1101 is used to obtain search information;
[0105] The query module 1102 is used to query reference information corresponding to the search information from the configuration data stored in the local database, and generate request information based on the identification information corresponding to the reference information.
[0106] The communication module 1103 is used to send request information to the server so that the server can query the corresponding query results from the target database based on the identification information. The configuration data includes target data in the target database that is received in advance from the server. The configuration data is used to be stored in the local database in advance.
[0107] Display module 1104 is used to receive and display the query results sent by the server.
[0108] In some embodiments, in querying reference information corresponding to search information from configuration data stored in a local database, and generating request information based on the identification information corresponding to the reference information, the query module 1102 is further configured to: determine the search item and search value corresponding to the search information; determine searchable items from the search items, wherein the searchable items belong to the configuration fields corresponding to the configuration data; determine the target field data matching the search value from the searchable field data corresponding to the searchable items in the local database; and generate request information based on the identification information corresponding to the target field data.
[0109] In some embodiments, in determining target field data matching the search value from searchable field data corresponding to searchable items in the local database, and generating request information based on the identifier information corresponding to the target field data, the query module 1102 is further configured to: determine searchable fields corresponding to searchable items; divide the searchable fields into at least one set of searchable fields based on the identifier fields corresponding to the searchable fields; determine target field data matching the set of search values corresponding to the set of searchable fields from searchable field data corresponding to searchable items in the local database; and generate request information based on at least one identifier field corresponding to the target field data.
[0110] In some embodiments, in dividing a searchable field into at least one set of searchable fields based on an identifier field corresponding to the searchable field, the query module 1102 is further configured to: determine the parent field to which the searchable field belongs; divide the searchable field into at least one set of searchable fields based on the parent field; each set of searchable fields includes at least one field; and the parent fields corresponding to different sets of searchable fields have different types.
[0111] In some embodiments, after determining the search terms and search values corresponding to the search information, the data query device is further configured to: determine unsearchable terms and corresponding search data from the search terms, wherein the unsearchable terms do not belong to the configuration fields; generate request information based on the identification information corresponding to the search data and the target field data; send the request information to the server, so that the server performs a first type of query on the target database based on the search data to obtain a first query result, and the server performs a second type of query on the target database based on the field data corresponding to the searchable fields in the target field data to obtain a second query result; determine the query result based on the first query result and the second query result; and receive and display the query result sent by the server.
[0112] In some embodiments, before generating request information based on the identification information corresponding to the reference information, the data query device is further configured to: if the reference information obtained by the query exceeds a preset amount of information, generate request information based on the search information and send the request information to the server so that the server performs a first type of query on the target database.
[0113] Each module in the aforementioned data query device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0114] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 12 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a data query method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0115] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0116] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0117] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0118] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with relevant regulations.
[0119] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0120] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0121] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A data query method, characterized in that, The method includes: Get search information; From the configuration data stored in the local database, query the reference information corresponding to the search information, and generate request information based on the identification information corresponding to the reference information, including: determining the search item and search value corresponding to the search information; determining the searchable item from the search item, wherein the searchable item belongs to the configuration field corresponding to the configuration data; determining the target field data matching the search value from the searchable field data corresponding to the searchable item in the local database, and generating the request information based on the identification information corresponding to the target field data; The request information is sent to the server so that the server can retrieve the corresponding query results from the target database based on the identification information. The configuration data includes target data from the target database that has been received from the server in advance. The configuration data is used to be stored in the local database in advance. Receive and display the query results sent by the server.
2. The method according to claim 1, characterized in that, The step of determining the target field data matching the search value from the searchable field data corresponding to the searchable item in the local database, and generating request information based on the identifier information corresponding to the target field data, includes: Determine the searchable fields corresponding to the searchable items; Based on the identifier field corresponding to the searchable field, the searchable field is divided into at least one set of searchable fields; From the searchable field data corresponding to the searchable items in the local database, determine the target field data that matches the search value set corresponding to the searchable field set; The request information is generated based on at least one identifier field corresponding to the target field data.
3. The method according to claim 2, characterized in that, The step of dividing the searchable fields into at least one set of searchable fields based on the identifier field corresponding to the searchable fields includes: Determine the parent field to which the searchable field belongs; Based on the parent field, the searchable field is divided into at least one set of searchable fields; each set of searchable fields includes at least one field; the parent field corresponding to different sets of searchable fields has a different type.
4. The method according to claim 1, characterized in that, After determining the search terms and search values corresponding to the search information, the method further includes: From the search items, determine the unsearchable items and their corresponding search data, wherein the unsearchable items do not belong to the configuration field; Based on the identification information corresponding to the search data and the target field data, request information is generated; The request information is sent to the server so that the server performs a first type of query on the target database based on the search data to obtain a first query result, and the server performs a second type of query on the target database based on the field data corresponding to the searchable field in the target field data to obtain a second query result, and determines the query result based on the first query result and the second query result; Receive and display the query results sent by the server.
5. The method according to claim 1, characterized in that, Before generating request information based on the identifier information corresponding to the reference information, the method further includes: If the reference information obtained from the query exceeds the preset information amount, then the request information is generated based on the search information and sent to the server so that the server can perform a first type of query on the target database.
6. A data query device, characterized in that, The device includes: The acquisition module is used to obtain search information; The query module is used to query reference information corresponding to the search information from configuration data stored in a local database, and generate request information based on the identification information corresponding to the reference information. This includes: determining the search terms and search values corresponding to the search information; determining searchable terms from the search terms, wherein the searchable terms belong to configuration fields corresponding to the configuration data; determining target field data matching the search value from the searchable field data corresponding to the searchable terms in the local database, and generating the request information based on the identification information corresponding to the target field data. A communication module is used to send the request information to the server so that the server can retrieve the corresponding query results from the target database based on the identification information. The configuration data includes target data from the target database that has been received in advance from the server. The configuration data is used to be stored in the local database in advance. The display module is used to receive and display the query results sent by the server.
7. The apparatus according to claim 6, characterized in that, The query module is also used for: Determine the searchable fields corresponding to the searchable items; Based on the identifier field corresponding to the searchable field, the searchable field is divided into at least one set of searchable fields; From the searchable field data corresponding to the searchable items in the local database, determine the target field data that matches the search value set corresponding to the searchable field set; The request information is generated based on at least one identifier field corresponding to the target field data.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.