A search engine expansion method, device, electronic device and storage medium

By expanding the routing table of the search engine and determining and storing the node identifiers of index data fragments, the problem of high redundancy cost and difficulty in user-insensitive expansion in traditional methods is solved, and efficient and low-cost index data fragmentation is achieved. Expansion.

CN112182328BActive Publication Date: 2024-09-17BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010911635.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-02
Publication Date
2024-09-17
Estimated Expiration
2040-09-02

AI Technical Summary

Technical Problem

When traditional search engines expand index data sharding, they need to create new clusters, resulting in high system redundancy costs, and there are challenges in implementing index data sharding expansion without users being aware of it.

Method used

By expanding the pre-created routing table, determining the relationship between the shard ID and the node ID of the expanded index data shards, and storing the expanded index data shards to the target node, avoiding the need to re-create a new cluster, reducing costs and achieving Unconscious expansion.

Benefits of technology

It reduces the cost of the search engine system, achieves imperceptible expansion of index data fragmentation, and improves user experience and system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112182328B
    Figure CN112182328B
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for expanding a search engine, the method comprising: determining the number of expansions of index data shards; expanding a pre-created first routing table according to the number of expansions of the index data shards to obtain an expanded first routing table; determining the node identifiers corresponding to the shard identifiers of each expanded index data shard according to the correspondence between the shard identifiers and the node identifiers stored in the expanded first routing table; for each expanded index data shard, storing the expanded index data shard in a target index node, the node identifier of the target index node being the node identifier corresponding to the shard identifier of the expanded index data shard. The technical solution provided by the embodiments of the present application can reduce the cost of the search engine system. Moreover, the expansion of the index data shards is achieved without the user terminal being aware of it.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of search technology, and in particular to a method, device, electronic device and storage medium for expanding the capacity of a search engine. Background Art

[0002] The index data of traditional search engines are all stored locally, but as the index data of search engines increases, it is impossible to store all the index data locally.

[0003] Usually, this problem is solved by sharding the index data. Specifically, the index data can be divided into multiple index data shards, and different index data shards are distributed on different index nodes, that is, the index data is distributed to multiple index nodes.

[0004] As the index data increases, the index data shards will be expanded. For example, the original index data was divided into 2 index data shards, and now the index data needs to be divided into 4 index data shards. In the related art, when storing the expanded index data shards, the method usually adopted is: creating a new cluster for storing the expanded index data shards. The method of creating a new cluster to store the expanded index data shards in the related art has the problem of high redundancy cost of the search engine system. Summary of the invention

[0005] In order to solve the problem of high redundancy cost of search engine system in the related art of creating a new cluster to store the expanded index data shards, the present application shows a search engine expansion method, device, electronic device and storage medium.

[0006] In a first aspect, an embodiment of the present application provides a method for expanding the capacity of a search engine, the method comprising:

[0007] Determine the number of index data shards to be expanded;

[0008] Expanding the pre-created first routing table according to the expanded number of the index data shards to obtain the expanded first routing table, wherein the first routing table stores the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes;

[0009] Determine the node identifier corresponding to the shard identifier of each index data shard after expansion according to the correspondence between the shard identifiers and the node identifiers stored in the expanded first routing table;

[0010] For each expanded index data shard, the expanded index data shard is stored in a target index node, and the node identifier of the target index node is a node identifier corresponding to the shard identifier of the expanded index data shard.

[0011] Optionally, the expanding the first routing table based on the expanded number of index data shards to obtain the expanded first routing table includes:

[0012] Determine the multiple of the number of index data shards after expansion and the number of index data shards before expansion;

[0013] The first routing table is expanded by the multiple to obtain an expanded first routing table.

[0014] Optionally, the first routing table is expanded based on the expanded number of index data shards, so that each expanded index data shard includes a plurality of index data blocks;

[0015] For each expanded index data shard, storing the expanded index data shard in a target index node includes:

[0016] For each expanded index data shard, the startup node identifier is the target index node corresponding to the expanded index data shard, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard;

[0017] For each expanded index data shard, storing the target index data block included in the expanded index data shard to the target index node;

[0018] The target index data block stored in the index node before the expansion is deleted.

[0019] Optionally, the first routing table is expanded based on the expanded number of index data shards to obtain the expanded target index data block stored in the index node before the expansion is deleted, and the method further includes:

[0020] Updating a pre-created second routing table, wherein the second routing table is used to store a correspondence between data block identifiers of index data blocks and shard identifiers of index data shards;

[0021] A third routing table is created, wherein the third routing table is used to store the correspondence between the data block identifiers of the index data blocks and the node identifiers of the index nodes.

[0022] Optionally, the method of expanding the first routing table based on the expanded number of index data shards further includes:

[0023] Receiving a target search request sent by a terminal, and determining a target index data identifier corresponding to a target search term carried in the target search request;

[0024] Determine the target data block identifier corresponding to the target index data identifier according to the predetermined correspondence relationship between the index data identifier and the data block identifier of the index data block;

[0025] Determine the target data fragment identifier corresponding to the target data block identifier according to the correspondence between the data block identifier and the data fragment identifier stored in the updated second routing table;

[0026] Determine the target node identifier corresponding to the target data shard identifier according to the corresponding relationship between the shard identifier and the node identifier;

[0027] The target search request is sent to the index node having the target node identifier, index data matching the target search term fed back by the index node having the target node identifier is received, and the index data is sent to the terminal.

[0028] In a second aspect, an embodiment of the present application provides a search engine expansion device, the device comprising:

[0029] An expansion data determination module is used to determine the expansion quantity of index data shards;

[0030] A routing table expansion module, used to expand a pre-created first routing table according to the expansion quantity of the index data shards to obtain an expanded first routing table, wherein the first routing table stores a correspondence between shard identifiers of the index data shards and node identifiers of the index nodes;

[0031] A node identification determination module, used to determine the node identification corresponding to the shard identification of each index data shard after expansion according to the correspondence between the shard identification and the node identification stored in the first routing table after expansion;

[0032] The index data shard storage module is used to store each expanded index data shard in a target index node, wherein the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard.

[0033] Optionally, the first routing table is expanded based on the expanded number of index data shards to obtain an expansion module for expanding the routing table, which is specifically used for:

[0034] Determine the multiple of the number of index data shards after expansion and the number of index data shards before expansion;

[0035] The first routing table is expanded by the multiple to obtain an expanded first routing table.

[0036] Optionally, the first routing table is expanded based on the expanded number of index data shards, so that each expanded index data shard includes a plurality of index data blocks;

[0037] The index data shard storage module is specifically used for:

[0038] For each expanded index data shard, the startup node identifier is the target index node corresponding to the expanded index data shard, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard;

[0039] For each expanded index data shard, storing the target index data block included in the expanded index data shard to the target index node;

[0040] The target index data block stored in the index node before the expansion is deleted.

[0041] Optionally, the first routing table is expanded based on the expanded number of index data shards, and the expansion is obtained in the device further comprising:

[0042] A routing table updating module, used for updating a pre-created second routing table after deleting the target index data block stored in the index node before the expansion, wherein the second routing table is used to store the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard;

[0043] The routing table creation module is used to create a third routing table, wherein the third routing table is used to store the correspondence between the data block identifier of the index data block and the node identifier of the index node.

[0044] Optionally, the first routing table is expanded based on the expanded number of index data shards to obtain the expanded device further comprising:

[0045] A search request receiving module, configured to receive a target search request sent by a terminal, and determine a target index data identifier corresponding to a target search term carried in the target search request;

[0046] A target data block identifier determination module, configured to determine a target data block identifier corresponding to the target index data identifier according to a predetermined correspondence between an index data identifier and a data block identifier of the index data block;

[0047] a target data shard identifier determining module, configured to determine a target data shard identifier corresponding to the target data block identifier according to a correspondence between data block identifiers and data shard identifiers stored in the updated second routing table;

[0048] A target node identifier determination module, used to determine a target node identifier corresponding to the target data slice identifier according to a correspondence between the slice identifier and the node identifier;

[0049] The index data sending module is used to send the target search request to the index node with the target node identifier, receive the index data matching the target search term fed back by the index node with the target node identifier, and send the index data to the terminal.

[0050] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the search engine expansion method described in the first aspect are implemented.

[0051] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the search engine expansion method described in the first aspect are implemented.

[0052] The technical solution provided by the embodiment of the present application is to expand the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes to obtain the expanded first routing table, and determine the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the expanded first routing table, and store the expanded index data in the corresponding target index node. Since the existing index data shards before the expansion have been stored in their corresponding target index nodes, it is only necessary to store the newly added index data shards after the expansion in their corresponding target index nodes, unlike the related art, which requires the re-creation of a new cluster to store the expanded index data shards, thereby reducing the cost of the search engine system. In addition, the expansion of the index data shards is achieved without the user terminal being aware of it. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 It is a flowchart of the steps of a method for expanding the capacity of a search engine provided in an embodiment of the present application;

[0054] Figure 2 yes Figure 1 A flowchart of steps of an implementation method of S140 in the illustrated embodiment;

[0055] Figure 3 It is a flowchart of the steps of a method for expanding the capacity of a search engine provided in an embodiment of the present application;

[0056] Figure 4 A schematic diagram of sharding index data;

