Data query method and device based on regular matching, equipment and medium

By employing regular expression matching in data queries, converting the query data into hash fields, and utilizing a cached database for high-speed matching, the problem of low query efficiency in existing technologies is solved, enabling fast data retrieval.

CN116049509BActive Publication Date: 2026-02-10SHENZHEN PROSCENIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211563104.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-07
Publication Date
2026-02-10
Estimated Expiration
2042-12-07

AI Technical Summary

Technical Problem

Existing data query methods suffer from low query efficiency in both relational and non-relational databases, especially when dealing with one-to-many or many-to-many relationship data, where they cannot effectively utilize database indexes, resulting in slow query speeds.

Method used

A regular expression-based matching method is adopted, which converts the query data into a hash field by pre-setting regular expression matching rules, uses the regular expression matching dictionary of the cache database for high-speed matching, and combines it with relational database queries to achieve fast data retrieval.

Benefits of technology

It improves the speed and efficiency of data querying, and performs high-speed matching in the cache database through a short hash field, reducing the need for big data queries in relational databases and improving the matching speed of complex filtering conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049509B_ABST
    Figure CN116049509B_ABST
Patent Text Reader

Abstract

The application discloses a data query method and device based on regular matching, equipment and medium, the method comprises: obtaining a query request containing query data; the query data contains at least one first string; according to the preset regular matching rule and the preset association sequence, all first strings in the query data are regularly matched, and a first hash field with a hash structure is generated; according to the first hash field, a second hash field matched with the first hash field is queried in the regular matching dictionary of the cache database; according to the storage code associated with the second hash field, the relational data corresponding to the query data is obtained from the relational database. The application improves the speed and efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data querying based on regular expression matching, and more particularly to a data querying method, apparatus, device, and medium based on regular expression matching. Background Technology

[0002] Currently, to quickly retrieve the data needed for business execution from massive amounts of data, facilitate data searching and replacement, and maintain relationships between data, data is generally stored in relational databases. DQL (Data Query Language) is used to perform queries across multiple tables, ultimately combining the required data and returning the results to the client. Alternatively, data can be stored in non-relational databases (such as NoSQL databases), using the database's built-in query language to perform relevant business data queries and return the results to the client. However, data stored in relational databases often contains many one-to-many or many-to-many relationships due to actual business needs. If stored across multiple tables, queries will use numerous join queries and IN (the IN operator is used to determine if a list or tuple contains a specific element, or if a string contains a specific string) operations, making it impossible to use database indexes and resulting in low query efficiency. If stored in a single table, the relationships between data are stored as JSON (JavaScript Object Notation) strings, a storage structure that also hinders fast querying of related fields. Data stored in non-relational databases (such as NoSQL databases) can be horizontally expanded into single-document storage due to the special nature of their storage structure, reducing join operations during queries. However, their queries are relatively slow in terms of range queries and fuzzy matching. Summary of the Invention

[0003] Based on this, the present invention provides a data query method, apparatus, device and medium based on regular expression matching to solve the problems of low processing speed and efficiency of existing data query methods.

[0004] A data query method based on regular expression matching includes:

[0005] Obtain a query request containing query data; the query data contains at least one first string;

[0006] According to the preset regular expression matching rules and the preset association sequence, all first strings in the query data are matched using regular expressions to generate a first hash field with a hash structure.

[0007] Based on the first hash field, a second hash field matching the first hash field is queried in the regular expression matching dictionary of the cache database; the regular expression matching dictionary stores multiple sets of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field;

[0008] Based on the storage code associated with the queried second hash field, relational data corresponding to the queried data is retrieved from the relational database.

[0009] A data query device based on regular expression matching includes:

[0010] The condition acquisition module is used to acquire a query request containing query data; the query data contains at least one first string;

[0011] The first matching module is used to perform regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences, and generate a first hash field with a hash structure.

[0012] The first query module is used to query a second hash field that matches the first hash field in the regular expression matching dictionary of the cache database based on the first hash field; the regular expression matching dictionary stores multiple sets of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field;

[0013] The second query module is used to retrieve relational data corresponding to the queried data from the relational database based on the storage code associated with the queried second hash field.

