Data retrieval method, device, electronic device and storage medium

By generating search IDs and cacheing multi-page page data, the Elasticsearch search engine's efficiency problem during page turn or repeated searches is solved, achieving faster response speed and better user experience.

CN113971238BActive Publication Date: 2025-08-12HANGZHOU DBAPPSECURITY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111299034.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-04
Publication Date
2025-08-12
Estimated Expiration
2041-11-04

AI Technical Summary

Technical Problem

In the prior art, Elasticsearch search engines need to search data repeatedly when users turn pages or search repeatedly, resulting in reduced processing efficiency and increased response time, and poor user experience.

Method used

By generating search IDs and cache multi-page page data, the number of searches by front-end devices from the Elasticsearch search engine is reduced, and the search IDs are used to quickly obtain target page data in the cache device.

Benefits of technology

It effectively reduces the burden on Elasticsearch search engines by front-end devices, improves response speed, reduces user waiting time, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113971238B_ABST
    Figure CN113971238B_ABST
Patent Text Reader

Abstract

The present invention provides a data retrieval method and related device, which include: upon receiving retrieval information sent by a front-end device, generating a retrieval ID using the retrieval information; utilizing the retrieval information to retrieve a preset number of pages of page data from an Elasticsearch search engine; wherein the page data includes a preset number of retrieval data items; establishing a correspondence between the page data and the retrieval ID and saving the correspondence to a cache device, and sending the first page of page data and the retrieval ID to the front-end device; upon receiving a retrieval ID to be queried and a target page number sent by the front-end device, searching the cache device for corresponding target page data according to the retrieval ID to be queried and the target page number, and sending the target page data to the front-end device; wherein the target page number is calculated based on the preset number of items. The present invention can obtain multiple pages of page data from a search engine, identify them, and cache them, making it easier for the front-end to obtain page data from the cache through identification, thereby improving retrieval efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology, and in particular to a data retrieval method, device, electronic equipment and storage medium. Background Art

[0002] Elasticsearch is a distributed full-text search engine. In related technologies, when a user flips pages or performs repeated searches, the front-end device must repeatedly send search information to the back-end Elasticsearch search engine, which then repeatedly retrieves data and returns it to the front-end device. However, these additional data retrieval operations can reduce Elasticsearch's processing efficiency and increase response time, further increasing the time users wait for data retrieval and reducing their experience with the Elasticsearch search engine. Summary of the Invention

[0003] The purpose of the present invention is to provide a data retrieval method, device, electronic device and storage medium, which can obtain multiple pages of page data from a search engine at one time and mark and cache them, making it easier for the front end to obtain page data from the cache through marking, thereby improving the efficiency of front-end information retrieval.

[0004] To solve the above technical problems, the present invention provides a data retrieval method, comprising:

[0005] When receiving the search information sent by the front-end device, generating a search ID using the search information;

[0006] Using the search information, searching for a preset number of page data from an Elasticsearch search engine; the page data includes a preset number of search data;

[0007] Establishing a correspondence between the page data and the search ID and saving the correspondence to a cache device, and sending the first page data of the page data and the search ID to the front-end device;

[0008] When the retrieval ID and target page number to be queried are received from the front-end device, the corresponding target page data is queried in the cache device according to the retrieval ID and target page number to be queried, and the target page data is sent to the front-end device; the target page number is calculated based on the preset number of entries.

[0009] Optionally, after generating a search ID using the search information, the method further includes:

[0010] Matching is performed in the cache device according to the search ID, and the first page data in the page data corresponding to the matched target search ID is sent to the front-end device.

[0011] Optionally, after sending the first page data of the page data and the search ID to the front-end device, the method further includes:

[0012] The remaining page data in the page data is transmitted to the front-end device in an asynchronous transmission manner, so that the front-end device caches the remaining page data locally and reads the remaining page data locally.

[0013] Optionally, using the search information to retrieve a preset number of pages of page data from an Elasticsearch search engine includes:

[0014] Using the search information, simultaneously searching for the page data from a primary cluster and a backup cluster of the Elasticsearch search engine, and recording a first response time and a second response time of the primary cluster and the backup cluster returning the page data, respectively;

[0015] If both the first response time and the second response time are less than a preset time, the step of establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device is performed using the page data returned by the primary cluster;

[0016] If the first response time or the second response time is not less than the preset time, the step of establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device is performed using the earliest returned page data.

[0017] Optionally, it also includes:

[0018] The standby cluster periodically synchronizes data with the active cluster.

[0019] Optionally, the cache device is a Redis database.

[0020] Optionally, using the search information to retrieve a preset number of pages of page data from an Elasticsearch search engine includes:

[0021] Using the search information, searching the Elasticsearch search engine for the first page of data in a normal query manner;

[0022] The search information is used to search the remaining page data one by one from the Elasticsearch search engine in an asynchronous query manner.

[0023] The present invention also provides a data retrieval device, comprising:

[0024] A search ID generating module, configured to generate a search ID using the search information when the search information is received from the front-end device;

[0025] A first retrieval module is configured to use the retrieval information to retrieve a preset number of page data from an Elasticsearch search engine; the page data includes a preset number of retrieval data;

[0026] a cache module, configured to establish a correspondence between the page data and the search ID and save the correspondence to a cache device, and to send the first page data of the page data and the search ID to the front-end device;

[0027] The second retrieval module is used to query the corresponding target page data in the cache device according to the retrieval ID to be queried and the target page number when receiving the retrieval ID to be queried and the target page number sent by the front-end device, and send the target page data to the front-end device; the target page number is calculated based on the preset number of items.

[0028] The present invention further provides an electronic device, comprising:

[0029] memory for storing computer programs;

[0030] A processor is configured to implement the steps of the data retrieval method described above when executing the computer program.

[0031] The present invention also provides a storage medium having a computer program stored thereon, and the computer program, when executed by a processor, implements the steps of the data retrieval method as described above.

[0032] The present invention provides a data retrieval method, comprising: upon receiving retrieval information sent by a front-end device, generating a retrieval ID using the retrieval information; utilizing the retrieval information to retrieve a preset number of page data from an Elasticsearch search engine; the page data comprising a preset number of retrieval data; establishing a correspondence between the page data and the retrieval ID and saving the correspondence to a cache device, and sending the first page of page data in the page data and the retrieval ID to the front-end device; upon receiving a to-be-queried retrieval ID and a target page number sent by the front-end device, querying the corresponding target page data in the cache device according to the to-be-queried retrieval ID and the target page number, and sending the target page data to the front-end device; the target page number is calculated based on the preset number of entries.

[0033] It can be seen that when the present invention receives the search information sent by the front-end device, it will first use the search information to generate a search ID, and retrieve a preset number of page data from the Elasticsearch search engine based on the search information; after obtaining the page data, the present invention will establish a corresponding relationship between the search ID and the page data and cache it. In other words, when the present invention receives the search information, it will obtain a batch of page data from the Elasticsearch search engine, and identify and cache this batch of page data. In this way, when the front-end device turns pages or performs repeated searches, it can directly obtain the target page data from the cache device through the search ID identification information, which can effectively reduce the number of times the front-end device sends search information to the Elasticsearch search engine, reduce the burden of repeated queries on the Elasticsearch search engine by the front-end device, and improve the speed at which the back-end responds to the front-end device, reducing user waiting time, thereby effectively improving the user experience of using the Elasticsearch search engine. The present invention also provides a data retrieval device, an electronic device, and a storage medium with the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0035] Figure 1 A flow chart of a data retrieval method provided by an embodiment of the present invention;