[0057] Figure 5 This is a schematic diagram of the process of expanding the index data shards;

[0058] Figure 6 A schematic diagram of creating a third routing table after expanding the index data shard;

[0059] Figure 7 It is a structural block diagram of a search engine expansion device provided in an embodiment of the present application;

[0060] Figure 8 It is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0062] In the related art, when the index data shards of the search engine are expanded, a new cluster for storing multiple index data shards is usually created. However, this method of storing multiple index data shards in the related art has the problem of high redundancy cost of the search engine system.

[0063] In order to solve the above technical problems existing in the related art, the embodiments of the present application provide a search engine expansion method, device, electronic device and storage medium.

[0064] In the first aspect, a search engine expansion method provided in an embodiment of the present application is first described in detail.

[0065] It should be noted that the execution subject of the search engine expansion method provided in the embodiment of the present application may be a search engine expansion device, and the search engine expansion device may run in an electronic device, and the electronic device may be a server. The embodiment of the present application does not specifically limit the electronic device.

[0066] like Figure 1 As shown, a flowchart of a method for expanding the capacity of a search engine provided in an embodiment of the present application may specifically include the following steps:

[0067] S110, determining the expansion quantity of the index data shards.

[0068] Specifically, as the index data of the search engine increases, it is impossible to store all the index data locally. Therefore, the index data is usually divided into multiple index data shards, and different index data are distributed on different index nodes, that is, the index data is distributed to multiple index nodes.

[0069] In actual applications, as the index data continues to increase, the number of index data shards needs to be increased, that is, the index data shards need to be expanded. For example, before the index data shards are expanded, the number of index data shards is 2, and the shard identifiers of these two index data shards are shard0 and shard1 respectively. Now the index data needs to be divided into 4 index data shards, and the shard identifiers of these four index data shards are shard0, shard1, shard2 and shard3 respectively. Then, the number of index data shards to be expanded is 2.

[0070] Of course, in practical applications, the number of index data shards to be expanded can be determined based on the amount of index data. The embodiment of the present application does not specifically limit the number of index data shards to be expanded.

[0071] S120, expand the pre-created first routing table according to the expanded number of index data shards to obtain the expanded first routing table.

[0072] The first routing table stores the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes.

[0073] Specifically, when storing index data, a routing table for storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes is created. For the sake of clear description of the solution, this routing table may be referred to as a first routing table.

[0074] In order to store the expanded index data shards on the corresponding index nodes in subsequent steps, after the expansion number of the index data shards is determined, the pre-created first routing table can be expanded according to the expansion number of the index data shards.

[0075] For example, before the expansion, the number of index data shards is 2, and the shard identifiers of the two index data shards are shard0 and shard1 respectively. The corresponding relationship between the shard identifiers of the index data shards stored in the first routing table before the expansion and the node identifiers of the index nodes is: shard0→node0, node2…; shard1→node1, node3…. After the expansion, the number of index data shards is 4, and the shard identifiers of the four index data shards are shard0, shard1, shard2 and shard3 respectively. Compared with the number of index data shards before the expansion, the expanded number of index data shards is 2, and the corresponding relationship between the shard identifiers of the index data shards stored in the first routing table after the expansion and the node identifiers of the index nodes is: shard0→node0, node2…; shard1→node1, node3…; shard2→node0, node2…; shard3→node1, node3….

[0076] In one implementation, based on the expanded number of index data shards, the first routing table is expanded to obtain the expanded first routing table, which may include the following steps, namely step a1 and step a2:

[0077] Step a1, determining a multiple of the number of index data shards after expansion and the number of index data shards before expansion.

[0078] Step a2: expand the first routing table by a multiple to obtain the expanded first routing table.

[0079] Specifically, in this embodiment, when the pre-created first routing table is expanded, the multiple between the number of index data shards after the expansion and the number of index data shards before the expansion can be determined. For example, the number of index data shards before the expansion is 2, and the number of index data shards after the expansion is 4, then the number of index data shards after the expansion is twice the number of index data shards before the expansion. Then, the first routing table is expanded by the multiple determined to obtain the expanded first routing table. For example, if the number of index data shards after the expansion is twice the number of index data shards before the expansion, then the first routing table is expanded by 2 times.

[0080] S130, determining the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the correspondence between the shard identifiers and the node identifiers stored in the expanded first routing table.

[0081] Specifically, since the correspondence between the shard identifiers and node identifiers of each index data shard is stored in the expanded first routing table, after obtaining the expanded first routing table, the node identifier corresponding to the shard identifier of each index data shard after expansion can be determined based on the correspondence between the shard identifiers and node identifiers stored in the expanded first routing table.