[0014] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described data query method based on regular expression matching.

[0015] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described data query method based on regular expression matching.

[0016] The aforementioned data query method, apparatus, device, and medium based on regular expression matching, wherein the data query method converts the query data into a first hash field by using preset regular expression matching rules, queries a second hash field that matches the first hash field in the regular expression matching dictionary of the cache database, and finally retrieves the relational data corresponding to the query data from the relational database through the storage encoding associated with the second hash field. This invention utilizes preset regular expression matching rules (high-speed matching) in conjunction with a cache database (high-speed read / write) to achieve rapid matching of complex filtering conditions, thereby improving the speed and efficiency of data querying. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of the application environment of a data query method based on regular expression matching in one embodiment of the present invention;

[0019] Figure 2 This is a flowchart of a data query method based on regular expression matching in one embodiment of the present invention;

[0020] Figure 3 This is a flowchart of step S300 of a data query method based on regular expression matching in one embodiment of the present invention;

[0021] Figure 4 This is a schematic diagram of a data query device based on regular expression matching in one embodiment of the present invention;

[0022] Figure 5 This is another schematic diagram of a data query device based on regular expression matching in one embodiment of the present invention;

[0023] Figure 6 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0025] The data query method based on regular expression matching provided in this application can be applied to, for example... Figure 1 In this application environment, the client (computer device / terminal device) communicates with the server (server side) via a network. Clients (computer devices / terminal devices) include, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0026] In one embodiment, such as Figure 2 As shown, a data query method based on regular expression matching is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:

[0027] S100, Obtain a query request containing query data; the query data contains at least one first string. Understandably, the query data is input by the user through a client, and the query request is sent from the client to the server. For example, in an e-commerce system, when querying a product, the product's name, type, quantity, or specifications can all be entered as a first string in the query data. Furthermore, taking a timer program as an example, the timer program is used to trigger a scheduled task (containing query data) at a specified time. Multiple scheduled tasks can be set within the timer program. Each scheduled task can be set to create scheduled tasks according to daily, weekly, or custom time ranges (the limitations on days and weeks within the time range can all be considered as a first string). After creating a scheduled task, it will be triggered when the specified time is reached.

[0028] S200, perform regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences to generate a first hash field with a hash structure. Understandably, the preset regular expression matching rules include using the first hash field (generated from all first hash strings according to a preset association sequence) to describe and match the query field (generated from all first strings according to a preset association sequence). The preset association sequence is the concatenation sorting sequence used by the relational database in the server when concatenating strings in the relational data.

[0029] In one embodiment, step S200, which involves performing regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences to generate a first hash field with a hash structure, includes:

[0030] Obtain the preset association sequence from the second hash field in the regular expression matching dictionary, and sort all the first strings in the query data according to the preset association sequence to obtain the field to be queried. In one embodiment, the field to be queried is generated by concatenating all the first strings according to the preset association sequence using preset symbols. The preset symbols include, but are not limited to, "_" or " / ", as long as they are concatenated according to a uniform preset symbol. For example, in the above timer program, the field to be queried is obtained as follows: the timer task is divided into 3 segments (3 first strings) according to the time type order (i.e., the preset association sequence) using "_" (preset symbol). Specifically, the preset association sequence of the field to be queried for the timer task can be: the number of days in a year of the current time _ the number of days in a week of the current time _ the number of seconds in a day of the current time. All the first strings after the above sorting are the field to be queried.

[0031] According to preset regular expression matching rules, all the first strings in the field to be queried are matched using regular expressions to generate a first hash string corresponding to each of the first strings. Understandably, the first hash string refers to a short string (which may consist of one or a few characters) extracted or converted from the first string, and is used to briefly describe the more complex first string.

[0032] All the generated first hash strings are concatenated according to the preset association sequence to generate a first hash field with a hash structure. Understandably, the first hash field is generated by concatenating at least one first hash string according to the preset association sequence using preset symbols. The first hash field also includes preset query conditions corresponding to each first hash string, and the preset query conditions include, but are not limited to, all, equal, contain, range, or size. Understandably, the number of first hash strings in the first hash field is equal to the number of second hash strings in the second hash field, so that the first hash field can match the second hash field. Understandably, if, when sorted according to the preset association sequence, a first hash string in the first hash field does not have a corresponding first string (i.e., the string at that position is an empty string), then that first hash string is recorded as {*}. For example, in the above timer program:

