An indexing method and system for spatiotemporal knowledge graphs
By constructing an entity spatio-temporal index and a relational spatio-temporal index, combined with Hilbert curves and Bloom filters, the problem of being unable to query spatio-temporal-entity-relationships in the existing technology is solved, and the efficient query capability of the spatio-temporal knowledge graph is achieved.
Patent Information
- Application Number
- CN202410869121.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Existing knowledge graph technology cannot provide query capabilities for spatio-temporal-entity-relationships, and cannot effectively handle entities and relationships with spatio-temporal attributes.
An indexing method for spatiotemporal knowledge graphs is designed. By constructing entity spatiotemporal index and relational spatiotemporal index, spatiotemporal range retrieval and nearest neighbor retrieval are realized. Hilbert curve is used to convert spatiotemporal attributes into integers, and multi-version B-tree and inverted index are constructed. Query combined with Bloom filter.
It achieves a comprehensive description of the spatiotemporal knowledge graph, makes entities and relationships have spatiotemporal attributes, provides query capabilities for spatiotemporal-entity-relationships, and improves query efficiency and practical significance.
Smart Images

Figure CN118394877B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph management technology, and in particular to an indexing method and system for spatiotemporal knowledge graphs. Background Art
[0002] The existing knowledge graph indexing method obtains the spatiotemporal attribute data of spatiotemporal nodes to construct a 3DR index tree; aggregates all spatiotemporal entities contained in each node in the 3DR index tree to obtain a hypergraph node, and inputs the second-order subgraph of the hypergraph node as training data into the graph neural network model for training to obtain a subgraph matching model; decomposes the query request to obtain the query subgraph and spatiotemporal constraints into the subgraph matching model for calculation to obtain the embedding vector and spatiotemporal range parameters of the query subgraph; prunes the spatiotemporal attribute data to find the spatiotemporal entity subgraph under each leaf node, and prunes each spatiotemporal entity subgraph according to the query subgraph and subgraph matching model to obtain the spatiotemporal subgraph embedding vector; compares the relative position relationship between the embedding vector and the spatiotemporal subgraph embedding vector in the vector space to obtain the query result. However, in the spatiotemporal knowledge graph, both entities and relationships have spatiotemporal attributes, and the existing knowledge graph technology cannot provide the ability to query spatiotemporal-entity-relationship. Summary of the invention
[0003] The present invention provides an indexing method and system for spatiotemporal knowledge graphs to solve the problem that the prior art cannot provide the ability to query spatiotemporal-entity-relationships.
[0004] In order to achieve the above object, the present invention is implemented by the following technical solutions:
[0005] In a first aspect, the present invention provides an indexing method for a spatiotemporal knowledge graph, comprising:
[0006] S1: Construct an index structure corresponding to the target spatiotemporal knowledge graph; the index structure includes an entity spatiotemporal index and a relationship spatiotemporal index;
[0007] S2: When the search type is a time-space range search, the set time-space range search method is executed; when the search type is a nearest neighbor search, the set nearest neighbor search method is executed;
[0008] Wherein, the set spatiotemporal range retrieval method and the nearest neighbor retrieval method are both implemented based on the entity spatiotemporal index and the relationship spatiotemporal index.
[0009] In a second aspect, the present application provides an indexing system for a spatiotemporal knowledge graph, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0010] Beneficial effects:
[0011] The indexing method for spatiotemporal knowledge graph provided by the present invention constructs an index structure corresponding to the target spatiotemporal knowledge graph; the index structure includes entity spatiotemporal index and relationship spatiotemporal index; when the search type is spatiotemporal range search, the set spatiotemporal range search method is executed, and when the search type is nearest neighbor search, the set nearest neighbor search method is executed. The spatiotemporal attributes of the spatiotemporal knowledge graph are fully described, so that not only entities have spatiotemporal attributes, but also relationships have spatiotemporal attributes, and the ability to query spatiotemporal-entity-relationship is provided.
[0012] In a further technical solution, an index structure designed for the spatiotemporal knowledge graph takes into account both spatiotemporal attributes and name attributes, and can perform synchronous retrieval with high efficiency.
[0013] In a further technical solution, a spatiotemporal range retrieval method is designed, which fully considers the spatiotemporal attributes of entities and the spatiotemporal attributes of relationships, and has a broader practical significance.
[0014] In a further technical solution, a nearest neighbor retrieval method is designed, which provides an effective means for using the nearest neighbor to find useful entity relationships in practice. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 The present invention is a flowchart of an indexing method for spatiotemporal knowledge graphs according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0016] The technical solution of the present invention is described clearly and completely below. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0017] Unless otherwise defined, the technical terms or scientific terms used in the present invention shall have the usual meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "one" do not indicate quantity restrictions, but indicate the existence of at least one. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship also changes accordingly.
[0018] See also Figure 1 , the present application provides an indexing method for spatiotemporal knowledge graphs, including:
[0019] S1: Construct an index structure corresponding to the target spatiotemporal knowledge graph; the index structure includes an entity spatiotemporal index and a relationship spatiotemporal index;
[0020] S2: When the search type is a time-space range search, the set time-space range search method is executed; when the search type is a nearest neighbor search, the set nearest neighbor search method is executed;
[0021] Wherein, the set spatiotemporal range retrieval method and the nearest neighbor retrieval method are both implemented based on the entity spatiotemporal index and the relationship spatiotemporal index.
[0022] In this implementation, the target spatiotemporal knowledge graph refers to a knowledge graph that satisfies the following conditions:
[0023] (1) It has entities, relations, and spatiotemporal attributes. Let the spatiotemporal knowledge graph be STKG;
[0024] (2) It is composed of multiple entities, and there are relationships between entities;
[0025] (3) The entity has a name attribute, as well as time t and space (x, y) attributes;
[0026] (4) The relation has a kind attribute cat, as well as time t and space (x, y) attributes.
[0027] In addition, in this embodiment, the retrieval types of the target spatiotemporal knowledge graph include spatiotemporal range retrieval and nearest neighbor retrieval.
[0028] Specifically, the time and space range retrieval is a given time range [t1,t2], space range [x1,y1,x2,y2], partial entity name pn1, and relationship type cat1. All entities and relationships whose entity time attributes are in [t1,t2], entity space attributes are in [x1,y1,x2,y2], relationship time attributes are in [t1,t2], relationship space attributes are in [x1,y1,x2,y2], entity names start with pn1, and the type of relationship between entities is cat1 are retrieved.
[0029] The nearest neighbor search is for a given time range [t3, t4], a spatial point [x3, y3], a partial entity name pn2, and a relationship type cat2. The two entities whose entity spatiotemporal attributes are in [t3, t4] and are closest to the spatial point [x3, y3] are retrieved, and whose relationship time attributes are in [t3, t4], one of whose entity names starts with pn2, and whose relationship type is cat2.
[0030] The above-mentioned indexing method for spatiotemporal knowledge graph constructs an index structure corresponding to the target spatiotemporal knowledge graph; the index structure includes entity spatiotemporal index and relationship spatiotemporal index; when the search type is spatiotemporal range search, the set spatiotemporal range search method is executed, and when the search type is nearest neighbor search, the set nearest neighbor search method is executed. The spatiotemporal attributes of the spatiotemporal knowledge graph are fully described, so that not only entities have entity attributes, but also relationships have spatiotemporal attributes, which can provide the ability to query spatiotemporal-entity-relationship.
[0031] Optionally, in one example, the specific steps of constructing the index structure corresponding to the target spatiotemporal knowledge graph are as follows:
[0032] (1) Given a spatiotemporal knowledge graph STKG, construct a Hilbert space filling curve to divide the space corresponding to the spatiotemporal knowledge graph, so that any point (x, y) in the space can be converted into a value in the integer space through the mapping of the Hilbert curve, that is, H: (x, y) → Z; where H represents the Hilbert curve, (x, y) represents the coordinates of any point in the space, and Z represents the value in the integer space.
[0033] (2) For the time and space attributes in the entity, the spatial attributes are converted into one-dimensional space integers using the Hilbert curve. That is, the time and space attributes in the entity are converted into time and integers (original space values), and a multi-version B-tree of the entity time and space index is constructed. The time of the multi-version B-tree of the entity time and space index is the time in the entity, and the key value of the multi-version B-tree of the entity time and space index is an integer (original space value).
[0034] (3) Similarly, for the time and space attributes in the relationship, the spatial attributes are converted into one-dimensional space integers using the Hilbert curve. That is, the time and space attributes in the relationship are converted into time and integers (original space values), and a multi-version B-tree of the relationship time and space index is constructed. The time of the multi-version B-tree of the relationship time and space index is the time in the relationship, and the key value of the multi-version B-tree of the relationship time and space index is an integer (original space value).
[0035] (4) Construct an inverted index for the names of the entities in the target spatiotemporal knowledge graph. The keys of the inverted index are all entity names, and the elements in the linked list pointed to by the keys are leaf nodes in the entity spatiotemporal index.
[0036] (5) For the name of the relationship in the target spatiotemporal knowledge graph, a Bloom filter is constructed in the leaf node of the relational spatiotemporal index. That is, given a name, the Bloom filter gives two answers: one is that it is definitely not in the leaf node, and the other is the probability of existing in the leaf node, that is, it may be in the leaf node.
[0037] In this implementation, an index structure for the spatiotemporal knowledge graph is designed. The index structure takes into account both spatiotemporal attributes and name attributes, and can perform synchronous retrieval with high efficiency.
[0038] Specifically, the spatiotemporal attribute is converted into time, and the spatial attribute is converted into an integer. The integer is the original space value, which means that this integer is specifically the value of the integer space.
[0039] Optionally, in one example, the steps of space-time range retrieval are as follows:
[0040] (1) Given the time and space range retrieval conditions, the time range [t1, t2], the space range [x1, y1, x2, y2], the partial entity name pn1, and the relationship type cat1;
[0041] (2) In the entity spatiotemporal index, the search conditions [t1, t2] and [x1, y1, x2, y2] are input into the multi-version B-tree, and the B-tree returns a set of leaf nodes SEL that meet the conditions;
[0042] (3) For the partial entity name pn1, use the constructed inverted index to filter, that is, find the keys starting with pn1, and intersect the leaf nodes in the linked list corresponding to these keys with SEL to obtain a further result set SELF;
[0043] (4) In the relational spatiotemporal index, the search conditions [t1, t2] and [x1, y1, x2, y2] are input into the multi-version B-tree, and the B-tree returns the leaf node set SRL that meets the conditions;
[0044] (5) For the relationship type cat1, use the constructed Bloom filter to filter, and intersect the leaf nodes that may contain cat1 with SRL to obtain a further result set SRLF;
[0045] (6) Check the corresponding relationships in the SELF and SRLF sets, and select the entities that are only in SELF and have a relationship in SRLF as the final retrieval results.
[0046] In this implementation, a spatiotemporal range retrieval method is designed, which fully considers the spatiotemporal attributes of entities and the spatiotemporal attributes of relationships and has a wider practical significance.
[0047] Optionally, in one example, the steps of the nearest neighbor search method are as follows:
[0048] (1) Given the nearest neighbor search conditions, time range [t3, t4], spatial point [x3, y3], partial entity name pn2, and relationship type cat2;
[0049] (2) For the spatial point [x3, y3], construct the range [x3-r, y3-r, x3+r, y3+r] with radius r;
[0050] (3) In the entity spatiotemporal index, the search conditions [t3, t4] and [x3-r, y3-r, x3+r, y3+r] are input into the multi-version B-tree, and the B-tree returns a set of leaf nodes SEL that meet the conditions;
[0051] (4) For the partial entity name pn2, use the constructed inverted index to filter, that is, find the keys starting with pn2, and intersect the leaf nodes in the linked list corresponding to these keys with SEL to obtain a further result set SELF;
[0052] (5) In the relational spatiotemporal index, the search condition [t3, t4] is input into the multi-version B-tree, and the B-tree returns the set of leaf nodes SRL that meet the condition;
[0053] (6) For the relationship type cat2, use the constructed Bloom filter to filter, and intersect the leaf nodes that may contain cat2 with SRL to obtain a further result set SRLF;
[0054] (7) Check the correspondence between SELF and SRLF sets, and select the entities in SELF that also have a relationship in SRLF. If there are multiple relationships, select the two entities closest to [x3, y3]. If the correspondence between SELF and SRLF is an empty set, then r = 2r, and go to S2. If it is still empty at 2r, the next time is 4r.
[0055] In this implementation, a nearest neighbor retrieval algorithm is designed, which provides an effective means for using the nearest neighbor to find useful entity relationships in practice.
[0056] The present application also provides an indexing system for spatiotemporal knowledge graphs, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program. The indexing system for spatiotemporal knowledge graphs can implement various embodiments of the above-mentioned indexing method for spatiotemporal knowledge graphs, and can achieve the same beneficial effects, which will not be described in detail here.
[0057] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. An indexing method for spatiotemporal knowledge graphs, characterized in that: include: S1: Construct an index structure corresponding to the target spatiotemporal knowledge graph; the index structure includes an entity spatiotemporal index and a relationship spatiotemporal index; S2: When the search type is a time-space range search, the set time-space range search method is executed; when the search type is a nearest neighbor search, the set nearest neighbor search method is executed; Wherein, the set spatiotemporal range retrieval method and the nearest neighbor retrieval method are both implemented based on the entity spatiotemporal index and the relationship spatiotemporal index; The S1 includes: For the target spatiotemporal knowledge graph, construct a Hilbert space filling curve to divide the space corresponding to the spatiotemporal knowledge graph, so that any point (x, y) in the space can be converted into a value in the integer space through the mapping of the Hilbert space filling curve; The time attribute and the space attribute in the entity of the target spatiotemporal knowledge graph are converted into time and integer using the Hilbert space filling curve, and a multi-version B-tree of the entity spatiotemporal index is constructed, wherein the key value of the multi-version B-tree of the entity spatiotemporal index is the integer converted in the entity, and the time of the multi-version B-tree of the entity spatiotemporal index is the time converted in the entity; The time attribute and the space attribute in the relationship of the target spatiotemporal knowledge graph are converted into time and integer using the Hilbert space filling curve, and a multi-version B-tree of the relational spatiotemporal index is constructed, wherein the key value of the multi-version B-tree of the relational spatiotemporal index is the integer converted in the relationship, and the time of the multi-version B-tree of the relational spatiotemporal index is the converted time in the relationship; The method further comprises: constructing an inverted index; The step of constructing an inverted index includes: Construct an inverted index for the names of the entities in the target spatiotemporal knowledge graph, where the keys of the inverted index are the names of all entities, and the elements in the linked list pointed to by the keys are the leaf nodes in the entity spatiotemporal index; The method further comprises: constructing a Bloom filter; The constructing of the Bloom filter comprises: For the name of the relationship of the target spatiotemporal knowledge graph, a Bloom filter is constructed in the leaf node of the spatiotemporal index of the relationship. The output of the Bloom filter is two cases, one is that it is definitely not in the leaf node, and the other is the probability of existing in the leaf node; The method for executing the set spatiotemporal range search comprises: Determine the time and space range search conditions, including the time range [t1, t2], the space range [x1, y1, x2, y2], the partial entity name pn1, and the relationship type cat1; In the entity spatiotemporal index, the time range [t1, t2] and the space range [x1, y1, x2, y2] in the search condition are input into the multi-version B-tree of the entity spatiotemporal index, and the multi-version B-tree of the entity spatiotemporal index returns a leaf node set SEL that meets the condition; For the partial entity name pn1, the inverted index is used for filtering to find the keys starting with the partial entity name pn1, and the leaf nodes in the linked lists corresponding to these keys are intersected with SEL to obtain the result set SELF of the entity spatiotemporal index; In the relational spatiotemporal index, the time range [t1, t2] and the space range [x1, y1, x2, y2] in the search condition are input into the multi-version B-tree of the relational spatiotemporal index, and the multi-version B-tree of the relational spatiotemporal index returns a leaf node set SRL that meets the condition; For the relationship type cat1, the Bloom filter is used to filter, so as to intersect the leaf nodes with a certain probability of the existence of cat1 with SRL to obtain the result set SRLF of the relationship spatiotemporal index; The entities that have relationships in both SELF and SRLF are taken as the final retrieval results.
2. The indexing method for spatiotemporal knowledge graph according to claim 1, characterized in that: The nearest neighbor search method for executing the setting includes: Determine the nearest neighbor search conditions, including the time range [t3, t4], the spatial point [x3, y3], the partial entity name pn2, and the relationship type cat2; For the spatial point [x3, y3], construct the spatial range [x3-r, y3-r, x3+r, y3+r] with r as radius; In the entity spatiotemporal index, the time range [t3, t4] and the space range [x3-r, y3-r, x3+r, y3+r] in the search condition are input into the multi-version B-tree of the entity spatiotemporal index, and the multi-version B-tree of the entity spatiotemporal index returns a leaf node set SEL that meets the condition; For the partial entity name pn2, the inverted index is used for filtering to find the keys starting with the partial entity name pn2, and the leaf nodes in the linked lists corresponding to these keys are intersected with SEL to obtain the result set SELF; In the relational spatiotemporal index, the time range [t3, t4] in the search condition is input into the multi-version B-tree of the relational spatiotemporal index, and the multi-version B-tree of the relational spatiotemporal index returns a leaf node set SRL that meets the condition; For the relationship type cat2, the constructed Bloom filter is used to filter, so as to intersect the leaf nodes with a certain probability of the existence of cat2 with SRL, and obtain the result set SRLF of the relationship spatiotemporal index; Only the entities in SELF and with relationships in SRLF are taken as the final retrieval results.
3. The indexing method for spatiotemporal knowledge graph according to claim 2 is characterized in that: If there are multiple relations in the SRLF, the two entities closest to the spatial point [x3, y3] are selected as the final retrieval results; If the correspondence between SELF and SRLF is an empty set, the radius is adjusted to construct a new spatial range, and the search step is re-executed based on the new spatial range, wherein the radius is adjusted in a manner that satisfies the following relationship: r=2r。 4. An indexing system for spatiotemporal knowledge graphs, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