[0036] Figure 2 This is a structural block diagram of a data retrieval device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0038] Elasticsearch is a distributed full-text search engine. In related technologies, when a user turns pages or performs repeated searches, the front-end device needs to repeatedly send search information to the Elasticsearch search engine located at the back end, so that the engine can repeatedly retrieve data and return it to the front-end device. However, these additional data retrieval operations can easily reduce the processing efficiency of the Elasticsearch search engine and increase the response time, thereby increasing the time users wait for data retrieval and reducing the user experience of the Elasticsearch search engine. In view of this, the present invention provides a data retrieval method that can obtain multiple pages of page data from the search engine at one time and mark and cache them, so that the front end can obtain page data from the cache through marking, thereby improving the efficiency of front-end information retrieval. Please refer to Figure 1 , Figure 1 A flowchart of a data retrieval method provided by an embodiment of the present invention may include:

[0039] S101. When receiving search information sent by a front-end device, generate a search ID using the search information;

[0040] In the embodiment of the present invention, the search information is the information required by the Elasticsearch search engine for the search. The embodiment of the present invention does not limit the specific content of the search information. For example, the search information may include search keywords, query conditions, search-related options, and a search time range, and can be selected according to actual application needs.

[0041] Furthermore, the embodiment of the present invention will obtain a large amount of search data from the Elasticsearch search engine at one time and cache it in batches to reduce the number of times data is retrieved from the search engine. In order to uniformly manage the searched data, it is necessary to label these data. In the embodiment of the present invention, considering that these data are all retrieved through search information, that is, they carry characteristic information of the search information, the search data can be labeled using the search information. Specifically, a search ID (searchID) will be generated using the search information, and the search data will be labeled using the search ID. The embodiment of the present invention does not limit how to generate the search ID, for example, a unique digital ID can be generated for the search information; of course, the character strings corresponding to the search information can also be spliced, and the spliced character strings can be converted into MD5 values, and then the MD5 value can be set as the search ID, where MD5 (Message-Digest Algorithm) is a message digest algorithm that can generate a hash value to ensure that the information transmission is complete and consistent. In the embodiment of the present invention, considering that the MD5 value is easy to calculate and restore, the search ID can be generated by the above-mentioned method of generating the MD5 value.

[0042] S102: Using the search information, searching for a preset number of page data from an Elasticsearch search engine; the page data includes a preset number of search data items.

[0043] In an embodiment of the present invention, upon receiving a search message sent by a front-end device, multiple pages of page data are retrieved from the Elasticsearch search engine, each page of page data containing a preset number of search data items. The embodiment of the present invention does not limit the specific values of the preset number of pages and items, and these values can be set according to actual application requirements. Furthermore, the embodiment of the present invention does not limit whether different methods are needed to differentiate and retrieve page data. When a single retrieval method can ensure the efficiency of returning page data to the front-end device, a single retrieval method can be used for retrieval. When the efficiency of returning page data to the front-end device needs to be improved, different methods can also be used to retrieve different page data items. In an embodiment of the present invention, considering that the first page of page data is the page data that the front-end device urgently needs to display and needs to be returned as quickly as possible, while the remaining page data is cached data and does not need to be returned to the front-end, or can be returned to the front-end at a lower speed, that is, the first page of page data and the remaining page data in the page data have different requirements for return speed, it is difficult to ensure retrieval efficiency using a single retrieval method. Therefore, different retrieval methods can be used to retrieve different page data items. Specifically, since the first page of page data needs to be returned to the front-end device as quickly as possible, a normal query method (such as a synchronous query method) can be used to obtain it from the Elasticsearch search engine; and the remaining page data can be returned at a lower speed or do not need to be returned, so it can be retrieved from the Elasticsearch search engine using a slower asynchronous query method.

[0044] In one possible scenario, using the search information to retrieve a preset number of pages of page data from the Elasticsearch search engine may include:

[0045] Step 11: Use the search information to retrieve the first page of data from the Elasticsearch search engine in a normal query mode.

[0046] In order to increase the speed of returning data to the front-end device, the first page of page data can be returned to the front-end device immediately when the first page of page data is obtained, without waiting for the remaining pages of data to be retrieved.

[0047] Step 12: Use the search information to asynchronously query the Elasticsearch search engine to retrieve the remaining page data one by one.