[0082] For example, if the corresponding relationship between the shard identifiers of the index data shards stored in the first routing table after expansion and the node identifiers of the index nodes is: shard0→node0, node2...; shard1→node1, node3...; shard2→node0, node2...; shard3→node1, node3... Then, according to the corresponding relationship between the shard identifiers of the index data shards stored in the first routing table after expansion and the node identifiers of the index nodes, it can be determined that the node identifier corresponding to shard0 is node0; the node identifier corresponding to shard1 is node1; the node identifier corresponding to shard2 is node2; and the node identifier corresponding to shard3 is node3.

[0083] S140: For each expanded index data shard, store the expanded index data shard in a target index node.

[0084] The node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard.

[0085] Specifically, after determining the node identifier corresponding to the shard identifier of each index data shard after expansion, each index data shard after expansion may be stored in the corresponding target index node.

[0086] For example, after the expansion, the number of index data shards is 4, and the shard identifiers of these four index data shards are shard0, shard1, shard2, and shard3 respectively; and the node identifier corresponding to shard0 is node0; the node identifier corresponding to shard1 is node1; the node identifier corresponding to shard2 is node2; and the node identifier corresponding to shard3 is node3. Then, the index data with the index data shard identifier shard0 can be stored in the target index node with the node identifier node0; the index data with the index data shard identifier shard1 can be stored in the target index node with the node identifier node1; the index data with the index data shard identifier shard2 can be stored in the target index node with the node identifier node2; and the index data with the index data shard identifier shard3 can be stored in the target index node with the node identifier node3.

[0087] It should be noted that before the index data shards are expanded, the index data shard 0 is already stored in the index node with the node ID node0; the index data shard 1 is already stored in the index node with the node ID node1. Therefore, after the index data shards are expanded, it is only necessary to store the index data shard 2 in the index node with the node ID node2, and store the index data shard 3 in the index node with the node ID node3.

[0088] In actual applications, when storing index data, the index data exists in the form of index data block buckets, that is, each index data block may include multiple index data; and each index data shard may include multiple index data blocks.

[0089] In one embodiment, when each index data shard includes multiple index data blocks, for each expanded index data shard, the expanded index data shard is stored in the target index node, such as Figure 2 As shown, the following steps may be included:

[0090] S210: For each expanded index data shard, the startup node is identified as a target index node corresponding to the expanded index data shard.

[0091] The node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard.

[0092] Specifically, after determining the node identifier corresponding to the shard identifier of each index data shard after expansion, the target index node corresponding to each index data shard after expansion is determined. Therefore, for each index data shard after expansion, the target index node corresponding to the index data shard after expansion can be started.

[0093] It can be understood that the target index nodes corresponding to the existing index score shards before the expansion have been started, so it is only necessary to start the target index nodes corresponding to the newly added index data shards after the expansion.

[0094] S220: For each expanded index data shard, store the target index data block included in the expanded index data shard to the target index node.

[0095] Specifically, for each expanded index data shard, after starting the target index node corresponding to the expanded index data shard, the target index data block included in the expanded index data shard can be stored in the target index node, that is, the data block bucket included in the expanded index data shard is migrated to the target index node.

[0096] S230, deleting the target index data block stored in the index node before the expansion.

[0097] For each expanded index data shard, after the target index data blocks included in the expanded index data shard are stored in the target index node, the target index data blocks stored in the index node before the expansion can be deleted to save the storage space of the index node before the expansion.

[0098] For example, the index data consists of 100 buckets, and the number of index data shards before expansion is 2, then each index data shard includes 50 buckets, and two index nodes can be started before expansion, each index node stores 50 buckets. If the number of index data shards after expansion is 4, then each index data shard includes 25 buckets, and a total of four index nodes need to be started after expansion, that is, compared with before expansion, two new index nodes need to be started after expansion, and the buckets to be stored in the two newly started index nodes will be migrated to the two newly started index nodes, and the buckets that have been migrated to the two newly started index nodes will be deleted from the index nodes that have been started before expansion.

[0099] The technical solution provided by the embodiment of the present application is to expand the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes to obtain the expanded first routing table, and determine the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the expanded first routing table, and store the expanded index data in the corresponding target index node. Since the existing index data shards before the expansion have been stored in their corresponding target index nodes, it is only necessary to store the newly added index data shards after the expansion in their corresponding target index nodes, unlike the related art, which requires the re-creation of a new cluster to store the expanded index data shards, thereby reducing the cost of the search engine system. In addition, the expansion of the index data shards is achieved without the user terminal being aware of it.

[0100] Based on the above embodiment, in one implementation manner, after deleting the target index data block stored in the index node before expansion, the expansion method of the search engine may further include the following steps, namely step b1 and step b2:

[0101] Step b1, updating the pre-created second routing table.

