Multi-source database retrieval method and device, storage medium and computer device
By automatically constructing structured search statements, the problems of low efficiency and low accuracy caused by manually writing search languages are solved, realizing efficient and accurate information retrieval from multi-source databases, and is applicable to various database types.
Patent Information
- Application Number
- CN202311070511.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-08-24
AI Technical Summary
In existing technologies, manually written retrieval languages are inefficient and lack accuracy when retrieving information from multi-source databases, and are limited by the varying skill levels of staff.
By receiving retrieval requests from clients, the system determines the standard and retrieval field information from multiple source databases, automatically constructs structured retrieval statements, and utilizes a persistence layer framework and the ODataApi module for information retrieval, masking database differences and making it suitable for various database types.
It improves the efficiency and accuracy of information retrieval in multi-source databases, realizes synchronous information retrieval across databases and tables, is applicable to various database types, and eliminates the need for manual writing of search statements.
Smart Images

Figure CN117149871B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology, and in particular to a multi-source database retrieval method, apparatus, storage medium, and computer equipment. Background Technology
[0002] Various databases provide abundant knowledge and information resources for the efficient sharing of knowledge resources across society. Faced with massive amounts of literature data, databases are used for the storage and retrieval of massive amounts of data.
[0003] Currently, information retrieval in databases is typically done by manually writing search languages. However, this method requires different search languages for different databases, resulting in low efficiency. Furthermore, the varying skill levels of staff can lead to errors in the search language, further reducing the accuracy of information retrieval across different databases. Summary of the Invention
[0004] This invention provides a multi-source database retrieval method, apparatus, storage medium, and computer equipment, which mainly improves the retrieval efficiency and accuracy of information in multi-source databases.
[0005] According to a first aspect of the present invention, a multi-source database retrieval method is provided, comprising:
[0006] Receive a search request sent by a client, wherein the search request carries a search type identifier and search condition information;
[0007] Determine the standard field information in the multi-source database corresponding to the search type identifier, and determine the search field information in the search condition information;
[0008] Based on the standard field information and the search field information, the valid field information is determined;
[0009] Based on the effective field information, construct the structured search statement corresponding to the multi-source database;
[0010] Based on the structured search statement, information is retrieved from the multi-source database to obtain search results.
[0011] Optionally, determining the valid field information based on the standard field information and the search field information includes:
[0012] Determine the standard semantic information vector corresponding to the standard field information, and determine the retrieval semantic information vector corresponding to the retrieval field information;
[0013] Based on the standard semantic information vector and the retrieval semantic information vector, calculate the similarity between the standard field information and the retrieval field information;
[0014] A target similarity greater than a preset threshold is determined from the similarity, and the standard field information corresponding to the target similarity is determined as the valid field information.
[0015] Optionally, constructing the structured search statement corresponding to the multi-source database based on the valid field information includes:
[0016] Determine the preset search statement construction rules corresponding to the multi-source database;
[0017] The effective field information is concatenated using the preset search statement construction rules to obtain the structured search statement corresponding to the multi-source database.
[0018] Optionally, the step of retrieving information from the multi-source database based on the structured search statement to obtain search results includes:
[0019] Configure the driver class name value in the configuration file corresponding to the multi-source database;
[0020] Based on the driver class name value, determine the driver corresponding to the multi-source database;
[0021] Based on the structured search statement, the driver program performs information retrieval in the multi-source database to obtain search results.
[0022] Optionally, before performing information retrieval in the multi-source database based on the structured search statement using the driver to obtain search results, the method further includes:
[0023] Determine the connection information corresponding to the multi-source database;
[0024] Log in to the multi-source database based on the connection information.
[0025] Optionally, the step of retrieving information from the multi-source database based on the structured search statement to obtain search results includes:
[0026] The general retrieval method corresponding to the multi-source database is encapsulated to obtain the encapsulated retrieval method, and the preset call identifier corresponding to the encapsulated retrieval method is determined.
[0027] Determine the preset functional call interface corresponding to the multi-source database, and use the preset call identifier to call the encapsulated retrieval method in the preset functional call interface;
[0028] Based on the encapsulated retrieval method and the structured retrieval statement, information retrieval is performed in the multi-source database to obtain retrieval results.
[0029] Optionally, after obtaining search results by performing information retrieval in the multi-source database based on the structured search statement, the method further includes:
[0030] Determine whether lazy-loaded fields exist in the search results;
[0031] If the lazy-loaded field exists in the search results, then the lazy-loaded field will be deleted from the search results to obtain a simplified search result.
[0032] According to a second aspect of the present invention, a multi-source database retrieval apparatus is provided, comprising:
[0033] The receiving unit is used to receive a search request sent by the client, wherein the search request carries a search type identifier and search condition information;
[0034] The first determining unit is used to determine the standard field information in the multi-source database corresponding to the search type identifier, and to determine the search field information in the search condition information;
[0035] The second determining unit is used to determine valid field information based on the standard field information and the search field information;
[0036] The construction unit is used to construct a structured retrieval statement corresponding to the multi-source database based on the effective field information.
[0037] The retrieval unit is used to perform information retrieval in the multi-source database based on the structured retrieval statement and obtain retrieval results.
[0038] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described multi-source database retrieval method.
[0039] According to a fourth aspect of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described multi-source database retrieval method.
[0040] According to the present invention, a multi-source database retrieval method, apparatus, storage medium, and computer device, compared with the current method of manually writing retrieval languages to perform information retrieval in databases, the present invention receives a retrieval request sent by a client, wherein the retrieval request carries a retrieval type identifier and retrieval condition information; determines standard field information in the multi-source database corresponding to the retrieval type identifier, and determines retrieval field information in the retrieval condition information; simultaneously, based on the standard field information and the retrieval field information, determines valid field information; then, based on the valid field information, constructs a structured retrieval statement corresponding to the multi-source database; finally, based on the structured retrieval statement, performs information retrieval in the multi-source database to obtain retrieval results. Therefore, by using the standard field information and search field information in the search condition information of the multi-source database corresponding to the search type identifier, the effective field information is determined, and the structured search statement corresponding to the multi-source database is automatically constructed based on the effective field information. Finally, information is retrieved in the multi-source database based on the structured search statement. Thus, by automatically constructing structured search statements corresponding to different data sources through effective fields, and by using the automatically constructed different structured search statements to retrieve information in the corresponding data sources, the efficiency and accuracy of information retrieval can be improved. At the same time, by constructing structured search statements corresponding to different data sources, synchronous information retrieval in different data sources can be achieved. Attached Figure Description
[0041] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0042] Figure 1 A flowchart of a multi-source database retrieval method provided by an embodiment of the present invention is shown;
[0043] Figure 2 A schematic diagram illustrating the workflow of a persistence layer framework provided in an embodiment of the present invention is shown.
[0044] Figure 3 A schematic diagram of the retrieval method supported by an embodiment of the present invention is shown;
[0045] Figure 4 This invention provides a flowchart of another multi-source database retrieval method according to an embodiment of the invention.
[0046] Figure 5 This diagram illustrates the structure of a multi-source database retrieval device according to an embodiment of the present invention.
[0047] Figure 6This invention provides a schematic diagram of the structure of another multi-source database retrieval device according to an embodiment of the invention.
[0048] Figure 7 A schematic diagram of the physical structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0049] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the present application can be combined with each other.
[0050] Currently, the method of retrieving information from databases by manually writing search languages results in low efficiency. At the same time, due to the varying technical skills of staff, errors may occur in the search language, leading to low accuracy in information retrieval across different databases.
[0051] To address the aforementioned problems, embodiments of the present invention provide a multi-source database retrieval method, such as... Figure 1 As shown, the method includes:
[0052] 101. Receive a search request sent by the client, wherein the search request carries a search type identifier and search condition information.
[0053] The search types include patents, papers, abstracts, etc.; the search type identifier is an icon or character identifier set according to actual needs. As long as the search type identifier can uniquely identify the search type, the embodiments of the present invention do not specifically limit the form of the search type identifier.
[0054] In this embodiment of the invention, the user enters search criteria in the client's search box and selects the search type, thus triggering a search instruction. After the search instruction is triggered, a search request sent by the client is received. This embodiment of the invention utilizes a persistence layer framework to retrieve information from multiple source databases. This persistence layer framework can meet cross-platform requirements. It supports domestic platforms and is compatible with mainstream domestic chips and operating systems. Compatible chips include Loongson, Zhaoxin, Hygon, Phytium, Shenwei, Kunpeng, and Kylin chips, and compatible operating systems include NeoKylin, GalaxyKylin, Zhongke Fangde, and Tongxin. Simultaneously, this persistence layer framework supports multiple source databases, including domestic and non-domestic databases. This invention provides support for various data sources, including KBase (Tsinghua Tongfang Full-Text Database Management System), MySQL (relational database), SQLite (an open-source, lightweight, embedded relational database), and DM. This persistence layer framework supports various middleware, including domestic and non-domestic middleware. In addition to being compatible with Tomcat (an open-source Java Servlet container), this invention is also compatible with mainstream domestic middleware, including TongWeb (an application server product compliant with J2EE specifications) and Kingdee Middleware, to support projects with different deployment requirements.
[0055] like Figure 2 As shown, the persistence layer framework in this embodiment of the invention includes three modules: DataClient module (information retrieval module), DataContext module (statement construction module), and ODataApi module (request receiving module).
[0056] In this embodiment of the invention, the ODataApi module constructs an OData (Open Data Protocol) model based on the DC metadata specification (Dublin metadata specification), supporting multi-table retrieval in multi-source databases. The ODataApi module first determines the domain (retrieval type), which includes: literature, journals, dissertations, conferences, newspapers, yearbooks, patents, standards, achievements, etc. According to the DC metadata specification, different OData models correspond to different domains. The function of the OData model is to store various attribute information in data tables of different domains, and different retrieval type identifiers correspond to different OData models. Fifteen core elements are identified: Title, Date, Creator, Subject, Publisher, Type, Description, Contributor, Format, Source, Rights, Identifier, Language, Relation, and Coverage.
[0057] Furthermore, the data tables in the multi-source database are divided according to domain, and the attribute information of the data tables in the multi-source database is constructed as follows: database field name (Mapping), the name of the database field after mapping according to the DC specification (Name), the search expression (Expression), whether it is lazy-loaded (Lazy), the formatting type (Format), and the database information of the table, etc. Among them, fields with the same meaning but different names in different data tables are uniformly mapped in the OData model. For example, newspaper name, article title, and subtitle are all mapped to Title, thereby supporting unified retrieval of different fields in multiple tables.
[0058] Furthermore, upon receiving a search request, the ODataApi module loads the corresponding OData model based on the search type identifier carried in the search request. This allows it to retrieve standard field information from the multi-source databases associated with that search type, including table name, field name, field type, and field attributes. The module then parses the search criteria; if the search field information in the criteria can be mapped to a field in the OData model, it is considered valid. The ODataApi module also enables the construction of structured search statements and can construct a database connection entity based on configured database information (login information, such as username and password) to facilitate successful database login.
[0059] Furthermore, the retrieved field information and standard field information are passed to the DataContext module. The DataContext module can construct ORM (Object-Relational Mapping) entities. The DataContext module is a persistence layer non-relational framework that supports mapping and follows the JPA specification (JPA is a Java Application Programming Interface specification that describes the management of relational data in Java applications, acting as a bridge between object-oriented domain models and relational database systems). The DataContext module parses the javax.persistence tags in the metadata of the entity classes corresponding to the retrieved field information and the multi-source database tables, obtains the valid field information corresponding to the javax.persistence tags on the entity classes, and concatenates the valid field information with the current multi-source database retrieval dialect to obtain a structured retrieval statement. The DataContext module can also construct a database connection entity based on the configured database information (login information, such as username, password, etc.) to ensure successful database login.
[0060] No manual writing of any search statements is required; any developer without SQL syntax knowledge can perform database query operations.
[0061] Furthermore, after constructing the structured search statement, the DataClient module of this invention is called. The DataClient module encapsulates common database operation methods on top of JDBC (Java Database Connect), providing services for multiple data sources. Each type of database has its own unique driverClassName value. By modifying or overriding the driverClassName value in the data source information of the DataClient module configuration file, the corresponding driver is matched based on this value. Finally, the retrieval of dynamic data sources is achieved based on the driver and the structured search statement. Therefore, the method of retrieving information from multiple source databases using the persistence layer framework provided by this invention does not require manually writing any search statements. Any developer without SQL syntax knowledge can complete database query operations, thereby improving the efficiency and accuracy of information retrieval in multiple source databases. It also enables simultaneous information retrieval in multiple source databases, meaning the persistence layer framework provided by this invention is applicable to various databases, enabling cross-database and cross-table retrieval, and has a wider range of applications. Figure 3 As shown, a retrieval method supported by an embodiment of the present invention is provided.
[0062] 102. Determine the standard field information in the multi-source database corresponding to the search type identifier, and determine the search field information in the search condition information.
[0063] Among them, the multi-source database refers to the data source from which the user needs to retrieve information. The standard field information refers to the attribute information of each data table in the multi-source database, including: data table name, field name, field type, field attribute, etc. The retrieval field information refers to the retrieval field obtained from the retrieval conditions entered by the user.
[0064] In this embodiment of the invention, if the search type identifier is a patent type search identifier, then the multi-source database corresponding to the patent type is determined, and each data table is determined in the multi-source database corresponding to the patent type, along with the attribute information (standard field information) corresponding to each data table. Simultaneously, a search field, such as "Haiguang," is determined in the search conditions. Then, based on the search field and the standard field information, valid field information is determined, and a structured search statement corresponding to the multi-source database is automatically constructed based on the valid field information. Finally, information retrieval is performed in the corresponding database using different structured search statements. This automatic construction of structured search statements using valid field information, and the use of these automatically constructed structured search statements for information retrieval, improves the efficiency and accuracy of information retrieval in the multi-source database. Furthermore, by constructing structured search statements corresponding to different data sources, the need for simultaneous information retrieval from different data sources can be met, further improving the efficiency of information retrieval.
[0065] 103. Determine the valid field information based on standard field information and retrieval field information.
[0066] In this embodiment of the invention, after receiving a search request from a client, the request includes a search type identifier and search condition information. Based on the search type identifier, the corresponding data table attribute information is loaded and stored in memory for easy subsequent retrieval. After successful loading, the search condition information is parsed according to the prescribed OData standard. If a search field in the search condition information can be mapped to a field in memory, it is considered a valid field. Then, based on the valid field information and search rules, a structured search statement is automatically constructed. Finally, data is retrieved from multiple source databases using the structured search statement. This information retrieval method is applicable to various types of databases and also improves the efficiency and accuracy of information retrieval.
[0067] 104. Based on valid field information, construct structured search statements corresponding to multi-source databases.
[0068] 105. Based on structured search statements, information is retrieved from multiple source databases to obtain search results.
[0069] In this embodiment of the invention, after obtaining valid fields, the valid fields of each part are concatenated into a complete structured search statement (SQL) according to preset rules. This enables the construction of structured search statements corresponding to different data sources. Ultimately, the structured search statements corresponding to different data sources are used to perform information retrieval in the corresponding data sources. Based on this, step 105 specifically includes: encapsulating the general search method corresponding to the multi-source database to obtain the encapsulated search method, and determining the preset call identifier corresponding to the encapsulated search method; determining the preset functional call interface corresponding to the multi-source database, and calling the encapsulated search method in the preset functional call interface using the preset call identifier; and performing information retrieval in the multi-source database based on the encapsulated search method and the structured search statement to obtain search results.
[0070] Specifically, the DataClient module is a basic database access module that encapsulates commonly used general database retrieval methods on top of JDBC. It provides the DataContext and ODataApi modules with fundamental methods for database operations, supporting operation on domestic platforms, domestic and non-domestic middleware, and supporting multiple databases. When performing information retrieval, a parent class is first defined, and a class is created for each type of database. These classes inherit from DataClient using the Java keyword `extends`. The differences in database connections across different middlewares are handled in DataClient and its subclasses to shield the caller from environmental differences. For example, in the special environment of a domestic platform, all executable SO files require signature verification. Only after successful verification are they loaded into memory. Due to this special nature, when multiple web applications requiring database connections are deployed on the same middleware, the database SO files cannot be shared by multiple applications. Therefore, a configuration item is added to the configuration file to indicate whether the current environment is a dedicated server for a domestic platform. If so, before loading the database driver, the application's system properties are set so that each application loads its own SO file. The settings are as follows:
[0071] System.setProperty("jna.debug_load","true");
[0072] System.setProperty("jna.library.path",path);
[0073] System.setProperty("jna.boot.library.path",path);
[0074] Furthermore, database configuration information is added to the configuration files corresponding to the multi-source databases. Each type of database has its own unique driverClassName value (driver class name value). By modifying or overriding the driverClassName value of the data source information in the DataClient module configuration file, the corresponding driver is matched based on this value. This enables dynamic loading of matching drivers for databases of different data types. Finally, information retrieval is performed in the multi-source databases based on the matched driver and structured search statements. During the retrieval process, the preset call identifier corresponding to the encapsulated retrieval method can be determined. The preset call identifier is set according to actual needs and can be an identifier such as punctuation marks, like ":". At the same time, the preset functional call interface corresponding to the multi-source database is determined. The preset functional call interface is used to implement Lambda expression-based queries. With the underlying support provided by Java 8, the retrieval method is called using the preset call identifier. Then, based on the called retrieval method and structured search statements, information retrieval is performed in the multi-source databases to obtain the retrieval results. This embodiment of the invention calls the encapsulated retrieval method by method reference, which avoids the low efficiency and errors caused by manually writing the calling method code. The method call process is as follows:
[0075] @FunctionalInterface
[0076] public interface Field<T,R> extends Function<T,R> Serializable
[0077] Furthermore, the search results returned by the search methods provided by the DataClient module are mapped to entities, and the Class parameter of the entity is added to the search methods, which by default return a List. <map>If the input parameter is not empty, it is mapped according to the input Class, and the returned result type is List<entity>, thus obtaining the search results. Therefore, this embodiment of the invention does not require writing any SQL statements; it only requires inputting search conditions or parameter information into the information retrieval system and connecting them with conjunctions to complete the information retrieval operation in multi-source databases, improving the efficiency and accuracy of information retrieval in multi-source databases. For example, the retrieval process is as follows:
[0078] Query q=dc.query(Article.class)
[0079] .like(Article::getTitle,"Computer")
[0080] .and()
[0081] .like(Article::getDescription,"Technology")
[0082] .or()
[0083] .eq(Article::getPubDate,"2022-12-28")
[0084] .not()
[0085] .eq(Article::getId,10);
[0086] According to the multi-source database retrieval method provided by the present invention, compared with the current method of manually writing retrieval languages to perform information retrieval in databases, the present invention receives a retrieval request sent by a client, wherein the retrieval request carries a retrieval type identifier and retrieval condition information; determines standard field information in the multi-source database corresponding to the retrieval type identifier, and determines retrieval field information in the retrieval condition information; simultaneously, based on the standard field information and the retrieval field information, determines valid field information; then, based on the valid field information, constructs a structured retrieval statement corresponding to the multi-source database; finally, based on the structured retrieval statement, performs information retrieval in the multi-source database to obtain retrieval results. Therefore, by using the standard field information and search field information in the search condition information of the multi-source database corresponding to the search type identifier, the effective field information is determined, and the structured search statement corresponding to the multi-source database is automatically constructed based on the effective field information. Finally, information is retrieved in the multi-source database based on the structured search statement. Thus, by automatically constructing structured search statements corresponding to different data sources through effective fields, and by using the automatically constructed different structured search statements to retrieve information in the corresponding data sources, the efficiency and accuracy of information retrieval can be improved. At the same time, by constructing structured search statements corresponding to different data sources, synchronous information retrieval in different data sources can be achieved.
[0087] Furthermore, to better illustrate the above-described process of searching in a multi-source database, as a refinement and extension of the above embodiments, this invention provides another multi-source database retrieval method, such as... Figure 4 As shown, the method includes:
[0088] 201. Receive a search request sent by the client, wherein the search request carries a search type identifier and search condition information.
[0089] 202. Determine the standard field information in the multi-source database corresponding to the search type identifier, and determine the search field information in the search condition information.
[0090] Specifically, upon receiving a retrieval request from a client, the system matches the corresponding multi-source databases based on the retrieval type identifier carried in the request. It then determines the standard field information, such as table names, field names, and field values, within these databases. Simultaneously, it parses the retrieval condition information to obtain the retrieval field information. Finally, based on the standard field information and the retrieval field information, it determines the valid field information. By identifying the valid field information and constructing a structured retrieval statement corresponding to the multi-source database, the accuracy of the structured retrieval statement can be improved, thereby enhancing the accuracy of information retrieval.
[0091] 203. Based on standard field information and retrieval field information, determine the valid field information.
[0092] In this embodiment of the invention, after determining the standard field information and the valid field information, in order to improve the accuracy of constructing structured search statements, it is also necessary to determine the valid field information based on the standard field information and the search field information. Based on this, step 203 specifically includes: determining the standard semantic information vector corresponding to the standard field information and determining the search semantic information vector corresponding to the search field information; calculating the similarity between the standard field information and the search field information based on the standard semantic information vector and the search semantic information vector; determining a target similarity greater than a preset threshold in the similarity, and determining the standard field information corresponding to the target similarity as the valid field information.
[0093] The preset threshold is set according to actual needs. Specifically, standard field information is input into a preset semantic information extraction model for semantic extraction to obtain a standard semantic information vector corresponding to the standard field information. This semantic information extraction model includes an attention layer and a feedforward neural network layer. The specific method for extracting the standard semantic information vector using the semantic information extraction model is as follows: determine each character contained in the standard field information and the embedding vector corresponding to each character; input the embedding vector into the attention layer for feature extraction to obtain a first feature vector corresponding to each character; add the first feature vector and the embedding vector to obtain a second feature vector corresponding to each character; input the second feature vector into the feedforward neural network layer for feature extraction to obtain the standard semantic information vector corresponding to the standard field information. Similarly, retrieval field information is input into the preset semantic information extraction model for semantic extraction. By following the semantic extraction process of the preset semantic information extraction model, the retrieval semantic information vector corresponding to the retrieval field information can be obtained.
[0094] Furthermore, based on the standard semantic information vector and the retrieval semantic information vector, the cosine similarity between each standard field information and each retrieval field information can be calculated. Then, among each cosine similarity, a target cosine similarity greater than a preset threshold is determined, and the standard field information corresponding to the target cosine similarity is determined as the valid field information. Thus, by extracting the semantic information corresponding to the standard field information and the retrieval field information, and determining the valid fields based on the semantic information, the accuracy of obtaining valid field information can be improved, thereby improving the accuracy of information retrieval.
[0095] 204. Based on valid field information, construct structured search statements corresponding to multiple source databases.
[0096] The structured search statement can be an SQL statement. In this embodiment of the invention, to perform information retrieval in a multi-source database, it is first necessary to construct a structured search statement for information retrieval. Based on this, step 204 specifically includes: determining the preset search statement construction rules corresponding to the multi-source database; and using the preset search statement construction rules to concatenate the valid field information to obtain the structured search statement corresponding to the multi-source database.
[0097] Specifically, different databases correspond to different preset search statement construction rules. These rules include construction dialects, construction formats, statement keywords, and enumeration classes of database fields. It's important to note that, based on the dialect-related classes for each database, common statement keywords and database field information are extracted to establish a unified naming and definition standard. This masks the differences between databases, ensuring that when switching between different types of databases, the caller is unaware of these differences due to the unified naming and definition standard, achieving "zero" business adjustment and facilitating multi-source database switching. Furthermore, the preset search statement construction rules corresponding to each multi-source database are determined, and the valid field information is concatenated according to these rules to obtain the structured search statement for each multi-source database.
[0098] 205. Configure the driver class name value in the configuration file corresponding to the multi-source database.
[0099] 206. Determine the driver corresponding to the multi-source database based on the driver class name value.
[0100] 207. Based on the structured search statement, use the driver program to perform information retrieval in a multi-source database and obtain the search results.
[0101] In accordance with the embodiments of the present invention, in order to perform information retrieval in a multi-source database, it is first necessary to connect to or log in to the multi-source database. Based on this, the method includes: determining the connection information corresponding to the multi-source database; and logging into the multi-source database based on the connection information.
[0102] The connection information includes: database address, username, and password. Specifically, the database address, login username, and login password for each of the multiple source databases are determined. Then, the user logs into the multiple source databases using this information. Further, database configuration information is added to the configuration files of the multiple source databases. Each type of database has its own unique driver class name value (driverClassName value). By modifying or overriding the driverClassName value in the data source information of the configuration file, the system matches the corresponding driver based on this value. This allows for the dynamic loading of matching drivers for databases of different data types. Finally, using a structured search query, the system retrieves information from the corresponding databases using the matched drivers to obtain the search results.
[0103] Furthermore, in the process of information retrieval in a multi-source database, in order to reduce the system memory usage, it is necessary to simplify the retrieved results. Based on this, the method includes: determining whether there is a lazy-loaded field in the retrieval results; if the lazy-loaded field exists in the retrieval results, then deleting the lazy-loaded field from the retrieval results to obtain simplified retrieval results.
[0104] Specifically, to prevent unnecessary large fields from being retrieved during searches, reduce memory usage, and optimize search efficiency, a "Lazy" tag is defined to mark whether a field is a lazy-loaded field. If a field is marked as a lazy-loaded field, it will not be retrieved by default, and the search results displayed to the user will not include lazy-loaded fields. The definition method is as follows:
[0105] @Lazy
[0106] public Blob getImage(){
[0107] Return image;
[0108] }
[0109] According to another multi-source database retrieval method provided by the present invention, compared with the current method of manually writing retrieval languages to perform information retrieval in databases, the present invention receives a retrieval request sent by a client, wherein the retrieval request carries a retrieval type identifier and retrieval condition information; determines the standard field information in the multi-source database corresponding to the retrieval type identifier, and determines the retrieval field information in the retrieval condition information; simultaneously, based on the standard field information and the retrieval field information, determines the valid field information; then, based on the valid field information, constructs a structured retrieval statement corresponding to the multi-source database; and configures the driver class name value in the configuration file corresponding to the multi-source database; then, based on the driver class name value, determines the driver corresponding to the multi-source database; finally, based on the structured retrieval statement, uses the driver to perform information retrieval in the multi-source database to obtain the retrieval results. Therefore, by using the standard field information and search field information in the search condition information of the multi-source database corresponding to the search type identifier, valid field information is determined. Based on this valid field information, a structured search statement corresponding to the multi-source database is automatically constructed. Finally, information is retrieved from the multi-source database using this structured search statement. This automatic construction of structured search statements improves information retrieval efficiency and accuracy. Furthermore, by constructing structured search statements corresponding to different data sources, synchronous information retrieval across different data sources can be achieved. Additionally, by configuring driver class name values in the configuration files corresponding to the multi-source database and matching the corresponding drivers based on these values, different types of databases can be dynamically loaded with matching drivers, creating different connection objects, thereby further improving information retrieval efficiency.
[0110] Furthermore, as Figure 1 In specific implementation, embodiments of the present invention provide a multi-source database retrieval device, such as... Figure 5 As shown, the device includes: a receiving unit 31, a first determining unit 32, a second determining unit 33, a constructing unit 34, and a retrieving unit 35.
[0111] The receiving unit 31 can be used to receive a search request sent by the client, wherein the search request carries a search type identifier and search condition information.
[0112] The first determining unit 32 can be used to determine the standard field information in the multi-source database corresponding to the search type identifier, and to determine the search field information in the search condition information.
[0113] The second determining unit 33 can be used to determine valid field information based on the standard field information and the search field information.
[0114] The construction unit 34 can be used to construct a structured retrieval statement corresponding to the multi-source database based on the effective field information.
[0115] The retrieval unit 35 can be used to perform information retrieval in the multi-source database based on the structured retrieval statement and obtain retrieval results.
[0116] In specific application scenarios, in order to determine valid field information, such as Figure 6 As shown, the second determining unit 33 includes a first determining module 331 and a calculation module 332.
[0117] The first determining module 331 can be used to determine the standard semantic information vector corresponding to the standard field information, and to determine the retrieval semantic information vector corresponding to the retrieval field information.
[0118] The calculation module 332 can be used to calculate the similarity between the standard field information and the search field information based on the standard semantic information vector and the search semantic information vector.
[0119] The first determining module 331 can be specifically used to determine a target similarity greater than a preset threshold in the similarity, and to determine the standard field information corresponding to the target similarity as the valid field information.
[0120] In specific application scenarios, in order to construct structured retrieval statements corresponding to multi-source databases, the construction unit 34 includes a second determining module 341 and a splicing module 342.
[0121] The second determining module 341 can be used to determine the preset retrieval statement construction rules corresponding to the multi-source database.
[0122] The splicing module 342 can be used to splice the effective field information using the preset search statement construction rules to obtain the structured search statement corresponding to the multi-source database.
[0123] In specific application scenarios, in order to perform information retrieval in a multi-source database, the retrieval unit 35 includes a configuration module 351, a third determination module 352, and a retrieval module 353.
[0124] The configuration module 351 can be used to configure the driver class name value in the configuration file corresponding to the multi-source database.
[0125] The third determining module 352 can be used to determine the driver corresponding to the multi-source database based on the driver class name value.
[0126] The retrieval module 353 can be used to retrieve information from the multi-source database based on the structured retrieval statement and the driver program to obtain retrieval results.
[0127] In specific application scenarios, in order to log in to a multi-source database, the retrieval unit 35 also includes a login module 354.
[0128] The third determining module 352 can be used to determine the connection information corresponding to the multi-source database.
[0129] The login module 354 can be used to log in to the multi-source database based on the connection information.
[0130] In specific application scenarios, in order to perform information retrieval in multi-source databases, the retrieval unit 35 also includes an encapsulation module 355 and a calling module 356.
[0131] The encapsulation module 355 can be used to encapsulate the general retrieval method corresponding to the multi-source database to obtain the encapsulated retrieval method, and determine the preset call identifier corresponding to the encapsulated retrieval method.
[0132] The calling module 356 can be used to determine the preset functional calling interface corresponding to the multi-source database, and use the preset calling identifier to call the encapsulated retrieval method in the preset functional calling interface.
[0133] The retrieval module 353 can also be used to perform information retrieval in the multi-source database based on the encapsulated retrieval method and the structured retrieval statement to obtain retrieval results.
[0134] In specific application scenarios, in order to simplify the search results, the device further includes a deletion unit 36.
[0135] The second determining unit 33 can also be used to determine whether a lazy-loaded field exists in the search results.
[0136] The deletion unit 36 can be used to delete the lazy-loaded field from the search results if the lazy-loaded field exists in the search results, so as to obtain a simplified search result.
[0137] It should be noted that other corresponding descriptions of the functional modules involved in the multi-source database retrieval device provided in this embodiment of the invention can be found in [reference]. Figure 1 The corresponding description of the method shown will not be repeated here.
[0138] Based on the above, Figure 1 Accordingly, this embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the following steps: receiving a retrieval request sent by a client, wherein the retrieval request carries a retrieval type identifier and retrieval condition information; determining standard field information in a multi-source database corresponding to the retrieval type identifier, and determining retrieval field information in the retrieval condition information; determining valid field information based on the standard field information and the retrieval field information; constructing a structured retrieval statement corresponding to the multi-source database based on the valid field information; and performing information retrieval in the multi-source database according to the structured retrieval statement to obtain retrieval results.
[0139] Based on the above, Figure 1 The method shown and as Figure 5 The embodiment of the device shown in the invention also provides a physical structure diagram of a computer device, such as... Figure 7 As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor. Both the memory 42 and the processor 41 are mounted on a bus 43. When the processor 41 executes the program, it performs the following steps: receiving a search request sent by a client, wherein the search request carries a search type identifier and search condition information; determining standard field information in a multi-source database corresponding to the search type identifier, and determining search field information in the search condition information; determining valid field information based on the standard field information and the search field information; constructing a structured search statement corresponding to the multi-source database based on the valid field information; and performing information retrieval in the multi-source database according to the structured search statement to obtain search results.
[0140] The present invention receives a search request from a client, which carries a search type identifier and search condition information. It then determines standard field information in a multi-source database corresponding to the search type identifier and search field information in the search condition information. Simultaneously, based on the standard field information and the search field information, it determines valid field information. Then, based on the valid field information, it constructs a structured search statement corresponding to the multi-source database. Finally, based on the structured search statement, it performs information retrieval in the multi-source database to obtain search results. Thus, by using the standard field information in the multi-source database corresponding to the search type identifier and the search field information in the search condition information, valid field information is determined. A structured search statement corresponding to the multi-source database is automatically constructed based on the valid field information. Finally, information retrieval is performed in the multi-source database based on the structured search statement. This automatically constructs structured search statements corresponding to different data sources using valid fields, and performs information retrieval in the corresponding data sources based on the automatically constructed different structured search statements. By automatically constructing structured search statements, information retrieval efficiency and accuracy can be improved. Furthermore, by constructing structured search statements corresponding to different data sources, synchronous information retrieval across different data sources can be achieved.
[0141] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0142] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / map>
Claims
1. A multi-source database retrieval method, characterized in that, include: Receive a search request sent by a client, wherein the search request carries a search type identifier and search condition information; Determine the standard field information in the multi-source database corresponding to the search type identifier, and determine the search field information in the search condition information; Based on the standard field information and the search field information, valid field information is determined. The method for determining valid field information includes: loading the attribute information of the corresponding data table in the multi-source database according to the search type identifier, and storing the attribute information in memory. The attribute information is the standard field information. If the search field information can find the mapping field in memory, then the search field information is taken as valid field information. Based on the effective field information, construct the structured search statement corresponding to the multi-source database; Based on the structured search statement, information is retrieved from the multi-source database to obtain search results; Specifically, based on the valid field information, constructing the structured search statement corresponding to the multi-source database includes: The structured search statement is obtained by combining the valid field information with the search dialects of multiple source databases.
2. The method according to claim 1, characterized in that, The determination of valid field information based on the standard field information and the search field information includes: Determine the standard semantic information vector corresponding to the standard field information, and determine the retrieval semantic information vector corresponding to the retrieval field information; Based on the standard semantic information vector and the retrieval semantic information vector, calculate the similarity between the standard field information and the retrieval field information; A target similarity greater than a preset threshold is determined from the similarity, and the standard field information corresponding to the target similarity is determined as the valid field information.
3. The method according to claim 1, characterized in that, The step of constructing a structured search statement corresponding to the multi-source database based on the valid field information includes: Determine the preset search statement construction rules corresponding to the multi-source database; The effective field information is concatenated using the preset search statement construction rules to obtain the structured search statement corresponding to the multi-source database.
4. The method according to claim 1, characterized in that, The process of retrieving information from the multi-source database based on the structured search statement to obtain search results includes: Configure the driver class name value in the configuration file corresponding to the multi-source database; Based on the driver class name value, determine the driver corresponding to the multi-source database; Based on the structured search statement, the driver program performs information retrieval in the multi-source database to obtain search results.
5. The method according to claim 4, characterized in that, Before obtaining search results by using the driver program to perform information retrieval in the multi-source database based on the structured search statement, the method further includes: Determine the connection information corresponding to the multi-source database; Log in to the multi-source database based on the connection information.
6. The method according to claim 1, characterized in that, The process of retrieving information from the multi-source database based on the structured search statement to obtain search results includes: The general retrieval method corresponding to the multi-source database is encapsulated to obtain the encapsulated retrieval method, and the preset call identifier corresponding to the encapsulated retrieval method is determined. Determine the preset functional call interface corresponding to the multi-source database, and use the preset call identifier to call the encapsulated retrieval method in the preset functional call interface; Based on the encapsulated retrieval method and the structured retrieval statement, information retrieval is performed in the multi-source database to obtain retrieval results.
7. The method according to claim 1, characterized in that, After obtaining the search results by performing information retrieval in the multi-source database based on the structured search statement, the method further includes: Determine whether lazy-loaded fields exist in the search results; If the lazy-loaded field exists in the search results, then the lazy-loaded field will be deleted from the search results to obtain a simplified search result.
8. A multi-source database retrieval device, characterized in that, include: The receiving unit is used to receive a search request sent by the client, wherein the search request carries a search type identifier and search condition information; The first determining unit is used to determine the standard field information in the multi-source database corresponding to the search type identifier, and to determine the search field information in the search condition information; The second determining unit is used to determine valid field information based on the standard field information and the search field information. The method for determining valid field information includes: loading the attribute information of the corresponding data table in the multi-source database according to the search type identifier, and storing the attribute information in memory. The attribute information is the standard field information. If the search field information can find the mapping field in memory, then the search field information is taken as valid field information. The construction unit is used to construct a structured retrieval statement corresponding to the multi-source database based on the effective field information; wherein, constructing a structured retrieval statement corresponding to the multi-source database based on the effective field information includes: combining the effective field information with the retrieval dialect of the multi-source database to obtain a structured retrieval statement. The retrieval unit is used to perform information retrieval in the multi-source database based on the structured retrieval statement and obtain retrieval results.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data retrieval method and device
CN110866091A
Cross-domain heterogeneous data retrieval system and retrieval method
CN112148938A
Data processing method and device based on public semantic field
CN115544024A
Standard field automatic matching method and device, equipment and storage medium
CN115878756A