Embodiments of the present disclosure generally relate to document indexes, and more specifically, to a method and a device for managing document indexes.
Typically, there are various frameworks that provide a capability of searching and returning a matched document to a user. Some distributed search engines distribute index data over many nodes, and thus a query on an index can be executed simultaneously by many nodes. The result obtained by these nodes can be combined and returned to the user.
However, the user needs to determine how many partitions (which are also referred to as shards, segments or the like) an index is distributed across, and the number cannot be changed after being created. This is because changing the number needs to rehash basically all the documents corresponding to the partitions. Moreover, as the system data increases, the performance of these traditional systems may deteriorate dramatically.
In order to solve the above and other potential problems, embodiments of the present disclosure provide a method and a device for managing document indexes.
According to an aspect, there is provided a method of managing document indexes.
The method comprises: in response to a first request for adding a target segment to a document set including a plurality of segments, determining an original segment associated with the target segment from the plurality of segments; partitioning the original segment into a first portion and a second portion, the first portion being used to update the original segment, the second portion being used as the target segment; and rebuilding indexes for documents in the target segment.
According to an aspect, there is provided a device for managing document indexes. The device comprises: a processing unit; and a memory coupled to the processing unit and including instructions stored thereon, the instructions when executed by the processing unit causing the device to perform a method. The method comprises: in response to a first request for adding a target segment to a document set including a plurality of segments, determining an original segment associated with the target segment from the plurality of segments; partitioning the original segment into a first portion and a second portion, the first portion being used to update the original segment, the second portion being used as the target segment; and rebuilding indexes for documents in the target segment.
According to an aspect, there is provided a computer readable medium storing machine executable instructions thereon which, when executed by at least one processor, cause the at least one processor to perform methods according to one or more aspects of the present disclosure.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the present disclosure, nor is it intended to be used to limit the scope of the present disclosure.
Through the following detailed description on the example embodiments of the present disclosure with reference to the accompanying drawings, the above and other objectives, features, and advantages of the present disclosure will become more apparent, in which the same reference symbols refer to the same components.
The preferred embodiments disclosed herein will be described in detail below with reference to the accompanying drawings. Although the drawings illustrate the preferred embodiments of the present disclosure, it would be appreciated that the present disclosure can be implemented in various forms but cannot be limited by the embodiments described herein. Rather, these embodiments are provided to disclose the present disclosure more thoroughly and completely, and to convey the scope of the present disclosure fully to those skilled in the art.
As used herein, the term “includes” and its variants are to be read as open-ended terms that mean “includes, but is not limited to.” The term “or” is to be read as “and/or” unless the context clearly indicates otherwise. The term “based on” is to be read as “based at least in part on.” The term “one example embodiment” and “an embodiment” are to be read as “at least one example embodiment.” The term “another embodiment” is to be read as “at least one other embodiment.” The terms “first,” “second,” and the like may refer to different or same objects. Other definitions, explicit and implicit, may be included below.
In some cases, there may be a need for adding one partition to the index 10 to improve the performance. As shown in
In some embodiments, the cluster 100 can receive a request for adding a partition (for example, a fourth partition). When a fourth partition is added to the first to third partitions 102-106, a value (for example, a Hash value) associated with the newly added fourth partition can be determined, which is shown as a circle 214 in the
After the fourth partition is determined, the fourth partition can be migrated to its target location. For example, the target location can be the node 120 or 140 as shown in
In order to show some concept of the present disclosure,
As shown in
In some embodiments, the cluster 100 can receive a request for adding a partition (for example, a fourth partition). For example, a fourth partition can be added to the first to third partitions 102-106, which may also include three segments. The values corresponding to the three segments can be determined, shown as circles 441-443 in
After three segments corresponding to the fourth partition have been determined, these three segments can be merged, and the fourth partition can be migrated to its target location. For example, the target location can be node 120 or 140 as shown in
It would be appreciated that embodiments of the present disclosure have been introduced above in combination of partitions and segments, but these terms are only provided as an example. For example, the partitions can be all replaced by shards or segments in the examples as shown in
Table 1 shows comparative data of index management in the prior art and the embodiment as shown in
It can be seen from Table 1 that, as compared to the prior art, embodiments of the present disclosure bring about a substantially reduced number of documents to be re-indexed. The effect will be greatly improved as the number of partitions and document data increase.
At 602, in response to a first request for adding a target segment to a document set including a plurality of segments, an original segment associated with the target segment is determined from the plurality of segments. For example, the segments described herein may be the segments as shown in
In some embodiments, a plurality of segments are associated with respective ranges of values on a closed ring. The value can be a Hash value. For example, as shown in
At 604, the original segment is divided into a first portion and a second portion. The first portion is used to update the original segments, and the second segment is used as the target segment.
In some embodiments, if it is determined that the value divides or splits the range of values into a first range of values and a second range of values, the original segment can be partitioned into a first portion and a second portion corresponding to the first range of values and the second range of values, respectively. Based on a predetermined direction associated with the closed ring, it can be determined that the first portion is used to update the original segment, and the second portion is used as the target segment.
At 606, an index is rebuilt for documents within the target segment. In some embodiments, for example, embodiments as shown in
In some embodiments, as shown in
At 702, an index operation can be suspended to prevent damage to the index operation when a partition is added. At 704, the respective segment can be partitioned to obtain a target segment. At 706, the obtained target segment can be moved to its target location if necessary. At 708, the target segments are merged to form a target shard. At 710, it is determined whether all the target segments are merged. If yes, the method 700 moves to 712 to restart the index operation. If no, the method 700 moves to 714 to wait for a time period, and then moves to 710 after the time period to determine whether all segments have been completed.
The following components in the device 800 are connected to the I/O interface 805: an input unit 806, such as a keyboard, a mouse and the like; an output unit 807, such as various kinds of displays and a loudspeaker, etc.; a storage unit 808, such as a magnetic disk, an optical disk, and etc.; a communication unit 809, such as a network card, a modem, and a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information/data with other devices through a computer network such as the Internet and/or various kinds of telecommunications networks.
Various processes and processing described above, e.g., the method 300, can be executed by the processing unit 801. For example, in some embodiments, the method 300 can be implemented as a computer software program that is tangibly embodied on a machine readable medium, e.g., the storage unit 808. In some embodiments, part or all of the computer programs can be loaded and/or mounted onto the device 800 via ROM 802 and/or communication unit 808. When the computer program is loaded to the RAM 803 and executed by the CPU 801, one or more steps of the method 300 as described above can be executed. Alternatively, CPU 801 can also be configured to perform the method 300 as described above in any other appropriate manner (for example, by means of firmware).
The present disclosure can be a method, a device, a system and/or a computer program product. The computer program product can include a computer readable storage medium on which computer readable program instructions are carried out for performing each aspect of the present application.
The computer readable medium may be a tangible medium that may contain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the machine readable storage medium would include a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present disclosure may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.
Aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the disclosure. It would be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, snippet, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reversed order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The descriptions of the various embodiments of the present disclosure have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Number | Date | Country | Kind |
---|---|---|---|
201810358924.7 | Apr 2018 | CN | national |