[0102] The second routing table is used to store the correspondence between the data block identifier of the index data block and the fragment identifier of the index data fragment.

[0103] Step b2: Create a third routing table.

[0104] The third routing table is used to store the correspondence between the data block identifier of the index data block and the node identifier of the index node.

[0105] From the above description, it can be seen that the expansion of the index data shard is actually to divide the index data blocks included in the index data shard before the expansion into multiple index data shards. That is to say, after the index data shard is expanded, the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard has changed. Therefore, the second routing table needs to be updated.

[0106] For example, before the index data shard is expanded, there are two index data shards, each of which includes 50 data blocks, and the shard identifiers of the two index data shards are shard0 and shard1. Then, before the index data is sharded, the corresponding relationship between the data block identifiers of the index data blocks stored in the second routing table and the shard identifiers of the index data shards is: the shard identifier of the index data shard corresponding to bucket0 to bucket49 is shard0; the shard identifier of the index data shard corresponding to bucket50 to bucket99 is shard1.

[0107] After the index data shards are expanded, the number of index data shards is four, each index data shard includes 25 data blocks, and the shard identifiers of these four index data shards are shard0, shard1, shard2, and shard3. Then, after the index data is sharded, the corresponding relationship between the data block identifiers of the index data blocks stored in the updated second routing table and the shard identifiers of the index data shards is as follows: the shard identifier of the index data shards corresponding to bucket0 to bucket24 is shard0; the shard identifier of the index data shards corresponding to bucket25 to bucket49 is shard1; the shard identifier of the index data shards corresponding to bucket50 to bucket74 is shard2; the shard identifier of the index data shards corresponding to bucket75 to bucket99 is shard3.

[0108] Furthermore, after the index data shard is expanded, the correspondence between the data block identifier of the index data block and the node identifier of the index node also changes, so it is necessary to create a third routing table.

[0109] Still taking the above example as an example, before the index data shard is expanded, the node identifier of the index node corresponding to bucket0 to bucket54 is node0, and the node identifier of the index node corresponding to bucket55 to bucket99 is node1. After the index data shard is expanded, the node identifier of the index node corresponding to bucket0 to bucket24 is node0, the node identifier of the index node corresponding to bucket25 to bucket49 is node1, the node identifier of the index node corresponding to bucket50 to bucket74 is node2, and the node identifier of the index node corresponding to bucket75 to bucket99 is node3.

[0110] It can be seen that through the technical solution provided by this embodiment, after the index data shard is expanded, the second routing table for storing the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard is accurately updated, and the third routing table for storing the correspondence between the data block identifier of the index data block and the node identifier of the index node is created, so that in the subsequent steps, the search engine can accurately provide search services.

[0111] Based on the above embodiment, in one implementation, the search engine expansion method may further include the following steps: Figure 3 shown.

[0112] S310, receiving a target search request sent by a terminal, and determining a target index data identifier corresponding to a target search term carried in the target search request.

[0113] When a user needs to query the data he needs through a search engine, he can send a target search request through a terminal, which carries a target search term input by the user. After receiving the target search request sent by the terminal, the target index data identifier corresponding to the target search term carried in the target search request can be determined.

[0114] S320: Determine a target data block identifier corresponding to the target index data identifier according to a predetermined correspondence relationship between the index data identifier and the data block identifier of the index data block.

[0115] Specifically, there are usually multiple index data, each of which can be represented by doc. When storing multiple index data, the multiple index data can be divided into different index data blocks, and each index data block can be represented by bucket. In practical applications, the correspondence between the index data identifier and the data block identifier of the index data block is fixed before and after the index data sharding is expanded. Therefore, after determining the target index data identifier corresponding to the target search term carried by the target search request, the target data block identifier corresponding to the target index data identifier can be determined based on the correspondence between the predetermined index data identifier and the data block identifier of the index data block.

[0116] S330: Determine a target data fragment identifier corresponding to the target data block identifier according to the correspondence between the data block identifier and the data fragment identifier stored in the updated second routing table.

[0117] Specifically, since the second routing table stores the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard, after determining the target data block identifier corresponding to the target index data identifier, the target data shard identifier corresponding to the target data block identifier can be searched in the updated second routing table.

[0118] S340, determining a target node identifier corresponding to the target data shard identifier according to a correspondence between the shard identifier and the node identifier.

[0119] Specifically, since the correspondence between the shard identifier and the node identifier is determined after the index data shard is expanded, the target node identifier corresponding to the target data shard identifier can be determined based on the correspondence between the shard identifier and the node identifier, so that in subsequent steps, the required index data can be obtained from the index node with the target node identifier.