[0048] It should be noted that the embodiments of the present invention do not limit how to retrieve data from the Elasticsearch search engine using normal query methods or asynchronous query methods. For details, see the relevant Elasticsearch technologies. It should be noted that the number of asynchronous queries is the same as the number of remaining pages. For example, if there are 9 pages remaining, 9 asynchronous queries will be initiated to the Elasticsearch search engine.

[0049] S103: Establish a corresponding relationship between the page data and the search ID and save them to the cache device, and send the first page data and the search ID in the page data to the front-end device.

[0050] In an embodiment of the present invention, in order to avoid repeatedly retrieving data from the Elasticsearch search engine, the retrieval data obtained by batch retrieval can be saved to a cache device, and the retrieval ID of this batch can be sent to the front-end device, so that the front-end device can use the retrieval ID to quickly obtain data from the cache device when turning pages or repeating the search, thereby reducing the response delay and improving the response speed. It should be noted that the embodiment of the present invention is not limited to a specific cache device, and reference can be made to the relevant database technology. In one possible scenario, considering that the Redis database has a simple structure and a fast query speed, Redis can be used as a cache device, where the Redis database is a key-value storage system.

[0051] It should be noted that the embodiments of the present invention do not limit the number of search IDs and page data sets that a cache device can store; this number can be set based on actual application requirements. Of course, the cache device can also implement an expiration mechanism for search IDs and page data to ensure the high timeliness of page data. The embodiments of the present invention do not limit the specific expiration mechanism; for example, reference can be made to the related art of Redis expiration policies.

[0052] Furthermore, considering that the front-end device reads page data from the local cache to further improve the response efficiency, after sending the first page of page data to the front-end device, the remaining page data can also be sent to the front-end device for caching, so that the front-end device can read the remaining page data through the local cache. Of course, the remaining page data can be sent to the front-end device via a slow transmission method, for example, it can be sent via asynchronous transmission. It should be noted that the embodiment of the present invention does not limit the specific method of asynchronous transmission, and reference may be made to the relevant technology of asynchronous transmission. The embodiment of the present invention also does not limit how the front-end device caches page data, and reference may be made to the relevant technology of the browser.

[0053] In one possible scenario, after sending the first page of page data and the search ID to the front-end device, the following steps may also be included:

[0054] Step 21: Transmit the remaining page data in the page data to the front-end device through asynchronous transmission, so that the front-end device caches the remaining page data locally and reads the remaining page data from the local.

[0055] Of course, in addition to returning the remaining page data, the backend can also return the search ID to the front-end device at the same time, so that the front-end device can confirm that the received page data belongs to the batch corresponding to the search ID, and then cache it according to the search ID.

[0056] S104. When receiving the retrieval ID and target page number to be queried sent by the front-end device, query the corresponding target page data in the cache device according to the retrieval ID and target page number to be queried, and send the target page data to the front-end device; the target page number is calculated based on the preset number of entries.

[0057] In an embodiment of the present invention, since the backend caches page data obtained in batches and marks them with search IDs, the front-end device can directly obtain the required target page data from the backend using the search ID. Specifically, the front-end device can obtain the target page data from the backend by sending two parameters to the backend: the search ID to be queried and the target page number. The target page number is calculated based on the preset number of search data items contained in each page data. Specifically, since page data is usually obtained from the Elasticsearch search engine in sequence, the page data has a sequence, and thus the search data between each page also has a sequence, so sequence numbers can be set for the search data. For example, for ten pages of page data, each page has 10 search data items. Therefore, the search data for the first page of page data can be assigned sequence numbers 0 to 9, the search data for the second page of page data can be assigned sequence numbers 10 to 19, and so on. When the front-end device obtains the page data, it can use the label of the first search data item in the currently output page data and the preset number of items to calculate the label of the first search data item in the target page data, and then use the label of the first search data item in the target page data as the target page number. For example, in the above example, if the page currently output by the front-end device is the first page of page data, and the page to be obtained is the second page of page data, the front-end device can use the sequence number 0 of the first search data of the first page of page data and the preset number of items 10 to calculate the sequence number 10 of the first search data of the second page of data, and then obtain the second page of data from the back-end based on the sequence number 10. Of course, the front-end device can also send the preset number of items to the back-end so that the back-end can perform verification calculations. Specifically, the front-end device can send parameters from and pageSize, where from is the target page number and pageSize is the preset number of search data items contained in each page of data.