[0033] If the scheduled task (i.e., querying data) is "9:00 to 18:00 every day", then the first string in the query field, "the number of days in a year where the current time is", is "every day" (the default query condition is all). In this case, the first hash string corresponding to the first string can be recorded as {*}. If the first string in the query field, "the number of days in a week where the current time is", is an empty field, then the first hash string corresponding to the first string can also be recorded as {*}. If the first string in the query field, "the number of seconds in a day where the current time is", is "32400 seconds to 64800 seconds" (the default query condition is range), then the first hash string corresponding to the first string can also be recorded as [32400, 64800]. Finally, the first hash field corresponding to the above query fields is generated, that is: day_{*}_{*}_[32400, 64800] (which is the first hash field corresponding to the above query data).

[0034] Similarly, if the scheduled task (i.e., querying data) is "from 9:00 to 18:00 every Monday and Tuesday", then the first string "the number of days in a year of the current time" in the query field is an empty field, and the first hash string corresponding to this first string can be recorded as {*}; the first string "the number of days in a week of the current time" in the query field is Monday and Tuesday (the default query condition is inclusive), and the first hash string corresponding to this first string can be recorded as [1|2]; the first string "the number of seconds in a day of the current time" in the query field is from 32400 seconds to 64800 seconds (the default query condition is range), and the first hash string corresponding to this first string can be recorded as [32400,64800]; finally, the first hash field corresponding to the above query fields is generated as: day_{*}_[1|2]_[32400,64800] (i.e., the first hash field corresponding to the above query data);

[0035] If the scheduled task (i.e., querying data) is "2022-06-01, 9:00 to 2022-06-10, 18:00", then the first string in the query field, "the number of days in the year the current time is", is 2022-06-01 to 2022-06-10 (the default query condition is a range). In this case, the first hash string corresponding to this first string can be recorded as [152, 161]. If the first string in the query field, "the number of days in the week the current time is", is an empty field, then the first string... The first hash string corresponding to the character string can be recorded as {*}; the first string in the field to be queried, "the current time in seconds of the day", is between 32400 and 64800 seconds (the preset query condition is a range), and the first hash string corresponding to this first string can be recorded as [32400, 64800]; finally, the first hash field corresponding to the above-mentioned field to be queried is generated: day_[152, 161]_{*}_[32400, 64800] (that is, the first hash field corresponding to the above-mentioned query data). S300, according to the first hash field, the second hash field matching the first hash field is queried in the regular expression matching dictionary of the cache database; the regular expression matching dictionary stores at least one set of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field. Understandably, the first hash field and the second hash field are generated using the first hash string and the second hash string respectively in a specified order according to the preset association sequence, and the number of first hash strings in the first hash field is equal to the number of second hash strings in the second hash field. The regular expression matching dictionary stores at least one set of structure arrays, including but not limited to Key-Value (i.e., key-value pair) structure arrays. The Key is the storage code, and the Value is the second hash field. That is, the regular expression matching dictionary includes the second hash field and the storage code associated with the second hash field. The storage code (Key) associated with the second hash field can be retrieved from the regular expression matching dictionary through the second hash field (Value). In one embodiment, the cache database is a REDIS-type Key-Value database, which can cache the Key-Value structure array.

[0036] In one embodiment, such as Figure 3 As shown, in step S300, querying the regular expression matching dictionary of the cache database for a second hash field that matches the first hash field, based on the first hash field, includes:

[0037] S310, based on the first hash field, a regular expression matching query is performed using the GET method in the regular expression matching dictionary of the cache database, and it is confirmed whether a second hash field matching the first hash field exists in the regular expression matching dictionary. Understandably, the regular expression matching dictionary includes a HASH-MAP, which is a hash-associative container that associates the Value and Key of an object (e.g., a Key-Value structure array). The regular expression matching dictionary consists of multiple such structure arrays. The regular expression matching dictionary interface corresponds to the query instruction, meaning that the regular expression matching dictionary can query whether a second hash field matching the first hash field exists in the regular expression matching dictionary according to the query instruction.

