A data query method, system, electronic device and storage medium
By sequentially using the query results of each index as the query conditions for the next index, the results of related queries can be obtained directly, which solves the problem of low efficiency in multi-index queries in existing technologies and achieves efficient data querying.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-13
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies cannot directly perform related queries when using search engines for multi-index queries, resulting in low query processing efficiency.
By receiving the related query request from the client, the system sequentially queries each target index based on the current query conditions of each target index. It then uses the initial query result and initial query conditions of each index as the current query conditions of the next index to directly obtain the related query result and return it to the client.
It improves the efficiency of data querying, reduces the amount of data to be queried, and avoids additional join operations.
Smart Images

Figure CN115599801B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, and in particular to a data query method and system, an electronic device and a storage medium. BACKGROUND
[0002] Generally, when searching using a search engine, data in two or more indexes is usually queried, and in some cases, such as when there are associated fields in the two or more indexes, the search engine needs to perform a query operation on each of the two or more indexes, and then other application programs need to perform an association operation on the results of the two-index query, and it is not possible to directly use the search engine to perform an associated query when querying.
[0003] The above query method has the problem of low query processing efficiency. SUMMARY
[0004] The present application provides a data query method, system, electronic device and storage medium to improve the efficiency of data query.
[0005] The first aspect of the present application provides a data query method, comprising:
[0006] receiving an association query request from a client, the association query request being used to request data query on at least two target indexes, and comprising initial query conditions of each of the target indexes;
[0007] sequentially querying storage data corresponding to each of the target indexes based on current query conditions of each of the target indexes, to obtain initial query results of each of the target indexes, and taking the initial query result of the last target index as an association query result, wherein the current query condition of the first target index is the initial query condition of the target index, and the current query condition of the non-first target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index;
[0008] feeding back the association query result to the client.
[0009] The second aspect of the present application provides an electronic device, comprising a memory and a processor coupled to each other, the processor being used to execute program instructions stored in the memory to implement the above-mentioned data query method.
[0010] The third aspect of the present application provides a data query system, comprising a coordination node and a plurality of data nodes.
[0011] The coordination node is configured to receive an association query request from a client, and sequentially send current query conditions of each target index to data nodes corresponding to the target indexes, the association query request is configured to request data query on at least two target indexes, and includes initial query conditions of each target index, and the data nodes corresponding to the target indexes store storage data corresponding to the target indexes;
[0012] The data node corresponding to the target index is configured to query the storage data corresponding to the target index based on the current query condition of the target index, obtain an initial query result of the target index, and in response to the target index being the last queried target index, feed back the initial query result of the target index as an association query result to the coordination node, wherein the current query condition of a first target index is the initial query condition of the target index, and the current query condition of a non-first target index is obtained based on the initial query condition of the target index and an initial query result of a previous target index.
[0013] The coordination node is further configured to feed back the association query result to the client.
[0014] The fourth aspect of the present application provides a computer readable storage medium, which stores program instructions, and the program instructions are executed by a processor to implement the data query method in the first aspect.
[0015] The above scheme sequentially queries multiple target indexes based on current query conditions of the target indexes after receiving an association query request from a client, and each subsequent target index uses the query result of a previous target index and the initial query condition of the target index as the current query condition to perform association query to obtain an association query result, and the association query result is fed back to the client to display the query result of the data query on the client. Since the association operation is directly considered in the index query process, the association query result can be directly obtained based on the query result of the last queried index. Compared with the mode of separately querying each index based on the initial query condition of each index and then associating the query results of each index, the above scheme improves the query efficiency of data query and reduces the amount of query data.
[0016] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the present application. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings incorporated in and forming a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.
[0018] Figure 1 is a flowchart of an embodiment of the data query method of the present application;
[0019] Figure 2 is a flowchart of another embodiment of the data query method of the present application;
[0020] Figure 3 is a flowchart of yet another embodiment of the data query method of the present application;
[0021] Figure 4 is an interaction diagram of an embodiment of the data query system of the present application;
[0022] Figure 5 is a structural diagram of an embodiment of the data query system of the present application;
[0023] Figure 6 is a structural diagram of an embodiment of the electronic device of the present application;
[0024] Figure 7 is a structural diagram of an embodiment of the computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0025] The schemes of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0026] In the following description, specific details are set forth in order to provide a thorough understanding of the present application. However, persons having ordinary skill in the art will appreciate that the present application can be practiced without the specific details.
[0027] The term "and / or" herein merely describes an association relationship of associated objects, and means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. In addition, the character " / " herein generally means that the front and rear associated objects are in an "or" relationship. In addition, "multiple" herein means two or more than two. In addition, the term "at least one" herein means any one of multiple or any combination of at least two of multiple, for example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0028] Please refer to Figure 1 , Figure 1 is a flowchart of the data query method of the embodiment of the present application.
[0029] Specifically, it can include the following steps:
[0030] Step S102: receiving an association query request from a client, the association query request being used to request data query on at least two target indexes and including initial query conditions of the target indexes;
[0031] The execution subject of the data query method in the embodiments of the present disclosure can be a search engine, such as a distributed search engine (Elsticsearch), and can also be other search engines, which are not limited herein. It can be understood that the search engine described herein as an execution subject can be one or more node devices participating in running the search engine as an actual hardware execution entity.
[0032] In some embodiments, after the search engine receives the association query request sent by the client, the association query request includes index information of at least two target indexes, and the search engine determines the target indexes that need to be queried according to the index information of the at least two target indexes. Wherein, the at least two target indexes mentioned above refer to two, three or more target indexes. In this embodiment, the at least two target indexes can be at least two indexes that have an association field.
[0033] In this paper, the association field mentioned above refers to the existence of the same field name in at least two indexes, for example, taking the user ID as an example, the user ID is stored in index A and index B, and the user ID is called the association field of index A and index B. Or, there can also be the same field value in at least two indexes, for example, taking the user ID as an example, the ID value 101 of a certain user is stored in index A and index B, and the value 101 of the user ID is called the association field. Wherein, if there are multiple indexes, when the multiple indexes are associated and queried, the association field exists in the multiple indexes.
[0034] In some other possible embodiments, the search engine can determine the target indexes by itself after receiving the association query request sent by the client, for example, the search engine can default all indexes as target indexes for data query, the search engine can default all indexes for data query after receiving the association query request; or the search engine can determine the relevant at least two target indexes according to other information such as retrieval conditions contained in the association query request sent by the client.
[0035] Step S104: sequentially query the storage data corresponding to each target index based on the current query condition of each target index, and obtain the initial query result of each target index, and take the initial query result of the last target index as the association query result, wherein the current query condition of the first target index is the initial query condition of the target index, and the current query condition of the non-first target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index;
[0036] In the embodiments of the present disclosure, the above-mentioned sequentially querying the storage data corresponding to each target index is querying the storage data in each target index one by one, and when the querying of the storage data of one target index ends, the querying of the storage data of the next target index continues. Specifically, the querying order of each target index can be the querying order of the storage data in each target index according to the querying order of each target index carried in the associated query request, or the querying order of the storage data in each target index according to the self-number of each target index, for example, there are three target indexes including index A, index B and index C, and the querying order can be querying index A first, then querying index B, and finally querying index C, or querying index C first and querying index A last. In addition, the querying sequence can be determined according to the preset querying priority of each target index, for example, still taking index A, index B and index C as the target indexes, if the preset querying priority of index B is the highest among the three target indexes, the priority of index C is the second, and the priority of index A is the lowest, then the data in index B is queried first, the data in index C is queried second, and the data in index A is queried last. In other embodiments, other sequential querying manners can also be used, which are not limited herein.
[0037] In the embodiments of the present disclosure, each target index is sequentially queried, and the specific steps of querying each target index can include: querying the storage data corresponding to the target index based on the current query condition of the target index to obtain the initial query result of the target index. The current query condition of the target index is determined based on the initial query condition of the target index, specifically, the current query condition of the first target index is the initial query condition of the target index, and the current query condition of the non-first target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index. After querying the last target index, the initial query result of the last target index is taken as the associated query result.
[0038] Herein, the first target index refers to the target index ranked first in the querying order. The non-first target index refers to each target index ranked after the first target index in the querying order, for example, querying index A, index B and index C in turn, and index A is the first target index, and index B and index C are non-first target indexes. The last target index refers to the target index ranked last in the querying order.
[0039] Step S106: feeding back the associated query result to the client.
[0040] For example, there are two target indexes: index A and index B. After receiving the association query request, the search engine sequentially queries index A and B. Specifically, since index A is the first target index, the initial query condition of index A is taken as the current query condition of index A, and thus the search engine first queries the data in index A according to the initial query condition of index A. After the query, the initial query result of index A is obtained. Since index B is a non-first target index, the current query condition of index B is obtained according to the initial query result of index A and the initial query condition of index B, and then the data in index B is queried according to the current query condition of index B to obtain the initial query result of index B. Since index B is the last target index in the query sequence, the initial query result of index B is taken as the association query result, and the association query result is fed back to the client.
[0041] Specifically, if the association field in index A and index B is the user ID, that is, the user ID is stored in index A and index B, the age data is also stored in index A, and the date and the product ID purchased by the user are also stored in index B, to query which products a certain user purchased on a certain day, the initial query condition of index A can be the age, for example, the age is known to be 45 years old, and then the user ID satisfying the age of 45 years old is found from the data in index A, and then the data query is performed in index B by combining the user ID that has been queried; the initial query condition of index B is the date, for example, July 29, 2022. In order to find the data in index B that satisfies both the query condition of index A and the query condition of index B, that is, to perform the association query on index A and index B, the current query condition of index B needs to include the query result of index A and the initial query condition of index B, that is, the current query condition of index B is July 29, 2022, and the user ID, so that the product ID purchased by the user in index B on July 29, 2022 is found.
[0042] Since the search engine can directly perform the association query on the plurality of target indexes, it is not necessary to use other programs to perform the association operation on the query result of the search engine, thereby improving the data query efficiency and reducing the amount of query data.
[0043] In some possible embodiments, the initial query result of the first target index includes the data in the storage data corresponding to the first target index that satisfies the initial query condition of the first target index. The current query condition of the non-first target index is a combination of the initial query condition of the target index and the initial query result of the previous target index. The initial query result of the non-first target index includes the data in the storage data corresponding to the non-first target index that satisfies both the initial query condition of the non-first target index and the initial query result of the previous target index.
[0044] Still taking the two target indexes: index A and index B as an example, the initial query condition of index A is the current query condition of index A, and the current query condition of index B is the combination of the initial query result of index A and the initial query condition of index B after querying the data in index A. Then, the query result obtained by querying the data in index B with the current query condition is the data in index B that meets both the initial query result of index A and the initial query condition of index B. Thus, the data in the index that meets all the query conditions can be directly obtained after the associated retrieval, without the need for additional processing of the query result, thereby improving the query efficiency.
[0045] Referring to Figure 2 , Figure 2 is a flowchart of step S104 in another embodiment of the present application. Specifically, step 104 can include the following sub-steps, including:
[0046] Step S201: taking one of the target indexes that has not been queried as a to-be-queried index.
[0047] Among them, the target index that has not been queried can be selected as the to-be-queried index in the query order mentioned above.
[0048] Step S202: querying the storage data corresponding to the to-be-queried index based on the current query condition of the to-be-queried index to obtain the initial query result of the to-be-queried index.
[0049] Specifically, if the to-be-queried index is the first target index, its current query condition is the initial query condition of the to-be-queried index; if the to-be-queried index is not the first target index, its current query condition is obtained based on the initial query condition of the to-be-queried index and the initial query result of the previous target index. The storage data that meets the current query condition of the to-be-queried index is found from the storage data corresponding to the to-be-queried index to obtain the initial query result of the to-be-queried index.
[0050] Step S203: if there is storage data that meets the current query condition in the initial query result of the to-be-queried index, and the to-be-queried index is not the last target index, then the step of taking one of the target indexes that has not been queried as the to-be-queried index and the subsequent steps are executed again.
[0051] That is, if there is storage data that meets the current query condition in the initial query result of the to-be-queried index, and the to-be-queried index is not the last target index, then return to step S201 and repeat the execution of the steps shown in Figure 2
[0052] Step S204: If there is no storage data satisfying the current query condition in the initial query result of the index to be queried, or if there is storage data satisfying the current query condition in the initial query result of the index to be queried and the index to be queried is the last target index, the initial query result of the index to be queried is taken as the correlation query result.
[0053] Specifically, still taking two target indexes: index A and index B as an example, index A is queried first, index A is taken as the index to be queried first, and the initial query condition of index A is taken as the current query condition to query the data in index A to obtain the initial query result of index A. When the data in index A is queried using the initial query condition of index A, if no result satisfying the initial query condition is found in index A, the corresponding initial query result is empty; if a result satisfying the initial query condition is found, it is said that there is data satisfying the current query condition of index A in the initial query result of index A. If there is data satisfying the current query condition of index A in the initial query result of index A, the query is continued: index B is taken as the index to be queried, and the combination of the initial query result of index A and the initial query condition of index B is taken as the current query condition of index B to query the data in index B to obtain the initial query result of index B. Since index B is the last index to be queried, if there is data satisfying the current query condition of index B in the initial query result of index B at this time, the initial query result of index B is taken as the correlation query result and fed back to the client; if there is no data satisfying the current query condition of index B in the initial query result of index B, it is considered that there is no data in index B satisfying both the initial query condition of index A and the initial query condition of index B, the correlation query ends, and an empty result is output; or, the client is fed back that no desired result is queried.
[0054] In some possible embodiments, the execution subject of the data query method is a distributed search engine, and the storage data is stored in a distributed manner, i.e., the storage data corresponding to each target index is stored in a plurality of shards. Therefore, for the query step of each target index in the above step S104 or the above step S202, i.e., for each target index, the storage data corresponding to the target index is queried based on the current query condition of the target index to obtain the initial query result of the target index, including: the shards of the target index are queried respectively based on the shard query condition of each shard of the target index to obtain the shard query result of each shard corresponding to the target index, and the initial query result of the target index is obtained based on the shard query result of each shard corresponding to the target index. Specifically, the initial query result of the target index includes the shard query result of each shard corresponding to the target index, i.e., the shard query result of each shard of the target index is combined as the initial query result of the target index. Wherein, the shard query condition of each shard of the target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index, for example, the shard query condition of each shard of the target index is a combination of the initial query condition of the target index and the initial query result of the previous target index.
[0055] In some specific embodiments, in order to improve the query efficiency, the query steps of each shard of the same target index can be performed in parallel. That is, each shard of the target index is queried in parallel based on the shard query condition of each shard of the target index to obtain the shard query result of each shard corresponding to the target index.
[0056] In still some specific embodiments, there is an associated field between the at least two target indexes, and the storage data corresponding to the same associated field in the storage data corresponding to the at least two target indexes is stored in the shards with the same serial number. In order to consider reducing the query data amount, the shard query condition of each shard is a combination of the initial query result of the target index to which the shard belongs and the shard query result of the shard with the same serial number in the previous target index (the previous target index of the target index to which the shard belongs). In addition, the number of shards of the above target index can be the same. In addition, the routing value of the storage data corresponding to the associated field in the target index can be set as the value of the associated field, so that the associated field is stored in the shards with the same serial number in different indexes, so that the data association query operation does not need to be performed across shards, and the query efficiency can be further improved.
[0057] Specifically, the index A and the index B can be divided into three shards, the data in the index A and the index B is respectively stored in the three shards, and the routing value of the associated field of the index A and the index B is set as the value of the associated field. Since the values of the associated fields are the same, the routing values are also the same, and thus the associated field can be stored in the same number shards in the two indexes. For example, the ID value of a user is 101, and the routing value is also 101, and both are stored in the third shard of the two indexes.
[0058] The above method will be further illustrated below. Figure 3 For further illustration, the index A and the index B are divided into N+1 shards, and the shard numbers are 0 to N. After receiving the associated query request, the search engine first performs parallel data query on each shard of the index A according to the initial query request of the index A to obtain the shard query result corresponding to each shard of the index A. When querying the index B, parallel query is also performed on each shard of the index B according to the current query condition of the index B to obtain the shard query result of the index B. The current query condition of each shard of the index B is the combination of the shard query result of the same number shard of the index A and the initial query condition of the index B. For example, the current query condition of the first shard of the index B is the combination of the shard query result of the first shard of the index A and the initial query condition of the index B. After obtaining the shard query result of the index B, the shard query results of each shard of the index B are combined to obtain the initial query result of the index B, and the initial query result of the index B is fed back to the client as the associated query result.
[0059] In the embodiment, the data of the target index is stored in multiple different shards, which reduces the pressure of data query and storage, and parallel query of each shard improves the query efficiency.
[0060] In some possible embodiments, the query manner of the at least two target indexes is rolling query; that is, the method of the embodiment performs the above step S104 multiple times. Each time the above step S104 is executed, the query of each target index is performed on part of the stored data of each target index, and the associated query result obtained each time the above step S104 is executed is a rolling associated query result. After obtaining the rolling associated query result each time the rolling query is performed, the method of the embodiment further includes: in response to the current rolling query being a non-first rolling query, combining the current rolling associated query result with the associated query result of the last rolling query, and updating the combined result as the current rolling associated query result; and the above step S108 includes: in response to the current rolling associated query result meeting the feedback requirement, feeding back the current rolling associated query result to the client.
[0061] It can be understood that if the stored data of the target index is stored in multiple shards, each time the above step S104 is executed in a part of the shards of the target index, or part of the stored data is queried from each shard of the target index respectively. The above feedback requirement can be set according to user needs, for example, the stored data of each target index can be queried completely, or the data amount in the associated query result of this time of rolling reaches the data amount to be fed back. In a specific application scenario, the associated query request contains the data amount to be fed back, and the feedback requirement is that the data amount in the associated query result of this time of rolling reaches the data amount to be fed back.
[0062] Please continue to refer to Figure 4 After the search engine receives the associated query request, the initial query request of index A is used to perform rolling query on the data in index A. Each time of rolling query can query ten thousand data in the target index, or the data amount queried each time of rolling query can be set according to actual conditions, which is not limited here. After the query operation on ten thousand data in index A is completed, the initial query result of index A is obtained. The initial query result of index A and the initial query condition of index B are used as the current query condition of index B to perform rolling query on the data in index B, which also queries ten thousand data. After the query is completed, the initial query condition of index B is obtained, which is used as the associated query result of this time of rolling query. For the associated query result obtained by this time of rolling query, it is judged whether the feedback requirement is met. If the feedback requirement is not met, the above step of “sequentially querying the stored data corresponding to each target index based on the current query condition of each target index to obtain the initial query result of each target index, and using the initial query result of the last target index as the associated query result” is executed again, that is, the next ten thousand data is queried to obtain the associated query result of the second time of rolling query. The associated query result of the second time of rolling query is combined with the associated query result obtained by the first time of rolling query as the associated query result of the second time of rolling query. If the combined associated query result meets the feedback requirement, the combined associated query result is fed back to the client. If the combined associated query result still does not meet the feedback requirement, the next time of rolling query is continued, and so on, until the associated query result meeting the feedback requirement is obtained.
[0063] Using rolling query can make the total query data amount large enough, and avoid too large data amount each time, thereby improving the performance of data query.
[0064] Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0065] Please refer toFigure 4 and Figure 5 , Figure 4 is an interaction diagram of an embodiment of the data query system 50 of the present application, Figure 5 is a structural diagram of an embodiment of the data query system 50 of the present application. The data query system 50 comprises a coordination node 501 and a plurality of data nodes 502. It can be understood that the plurality of data nodes 502 can be one data node or more than two data nodes, Figure 5 only one data node is shown. The coordination node 501 is configured to receive an association query request from a client, and sequentially send current query conditions of each target index to a data node 502 corresponding to each target index, the association query request being configured to request data query on at least two target indexes, and comprising initial query conditions of each target index, the data node 502 corresponding to the target index storing storage data corresponding to the target index;
[0066] The data node 502 corresponding to the target index is configured to query the storage data corresponding to the target index based on the current query condition of the target index, to obtain an initial query result of the target index, and to feed back the initial query result of the target index as an association query result to the coordination node 501 in response to the target index being the last target index of the query, wherein the current query condition of the first target index is the initial query condition of the target index, and the current query condition of the non-first target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index;
[0067] The coordination node 501 is further configured to feed back the association query result to the client.
[0068] It should be noted that the coordination node 501 and the data node 502 are only roles in a certain task, and actually the same node can be used as the coordination node 501 or the data node 502 in different tasks. The coordination node 501 and the data node 502 can be one or a plurality of units integrated in the same device, or a plurality of different devices can be used as the data node 502 or the coordination node 501 to perform the functions of the data node 502 or the coordination node 501. For the case where the index has a plurality of shards, the data node 502 corresponding to the target index can be one or a plurality of data nodes.
[0069] It should be noted that the specific implementation steps of the coordination node 501 and the data node 502 to implement the above functions can be referred to the corresponding description of the method embodiments, which will not be described here.
[0070] Please refer to Figure 6 , Figure 6is a schematic diagram of a framework of an embodiment of the electronic device 60. The electronic device 60 includes a memory 61 and a processor 62 coupled with each other. The processor 62 is configured to execute program instructions stored in the memory 61 to implement the steps in the above-described data query method embodiments. In a specific implementation scenario, the electronic device 60 can include, but is not limited to, a microcomputer, a server, and in addition, the electronic device 60 can also include a notebook computer, a tablet computer, and other mobile devices, which are not limited herein.
[0071] Specifically, the processor 62 is configured to control itself and the memory 61 to implement the steps in the above-described data query method embodiments. The processor 62 can also be referred to as a CPU (Central Processing Unit). The processor 62 can be an integrated circuit chip with processing capability. The processor 62 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0072] Please refer to FIG. 8, Figure 7 is a schematic diagram of a framework of an embodiment of the non-volatile computer readable storage medium 70. The non-volatile computer readable storage medium 70 stores program instructions 701 capable of being executed by a processor, and the program instructions 701 are configured to implement the steps in the above-described data query method embodiments.
[0073] In some embodiments, the apparatus provided by the embodiments of the present disclosure has functions or includes modules that can be used to execute the methods described in the above method embodiments, and the specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
[0074] The above description of various embodiments tends to emphasize the differences between various embodiments, and the same or similar parts can be mutually referred to. For the sake of brevity, it will not be repeated here.
[0075] In several embodiments provided in the present application, it should be understood that the disclosed methods and apparatuses can be implemented in other manners. For example, the division of the apparatus embodiments described above is merely a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0076] In addition, each function unit in the various embodiments of the present application can be integrated into a processing unit, or each unit can exist physically independently, or two or more units can be integrated into one unit. The integrated unit can be implemented in the form of hardware or in the form of a software function unit.
[0077] If the integrated unit is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of the present application, essentially or in part, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (such as a personal computer, a server, or a network device) or a processor (or a plurality of processors) to perform all or part of the steps of the methods in the various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various other media that can store program codes.
Claims
1. A data query method, characterized in that, include: Receive a correlation query request from a client. The correlation query request is used to request data query on at least two target indexes and includes the initial query conditions for each target index. The at least two target indexes are at least two indexes with correlation fields. The stored data corresponding to each target index is queried sequentially based on the current query conditions of each target index to obtain the initial query results of each target index. The initial query result of the last target index is used as the associated query result. The current query condition of the first target index is the initial query condition of the target index, and the current query condition of the non-first target index is obtained based on the initial query condition of the target index and the initial query result of the previous target index. The results of the related query are then fed back to the client.
2. The method according to claim 1, characterized in that, The current query condition for a non-first target index is a combination of the initial query condition of the target index and the initial query result of the previous target index; The initial query result of the first target index includes data in the stored data corresponding to the first target index that satisfies the initial query conditions of the first target index; The initial query result for a non-first target index includes data in the stored data corresponding to the non-first target index that both satisfies the initial query conditions of the non-first target index and matches the initial query result corresponding to the previous target index.
3. The method according to claim 1, characterized in that, The step of sequentially querying the stored data corresponding to each target index based on the current query conditions of each target index to obtain the initial query results of each target index, and using the initial query result of the last target index as the associated query result, includes: Use one of the target indexes that has not yet been queried as the index to be queried; Based on the current query conditions of the index to be queried, the stored data corresponding to the index to be queried is queried to obtain the initial query results of the index to be queried. If the initial query results of the index to be queried contain stored data that meets the current query conditions, and the index to be queried is not the last target index, then the steps of taking one of the currently unqueried target indexes as the index to be queried and subsequent steps are executed again. If the initial query result of the index to be queried does not contain stored data that satisfies the current query condition, or if the initial query result of the index to be queried contains stored data that satisfies the current query condition and the index to be queried is the last target index, then the initial query result of the index to be queried will be used as the associated query result.
4. The method according to claim 1, characterized in that, The storage data corresponding to each target index is stored in several shards; for each target index, the storage data corresponding to the target index is queried based on the current query conditions of the target index to obtain the initial query results of the target index, including: Using the current query conditions of the target index, queries are performed on each of the shards corresponding to the target index to obtain the shard query results of each of the shards corresponding to the target index. The initial query results of the target index include the shard query results of each of the shards corresponding to the target index.
5. The method according to claim 4, characterized in that, The storage data corresponding to the same associated fields in the storage data of the at least two target indexes are stored on the shards with the same sequence number; The step of using the current query conditions of the target index to perform queries on each of the shards corresponding to the target index, and obtaining the shard query results for each of the shards corresponding to the target index, includes: Using the sharding query conditions of each shard of the target index, queries are performed on each shard corresponding to the target index to obtain the sharding query results of each shard corresponding to the target index. The sharding query conditions of the shard are a combination of the initial query conditions of the target index to which the shard belongs and the sharding query results of the shard with the same sequence number in the previous target index.
6. The method according to claim 5, characterized in that, All the target indexes mentioned above have the same number of shards; The routing value of the stored data corresponding to the associated field in the target index is the value of the associated field.
7. The method according to claim 4, characterized in that, The query steps for each of the shards of the same target index are executed in parallel.
8. The method according to claim 1, characterized in that, The query method for the at least two target indexes is a rolling query; each time the step of sequentially querying the stored data corresponding to each target index based on the current query conditions of each target index is executed, the initial query results of each target index are obtained, and the initial query result of the last target index is used as the associated query result, a rolling associated query result is obtained; After each scroll query yields a scroll of related query results, it also includes: Since this scrolling query is not the first scrolling query, the results of the current scrolling related queries are merged with the results of the previous scrolling related queries, and the merged results are updated as the results of the current scrolling related queries. The step of returning the associated query results to the client includes: If the results of the current scrolling related queries meet the feedback requirements, the results of the current scrolling related queries will be fed back to the client.
9. The method according to claim 8, characterized in that, The related query request includes the amount of data that needs to be fed back; the feedback requirement is that the amount of data in the related query results of this scrolling reaches the amount of data that needs to be fed back.
10. An electronic device, characterized in that, The method includes a memory and a processor coupled to each other, the processor being configured to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 9.
11. A data query system, characterized in that, It includes a coordinating node and several data nodes; The coordination node is used to receive association query requests from clients. The association query requests are used to request data queries on at least two target indexes, and include the initial query conditions of each target index. The current query conditions of each target index are sent to the data nodes corresponding to each target index in sequence. The data nodes corresponding to the target indexes store the stored data corresponding to the target indexes. The at least two target indexes are at least two indexes with associated fields. The data node corresponding to the target index is used to query the stored data corresponding to the target index based on the current query conditions of the target index, obtain the initial query result of the target index, and respond to the target index being the last queried target index, use the initial query result of the last queried target index as the associated query result and feed it back to the coordinating node. The current query conditions of the first target index are the initial query conditions of the target index, and the current query conditions of non-first target indexes are obtained based on the initial query conditions of the target index and the initial query result of the previous target index. The coordination node is also used to return the associated query results to the client.
12. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the method described in any one of claims 1 to 9.
Citation Information
Patent Citations
Graph database query method, index creation method and related equipment
CN114741570A
Recommending queries when searching against keywords
US20090299991A1