[0058] Furthermore, in addition to returning the target page data, the backend can also simultaneously return a search ID to the frontend, allowing the frontend to confirm that the target page data belongs to the batch corresponding to the search ID. Of course, if the target page data the frontend is looking for is not stored in the cache device, an empty message can also be returned to the frontend. If the frontend fails to receive the search ID, it will request the Elasticsearch search engine to retrieve the data in the normal manner using the search message.

[0059] Based on the above embodiment, when the present invention receives the retrieval information sent by the front-end device, it will first use the retrieval information to generate a retrieval ID, and retrieve a preset number of page data from the Elasticsearch search engine based on the retrieval information; after obtaining the page data, the present invention will establish a correspondence between the retrieval ID and the page data and cache it. In other words, when the present invention receives the retrieval information, it will obtain a batch of page data from the Elasticsearch search engine, and identify and cache this batch of page data. In this way, when the front-end device turns pages or repeatedly searches, it can directly obtain the target page data from the cache device through the retrieval ID identification information, which can effectively reduce the number of times the front-end device sends retrieval information to the Elasticsearch search engine, reduce the burden of repeated queries on the Elasticsearch search engine by the front-end device, and improve the speed at which the back-end responds to the front-end device, reduce user waiting time, and effectively improve the user experience of using the Elasticsearch search engine.

[0060] Based on the above embodiment, considering that the cache device already stores historical batches of page data, when converting the search information sent by the front-end device into a search ID, the cache device can also be directly searched for page data based on the search ID. In one possible scenario, after generating the search ID using the search information, the following steps may also be performed:

[0061] S201 : performing a match in a cache device according to a search ID, and sending the first page of page data corresponding to the matched target search ID to a front-end device.

[0062] This effectively improves the efficiency of returning data to the front-end device. Of course, it also increases the flexibility of the front-end device's information query. For example, when turning a page, the front-end device can query the back-end for the target page data based on the search ID to be queried. When re-searching, the search information is directly sent to the back-end, which generates the corresponding search ID and performs a match, thereby improving the front-end's processing efficiency.

[0063] Based on the above embodiment, considering that the working condition of the Elasticsearch search engine is easily affected by the request volume and network conditions, and thus when retrieving data from the search engine, it is easy for the search engine to not return data, in the embodiment of the present invention, a primary cluster and a backup cluster are deployed for the Elasticsearch search engine, and retrieval redundancy is set for the search engine to avoid query failures caused by failure of the primary cluster. In one possible scenario, using the retrieval information to retrieve a preset number of pages of page data from the Elasticsearch search engine may include:

[0064] S301: Use the search information to simultaneously search for page data from the primary cluster and the backup cluster of the Elasticsearch search engine, and record the first response time and the second response time of the primary cluster and the backup cluster returning the page data respectively.

[0065] S302: If the first response time and the second response time are both less than the preset time, the page data returned by the primary cluster is used to establish a correspondence between the page data and the search ID and save the correspondence to the cache device.

[0066] If both the first and second response times are less than the preset time, it indicates that both clusters can respond to data in a timely manner and no abnormalities exist. Subsequent operations can then be performed using the page data returned by the primary cluster. It should be noted that the preset time is not limited to a specific value in this embodiment of the present invention and can be set based on actual application requirements, for example, 1 second.

[0067] S303: If the first response time or the second response time is not less than the preset time, the earliest returned page data is used to establish a corresponding relationship between the page data and the search ID and save the corresponding relationship to the cache device.

[0068] If the first response time or the second response time is not less than the preset time, it means that there is an abnormality in the main cluster or the backup cluster. At this time, the earliest returned page data can be used for subsequent operations.