[0038] S320, when a second hash field matching the first hash field exists in the regular expression matching dictionary, the storage code associated with the queried second hash field is recorded. It can be understood that after confirming the existence of a second hash field matching the first hash field, the storage code associated with the second hash field can be queried in the regular expression matching dictionary through the second hash field.

[0039] In one embodiment, step S310, after confirming whether a second hash field matching the first hash field exists in the regular expression matching dictionary, includes: if a second hash field matching the first hash field does not exist in the regular expression matching dictionary, indicating that no relational data matching the query request exists in the relational database. It can be understood that if a second hash field matching the first hash field does not exist in the regular expression matching dictionary, it means that no storage code matching the first hash field exists in the cache database; therefore, no relational data corresponding to the first hash field (i.e., the query data) exists in the relational database.

[0040] S400, based on the storage code associated with the queried second hash field, relational data corresponding to the query data is retrieved from the relational database. In one embodiment, relational data refers to data with one-to-one or one-to-many relationships. For example, in an e-commerce system, product data (i.e., relational data) is entered by merchants in the client's management system through a page of the same type of form, including but not limited to information such as the product's name, type, quantity, and specifications. The query data corresponds to the relational data; therefore, the aforementioned information such as the product's name, type, quantity, or specifications can also be entered as a first string in the query data, thereby retrieving the specific relational data corresponding to the query data.

[0041] The data query method based on regular expression matching provided by this invention does not require direct matching from a relational database based on the entire query data. Instead, it first converts the query data into a first hash field using preset regular expression matching rules. Then, it searches for a second hash field in the regular expression matching dictionary of a cache database that matches the first hash field. Finally, it retrieves the corresponding relational data from the relational database using the storage encoding associated with the second hash field. This invention utilizes preset regular expression matching rules (for high-speed matching using a concise first hash field) in conjunction with a cache database (for high-speed read and write operations, eliminating the need for direct large-scale queries in the relational database), thereby achieving rapid matching of complex filtering conditions and improving the speed and efficiency of data querying.

[0042] In one embodiment, before obtaining the query request containing query data in step S100, the method further includes:

[0043] Retrieve relational data to be stored, including at least one second string, wherein all second strings in the relational data have a preset association sequence. In one embodiment, for example in an e-commerce system, product data (i.e., relational data) is entered by merchants in the client's management system through a page of the same type of form. Information such as the name, type, quantity, or specifications of the product can all be used as a second string in the relational data. The preset association sequence can be set to be arranged in the order of "name_type_quantity_specification". The relational data is generated by concatenating all the second strings according to the preset association sequence using preset symbols. The preset symbols include, but are not limited to, "_" or " / ", as long as they are concatenated according to a unified preset symbol. Taking the above timer program as an example, when determining whether the current time matches the time specified by the above timed task, the current time can be arranged according to the number of days in the year (first second string) - the number of days in the week (second second string) - the number of seconds in the day (third second string). The order of the above arrangement is the preset association sequence, and the field composed of the above three second strings can be regarded as a relational data.

[0044] A storage code corresponding to the relational data is generated, and the storage code is associated with the relational data and stored in the relational database. Understandably, the storage code can be an auto-incrementing code in the relational database, or it can be generated by an open-source code generator, as long as the storage code is globally unique.

[0045] According to the preset regular expression matching rules and the preset association sequence, regular expression matching is performed on all the second strings in the relational data to generate a second hash field with the preset association sequence. It can be understood that the preset regular expression matching rules include using the second hash field generated from all the second hash strings according to the preset association sequence to describe and match the relational data generated from all the second strings according to the preset association sequence.

[0046] In one embodiment, the step of performing regular expression matching on all the second strings in the relational data according to the preset regular expression matching rules and the preset association sequence to generate a second hash field having the preset association sequence includes:

[0047] According to the preset regular expression matching rules, all the second strings in the relational data are subjected to regular expression matching to generate a second hash string corresponding to each of the second strings. Understandably, the second hash string is a single string (i.e., a short string) used to describe and match the second string (i.e., a complex string).

[0048] All the generated second hash strings are concatenated according to the preset association sequence to generate a second hash field with a hash structure. Understandably, the second hash field is generated by concatenating at least one second hash string according to the preset association sequence using preset symbols. For example, in the embodiment described above for illustrating the first hash field, if the relational data to be stored corresponding to the timer program is the current time, and the current time is "2022-06-01 (Wednesday), 9:00", then the second string "the number of days in the year in which the current time is" in the relational data is 2022-06-01, and the second hash string corresponding to this second string is 152; the second string "the number of days in the week in which the current time is" in the relational data is Wednesday, and the second hash string corresponding to this second string is 3; the second string "the number of seconds in the day in which the current time is" in the relational data is 32400 seconds, and the second hash string corresponding to this second string is 32400; finally, the second hash field corresponding to the relational data is generated: day_152_3_32400 (that is, the second hash field corresponding to the current time). Based on this, if the first hash field generated by querying data is

[0049] day_[152,161]_{*}_[32400,64800]; At this time, since [152,161] matches 152, {*} matches 3, and [32400,64800] matches 32400, it is considered that the first hash field above matches the second hash field above.

[0050] The storage code and the second hash field are stored as a set of structure arrays in the regular expression matching dictionary of the cache database. Understandably, the regular expression matching dictionary stores at least one set of structure arrays, each containing a second hash field with the preset association sequence and a storage code associated with the second hash field. The structure arrays include, but are not limited to, Key-Value (i.e., key-value pair) structure arrays, where the Key is the storage code and the Value is the second hash field. In other words, the regular expression matching dictionary includes the second hash field and the storage code associated with it, and the storage code (Value) associated with the second hash field can be retrieved from the regular expression matching dictionary using the second hash field (Key). In one embodiment, the cache database is a REDIS-type Key-Value database, which can cache the Key-Value structure arrays.

[0051] In one embodiment, a data query device based on regular expression matching is also provided, which corresponds one-to-one with the data query method based on regular expression matching in the above embodiments. For example... Figure 4 As shown, the data query device based on regular expression matching includes a condition acquisition module 100, a first matching module 200, a first query module 300, and a second query module 400. Detailed descriptions of each functional module are as follows:

[0052] The condition acquisition module 100 is used to acquire a query request containing query data; the query data contains at least one first string.

[0053] The first matching module 200 is used to perform regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences, and generate a first hash field with a hash structure;

[0054] The first query module 300 is used to query a second hash field that matches the first hash field in the regular expression matching dictionary of the cache database based on the first hash field; the regular expression matching dictionary stores multiple sets of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field;

[0055] The second query module 400 is used to query relational data corresponding to the query data from the relational database based on the storage code associated with the queried second hash field.

[0056] In one embodiment, such as Figure 5As shown, the data query device also includes a data acquisition module 500, an encoding generation module 600, a second matching module 700, and a storage module 800. Detailed descriptions of each functional module are as follows:

[0057] The data acquisition module 500 is used to acquire relational data to be stored, which includes at least one second string, wherein all the second strings in the relational data have a preset association sequence.

[0058] The encoding generation module 600 is used to generate a storage code corresponding to the relational data, and associate the storage code with the relational data and store it in a relational database;

[0059] The second matching module 700 is used to perform regular expression matching on all the second strings in the relational data according to the preset regular expression matching rules and the preset association sequence, and generate a second hash field with the preset association sequence;

[0060] The storage module 800 is used to associate and store the storage code and the second hash field as a set of structure arrays in the regular expression matching dictionary of the cache database.

[0061] In one embodiment, a computer device is also provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. 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, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps of the aforementioned data query method based on regular expression matching.

[0062] In one embodiment, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described data query method based on regular expression matching.