[0120] It should be noted that in actual applications, the number of target data shard identifiers may be one or more, and therefore, the number of target node identifiers corresponding to the target data shard identifiers may also be multiple, and the number of index nodes having the target node identifiers may also be multiple.

[0121] S350, sending a target search request to the index node with the target node identifier, receiving index data matching the target search term fed back by the index node with the target node identifier, and sending the index data to the terminal.

[0122] Specifically, after determining the target node identifier, a target index request may be sent to the index node with the target node identifier. Specifically, when the number of index nodes with the target node identifier is one, a target search request may be directly sent to the index node with the target node identifier; when the number of index nodes with the target node identifier is multiple, target search requests may be sent to each of the multiple index nodes with the target node identifier.

[0123] After sending a target search request to an index node with a target node identifier, index data matching the target search request fed back by the index node with the target node identifier can be received. When there is only one index node with a target node identifier, the index data matching the target search term fed back by the index node with the target node identifier can be directly sent to the terminal; when there are multiple index nodes with a target node identifier, the index data matching the target search term fed back by the multiple index nodes with the target node identifier can be fed back to the terminal.

[0124] It can be seen that through the technical solution provided in the implementation mode of the present application, after the index data shards are expanded, the search engine can accurately and efficiently provide search services to users, so that users are unaware of the expansion process of the index data shards, thereby improving the user experience.

[0125] In order to describe the solution clearly, the technical solution provided in the embodiment of the present application will be elaborated in detail below with reference to specific examples.

[0126] like Figure 4 The figure shows a schematic diagram of index sharding, that is, a schematic diagram of sharding index data.

[0127] from Figure 4 It can be seen that in terms of index data storage implementation, the index data is divided into multiple index data blocks. In addition, the number of index data blocks is fixed, that is, bucketNum is 64, and the data block to which the index data is divided is also fixed, that is, doc→bucket is fixed.

[0128] However, the relationship between the bucket and the index data shard is variable. That is, when the index data shard is expanded, the relationship between the bucket and the shard changes, and the corresponding relationship between the bucket and the node also changes.

[0129] When storing index data, three routing tables are generated, namely the node→bucket routing table, the bucket→shard routing table, and the shard→node routing table. The node→bucket routing table is used to store the correspondence between the node ID of the node and the data block ID of the bucket. The bucket→shard routing table is used to store the correspondence between the data block ID of the bucket and the shard ID of the shard. The shard→node routing table is used to store the correspondence between the shard ID and the node ID of the node.

[0130] And, from Figure 4 It can be seen that when receiving the client's request, the target shard identifier corresponding to the search request can be determined based on the correspondence between the index data identifier docid and the index data block identifier bucketNum, and the correspondence between the index data block identifier bucketNum and the shard identifier shardNum of the index data shard, and the search request is unpacked, that is, the search request is sent to the index node with the target shard identifier. After receiving the search request, the index node with the target shard identifier feeds back the corresponding search result, which includes the full index data and the incremental index data. Finally, the search results are merged and sent to the client.

[0131] like Figure 5 The figure shows a schematic diagram of index expansion and contraction, that is, a schematic diagram of the process of expanding the index data shards.

[0132] from Figure 5 It can be seen that the process of expanding the index data shard is divided into two steps.

[0133] The first step is to copy the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes, that is, to expand the capacity of the first routing table. Specifically, Figure 5 In the example, the index data shards are expanded from 2 to 4, so the first routing table is expanded twice.

[0134] In the second step, after obtaining the expanded first routing table, determine the correspondence between the shard identifier of the expanded index data shard and the node identifier of the index node, and store the expanded index data shard to the corresponding index node by restarting the index node. Since the index data shard is composed of index data block buckets, storing the expanded index data shard to the corresponding index node is actually adjusting the distribution of the bucket.

[0135] It should be noted that due to Figure 5The expansion process of the index data shard has been described in detail in the above embodiment and will not be repeated here.

[0136] like Figure 6 , a schematic diagram of the structure of the third routing table created after the index data shard is expanded. Specifically, since the corresponding relationship between the data block identifier of the index data block bucket and the node identifier of the index node has changed after the index data shard is expanded, it is necessary to create a bucket→node routing table so as to provide accurate search services for users in subsequent steps.

[0137] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.

[0138] In a second aspect, the present application provides a search engine expansion device, such as Figure 7 As shown, the device comprises:

[0139] An expansion data determination module 710 is used to determine the expansion quantity of index data shards;

[0140] A routing table expansion module 720, configured to expand a pre-created first routing table according to the expanded number of index data shards to obtain an expanded first routing table, wherein the first routing table stores a correspondence between shard identifiers of index data shards and node identifiers of index nodes;

