An efficient spatial keyword query method based on association rule mining
By mining association rules and optimizing indexes, and combining quadtrees, tries, and inverted lists, the problem of low query efficiency when the proportion of high-frequency words is high is solved, and efficient spatial keyword query is achieved.
Patent Information
- Application Number
- CN202310186672.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-01
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2043-03-01
AI Technical Summary
Existing spatial text indexes have low query efficiency when high-frequency words account for a large proportion, and traditional algorithms have failed to effectively handle the problem of uneven keyword distribution.
We employ a method based on association rule mining, which optimizes the query process to improve efficiency through data preprocessing, association rule mining, index building, and spatial keyword query stages, combined with quadtree indexes, trie indexes, and inverted lists.
It significantly improves the efficiency of spatial keyword queries, especially when high-frequency words account for a high proportion, thus enhancing query performance.
Smart Images

Figure CN116501775B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to an efficient spatial keyword query method based on association rule mining, and belongs to the field of spatial keyword query. BACKGROUND
[0002] The rapid development of mobile devices has generated a large number of location-based services, and more and more objects on the Internet have both spatial and textual attributes. Common spatial keyword queries include Boolean range query (BRQ), Boolean kNN query (BkQ) and top-k KNN query (TkQ). BRQ is the basis of many spatial text queries. The purpose of BRQ is to retrieve all objects that contain all keywords in W within the range R given a series of spatial text data and a spatial keyword query q (consisting of a spatial range R and a series of keywords W).
[0003] There are many BRQ query algorithms, such as IF-R*, WIBR-Tree, IR-Tree, CIBR, SFC-Quad, KR*-Tree, etc. Most of these indexes do not consider the difference in keyword distribution, so their efficiency is not high when the data is skewed. Skewed distribution is common, and in practice, most keywords only appear in a few objects, while a few keywords appear in most objects. Therefore, treating all keywords in the same way will inevitably reduce query efficiency. The SFC-QUAD algorithm sorts the objects in each inverted list according to the Z curve order, which makes spatially close objects as close as possible in the inverted list, thus improving the query performance. However, the query performance of SFC-QUAD increases significantly with the increase of high-frequency words. SUMMARY
[0004] The technical problem to be solved by the present application is to provide an efficient spatial keyword query method based on association rules, so as to solve the problem of low query efficiency of spatial text index when the proportion of high-frequency words is high.
[0005] The technical solution of the present application is: an efficient spatial keyword query method based on association rule mining, including data preprocessing stage, association rule mining stage, index construction stage and spatial keyword query stage. The association rule mining stage selects the corresponding frequent item set based on the depth control materialization strategy. The index construction stage constructs a quadtree index for the spatial part of the data set, and creates a trie and an inverted list for the text part of the data set. The query stage uses a coarse-grained spatial query and combines the inverted list and the corresponding materialized inverted list of the frequent item set for retrieval. The present application combines association rule mining, materialized inverted list and spatial keyword query, which can greatly improve the query efficiency of spatial keywords.
[0006] The specific steps are:
[0007] Step 1: data preprocessing stage: given a spatial keyword data set D, each object is represented as o = <o.C, o.W>, wherein o.C represents coordinates represented by longitude and latitude, and o.W represents a series of keywords, all objects in D are sorted according to Z curve sequence, and objects are numbered in turn, and the number of object o is denoted as o.ID;
[0008] Step 2: association rule mining stage: based on the association rule mining algorithm, frequent items are mined, and the final frequent item set F is selected according to the appropriate materialization depth h;
[0009] Step 3: index construction stage: a quadtree index is constructed for the o.C part of all objects in D, a trie index is constructed according to the frequent item set F, and an inverted index is constructed according to the o.W part of D;
[0010] Step 4: spatial keyword query stage: given a query q = <q.C, q.W>, q.C and q.W are queried in the quadtree, trie and inverted index in turn, and the query result is obtained.
[0011] The Step 2 is specifically:
[0012] Step 2.1: using Apriori algorithm to mine frequent items with support greater than a given value θ, obtaining a frequent item set F1, and m represents the maximum length of the frequent item set in F1;
[0013] Step 2.2: considering that materializing all frequent item sets in F1 results in large space overhead, a depth-controlled materialization strategy is introduced; specifically, for the materialization depth h ∈ H, wherein H = [0, m], the optimal space-time comprehensive cost corresponding to h is calculated according to formula (1) as follows:
[0014]
[0015] Wherein, And The normalized query time cost and storage space cost corresponding to the materialization depth h are respectively calculated according to formula (2) and (3) as follows:
[0016]
[0017]
[0018] In the formula, t h , t max respectively represent the query time corresponding to the materialization depth h and the maximum query time corresponding to all depths in H, s h And s maxrespectively represent the storage space corresponding to the depth h and the maximum storage space corresponding to all depths in H respectively;
[0019] The h corresponding to the optimal comprehensive cost can be selected by formula (1), and finally the frequent item set set F with the depth less than or equal to h is obtained.
[0020] The Step3 specifically is:
[0021] Step3.1: A quadtree index is constructed for the o.C part of the objects in D, which recursively quad-partitions the space composed of all object coordinates, and each leaf node in the quadtree stores the ID of the object, and the internal node stores the range [ID s ,ID e ] composed of the ID group of all child nodes, wherein ID s and ID e respectively represent the start ID and end ID;
[0022] Step3.2: A trie index is constructed according to the frequent item set set F, and the frequent item sets in F are organized by trie, each frequent item set is represented as a path starting from the root in the trie, each node N in the trie corresponds to a frequent item set f in F, and each node corresponds to a node inverted list N.NIL, which stores the ID of all objects containing f;
[0023] Step3.3: An inverted index is constructed for each element in o.W that does not appear in F, and each element points to an inverted list composed of all object IDs containing the element.
[0024] The Step4 specifically is:
[0025] Step4.1: Given a query q = <q.R, q.W>, wherein q.R represents a rectangular query region defined by the lower left corner coordinates and the upper right corner coordinates, and q.W represents the keyword set of the query, q.W f represents the frequent subset of q.W, that is, the subset composed of the elements belonging to q.W and appearing in F, and q.W n represents the non-frequent subset of q.W, that is, q.W n = q.W-q.W f .
[0026] Step4.2: Query the quadtree according to q.R: starting from the root node (d = 0) of the quadtree, recursively find the depth d corresponding to the sub-region that cannot completely contain q.R, obtain the ID range corresponding to the sub-region intersected by q.R, and record the union set IV of these ID ranges as the result of the coarse-grained space range query;
[0027] Step4.3: According to q.Wf Select p frequent item sets F S = {f1, f2,..., f p} satisfying and such that the total query cost is minimized;
[0028] Step 4.4: According to the p frequent item sets, query the trie index to obtain the inverted list I corresponding to the frequent item set f ;
[0029] Step 4.4: According to q.W n query the inverted index to obtain the non-frequent inverted list I n ;
[0030] Step 4.5: All IDs appearing in all inverted lists in I f and I n and belonging to a certain ID range of the query IV, that is, constitute a candidate set C satisfying the keyword query;
[0031] Step 4.6: Verify the results in C, verify whether the number o.C of the object o corresponding to each ID is in q.R, if so, o.ID is a result satisfying the spatial keyword query.
[0032] The method for selecting frequent item sets in Step 4.3 is as follows:
[0033] Step 4.3.1: Calculate all frequent item sets covered by q.W f A frequent item set f is covered by q.W f if and only if
[0034] Step 4.3.2: Set
[0035] Step 4.3.3: Sort the frequent item sets in F in descending order according to the benefit value B, which can be calculated according to the following formula: f :
[0036]
[0037] In the formula, represents the support of each element in f, e i ∈f, and |S f | represents the support corresponding to the frequent item set f;
[0038] Step 4.3.4: Loop to judge each For any f'∈F S If then F S =F S ∪{f}, finally F S stores the selected frequent item sets.
[0039] The present application has the advantages that the present application combines association rule mining, materialized inverted list and spatial keyword query, and can greatly improve the spatial keyword query efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 is the data table of the embodiment of the present application;
[0041] Figure 2 is the schematic diagram of the spatial text index of the present application;
[0042] Figure 3 is the comparison diagram of the query efficiency with the increase of the number of high-frequency words of the present application;
[0043] Figure 4 is the comparison diagram of the query efficiency with the increase of the total number of query words of the present application;
[0044] Figure 5 is the comparison diagram of the query efficiency with the increase of the query range of the present application. DETAILED DESCRIPTION
[0045] The present application will be further described below in combination with the drawings and specific embodiments.
[0046] Embodiment 1: An efficient spatial keyword query method based on association rules, the specific steps are as follows:
[0047] Step 1: Given a spatial keyword data set D, each object is represented as o=<o.C, o.W>, wherein o.C represents the coordinates represented by longitude and latitude, and o.W represents a series of keywords, all objects in D are sorted according to Z curve sequence, and the objects are numbered in turn, and the number of the object o is denoted as o.ID;
[0048] In this embodiment, the data set as shown in the figure is given, and all the objects in the figure have been sorted according to the Z curve. Figure 1
[0049] Step 2: Frequent items are mined based on the association rule mining algorithm, and the final frequent item set set F is selected according to the appropriate materialized depth h;
[0050] In this embodiment, the frequent item set set F={{a}, {b}, {c}, {a, b}, {b, c}, {d}} is obtained by association rule mining.
[0051] Step3: Construct quadtree index for o.C part of all objects in D; construct trie index according to frequent item set collection F; construct inverted index according to o.W part of D;
[0052] In this embodiment, the quadtree index, trie index and inverted index are constructed for all objects in D in sequence, and an index structure as shown in FIG. 2 is obtained. Figure 2
[0053] Step4: Given a query q = <q.C, q.W>, q.C and q.W are queried in the quadtree, trie and inverted index in sequence to obtain a query result.
[0054] In this example, given a spatial query q.R = {[0, 1], [2, 3]} and q.W = {a, b, c, e}, the final result {1, 2} is obtained through the quadtree, trie and inverted index query.
[0055] The Step 2 is specifically as follows:
[0056] Step2.1: Use the Apriori algorithm to mine frequent items with support greater than a given value θ, and obtain a frequent item set collection F. Let m represent the maximum length of the frequent item set collection F.
[0057] In this embodiment, for the data set in FIG. 1, the frequent item set with support greater than 3 is mined, and the frequent item set collection F = {{a}, {b}, {c}, {a, b}, {b, c}, {d}} is obtained. Figure 1
[0058] Step2.2: Considering that materializing all frequent item sets in F leads to a large space overhead, a depth-controlled materialization strategy is introduced. Specifically, for a materialization depth h ∈ H, where H = [0, m], the optimal space-time comprehensive cost corresponding to h is calculated according to formula (1) as follows:
[0059]
[0060] and respectively represent the normalized query time cost and storage space cost corresponding to the materialization depth h, which are calculated according to formulas (2) and (3) as follows:
[0061]
[0062]
[0063] In the formula, t h , t max respectively represent the query time corresponding to the depth h and the maximum query time corresponding to all depths in H. Correspondingly, s h and s max respectively represent the storage space corresponding to the depth h and the maximum storage space corresponding to all depths in H.
[0064] The h corresponding to the optimal comprehensive cost can be selected by formula (1), and finally the frequent item set F with a depth less than or equal to h is obtained.
[0065] The Step 3 specifically includes:
[0066] Step3.1: A quadtree index is constructed for the o.C part of the objects in D, which recursively quadriculates the space composed of all object coordinates, and each leaf node in the quadtree stores the ID of the object, and the internal node stores the range [ID s ,ID e ] composed of the ID of all child nodes, wherein ID s and ID e represent the start ID and the end ID respectively.
[0067] In this embodiment, a quadtree as shown in Figure 2 is constructed for the spatial data, and the quadtree nodes are one-to-one corresponding to the Z curve positions.
[0068] Step3.2: A trie index is constructed according to the frequent item set collection F, and the frequent item sets in F are organized by trie, and each frequent item set is represented as a path starting from the root in the trie; each node N in the trie corresponds to a frequent item set f in F, and each node corresponds to a node inverted list N.NIL, which stores the IDs of all objects containing f;
[0069] In this embodiment, the trie tree is constructed for the frequent item set collection F = {{a}, {b}, {c}, {a, b}, {b, c}, {d}}, and the trie tree as shown in Figure 2 is formed.
[0070] Step3.3: An inverted index is constructed for each element in o.W that does not appear in F, and each element points to an inverted list composed of all object IDs containing the element;
[0071] In this embodiment, the elements {e, f, g} that do not appear in F construct an inverted index, as shown in Figure 2 .
[0072] The Step 4 specifically includes:
[0073] Step4.1: Given a query q = <q.R, q.W>, where q.R represents a rectangular query region defined by the lower-left corner and the upper-right corner, and q.W represents the keyword set of the query; let q.W f denote the frequent subsets of q.W, i.e. the subsets of q.W that are present in F; q.W n denote the non-frequent subsets of q.W, i.e. q.W n = q.W - q.W f ;
[0074] In this embodiment, given a spatial query q.R = {[0, 1], [2, 3]} and q.W = {a, b, c, e}, and the frequent itemset universe F = {{a}, {b}, {c}, {a, b}, {b, c}, {d}}, the query keywords are divided into two categories q.W f = {a, b, c} and q.W n = {e}, and finally the set of frequent query keywords is obtained
[0075] Step4.2: Query the quadtree according to q.R: starting from the root node (d = 0) of the quadtree, recursively find the depth d at which the corresponding sub-region cannot completely contain q.R, obtain the ID range corresponding to the sub-region intersected with q.R at the d-th layer node, and let the union set IV of these ID ranges be the result of the coarse-grained spatial range query;
[0076] In this embodiment, for the query space q.R = {[0, 1], [2, 3]}, as shown in the box in Figure 2 q.R is completely contained in the root node of the quadtree, so the four child nodes of the root node are retrieved, and it is found that q.R is not completely contained in all four nodes, so the interval [0, 1] of the first child node and the interval [3, 5] of the third child node are obtained.
[0077] Step4.3: According to q.W f select p frequent itemsets F S = {f1, f2,..., f p} that satisfy and for each have so that the total query cost is minimized;
[0078] In this embodiment, two frequent itemsets F S = {{a, b}, {c}} are selected, which satisfy and for each have
[0079] Step4.4: According to the p frequent itemsets, query the trie index to obtain the inverted list I corresponding to the frequent itemsets f ;
[0080] In this embodiment, according to the 2 frequent itemsets obtained in Step4.3 and the range interval obtained in Step4.2, the path {{a, b}, {c}} in the trie tree is searched.
[0081] Step4.5: According to q.W n , query the inverted index to obtain the non-frequent inverted list I n ;
[0082] In this embodiment, the inverted list of the remaining keyword {e} is searched.
[0083] Step4.6: All IDs appearing in all inverted lists in I f and I n , and belonging to a certain ID range of the query IV, that is, constitute a candidate set C satisfying the keyword query;
[0084] In this embodiment, the inverted lists obtained in Step4.5 and Step4.6 are searched to obtain the candidate set C as shown in the red box in Figure 2 .
[0085] Step 4.7: Verify the results in C, verify whether the number o.C of the object o corresponding to each ID is in q.R, if yes, then o.ID is a result satisfying the spatial keyword query;
[0086] In this embodiment, the results in C are verified to obtain the results {0, 1}.
[0087] The method for selecting frequent itemsets in Step 4.3 is specifically:
[0088] Step4.3.1: Calculate all frequent itemsets covered by q.W f A frequent itemset f is covered by q.W f when and only when
[0089] Step4.3.2: Set
[0090] Step4.3.3: Sort the frequent itemsets in in descending order of benefit value, and the benefit B of the frequent itemset f can be calculated according to the following formula f :
[0091]
[0092] wherein represents the support of each element in f, e i f, and |S f represents the support corresponding to the frequent item set f.
[0093] In the embodiment, the support of each frequent item set f is calculated as follows: The benefit B f of each association rule in f is calculated as follows: {a,b} For the frequent item set {a, b}, the supports of its subsets {a}, {b} and {a, b} are 4, 4 and 3 respectively, and the benefit B
[0094] Step 4.3.4: Loop to judge each For any f' e F S , if , then F S = F S U {f}, and the stored in F S is the selected frequent item set.
[0095] The present application can be further illustrated by the following experimental results.
[0096] Experimental environment: CPU is Intel(R) Core(TM) i7-11800H CPU@2.3GHz, memory is 16GB, software environment is, operating system is windows 10, programming language is JAVA, and compiling environment is jdk1.8, and compiler is IntelliJ IDEA2021.1.3x64.
[0097] Experimental data: ROAD is the road network data of the United States, and contains 20 million coordinates; KOSARAK is the click stream data of an online news portal in Hungary, and contains 990,000 records. By randomly and repeatedly assigning a coordinate in ROAD to each record in KOSARAK, the data set of 990,000 records composed of RETAIL and EURO is formed.
[0098] Experimental result analysis: The experiment is a comparison of the query efficiency of the spatial keyword query algorithm of the present application and IF-R*, WIBR-Tree, IR-Tree, CIBR, SFC-Quad and KR*-Tree. The experiment is divided into three groups: the influence of the number of high-frequency words x on the index performance under the condition that the total number of query words is unchanged, and the experimental results are shown in Figure 3 ; the influence of the total number of query words y on the index performance under the condition that the number of high-frequency words is unchanged, and the experimental results are shown in Figure 4As shown; with the total number of query terms and the number of high-frequency terms remaining unchanged, the impact of the query space range on index performance is illustrated in the experimental results. Figure 5 As shown in the figure, this algorithm is more efficient than other methods, and its advantage becomes increasingly apparent as the proportion of high-frequency words increases. For example, in... Figure 3 In the above tests, this algorithm achieved an efficiency improvement of up to 26 times compared to the SFC-Quad algorithm; Figure 4 In the above tests, this algorithm achieved an efficiency improvement of up to 26 times compared to the SFC-Quad algorithm; Figure 5 In this algorithm, the growth rate of the query range is 24% lower than that of the SFC-Quad algorithm.
[0099] The specific embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1.A method for efficient spatial keyword query based on association rule mining, characterized in that: Step 1: Given a spatial keyword dataset D, each object is represented as o = <o.C, o.W>, wherein o.C represents the coordinates represented by longitude and latitude, and o.W represents a series of keywords, all objects in D are sorted according to Z curve sequence, and the objects are numbered in turn, and the number of the object o is denoted as o.ID; Step 2: Frequent items are mined based on association rule mining algorithm, and the final frequent item set F is selected according to a suitable materialized depth h; Step 3: A quadtree index is constructed for the o.C part of all objects in D, a trie index is constructed according to the frequent item set F, and an inverted index is constructed according to the o.W part of D; Step 4: Given a query q = <q.C, q.W>, q.C and q.W are queried in the quadtree, trie and inverted index in turn, and the query result is obtained. 2.The method of claim 1, wherein, The Step 2 is specifically: Step 2.1: The Apriori algorithm is used to mine frequent items with support greater than a given value θ, and a frequent item set F1 is obtained, wherein m represents the maximum length of the frequent item set in F1; Step 2.2: For the materialized depth h ∈ H, wherein H = [0, m], the optimal space-time comprehensive cost corresponding to h is calculated according to formula (1) as follows: wherein, and respectively represent the normalized query time cost and storage space cost corresponding to the materialization depth h, respectively calculated according to formulas (2) and (3) as follows: In the formula, t h and t max respectively represent the query time corresponding to the depth h and the maximum query time corresponding to all depths in H, s h and s max respectively represent the storage space corresponding to the depth h and the maximum storage space corresponding to all depths in H; The optimal comprehensive cost corresponding to h is selected through formula (1), and the frequent item set set F with a depth less than or equal to h is finally obtained. 3.The method of claim 1, wherein, The Step 3 is specifically: Step 3.1: Construct a quadtree index for the oC portion of objects in D. This index recursively divides the space consisting of all object coordinates into four equal parts. Each leaf node in the quadtree stores the object's ID, and internal nodes store the range of IDs of all their child nodes [ID]. s ID e ], where ID s and ID e These represent the start ID and end ID, respectively. Step 3.2: A trie index is constructed according to the frequent item set F, and the trie organizes the frequent item sets in F, wherein each frequent item set is represented as a path starting from the root in the trie, each node N in the trie corresponds to a frequent item set f in F, and each node corresponds to a node inverted list N.NIL, which stores the IDs of all objects containing f; Step 3.3: An inverted index is constructed for each element in o.W that does not appear in F, and each element points to an inverted list composed of all object IDs containing the element. 4.The method of claim 1, wherein, The Step 4 is specifically: Step4.1: Given a query q = <q.R, q.W>, where q.R represents a rectangular query region defined by the lower-left corner coordinate and the upper-right corner coordinate, and q.W represents the keyword set of the query, let q.W f denote the frequent subsets of q.W, i.e., the subsets of q.W that are composed of the elements belonging to q.W and appearing in F, and q.W n denote the non-frequent subsets of q.W, i.e., the subsets of q.W that are composed of the elements belonging to q.W but not appearing in F, and q.W n = q.W - q.W f ; Step 4.2: Starting from the root node of the quadtree, the depth d at which the corresponding sub-region cannot completely contain q.R is recursively found, the ID range corresponding to the sub-region intersected by q.R at the d-th layer node is obtained, and the union set IV of these ID ranges is taken as the result of the coarse-grained spatial range query; Step4.3: According to q.W f Select p frequent itemsets F S = {f1, f2,..., f p} that satisfy and for have such that the total query cost is minimized; Step 4.4: Query the trie index according to the p frequent itemsets to obtain the inverted list I corresponding to the frequent itemsets f ; Step4.4: According to q.W n Query the inverted index to obtain the non-frequent inverted list I n ; Step 4.5: All IDs that occur in the inverted lists in I f and I n that belong to some ID range of query IV, i.e. that constitute the candidate set C that satisfies the keyword query. Step 4.6: The results in C are verified, and the number of the object o corresponding to each ID is verified whether o.C is in q.R, and if yes, o.ID is the result of the spatial keyword query; 5.The method of claim 4, wherein, The method for selecting frequent item set in Step 4.3 is specifically: Step 4.3.1: Compute q.W f all frequent itemsets covered A frequent itemset f is covered by q.W f covered if and only if Step 4.3.2: Set Step4.3.3: Sort the frequent itemsets in descending order of the benefit value Bf The benefit Bf of the frequent itemset f can be calculated according to the following formula f : wherein represents the support of each element in f, e i ∈f, and |S f represents the support of the frequent item set f; Step4.3.4: Loop through each For any f'∈F S If Then F S =F S ∪{f}, finally the stored in F S is the selected frequent itemsets.
Citation Information
Patent Citations
Space keyword query method and device based on geohash and Patricia Trie
CN108846013A
Keyword search KSAARM algorithm combining time window and association rules mining
CN109783628A