[0063] 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, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0064] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0065] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A data query method based on regular expression matching, characterized in that, include: Retrieve the query request containing the query data; The query data contains at least one first string; According to the preset regular expression matching rules and the preset association sequence, all first strings in the query data are matched using regular expressions to generate a first hash field with a hash structure. Based on the first hash field, a second hash field matching the first hash field is queried in the regular expression matching dictionary of the cache database; the regular expression matching dictionary stores multiple sets of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field; Based on the storage code associated with the queried second hash field, relational data corresponding to the queried data is retrieved from the relational database; Before obtaining the query request containing the query data, the process also includes: Obtain relational data to be stored, which includes at least one second string, wherein all the second strings in the relational data have a preset association sequence; Generate a storage code corresponding to the relational data, and associate the storage code with the relational data and store it in the relational database; According to the preset regular expression matching rules and the preset association sequence, perform regular expression matching on all the second strings in the relational data to generate a second hash field with the preset association sequence; The storage code and the second hash field are stored together as a structure array in the regular expression matching dictionary of the cache database.

2. The data query method based on regular expression matching as described in claim 1, characterized in that, The step of performing regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences to generate a first hash field with a hash structure includes: Obtain the preset association sequence in the second hash field of the regular expression matching dictionary, and sort all the first strings in the query data according to the preset association sequence to obtain the field to be queried; According to the preset regular expression matching rules, perform regular expression matching on all the first strings in the field to be queried to generate a first hash string corresponding to each of the first strings; All the generated first hash strings are concatenated according to the preset association sequence to generate a first hash field with a hash structure.

3. The data query method based on regular expression matching as described in claim 1, characterized in that, The step of performing regular expression matching on all the second strings in the relational data according to the preset regular expression matching rules and the preset association sequence to generate a second hash field with the preset association sequence includes: According to the preset regular expression matching rule, perform regular expression matching on all the second strings in the relational data to generate a second hash string corresponding to each second string; All the generated second hash strings are concatenated according to the preset association sequence to generate a second hash field with a hash structure.

4. The data query method based on regular expression matching as described in claim 1, wherein querying the regular expression matching dictionary in the cache database for a second hash field that matches the first hash field, based on the first hash field, includes: Based on the first hash field, a regular expression matching query is performed using the GET method in the regular expression matching dictionary of the cache database, and it is confirmed whether there is a second hash field in the regular expression matching dictionary that matches the first hash field; When a second hash field that matches the first hash field exists in the regular expression matching dictionary, the storage code associated with the queried second hash field is recorded.

5. The data query method based on regular expression matching as described in claim 4, characterized in that, After confirming whether a second hash field matching the first hash field exists in the regular expression matching dictionary, the process includes: If no second hash field matching the first hash field exists in the regular expression matching dictionary, a message is displayed indicating that no relational data matching the query request exists in the relational database.

6. A data query device based on regular expression matching, characterized in that, include: The condition retrieval module is used to retrieve query requests containing query data; The query data contains at least one first string; The first matching module is used to perform regular expression matching on all first strings in the query data according to preset regular expression matching rules and preset association sequences, and generate a first hash field with a hash structure. The first query module is used to query a second hash field that matches the first hash field in the regular expression matching dictionary of the cache database based on the first hash field; the regular expression matching dictionary stores multiple sets of structure arrays, each set of structure arrays contains a second hash field with the preset association sequence and a storage code associated with the second hash field; The second query module is used to retrieve relational data corresponding to the queried data from the relational database based on the storage code associated with the queried second hash field. Also includes: A data acquisition module is used to acquire relational data to be stored, which includes at least one second string, wherein all the second strings in the relational data have a preset association sequence; The encoding generation module is used to generate a storage code corresponding to the relational data, and associate the storage code with the relational data and store it in the relational database; The second matching module is used to perform regular expression matching on all the second strings in the relational data according to the preset regular expression matching rules and the preset association sequence, and generate a second hash field with the preset association sequence. The storage module is used to associate the storage code and the second hash field as a set of structure arrays and store them in the regular expression matching dictionary of the cache database.

7. A computer 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, it implements the steps of the data query method based on regular expression matching as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the data query method based on regular expression matching as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data storage method and device, data query method and device, equipment and storage medium

    CN110147413A

  • Case information processing method and device, computer equipment and storage medium

    CN110377631A