[0141] The node identifier determination module 730 is used to determine the node identifier corresponding to the shard identifier of each index data shard after expansion according to the correspondence between the shard identifier and the node identifier stored in the first routing table after expansion;

[0142] The index data shard storage module 740 is used to store each expanded index data shard in a target index node, where the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard.

[0143] The technical solution provided by the embodiment of the present application is to expand the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes to obtain the expanded first routing table, and determine the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the expanded first routing table, and store the expanded index data in the corresponding target index node. Since the existing index data shards before the expansion have been stored in their corresponding target index nodes, it is only necessary to store the newly added index data shards after the expansion in their corresponding target index nodes, unlike the related art, which requires the re-creation of a new cluster to store the expanded index data shards, thereby reducing the cost of the search engine system. In addition, the expansion of the index data shards is achieved without the user terminal being aware of it.

[0144] Optionally, the first routing table is expanded based on the expanded number of index data shards to obtain an expansion module for expanding the routing table, which is specifically used for:

[0145] Determine the multiple of the number of index data shards after expansion and the number of index data shards before expansion;

[0146] The first routing table is expanded by the multiple to obtain an expanded first routing table.

[0147] Optionally, the first routing table is expanded based on the expanded number of index data shards, so that each expanded index data shard includes a plurality of index data blocks;

[0148] The index data shard storage module is specifically used for:

[0149] For each expanded index data shard, the startup node identifier is the target index node corresponding to the expanded index data shard, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard;

[0150] For each expanded index data shard, storing the target index data block included in the expanded index data shard to the target index node;

[0151] The target index data block stored in the index node before the expansion is deleted.

[0152] Optionally, the first routing table is expanded based on the expanded number of index data shards, and the expansion is obtained in the device further comprising:

[0153] A routing table updating module, used for updating a pre-created second routing table after deleting the target index data block stored in the index node before the expansion, wherein the second routing table is used to store the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard;

[0154] The routing table creation module is used to create a third routing table, wherein the third routing table is used to store the correspondence between the data block identifier of the index data block and the node identifier of the index node.

[0155] Optionally, the first routing table is expanded based on the expanded number of index data shards to obtain the expanded device further comprising:

[0156] A search request receiving module, configured to receive a target search request sent by a terminal, and determine a target index data identifier corresponding to a target search term carried in the target search request;

[0157] A target data block identifier determination module, configured to determine a target data block identifier corresponding to the target index data identifier according to a predetermined correspondence between an index data identifier and a data block identifier of the index data block;

[0158] a target data shard identifier determining module, configured to determine a target data shard identifier corresponding to the target data block identifier according to a correspondence between data block identifiers and data shard identifiers stored in the updated second routing table;

[0159] A target node identifier determination module, used to determine a target node identifier corresponding to the target data slice identifier according to a correspondence between the slice identifier and the node identifier;

[0160] The index data sending module is used to send the target search request to the index node with the target node identifier, receive the index data matching the target search term fed back by the index node with the target node identifier, and send the index data to the terminal.

[0161] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0162] In a third aspect, an embodiment of the present application provides an electronic device, such as Figure 8 As shown, it includes a memory 810, a processor 820, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the search engine expansion method described in the first aspect are implemented.

[0163] The technical solution provided by the embodiment of the present application is to expand the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes to obtain the expanded first routing table, and determine the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the expanded first routing table, and store the expanded index data in the corresponding target index node. Since the existing index data shards before the expansion have been stored in their corresponding target index nodes, it is only necessary to store the newly added index data shards after the expansion in their corresponding target index nodes, unlike the related art, which requires the re-creation of a new cluster to store the expanded index data shards, thereby reducing the cost of the search engine system. In addition, the expansion of the index data shards is achieved without the user terminal being aware of it.

[0164] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the search engine expansion method described in the first aspect are implemented.

[0165] The technical solution provided by the embodiment of the present application is to expand the first routing table storing the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes to obtain the expanded first routing table, and determine the node identifiers corresponding to the shard identifiers of each index data shard after expansion according to the expanded first routing table, and store the expanded index data in the corresponding target index node. Since the existing index data shards before the expansion have been stored in their corresponding target index nodes, it is only necessary to store the newly added index data shards after the expansion in their corresponding target index nodes, unlike the related art, which requires the re-creation of a new cluster to store the expanded index data shards, thereby reducing the cost of the search engine system. In addition, the expansion of the index data shards is achieved without the user terminal being aware of it.