[0069] Furthermore, to ensure that data in the standby cluster remains up to date, the standby cluster can be controlled to periodically synchronize data with the primary cluster. It should be noted that this embodiment of the present invention does not limit the specific value of the synchronization period; it can be set based on actual application requirements, for example, half an hour. This embodiment of the present invention also does not limit the specific method of data synchronization; reference can be made to the relevant technologies of Elasticsearch.

[0070] In one possible scenario, it may also include:

[0071] Step 31: The standby cluster periodically synchronizes data with the active cluster.

[0072] Based on the above embodiments, the present invention can deploy a primary cluster and a backup cluster for the Elasticsearch search engine, set retrieval redundancy for the search engine, and avoid query failures caused by failure of the primary cluster or the backup cluster.

[0073] The data retrieval device, electronic device, and storage medium provided by the embodiments of the present invention are introduced below. The data retrieval device, electronic device, and storage medium described below can correspond to the data retrieval method described above.

[0074] Please refer to Figure 2 , Figure 2 This is a structural block diagram of a data retrieval device provided by an embodiment of the present invention, the device comprising:

[0075] The search ID generating module 201 is used to generate a search ID using the search information when the search information sent by the front-end device is received;

[0076] The first retrieval module 202 is configured to use the retrieval information to retrieve a preset number of page data from the Elasticsearch search engine; the page data includes a preset number of retrieval data;

[0077] The cache module 203 is used to establish a correspondence between the page data and the search ID and save them to the cache device, and send the first page data and the search ID in the page data to the front-end device;

[0078] The second retrieval module 204 is used to query the corresponding target page data in the cache device according to the retrieval ID and target page number to be queried, and send the target page data to the front-end device when receiving the retrieval ID and target page number to be queried sent by the front-end device; the target page number is calculated based on the preset number of items.

[0079] Optionally, the device may further include:

[0080] The matching module is used to perform matching in the cache device according to the search ID, and send the first page of page data corresponding to the matched target search ID to the front-end device.

[0081] Optionally, the device may further include:

[0082] The asynchronous transmission module is used to transmit the remaining page data in the page data to the front-end device through asynchronous transmission, so that the front-end device caches the remaining page data locally and reads the remaining page data from the local.

[0083] Optionally, the first retrieval module 202 includes:

[0084] A first retrieval submodule is configured to use the retrieval information to simultaneously retrieve page data from a primary cluster and a backup cluster of the Elasticsearch search engine, and to record a first response time and a second response time of the primary cluster and the backup cluster returning the page data, respectively.

[0085] A first processing submodule, configured to, if both the first response time and the second response time are less than a preset time, use the page data returned by the primary cluster to execute the steps of establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device;

[0086] The second processing submodule is configured to use the earliest returned page data to establish a correspondence between the page data and the search ID and save the correspondence to the cache device if the first response time or the second response time is not less than a preset time.

[0087] Optionally, the device may further include:

[0088] The synchronization module is used for the standby cluster to periodically synchronize data with the active cluster.

[0089] Optionally, the cache module 203 is further configured to establish a correspondence between the page data and the search ID and save the correspondence to the Redis database.

[0090] Optionally, the first retrieval module 202 includes:

[0091] The second retrieval submodule is used to retrieve the first page of page data from the Elasticsearch search engine in a normal query mode using the retrieval information;

[0092] The third retrieval submodule is used to use the retrieval information to retrieve the remaining page data one by one from the Elasticsearch search engine in an asynchronous query manner.

[0093] An embodiment of the present invention further provides an electronic device, including:

[0094] memory for storing computer programs;

[0095] A processor is used to implement the steps of the above-mentioned data retrieval method when executing a computer program.

[0096] Since the embodiments of the electronic device part correspond to the embodiments of the data retrieval method part, the embodiments of the electronic device part refer to the description of the embodiments of the data retrieval method part, which will not be repeated here.

[0097] An embodiment of the present invention further provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the data retrieval method of any of the above embodiments are implemented.

[0098] Since the embodiments of the storage medium part correspond to the embodiments of the data retrieval method part, the embodiments of the storage medium part refer to the description of the embodiments of the data retrieval method part, and are not described here in detail.

[0099] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0100] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.

