Inverted index optimization method, device and electronic device
By renumbering high-frequency documents in the inverted chain and maintaining their distribution within the original number range, the problem of the friendliness of the inverted chain difference sequence to the compression algorithm and the compatibility of pagerank sorting is solved, and the query speed of the search engine is improved. and result stability.
Patent Information
- Application Number
- CN202010891820.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-28
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-08-28
AI Technical Summary
When establishing an inverted chain in the existing technology, in order to generate an inverted chain difference sequence that is friendly to the compression algorithm, the pagerank sorting needs to be destroyed, resulting in unstable recall results during queries. Especially in high-frequency query statements, docid redistribution leads to the pagerank effect. of destruction.
By sorting words based on the document number in the inverted chain, a two-dimensional space of words and documents is constructed, high-density blocks whose density is greater than or equal to the interval threshold are obtained, high-frequency documents are renumbered, and new documents are allocated within the original document number range. The document number is used to improve the compression rate of the inverted chain while maintaining the stability of pagerank sorting.
It improves search engine query speed and the stability of query result quality, avoids sorting damage caused by inserting documents with lower pageranks at the front of inverted links, and enhances the accuracy of query results.
Smart Images

Figure CN114117172B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of search, and in particular to an inverted index optimization method, device and electronic device. Background Art
[0002] When building an inverted index, search engines generally sort web pages according to algorithms such as PageRank. The sorted web pages are sorted from important to unimportant. The web pages that are ranked first, that is, the documents, are numbered first, and the documents that are ranked later are numbered later. Therefore, important documents will be assigned a smaller document number, docid, and unimportant documents will have a larger docid.
[0003] After the document ID docid is generated, we start to build a postings chain, adding the docid to each word in the document. Since the words in a document are fixed, the difference between the docids in the postings chain is determined when building the postings chain, and it is impossible to generate a postings chain difference sequence that is friendly to the compression algorithm.
[0004] In order to generate a postings index difference sequence that is friendly to compression algorithms, the prior art selects high-frequency query statements and reallocates new docids to the documents obtained by intersecting the high-frequency postings indexes, thereby shortening the docid differences in these intersection results. However, this method is extremely destructive to pagerank, as it will reallocate documents that were originally assigned larger docids in the postings index of high-frequency query statements to smaller docids, causing them to be recalled first during query. Therefore, this method is not applicable when pagerank exists. Summary of the invention
[0005] The embodiments of the present invention provide an inverted index optimization method, device and electronic device for optimizing an inverted index chain and improving an inverted index compression ratio.
[0006] An embodiment of the present invention provides an inverted index optimization method, comprising:
[0007] Sort the words based on the document number in the postings chain;
[0008] Constructing a two-dimensional space of words and documents based on word ranking and the postings chain;
[0009] In the two-dimensional space, obtaining a high-density block whose density of coordinate points is greater than or equal to an interval threshold;
[0010] Obtaining the original document number and the occurrence frequency of each document in the high-density block, and renumbering each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and a document with a higher occurrence frequency is assigned a smaller document number;
[0011] Based on the new document number, renumber the documents not in the high-density block;
[0012] Rebuild the postings list based on all new document numbers.
[0013] Optionally, obtaining, in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold includes:
[0014] Obtaining the number of files in which the document is divided when the original document is numbered;
[0015] Obtaining the interval size of the high-density block based on the number of bins, and obtaining a target block satisfying the interval size from the two-dimensional space;
[0016] A high-density block whose density of coordinate points is greater than or equal to the interval threshold is obtained from the target block.
[0017] Optionally, obtaining, in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold includes:
[0018] Binary encode the words according to the order of the words, and binary encode the documents according to the size of the document encoding;
[0019] Based on the binary codes of words and documents, converting the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes, wherein the high-order code of the target code corresponds to an area in the two-dimensional space;
[0020] A high-density block whose coordinate point density is greater than or equal to a range threshold is obtained based on the target code.
[0021] Optionally, the binary coding based on words and documents converts the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target coding, including:
[0022] Based on the binary code bit ratio between words and documents, the two-dimensional coordinate points in the two-dimensional space are converted into one-dimensional binary target codes by bit crossing.
[0023] Optionally, the step of acquiring a high-density block whose coordinate point density is greater than or equal to an interval threshold based on the target code includes:
[0024] Obtaining the interval range corresponding to the high k bits of the target code, and counting whether the coordinate points contained in the interval range are greater than or equal to the interval threshold, wherein the interval threshold is obtained according to a preset density threshold and the number of file bins of the document;
[0025] If the coordinate points contained in the interval range are greater than or equal to the interval threshold, the area corresponding to the interval range is used as the high-density block.
[0026] Optionally, the sorting of words based on the document numbers in the postings chain includes:
[0027] The document numbers between postings chains are compared, and the words corresponding to the postings chains are sorted based on the size and difference between the document numbers, wherein the words with similar postings chains are sorted similarly.
[0028] Optionally, based on the new document number, renumbering the documents not in the high-density block includes:
[0029] If the documents in the high-density block have not been renumbered in the high-density block, use the new document number;
[0030] If the documents in the high-density block have not been renumbered, obtain the document number range of the area where the document is located; in order of document numbers from small to large, search from the document number range for key values that are not mapped to the new document number, and use the key values as the new document number of the document.
[0031] Optionally, before sorting the words based on the document numbers in the postings chain, the method further includes:
[0032] Based on a topic model or preset industry vocabulary data, the words corresponding to the postings chain are screened, and the screened words are used for word sorting and document number rearrangement in a high-density block.
[0033] The embodiment of the present invention further provides an inverted index optimization device, comprising:
[0034] A sorting unit, used to sort the words based on the document numbers in the postings chain;
[0035] A generating unit, configured to construct a two-dimensional space of words and documents based on the word ranking and the postings chain;
[0036] An acquisition unit, configured to acquire, in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold;
[0037] a reconstruction unit, configured to obtain an original document number and an occurrence frequency of each document in the high-density block, and renumber each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and a document with a higher occurrence frequency is assigned a smaller document number;
[0038] The reconstruction unit is further used to renumber the documents not in the high-density block based on the new document number;
[0039] The reconstruction unit is further configured to reconstruct the postings list based on all new document numbers.
[0040] Optionally, the generating unit is specifically used for:
[0041] Obtaining the number of files in which the document is divided when the original document is numbered;
[0042] Obtaining the interval size of the high-density block based on the number of bins, and obtaining a target block satisfying the interval size from the two-dimensional space;
[0043] A high-density block whose density of coordinate points is greater than or equal to the interval threshold is obtained from the target block.
[0044] Optionally, the acquiring unit is specifically used for:
[0045] Binary encode the words according to the order of the words, and binary encode the documents according to the size of the document encoding;
[0046] Based on the binary codes of words and documents, converting the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes, wherein the high-order code of the target code corresponds to an area in the two-dimensional space;
[0047] A high-density block whose coordinate point density is greater than or equal to a range threshold is obtained based on the target code.
[0048] Optionally, the acquisition unit is further used for:
[0049] Based on the binary code bit ratio between words and documents, the two-dimensional coordinate points in the two-dimensional space are converted into one-dimensional binary target codes by bit crossing.
[0050] Optionally, the acquisition unit is further used for:
[0051] Obtaining the interval range corresponding to the high k bits of the target code, and counting whether the coordinate points contained in the interval range are greater than or equal to the interval threshold, wherein the interval threshold is obtained according to a preset density threshold and the number of file bins of the document;
[0052] If the coordinate points contained in the interval range are greater than or equal to the interval threshold, the area corresponding to the interval range is used as the high-density block.
[0053] Optionally, the sorting unit is specifically used to:
[0054] The document numbers between postings chains are compared, and the words corresponding to the postings chains are sorted based on the size and difference between the document numbers, wherein the words with similar postings chains are sorted similarly.
[0055] Optionally, the reconstruction unit is further used for:
[0056] If the documents in the high-density block have not been renumbered in the high-density block, use the new document number;
[0057] If the documents in the high-density block have not been renumbered, obtain the document number range of the area where the document is located; in order of document numbers from small to large, search from the document number range for key values that are not mapped to the new document number, and use the key values as the new document number of the document.
[0058] Optionally, the device further comprises:
[0059] A screening unit is used for screening the words corresponding to the postings chain based on a topic model or preset industry vocabulary data before sorting the words based on the document numbers in the postings chain, and using the screened words for word sorting and rearrangement of document numbers in high-density blocks.
[0060] The above one or more technical solutions in the embodiments of the present application have at least the following technical effects:
[0061] The embodiment of the present application provides an optimization method for an inverted index, which sorts words based on the document numbers in an inverted index chain; constructs a two-dimensional space of words and documents based on the word sorting and the inverted index chain; obtains a high-density block in which the density of coordinate points is greater than or equal to an interval threshold in the two-dimensional space; obtains the original document number and the frequency of occurrence of each document in the high-density block, and renumbers each document in the high-density block based on the original document number and the frequency of occurrence, wherein the new document number falls within the range to which the original document number belongs, and the document with a higher frequency of occurrence is assigned a smaller document number; renumbers documents not in the high-density block based on the new document number; and rebuilds the inverted index based on all the new document numbers. By renumbering documents based on the frequency of occurrence of the documents based on the original document number range, while improving the compression rate of the inverted index after renumbering, it is prevented that many documents with lower pagerank are inserted at the front position of the inverted index to destroy the effect of pagerank, thereby improving the search engine query speed and the stability of the query result quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 A flowchart of a search data processing method provided in an embodiment of the present application;
[0063] Figure 2 A block diagram of a data processing device provided in an embodiment of the present application;
[0064] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0065] Figure 4 A schematic diagram of the structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0066] In the technical solution provided in the embodiment of the present application, an inverted index optimization method is provided, in which the inverted index is renumbered according to the original document number range and the document appearance frequency, and the compression rate of the renumbered inverted index is improved, so as to prevent the insertion of many documents with low pagerank in the front position of the inverted index and destroy the effect of pagerank, thereby improving the search engine query speed and the stability of the query result quality.
[0067] The main implementation principles, specific implementation methods and corresponding beneficial effects of the technical solutions of the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0068] Technical terminology
[0069] Inverted chain: Documents containing term-x, such as the docid of a web page, are listed in a dedicated list for term-x, and the docids are sorted for query efficiency. The resulting ascending sequence of document numbers containing term-x is called an inverted chain.
[0070] For example, a postings chain Tx:50,99,354,556;
[0071] There are 4 documents in the inverted index of Tx, with document numbers 50, 99, 354, and 556 respectively. These 4 documents all contain the word Tx.
[0072] Example
[0073] Please refer to Figure 1 , an embodiment of the present application provides an inverted index optimization method, the method comprising:
[0074] S11, sorting the words based on the document numbers in the postings chain;
[0075] S12, constructing a two-dimensional space of words and documents based on word ranking and the postings chain;
[0076] S13, in the two-dimensional space, obtaining a high-density block whose density of coordinate points is greater than or equal to an interval threshold;
[0077] S14, obtaining the original document number and the occurrence frequency of each document in the high-density block, and renumbering each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and a document with a higher occurrence frequency is assigned a smaller document number;
[0078] S15, renumbering the documents not in the high-density block based on the new document number;
[0079] S16. Rebuild the postings list based on all new document numbers.
[0080] By sorting words based on the document numbers in the inverted chain, words with similar documents are sorted similarly; further, a two-dimensional space of words and documents is constructed based on the word sorting and the inverted chain, and high-density blocks are found in the two-dimensional space, that is, similar documents with more identical words are found; the documents in the high-density blocks are renumbered within the range of the original document numbers, and the documents with higher frequency are assigned smaller document numbers, thereby improving the document compression rate of the inverted chain. At the same time, the new document numbers are controlled within the range of the original document numbers, avoiding excessive changes in document numbers that damage the pagerank ranking, and improving the quality and stability of search engine search results.
[0081] In the following, Tn is used to represent a term, where n is an integer, for example, T0 represents term 0, and T1 represents term 1. Dm is used to represent a document (i.e., a web page), where m is an integer, for example, D1 represents web page 1, and D2 represents web page 2.
[0082] Before executing the optimization method provided in this embodiment, inverted data preparation is performed.
[0083] Get the generated postings data. Each word Tx (for convenience, it can also be recorded as Tx) with number x will have a posting list containing the word. The posting list is an ascending sequence of docids (integers). For example, three words T3, T5, and T7 are listed below. The posting list of each word is:
[0084] T3={D3, D13, D15, D16};
[0085] T5 = {D5, D7, D10, D11, D12};
[0086] T7 = {D6, D8, D9, D12};
[0087] As shown in Table 1, there are four documents numbered 3, 13, 15, and 16 in the third word. There are five documents numbered 5, 7, 10, 11, and 12 in the fifth word. There are four documents numbered 6, 8, 9, and 12 in the seventh word.
[0088] T3 3 13 15 16 T5 5 7 10 11 12 T7 6 8 9 12 T1 1 4 13 15 T6 5 7 10 12 T2 2 4 14 T4 3 15 T8 8 10 12
[0089] Table 1
[0090] For convenience of representation, a table in Table 1 is used to represent the two-dimensional space schematic composed of 8 words and 16 documents.
[0091] Before step S11 for the generated inverted list, steps S11.1 and / or S11.2 can be selectively executed.
[0092] S11.1, Exclude high-frequency words. High-frequency words can be words with high occurrence frequencies and no practical meanings, such as "了", "的", "吗", etc.;
[0093] S11.2, Based on the topic model or preset industry vocabulary data, screen the words corresponding to the inverted list, and use the screened words for word sorting and reordering the document numbers within the high-density block.
[0094] Based on the calculation of the topic model or the accumulation of industry vocabulary data for each industry, if there is such vocabulary data in the query statement to be searched, then only these words can be used to obtain a more accurate reordering result; if not, then use the set of words filtered by step S11.1. S11.2 can be determined whether to execute according to needs. If there is a summary of the word lists of some industry vocabulary or a summary of the word lists of the words frequently appearing in some hot topics, then in the subsequent steps, only process the inverted lists of the words appearing in the word list, and the words not appearing in the word list do not participate in the sorting process of the inverted list, that is, the words, but the words not appearing in the word list also need to execute S15 to reconstruct the inverted list based on the constructed document reordering mapping relationship to ensure that the overall inverted data is reordered. Through S11.2, the range of reordered words can be narrowed, and the reordering efficiency can be improved.
[0095] S11, Sort the words based on the document numbers in the inverted list.
[0096] The inverted list is the document number sequence of all documents containing a certain word. Compare the document numbers between the inverted lists, and sort the words corresponding to the inverted lists based on the size and difference between the document numbers. Among them, the words with similar inverted lists are sorted close to each other. The more identical documents, that is, the more identical document labels, and the smaller the difference between the document numbers of the non-identical documents, the more similar the inverted lists.
[0097] Specifically, the word sorting method can adopt the following method 1 or method 2:
[0098] Method 1: Sort each word Tx based on the document number in the inverted chain: Get the order of the document numbers in the inverted chain corresponding to the two words, and rank the word with the smaller i-th document number first; if the i-th document numbers are the same, compare the i+1th document numbers, and rank the word with the smaller i+1th document number first, i≥1; if all the document numbers corresponding to the two words are the same, compare the word numbers, and rank the word with the smaller number first. For example: for words T1 and T2 in Table 1, the first document number of T1 is 1, and the first document number of T2 is 2, 2>1, then T1 is ranked before T2, expressed as T1>T2; the first document numbers of words T3 and T4 are the same, both 3, and the second document number 13<15, then T3 is ranked before T4, that is, T3>T4.
[0099] Method 2: Sort each word Tx based on the document number in the postings chain: consider the postings chain of Tx as an N-bit (N is the space of docid, for example, 15 here) N-ary number; when comparing Tx and Ty, start from position 1 (i.e., docid=1). If Tx has doc-1 and Ty does not, it means that Tx is greater than Ty; if Tx does not have doc-1 and Ty does, it means that Tx is less than Ty; if both Tx and Ty have doc-1 or neither has doc-1, continue to compare the next docid (i.e., current docid+1) until the end position of the postings chain of one of the words is reached. If two postings chains are exactly the same, the word numbers can be compared.
[0100] For the above Table 1, after sorting, we get: T1>T2>T3; the comparison process can be: first compare the first position of the document data, T2 and T3 do not have D1 data, so they are both ranked after T1; then compare D2, so T3 is the smallest; then compare the second position of T1 and T2, T3 does not have D2, so T2>T3. When comparing T3 and T4, both have D3, so continue to compare backwards, the next one after D3 in T3 is D13, and the next one after D3 in T4 is D15, so T3>T4. For the inverted chain shown in the previous Table 1, the results after sorting are shown in Table 2:
[0101] 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 T1 000 1 4 13 15 T2 001 2 4 14 T3 010 3 13 15 16 T4 011 3 15 T5 100 5 7 10 11 12 T6 101 5 7 10 12 T7 110 6 8 9 12 T8 111 8 10 12
[0102] Table 2
[0103] In Table 2, 0000 to 1111 in the horizontal direction are binary codes of the horizontal x coordinates introduced in S12 below, and 000 to 111 in the vertical direction are binary codes of the vertical y coordinates introduced in S12.
[0104] S12. Constructing a two-dimensional space of words and documents based on the word ranking and the postings chain.
[0105] A two-dimensional space of words and documents is constructed based on the word sorting and the document coding of the documents in the postings chain. Specifically, for words, y coordinate values are assigned according to the order of word sorting (0-7 in the example, binary coding is 000b~111b, and the b suffix indicates binary coding). An x coordinate value is also assigned to the size of each document number docid in the postings chain. The horizontal coordinate of docid can be assigned by subtracting 1 from docid, and the resulting range is a closed interval on both sides of [0, N-1]. In the example, it is 0 to 15, corresponding to the 4-bit binary value 0000b to 1111b.
[0106] S13. In the two-dimensional space, obtain a high-density block whose density of coordinate points is greater than or equal to an interval threshold.
[0107] In the constructed two-dimensional space, the word dimension and the document dimension constitute a huge two-dimensional space of the number of words * the number of documents. Each document doc in the inverted index is a point in this two-dimensional plane. In order to improve the compression ratio, a block where points appear densely, namely a high-density block, is found in this space. A high-density block refers to an area where some relatively related document sets are located. The relevance is reflected in the fact that there are relatively many identical words between these documents, and the similarity between the documents is relatively high. Finding high-density blocks is a problem with relatively high computational complexity. This embodiment innovatively uses two-dimensional to one-dimensional encoding to cleverly solve this problem.
[0108] Specifically, the words are binary-encoded according to the size of the word ranking, and the documents are binary-encoded according to the size of the document codes; based on the binary codes of the words and documents, the two-dimensional coordinate points in the two-dimensional space are converted into one-dimensional binary target codes, wherein the high-order code of the target code corresponds to an area in the two-dimensional space; based on the target code, a high-density block whose coordinate point density is greater than or equal to an interval threshold is obtained.
[0109] Specifically, the step S13 may include the following steps S13.1 to S13.2.
[0110] S13.1, 2D to 1D encoding
[0111] The two-dimensional to one-dimensional encoding algorithm can use a space filling curve related algorithm, including Z-order, peano curve, Hilbert curve, etc. As an optional implementation, this embodiment uses a bit crossing method close to Z-order (including bit-by-bit crossing or bit-by-bit segment crossing) for transcoding. Specifically, based on the binary coding bit ratio between words and documents, a bit crossing method is used to convert the two-dimensional coordinate points in the two-dimensional space into a one-dimensional binary target code.
[0112] Points in two-dimensional space are represented by two-dimensional coordinates (x, y). The horizontal coordinate x is distributed as 1-2^M (1 to 2 to the Mth power), that is, x is represented as M bit values, and the vertical coordinate y is distributed as 1-2^N (1 to 2 to the Nth power), that is, y is represented as N bit values.
[0113] If M and N are close to the same, that is, a 1:1 relationship, a bit-by-bit crossover method is used to obtain a new target code. For example:
[0114] X=101001b
[0115] Y=011101b
[0116] Alternately cross Y first and then X to get:
[0117] 0 1 1 0 1 1 1 0 0 0 1 1b (the underlined bits are Y bits)
[0118] The integer value represented by this new binary target code is the coordinate value of the one-dimensional code.
[0119] If M and N differ greatly, such as a 3:2 ratio, the bit segment interleaving method can also be used, for example:
[0120] X=101110b
[0121] Y=1001b
[0122] Then, we cross every 3 bits in X and every 2 bits in Y, first X and then Y, and get:
[0123] 1 1 0 0 1 1 0 1 1 0b (the underlined bit is the Y bit)
[0124] The high bit of the one-dimensional target code can represent an interval. For example, for the one-dimensional data code 1011011001b obtained by bit-by-bit crossover, when both x and y are 5 bits, take the high 5 bits of this 10-bit code 10110b, which represents an interval in the xy plane, extract the bit 110b of x, and the bit 01b of y, then the corresponding area range is:
[0125] x:[11000,11011] (i.e., the left boundary is 11000 in binary, 24 in decimal, and the right boundary is 27 in the left and right closed interval)
[0126] y:[01000,01111] (i.e. a closed interval from 8 to 15)
[0127] It can be seen that when the binary code length of x / y is fixed, a shorter prefix code corresponds to a larger rectangular range, and a longer prefix code corresponds to a smaller rectangular range.
[0128] S13.2. Finding high-density intervals
[0129] High-density intervals can be found efficiently based on one-dimensional coding.
[0130] The selection of high-density intervals is very flexible. The first k bits of the one-dimensional code can be used, where k can take a value such as (M+N-7). Smaller k values correspond to larger intervals, and larger k values correspond to smaller intervals. You can even use unfixed k values and select in segments. As long as the point where the data at the beginning of the k-bit falls on an interval is greater than or equal to the interval threshold, it can be selected. For example, M+N=12, 7 low bits are cut off, k=M+N-7=5, that is, when K is 5, for the one-dimensional target code 0 0 0 1 1 0 0 1 1 1 10 b (underscore comes from x) The high 5 bits are 0 0 0 1 1 , falls on 0 0 0 1 1 00000000b~ 0 0 0 1 1 The number of points in the range 1111111b reaches the interval threshold (1 / 4)*(2^7)=32, where 1 / 4 is the dense threshold. k can be adjusted according to the number of intervals to be selected. In this way, a batch of interval codes can be selected, and each interval code can be decoded into the corresponding {[x1,x2],[y1,y2]} coordinate range.
[0131] In the specific real-time process, selecting a suitable interval size, i.e., the value of k, is related to the pagerank change after the inverted rearrangement. In this embodiment, the number of bins of the document when the original document is numbered, i.e., the number of bins when the document is sorted, can be obtained first; the interval size of the high-density block can be obtained based on the number of bins, and the target block that meets the interval size can be obtained from the two-dimensional space; and the high-density block whose density of coordinate points is greater than or equal to the interval threshold can be obtained from the target block.
[0132] The interval size of the high-density block is obtained based on the number of bins, that is, the pagerank value calculated before the inverted index is used to participate in the selection of the interval size, that is, to determine the value of k. The number of coding bits corresponding to the number of bins is the interval coding bit number of x, and the interval coding bit number of y is obtained according to the one-dimensional coding rule. The sum of the interval coding bit numbers of x and y is the value of k.
[0133] For example: if the pagerank value is divided into 1000 bins, the docs in the same bins have almost the same pagerank weight. The total number of bins, 1000, requires 10 bits to be represented in binary, which means that in the binary bit encoding of the corresponding interval encoding in the one-dimensional encoding, there must be 10 bits from x (that is, 10 bits are used to represent the 1000 bins of pagerank). If the x and y code lengths are the same, it means that an interval code must also contain 10 bits of y code width, that is, the range of an interval is 10+10=20 bits, that is, k is 20. If x is 15 bits and y is 10 bits, and every 3 x bits and 2 y bits are cross-coded, when the pagerank is still 1000 bins, it can be considered that an interval code is composed of a 10-bit x code prefix (because 1000 requires 10 bits to represent) and a 7-bit (up(10*2 / 3)=7, up means rounding up) y code prefix segmented cross-combination, that is, k=10+7=17. Then when 15 bits of x and 10 bits of y are encoded, the first 17 bits (i.e. 10+up(10*2 / 3)=17) of the 25-bit one-dimensional code obtained are interval codes. For example:
[0134] x=010,110,100,101,110b
[0135] y=10,11,10,01,01b
[0136] The one-dimensional encoding is:
[0137] 0 1 1 0 0,1 1 1 1 0,1 1 0 0 0,1 0 0 1 1,1 0 1 1 0b
[0138] Cut off the lower (25-17) = 8 bits to get the interval code: 0 1 1 0 0,1 1 1 1 0,1 1 0 0 0,10 b
[0139] 0 1 1 0 0,1 1 1 1 0,1 1 0 0 0,1 0 b Such an interval code corresponds to the following rectangular block:
[0140] x left and right closed interval: [010,110,100,1 00000000b; 010,110,100,1 11111111b]
[0141] y upper and lower closed interval: [10,11,10,0 000000b; 10,11,10,0 111111b]
[0142] Among them, the high-order part of the left and right closed intervals of x comes from the bits without underline marks in the interval code, and the high-order part of the upper and lower closed intervals of y comes from the bits with underline marks in the interval code. When writing, for clear correspondence, commas are used to segment the high-order parts of x and y.
[0143] It can be seen that the number of pagerank bins can help us select the length of interval encoding.
[0144] To this end, the integer values of the obtained one-dimensional code are sorted, so that the numerical points with the same interval code will be distributed continuously, and the process of finding a high-density interval becomes a problem of counting the number of integer values with the same prefix code, which is very friendly to computers. To determine whether an interval is a high-density interval, it is necessary to use the previous data exploration work. Here, a simple interval threshold can be set, for example, the interval threshold = (1 / 4) * the data capacity in the interval (that is, the range of the truncated x code value multiplied by the range of the truncated y code value, for example, 10 bits of x are truncated and 7 bits of y are truncated, then the data capacity is (2^10)*(2^7)=1024*128=131072). When the number of points contained in an interval reaches the interval threshold, it is confirmed that it is a high-density interval, and the interval code is saved for subsequent use. Among them, the number of points contained in the interval can be obtained by statistics. If all one-dimensional codes are sorted according to the size of the binary value, then the statistical process is to traverse and scan all point coordinates and record the number of points falling in each prefix interval.
[0145] After obtaining the high-density blocks in the two-dimensional space, further interval decoding and sorting are performed to prepare for the subsequent S14 renumbering.
[0146] Interval decoding and sorting
[0147] According to the interval definition and decoding method introduced above, the obtained high-density interval codes can be decoded to obtain some rectangular block areas. Each interval code can be decoded into a y range (corresponding to a term number range termidrange) and an x range (corresponding to a document number range docid range).
[0148] For example, for the above example, a high-density numerical interval is obtained as 1011011111b. Considering that docs with the same term are concentrated in a part of the domain names, it can be considered that the points in a high-density numerical interval have the same prefix. For this high-density numerical interval, the interval encoding prefix is 101101. By decoding it, we can get, for example, x=100~120, y=50~80.
[0149] The rectangular blocks after interval decoding, i.e., high-density blocks, are sorted according to the following order: termid priority (y range) > docid priority (x range); for example, for the above example, several high-density value intervals are obtained, and the intervals need to be sorted (smaller ids represent priority):
[0150] {x:[0,63],y:[0,31]}>{x:[0,63],y:[32,64]}>
[0151] {x:[64,127],y:[0,31]}>x:[64,127],y:[32,64]}
[0152] S14. Renumber each document in the high-density block.
[0153] The original document number and occurrence frequency of each document in the high-density block are obtained, and each document in the high-density block is renumbered based on the original document number and the occurrence frequency, wherein the new document number falls within the range of the original document number, and the document with higher occurrence frequency is assigned a smaller document number.
[0154] Specifically, according to the order of the sorted intervals obtained in the previous step, the docids in the interval are reallocated with new document codes ndid according to the following method, and the mapping relationship between the original document codes docid and ndid is recorded. The docids corresponding to the term codes new termid in the interval are reallocated with new docid; wherein, the reallocated new docid reduces the spacing between the original docids in the same inverted chain, thereby improving the compression efficiency.
[0155]
[0156] Table 3
[0157] For example, in the two-dimensional space of word*document as shown in Table 3, it is assumed that four high-density intervals (Q1, Q2, Q3, Q4) are obtained, which are:
[0158] Q1={x:[0,3],y:[0,3]}
[0159] Q2={x:[12,15],y:[0,3]}
[0160] Q3={x:[4,7],y:[4,7]}
[0161] Q4={x:[8,11],y:[4,7]}
[0162] First, rearrange the document numbers in Q1:
[0163] Q1 corresponds to y values in the interval [0,3], corresponds to the four words T1 to T4, corresponds to x values in the interval [0,3], and corresponds to the document number [1,4].
[0164] 1. Determine the starting x coordinate of the region according to the region code, which is 0 here, corresponding to docid=1, and the new ndid is allocated starting from 1.
[0165] 2. Find the most frequent docids in this range, which are 3 and 4 here. First, reassign ndid-1 to docid-3, record the mapping relationship (globally valid, and still saved after processing this area), and record the currently assigned ndid-1.
[0166] 3. Look at the remaining unassigned docids in the postings chain where docid-3 is located. There is none here. That is, the postings chain part where docid-3 is located, T3, T4, which falls within the range of x[0,3], has been processed. Start processing from the next most frequent docid-4.
[0167] 4. Assign a new ndid to docid-4. Since 1 has already been assigned in the record, assign it from the next ndid, 2, and also record the assignment relationship. Then process the remaining postings chains in T1 and T2 where docid-4 is located that fall within the current x region [0,3]. Docid-1 and docid-2 remain unassigned ndids in T1 and T2. According to the order of docids, first assign ndid-3 to docid-1, and then assign ndid-4 to docid-2.
[0168] The new inverted fragment obtained in this way becomes as shown in Table 4:
[0169] 0000 0001 0010 0011 T1 000 2(4) 3(1) T2 001 2(4) 4(2) T3 010 1(3) T4 011 1(3)
[0170] Table 4
[0171] Among them, the original document number docid is in the brackets in Table 4, and the number before the brackets is the newly allocated ndid.
[0172] After redistribution, the sum of the differences between ndids in T1 is 3-2=1, the sum of the differences between ndids in T2 is 4-2=2, the sum of the differences between ndids in T3 and T4 is 0, and the sum of the differences between ndids in all postings chains in the region is 3.
[0173] Before reallocation, the sum of differences between docids in T1 is 4-1=3, the sum of differences between docids in T2 is 4-2=2, the differences between docids in T3 / T4 are both 0, and the sum of differences between docids that have not been reallocated in the area is 5.
[0174] It can be seen that after redistribution, the difference of ids in the inverted chain has become smaller. At the same time, docid and ndid are still in the interval [1,4], and there is no migration between pagerank levels.
[0175] For example, for region Q2, Q2 corresponds to the y value interval [0,3], corresponds to the four words T1 to T4, corresponds to the x value interval [12,15], and corresponds to the document number [13,16].
[0176] 1. Determine the starting x coordinate of the region according to the region code, which is 12 here, corresponding to docid=13, so the new ndid is allocated starting from 13.
[0177] 2. Find the most frequent docid in this range, which is 15 here. Reassign ndid-13 to docid-15 first, record the mapping relationship (globally valid, and still saved after processing this area), and record the currently assigned ndid-13.
[0178] 3. Look at the remaining unassigned docids in the postings chain T1, T3, and T4 where docid-15 is located, and assign them backwards in order of frequency and docid size. Here docid-13 appears twice, and docid-14 and docid-16 appear once each. So docid-13 is assigned with the new ndid-14 first, followed by docid-14 assigned with ndid-15, and docid-16 assigned with ndid-16.
[0179] 4. You can see that all docids in the postings chain in region Q2 have been allocated, and the processing in this region is complete.
[0180] The newly obtained allocation method in the Q2 area is shown in Table 5:
[0181] 1100 1101 1110 1111 T1 000 13(15) 14(13) T2 001 15(14) T3 010 13(15) 14(13) 16(16) T4 011 13(15)
[0182] Table 5
[0183] Before allocation, the sum of the docdid differences in this area of T1, T2, T3, and T4 are 15-13=2, 0, 15-13=2, and 16-15=1, respectively, and the total is 2+0+2+1=5.
[0184] After allocation, the difference sums of the ndids in this area of T1, T2, T3, and T4 are: 14-13=1, 0, 14-13+16-13=3, 0 respectively, and the total is 1+0+3+0=4.
[0185] After the redistribution, the ID difference and the ndid are smaller. At the same time, docid and ndid are still in the interval [13,16], and there is no migration between pagerank levels.
[0186] For example, for region Q3, Q3 corresponds to the y value interval [4,7], corresponds to the four words T5 to T8, corresponds to the x value interval [4,7], and corresponds to the document number [5,8].
[0187] 1. Determine the starting x coordinate of the region according to the region code, which is 4 here, corresponding to docid=5, so the new ndid is allocated starting from 5.
[0188] 2. Find the most frequent docids in this range, which are 5, 7, and 8 here. Reassign ndid-5 to docid-5 first, record the mapping relationship (globally valid, and still saved after processing this area), and record the currently assigned ndid-5.
[0189] 3. Look at the postings link T5 where docid-5 is located. The remaining unassigned docids in T6 are assigned backwards in order of frequency and docid size. Here, only docid-7 appears twice, so docid-7 is assigned with a new ndid-6.
[0190] 4. Next, process the remaining high-frequency docids. Docid-5 and docid-7 have been reallocated. The one to be allocated is docid-8, which is assigned ndid-7.
[0191] 5. After allocating docid-5, docid-7, and docid-8, find the remaining unallocated docid in Q3, which is 6, and allocate ndid-8. The processing in Q3 is finished.
[0192] The newly obtained allocation method in the Q3 area is shown in Table 6:
[0193] 0100 0101 0110 0111 T5 100 5(5) 6(7) T6 101 5(5) 6(7) T7 110 7(8) 8(6) T8 111 7(8)
[0194] Table 6
[0195] Before allocation, the sum of the docid differences in this area of T5, T6, T7, and T8 are: 7-5=2, 7-5=2, 8-6=2, and 0 respectively, and the total is 2+2+2+0=6.
[0196] After allocation, the sum of the ndid differences in this area of T5, T6, T7, and T8 are: 6-5=1, 6-5=1, 8-7=1, and 0 respectively, and the total is 1+1+1+0=3.
[0197] After the redistribution, the ID difference is reduced. At the same time, docid and ndid are still in the interval [5,8], and there is no migration between pagerank levels.
[0198] For example, for region Q4, Q4 corresponds to the y value interval [4,7], corresponds to the four words T5 to T8, corresponds to the x value interval [8,11], and corresponds to the document number [9,12].
[0199] 1. Determine the starting x coordinate of the region according to the region code, which is 8 here, corresponding to docid=9, so the new ndid is allocated starting from 9.
[0200] 2. Find the most frequent docid in this range, which is 12 here. Reassign ndid-9 to docid-12 first, record the mapping relationship (globally valid, and still saved after processing this area), and record the currently assigned ndid-9.
[0201] 3. Look at the remaining unassigned docids in the postings chain T5, T6, T7, and T8 where docid-12 is located, and assign them backward in order according to frequency and docid size. Here, docid-10 appears 3 times, docid-9 appears once, and docid-11 appears once. Docid-10 is assigned with a new ndid-10, docid-9 is assigned with a new ndid=11, and docid-11 is assigned with ndid-12.
[0202] 4. Search for the remaining unassigned docids in Q4. If none are found, processing in the Q4 area ends.
[0203] The newly obtained allocation method in the Q4 area is shown in Table 7:
[0204] 0100 0101 0110 0111 T5 100 9(12) 10(10) 12(11) T6 101 9(12) 10(10) T7 110 9(12) 11(9) T8 111 9(12) 10(10)
[0205] Table 7
[0206] Before allocation, the difference sums of the docids in this area of T5, T6, T7, and T8 are: 11-10+12-11=2, 12-10=2, 12-9=3, 12-10=2, and the total is 2+2+3+2=9.
[0207] After allocation, the difference sums of the ndids in this area of T5, T6, T7, and T8 are: 10-9+12-10=3, 10-9=1, 11-9=2, 10-9=1, and the total is 3+1+2+1=7.
[0208] After the redistribution, the ID difference and the ndid are smaller. At the same time, docid and ndid are still in the interval [9,12], and there is no migration between pagerank levels.
[0209] S15. Based on the new document number, renumber the documents outside the high-density block.
[0210] The basic principle of renumbering is: if the document in the non-high-density block, that is, outside the high-density block, has been renumbered in the high-density block, use the new document number; if the document in the non-high-density block has not been renumbered, obtain the document number range of the area where the document is located; in order of document numbers from small to large, search from the document number range to obtain the key value that is not mapped to the new document number, and use the key value as the new document number of the document.
[0211] Specifically, after processing all high-density intervals based on the above, a mapping table from docid to ndid will be obtained. This mapping table can be used for the rearrangement of postings links outside the high-density intervals.
[0212] During the rearrangement of the remaining inverted chain fragments, two types of docids are encountered:
[0213] 1. The docids already in the previous docid to ndid mapping table can be directly mapped to ndids according to the existing mapping relationship.
[0214] 2. For docids that are not in the mapping table, ndids need to be assigned at this stage, but the method is as follows:
[0215] a) docids are judged one by one from small to large and ndids are assigned;
[0216] b) For the docid-xi to be assigned ndid, according to the left and right boundary values [x1,x2] of the region where its coordinate xi is located, the corresponding document number range is [x1+1,x2+1];
[0217] c) Search the key value range [x1+1,x2+1] in the mapping relationship table from small to large for the first key value that has not been mapped to an ndid value, and use it as the new ndid value of docid-xi, and record this relationship in the mapping table.
[0218] Since the allocation method of this embodiment is not only a one-to-one mapping of N numbers to N numbers, but also a one-to-one mapping of equal numbers within each interval, it can be ensured that the docid is still mapped to the ndid within this interval at this stage.
[0219] S16. Rebuild the postings list based on all new document numbers.
[0220] After obtaining all the mapping tables, scan the original postings chains and replace them with new ndids. After the replacement is completed, re-sort them in each postings chain to ensure that the ndids are still in ascending order in the new postings chains.
[0221] For the new postings chain, the posting compression algorithm can be used to obtain postings data with greatly reduced space. At the same time, it can be seen that each doc document still exists in the interval corresponding to its pagerank bin. For the query process, it can be guaranteed that under the same intersection depth, for example, when the intersection is 80% of the position of a postings chain, the documents obtained are not only still in descending order of pagerank, but the docids obtained are still the same as the docid set before the re-ranking.
[0222] In the above embodiment, firstly, the document space is divided according to the number of pagerank bins, which ensures that docid can be reallocated to ndid within the original pagerank bins, and the same document set can be obtained without changing the original query logic of the search engine, that is, when the intersection process is terminated in advance, the pagerank values of the recalled documents are guaranteed to be high-quality. At the same time, the concept of high-density blocks is introduced to reduce the number of postings chains involved in allocating new ndids when re-arranging the postings, which can control the calculation scale and improve the actual feasibility.
[0223] Secondly, the method provided in this embodiment can be applied to the entire word space, and can also use the topic model and the vocabulary accumulated in the industry to select the postings chain, and can be continuously improved as the industry vocabulary is enriched.
[0224] Thirdly, the method provided in this embodiment adopts binary coding, which is applicable to the differential coding system, and is also the most widely used coding system in search engines. Therefore, the method of this embodiment has a wider range of applications.
[0225] Fourthly, when searching for high-density blocks, this embodiment converts the high-density area into a one-dimensional code by converting the two-dimensional code into a one-dimensional code, and then finds the common prefix, which greatly improves the calculation efficiency. In specific calculations, the one-dimensional coordinate prefix can be used as the key for bucket calculations, and multiple computers can perform calculations at the same time. The more computers there are, the less calculation time there is. At the same time, within a single machine, the number of points in all buckets, bins, and bins can be obtained by sorting and traversing. The calculation complexity is O(n*log(n)), so the complexity is not high and it has higher feasibility.
[0226] In view of the above embodiment, an inverted index optimization method is provided. The present application embodiment also provides an inverted index optimization device. Please refer to Figure 2 , the device comprises:
[0227] A sorting unit 21, used to sort the words based on the document numbers in the postings chain;
[0228] A generating unit 22, configured to construct a two-dimensional space of words and documents based on the word ranking and the postings chain;
[0229] An acquisition unit 23 is used to acquire, in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold;
[0230] A reconstruction unit 24 is used to obtain the original document number and the occurrence frequency of each document in the high-density block, and renumber each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and the document with a higher occurrence frequency is assigned a smaller document number;
[0231] The reconstruction unit 24 is further configured to renumber the documents not in the high-density block based on the new document number;
[0232] The reconstruction unit 24 is further configured to rebuild the postings list based on all new document numbers.
[0233] As an optional implementation, the generation unit 22 can specifically: obtain the number of file divisions when the original document is numbered; obtain the interval size of the high-density block based on the number of file divisions, and obtain a target block that meets the interval size from the two-dimensional space; and obtain a high-density block whose coordinate point density is greater than or equal to an interval threshold from the target block.
[0234] As an optional implementation, the acquisition unit 22 may also: binary encode the words according to the order of the words, and binary encode the documents according to the size of the document codes; based on the binary codes of the words and the documents, convert the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes, wherein the high-order codes of the target codes correspond to an area in the two-dimensional space; based on the target codes, obtain a high-density block whose density of coordinate points is greater than or equal to an interval threshold. Specifically, when transcoding, the acquisition unit 22 may: based on the binary code bit ratio between the words and the documents, convert the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes by bit interleaving.
[0235] As an optional implementation, the acquisition unit 23 can also be used to: obtain the interval range corresponding to the high k bits of the target code, and count whether the coordinate points contained in the interval range are greater than or equal to the interval threshold, wherein the interval threshold is obtained based on a preset density threshold and the number of document classifications; if the coordinate points contained in the interval range are greater than or equal to the interval threshold, the area corresponding to the interval range is used as the high-density block.
[0236] As an optional implementation, the sorting unit 21 is specifically configured to compare document numbers between postings chains, and sort the words corresponding to the postings chains based on the size and difference between the document numbers, wherein words in similar postings chains are sorted similarly.
[0237] As an optional implementation, the reconstruction unit 24 can be used during renumbering to: if the documents in the high-density block have been renumbered in the high-density block, use the new document number; if the documents in the high-density block have not been renumbered, obtain the document number range of the area where the document is located; in order of document numbers from small to large, search from the document number range for key values that are not mapped to the new document number, and use the key values as the new document number of the document.
[0238] As an optional implementation, the device further includes: a screening unit 25, which is used to screen the words corresponding to the postings chain based on a topic model or preset industry vocabulary data before sorting the words based on the document numbers in the postings chain, and use the screened words for word sorting and document number rearrangement in the high-density block.
[0239] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0240] Figure 31 is a block diagram of an electronic device 300 for implementing an optimization method for an inverted index according to an exemplary embodiment. For example, the electronic device 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0241] Reference Figure 3 , the electronic device 300 may include one or more of the following components: a processing component 302 , a memory 304 , a power component 306 , a multimedia component 308 , an audio component 310 , an input / display (I / O) interface 312 , a sensor component 314 , and a communication component 316 .
[0242] The processing component 302 generally controls the overall operation of the electronic device 300, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 302 may include one or more processors 320 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 302 may include one or more modules to facilitate the interaction between the processing component 302 and other components. For example, the processing component 302 may include a multimedia module to facilitate the interaction between the multimedia component 308 and the processing component 302.
[0243] The memory 304 is configured to store various types of data to support operations on the device 300. Examples of such data include instructions for any application or method operating on the electronic device 300, contact data, phone book data, messages, pictures, videos, etc. The memory 304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0244] The power supply component 306 provides power to the various components of the electronic device 300. The power supply component 306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 300.
[0245] The multimedia component 308 includes a screen that provides a display interface between the electronic device 300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 308 includes a front camera and / or a rear camera. When the device 300 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0246] The audio component 310 is configured to present and / or input audio signals. For example, the audio component 310 includes a microphone (MIC), and when the electronic device 300 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 304 or sent via the communication component 316. In some embodiments, the audio component 310 also includes a speaker for presenting audio signals.
[0247] I / O interface 312 provides an interface between processing component 302 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0248] The sensor assembly 314 includes one or more sensors for providing various aspects of status assessment for the electronic device 300. For example, the sensor assembly 314 can detect the open / closed state of the device 300, the relative positioning of components, such as the display and keypad of the electronic device 300, and the sensor assembly 314 can also detect the position change of the electronic device 300 or a component of the electronic device 300, the presence or absence of user contact with the electronic device 300, the orientation or acceleration / deceleration of the electronic device 300, and the temperature change of the electronic device 300. The sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 314 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 314 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0249] The communication component 316 is configured to facilitate wired or wireless communication between the electronic device 300 and other devices. The electronic device 300 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0250] In an exemplary embodiment, the electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0251] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 304 including instructions, and the instructions can be executed by a processor 320 of an electronic device 300 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0252] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a mobile terminal, enables the mobile terminal to execute an inverted index optimization method, the method comprising: sorting words based on document numbers in an inverted index chain; constructing a two-dimensional space of words and documents based on the word sorting and the inverted index chain; in the two-dimensional space, obtaining a high-density block whose density of coordinate points is greater than or equal to an interval threshold; obtaining the original document number and occurrence frequency of each document in the high-density block, and renumbering each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and the document with a higher occurrence frequency is assigned a smaller document number; based on the new document number, renumbering documents not in the high-density block; and rebuilding the inverted index based on all the new document numbers.
[0253] Figure 44 is a schematic diagram of the structure of the server in the embodiment of the present application. The server 400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 422 (for example, one or more processors) and memory 432, and one or more storage media 430 (for example, one or more mass storage devices) storing application programs 442 or data 444. Among them, the memory 432 and the storage medium 430 can be short-term storage or permanent storage. The program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 422 can be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the server 400.
[0254] The server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input presentation interfaces 458, one or more keyboards 456, and / or, one or more operating systems 441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0255] Furthermore, the CPU 422 may execute the following method:
[0256] The words are sorted based on the document numbers in the inverted index; a two-dimensional space of words and documents is constructed based on the word sorting and the inverted index; in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold is obtained; the original document number and the occurrence frequency of each document in the high-density block are obtained, and each document in the high-density block is renumbered based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and the document with a higher occurrence frequency is assigned a smaller document number; based on the new document number, the documents not in the high-density block are renumbered; and the inverted index is rebuilt based on all the new document numbers.
[0257] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0258] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims. The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of protection of the present invention.
Claims
1. An optimization method for inverted index, It is characterized in that include: Sort the words based on the document number in the postings chain; Constructing a two-dimensional space of words and documents based on word ranking and the postings chain; In the two-dimensional space, obtaining a high-density block whose density of coordinate points is greater than or equal to an interval threshold; Obtaining the original document number and the occurrence frequency of each document in the high-density block, and renumbering each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and a document with a higher occurrence frequency is assigned a smaller document number; Based on the new document number, renumber the documents not in the high-density block; Rebuild the postings list based on all new document numbers; The step of obtaining a high-density block in the two-dimensional space, where the density of coordinate points is greater than or equal to the interval threshold, comprises: Binary encode the words according to the order of the words, and binary encode the documents according to the size of the document codes; Based on the binary codes of words and documents, converting the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes, wherein the high-order code of the target code corresponds to an area in the two-dimensional space; Acquire a high-density block whose coordinate point density is greater than or equal to an interval threshold based on the target code; The binary coding based on words and documents converts the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target coding, including: Based on the binary code bit ratio between the word and the document, the two-dimensional coordinate points in the two-dimensional space are converted into one-dimensional binary target codes by bit interleaving; The step of acquiring a high-density block whose coordinate point density is greater than or equal to an interval threshold based on the target code comprises: Obtaining the interval range corresponding to the high k bits of the target code, and counting whether the coordinate points contained in the interval range are greater than or equal to the interval threshold, wherein the interval threshold is obtained according to a preset density threshold and the number of file bins of the document; If the coordinate points contained in the interval range are greater than or equal to the interval threshold, the area corresponding to the interval range is used as the high-density block.
2. The method according to claim 1, It is characterized in that The step of obtaining a high-density block in the two-dimensional space, where the density of coordinate points is greater than or equal to the interval threshold, comprises: Obtaining the number of files in which the document is divided when the original document is numbered; Obtaining the interval size of the high-density block based on the number of bins, and obtaining a target block satisfying the interval size from the two-dimensional space; A high-density block whose density of coordinate points is greater than or equal to the interval threshold is obtained from the target block.
3. The method according to claim 1, It is characterized in that The step of sorting the words based on the document numbers in the postings chain includes: The document numbers between postings chains are compared, and the words corresponding to the postings chains are sorted based on the size and difference between the document numbers, wherein the words with similar postings chains are sorted similarly.
4. The method according to claim 1, It is characterized in that Based on the new document number, renumbering the documents not in the high-density block comprises: If the documents in the high-density block have not been renumbered in the high-density block, use the new document number; If the documents in the high-density block have not been renumbered, obtain the document number range of the area where the document is located; in order of document numbers from small to large, search from the document number range for key values that are not mapped to the new document number, and use the key values as the new document number of the document.
5. An inverted index optimization device, It is characterized in that include: A sorting unit, used to sort the words based on the document numbers in the postings chain; A generating unit, configured to construct a two-dimensional space of words and documents based on the word ranking and the postings chain; An acquisition unit is used to acquire, in the two-dimensional space, a high-density block whose density of coordinate points is greater than or equal to an interval threshold; the acquisition unit is specifically used to binary encode the words according to the order of the words, and to binary encode the documents according to the size of the document code; Based on the binary codes of words and documents, converting the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes, wherein the high-order code of the target code corresponds to an area in the two-dimensional space; Acquire a high-density block whose coordinate point density is greater than or equal to an interval threshold based on the target code; The acquisition unit converts the two-dimensional coordinate points in the two-dimensional space into one-dimensional binary target codes by bit interleaving based on the binary code bit ratio between the words and the documents during transcoding; The acquisition unit is further used to acquire the interval range corresponding to the high k bits of the target code, and to count whether the coordinate points contained in the interval range are greater than or equal to the interval threshold, wherein the interval threshold is obtained according to a preset density threshold and the number of file divisions of the document; if the coordinate points contained in the interval range are greater than or equal to the interval threshold, the area corresponding to the interval range is used as the high-density block; a reconstruction unit, configured to obtain an original document number and an occurrence frequency of each document in the high-density block, and renumber each document in the high-density block based on the original document number and the occurrence frequency, wherein the new document number falls within the range to which the original document number belongs, and a document with a higher occurrence frequency is assigned a smaller document number; The reconstruction unit is further used to renumber the documents not in the high-density block based on the new document number; The reconstruction unit is further configured to reconstruct the postings list based on all new document numbers.
6. An electronic device, It is characterized in that The invention comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to execute the operation instructions corresponding to the method according to any one of claims 1 to 4 contained in the one or more programs.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps corresponding to the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Document sequence rearrangement method and system for compressing inverted index
CN102929988A
Repeated data deletion framework-based reverse index representation method and system
CN106202154A