[0166] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0167] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0168] The present application is described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0169] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0171] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0172] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0173] The above is a detailed introduction to a search engine expansion method, device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for expanding the capacity of a search engine, characterized in that: The method comprises: Determine the number of index data shards to be expanded; Expanding the pre-created first routing table according to the expanded number of the index data shards to obtain the expanded first routing table, wherein the first routing table stores the correspondence between the shard identifiers of the index data shards and the node identifiers of the index nodes; Determine the node identifier corresponding to the shard identifier of each index data shard after expansion according to the correspondence between the shard identifiers and the node identifiers stored in the expanded first routing table; For each expanded index data shard, the expanded index data shard is stored in a target index node, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard; Wherein, each index data shard includes multiple index data blocks; For each expanded index data shard, storing the expanded index data shard in a target index node includes: For each expanded index data shard, the startup node identifier is the target index node corresponding to the expanded index data shard, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard; For each expanded index data shard, storing the target index data block included in the expanded index data shard to the target index node; Deleting the target index data block stored in the index node before the expansion; Wherein, after deleting the target index data block stored in the index node before expansion, the method further includes: Updating a pre-created second routing table, wherein the second routing table is used to store a correspondence between data block identifiers of index data blocks and shard identifiers of index data shards; A third routing table is created, wherein the third routing table is used to store the correspondence between the data block identifiers of the index data blocks and the node identifiers of the index nodes.

2. The method according to claim 1, characterized in that The method of expanding the pre-created first routing table according to the expanded number of index data shards to obtain the expanded first routing table includes: Determine the multiple of the number of index data shards after expansion and the number of index data shards before expansion; The first routing table is expanded by the multiple to obtain an expanded first routing table.

3. The method according to claim 1, characterized in that The method further comprises: Receiving a target search request sent by a terminal, and determining a target index data identifier corresponding to a target search term carried in the target search request; Determine the target data block identifier corresponding to the target index data identifier according to the predetermined correspondence relationship between the index data identifier and the data block identifier of the index data block; Determine the target data fragment identifier corresponding to the target data block identifier according to the correspondence between the data block identifier and the data fragment identifier stored in the updated second routing table; Determine the target node identifier corresponding to the target data shard identifier according to the corresponding relationship between the shard identifier and the node identifier; The target search request is sent to the index node having the target node identifier, index data matching the target search term fed back by the index node having the target node identifier is received, and the index data is sent to the terminal.

4. A search engine expansion device, characterized in that: The device comprises: An expansion data determination module is used to determine the expansion quantity of index data shards; A routing table expansion module, used to expand a pre-created first routing table according to the expansion quantity of the index data shards to obtain an expanded first routing table, wherein the first routing table stores a correspondence between shard identifiers of the index data shards and node identifiers of the index nodes; A node identification determination module, used to determine the node identification corresponding to the shard identification of each index data shard after expansion according to the correspondence between the shard identification and the node identification stored in the first routing table after expansion; An index data shard storage module, for storing each expanded index data shard in a target index node, wherein the node identifier of the target index node is a node identifier corresponding to the shard identifier of the expanded index data shard; Wherein, each index data shard includes multiple index data blocks; The index data shard storage module is specifically used for: For each expanded index data shard, the startup node identifier is the target index node corresponding to the expanded index data shard, and the node identifier of the target index node is the node identifier corresponding to the shard identifier of the expanded index data shard; For each expanded index data shard, storing the target index data block included in the expanded index data shard to the target index node; Deleting the target index data block stored in the index node before the expansion; The device also includes: A routing table updating module, used for updating a pre-created second routing table after deleting the target index data block stored in the index node before the expansion, wherein the second routing table is used to store the correspondence between the data block identifier of the index data block and the shard identifier of the index data shard; The routing table creation module is used to create a third routing table, wherein the third routing table is used to store the correspondence between the data block identifier of the index data block and the node identifier of the index node.

5. The device according to claim 4, characterized in that The routing table expansion module is specifically used for: Determine the multiple of the number of index data shards after expansion and the number of index data shards before expansion; The first routing table is expanded by the multiple to obtain an expanded first routing table.

6. The device according to claim 5, characterized in that The device also includes: A search request receiving module, configured to receive a target search request sent by a terminal, and determine a target index data identifier corresponding to a target search term carried in the target search request; A target data block identifier determination module, configured to determine a target data block identifier corresponding to the target index data identifier according to a predetermined correspondence between an index data identifier and a data block identifier of the index data block; a target data shard identifier determining module, configured to determine a target data shard identifier corresponding to the target data block identifier according to a correspondence between the data block identifiers and the data shard identifiers stored in the updated second routing table; A target node identifier determination module, used to determine the target node identifier corresponding to the target data slice identifier according to the corresponding relationship between the slice identifier and the node identifier; The index data sending module is used to send the target search request to the index node with the target node identifier, receive the index data matching the target search term fed back by the index node with the target node identifier, and send the index data to the terminal.

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

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the search engine expansion method according to any one of claims 1 to 3 are implemented.