[0101] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0102] The above is a detailed introduction to a data retrieval method, device, electronic device, and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the method and core ideas of the present invention. It should be pointed out that, for those skilled in the art, without departing from the principles of the present invention, several improvements and modifications may be made to the present invention, and such improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A data retrieval method, characterized in that: include: When receiving the search information sent by the front-end device, generating a search ID using the search information; Using the search information, searching for a preset number of page data from an Elasticsearch search engine; the page data includes a preset number of search data; Establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device, and sending the first page data of the page data and the search ID to the front-end device; when the front-end device turns pages or performs repeated searches, the front-end device uses the search ID to obtain page data from the cache device; Transmitting the remaining page data in the page data to the front-end device in an asynchronous transmission manner, and returning a search ID to the front-end device, so that the front-end device caches the remaining page data locally according to the search ID and reads the remaining page data from the local cache; When receiving the search ID and target page number sent by the front-end device, querying the corresponding target page data in the cache device according to the search ID and target page number sent by the front-end device, and sending the target page data to the front-end device; The target page number is calculated based on the preset number of entries; The step of using the search information to retrieve a preset number of page data from an Elasticsearch search engine includes: Using the search information, searching the Elasticsearch search engine for the first page of data in a normal query manner; The search information is used to search the remaining page data one by one from the Elasticsearch search engine in an asynchronous query manner.

2. The data retrieval method according to claim 1, wherein: After generating a search ID using the search information, the method further includes: Matching is performed in the cache device according to the search ID, and the first page data in the page data corresponding to the matched target search ID is sent to the front-end device.

3. The data retrieval method according to claim 1, wherein: The step of using the search information to retrieve a preset number of page data from an Elasticsearch search engine includes: Using the search information, simultaneously searching for the page data from a primary cluster and a backup cluster of the Elasticsearch search engine, and recording a first response time and a second response time of the primary cluster and the backup cluster returning the page data, respectively; If both the first response time and the second response time are less than a preset time, the step of establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device is performed using the page data returned by the primary cluster; If the first response time or the second response time is not less than the preset time, the step of establishing a correspondence between the page data and the search ID and saving the correspondence to the cache device is performed using the earliest returned page data.

4. The data retrieval method according to claim 3, wherein: Also includes: The standby cluster periodically synchronizes data with the active cluster.

5. The data retrieval method according to claim 1, wherein: The cache device is a Redis database.

6. A data retrieval device, characterized in that: include: A search ID generation module, configured to generate a search ID using the search information when the search information is received from the front-end device; A first retrieval module is configured to use the retrieval information to retrieve a preset number of page data from an Elasticsearch search engine; the page data includes a preset number of retrieval data; a cache module, configured to establish a correspondence between the page data and the search ID and save the correspondence to a cache device, and to send the first page data of the page data and the search ID to the front-end device; when the front-end device turns pages or performs repeated searches, it uses the search ID to obtain page data from the cache device; a second retrieval module, configured to, upon receiving the retrieval ID and target page number sent by the front-end device, query the cache device for corresponding target page data according to the retrieval ID and target page number sent by the front-end device, and send the target page data to the front-end device; The target page number is calculated based on the preset number of entries; an asynchronous transmission module, configured to transmit the remaining page data in the page data to the front-end device by asynchronous transmission, and simultaneously return a retrieval ID to the front-end device, so that the front-end device locally caches the remaining page data according to the retrieval ID and reads the remaining page data from the local cache; The first search module includes: A second retrieval submodule is configured to retrieve the first page data from the Elasticsearch search engine in a normal query manner using the retrieval information; The third retrieval submodule is configured to use the retrieval information to retrieve the remaining page data one by one from the Elasticsearch search engine in an asynchronous query manner.

7. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the data retrieval method according to any one of claims 1 to 5 when executing the computer program.

8. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the steps of the data retrieval method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and apparatus for obtaining Elastinceserach paging data

    CN106126731A

  • Paging query method and device, storage medium and electronic equipment

    CN111858581A

  • Data retrieval method, device and equipment and storage medium

    CN112579633A