Search

CN-121996682-A - Data query method and related device

CN121996682ACN 121996682 ACN121996682 ACN 121996682ACN-121996682-A

Abstract

The application discloses a data query method and a related device, which comprise the steps of receiving query natural sentences sent by a query user, carrying out intention recognition on the query natural sentences to obtain the type of query data and the query condition of the data to be queried, adopting Schema mapping operation to process the type of the data to be queried and the query condition of the data to be queried to obtain the query type and the query condition suitable for database operation, selecting a query mode based on the query type, selecting a database adapter, sending the query condition to the selected database adapter to obtain a query result obtained by the database adapter in a corresponding database according to the query condition suitable for database operation, inputting the query result into a data management layer to carry out data integration to obtain a data integration result, and outputting the data integration result. The application realizes the unified management and output of the data based on adopting a corresponding data query mode for different types of data.

Inventors

  • LIU PENG
  • SUN DANFENG
  • CUI XIUYUAN
  • YAO BIN

Assignees

  • 青岛巨商汇网络科技有限公司

Dates

Publication Date
20260508
Application Date
20251231

Claims (10)

  1. 1. A method of querying data, comprising: Receiving a query natural sentence sent by a query user, and carrying out intention recognition on the query natural sentence to obtain the type of data to be queried and the query condition of the data to be queried; Mapping the type of the data to be queried and the query conditions of the data to be queried by adopting a Schema mapping operation to obtain the query type suitable for database operation and the query conditions suitable for database operation; selecting a query mode based on the query type suitable for database operation, selecting a database adapter based on the query mode, and sending the query condition suitable for database operation to the selected database adapter to obtain a query result obtained by querying the database adapter in a corresponding database according to the query condition suitable for database operation; And inputting the query result into a data management layer for data integration to obtain a data integration result, and outputting the data integration result.
  2. 2. The data query method according to claim 1, wherein the performing intent recognition on the query natural sentence to obtain the type of the data to be queried and the query condition of the data to be queried includes: Performing intention recognition operation on the query natural sentence based on LLM (logical level management), and obtaining a recognition result, wherein the LLM is a large language model constructed in advance; If the identification result only comprises the structuring condition, judging that the query type of the data to be queried is structuring data, and determining the query condition of the queried data based on the identification result; if the identification result only contains semantic search conditions, judging that the query type of the data to be queried is unstructured data, and determining the query conditions of the data to be queried based on the identification result; And if the identification result simultaneously comprises the structural condition and the semantic search condition, judging that the query type of the data to be queried is mixed data, and determining the query condition of the data to be queried based on the identification result.
  3. 3. The data query method of claim 2, wherein the determining the query conditions for the queried data based on the recognition result comprises: If the query type of the data to be queried is determined to be structured data, extracting a target entity and an attribute field for representing the structured data from the identification result, and determining the query condition of the queried data based on the target entity and the attribute field; If the query type of the data to be queried is judged to be unstructured data, extracting text content used for representing the unstructured data from the identification result, and determining the query condition of the queried data based on the text content; and if the query type of the data to be queried is judged to be mixed data, respectively extracting target entities, attribute fields and text contents used for representing the structured data and the unstructured data from the identification result, and determining the query conditions of the queried data based on the target entities, the attribute fields and the text contents.
  4. 4. The data query method according to claim 1, wherein the selecting a query manner based on the query type applicable to the database operation, selecting a database adapter based on the query manner, and sending the query condition applicable to the database operation to the selected database adapter to obtain the query result obtained by querying the database adapter in the corresponding database according to the query condition applicable to the database operation, includes: if the query type suitable for database operation is unstructured data, selecting a vector query mode, and selecting Milvus an adapter and a MySQL adapter based on the vector query mode; Carrying out vectorization operation on query conditions suitable for database operation by adopting a preset embedding model to obtain a query vector; Invoking Milvus an adapter to search the similarity of the query vector in a vector database to obtain a set of vector data; The vector data in the searched set are sequenced from high to low according to the similarity, and vector IDs of the first K vector data with the highest similarity are obtained, wherein the similarity is the similarity between the query vector and the vector data in the vector database; And calling a MySQL adapter to inquire the storage address of unstructured data corresponding to the vector IDs of the first K vector data in a structured database, and obtaining the unstructured data from the storage address.
  5. 5. The data query method according to claim 1, wherein the selecting a query manner based on the query type applicable to the database operation, selecting a database adapter based on the query manner, and sending the query condition applicable to the database operation to the selected database adapter to obtain the query result obtained by querying the database adapter in the corresponding database according to the query condition applicable to the database operation, includes: If the query type suitable for database operation is mixed data, selecting a vector query mode and a data query mode, and selecting Milvus an adapter and a MySQL adapter based on the vector query mode and the data query mode; Carrying out vectorization operation on query conditions related to unstructured data by adopting a preset embedding model to obtain query vectors, and extracting structured query conditions related to structured data; calling a MySQL adapter to query structured data in a structured database based on the structured query conditions; Invoking Milvus an adapter to search the similarity of the query vector in a vector database to obtain a set of vector data; The vector data in the searched set are sequenced from high to low according to the similarity, and vector IDs of the first K vector data with the highest similarity are obtained, wherein the similarity is the similarity between the query vector and the vector data in the vector database; And calling a MySQL adapter to inquire the storage address of unstructured data corresponding to the vector IDs of the first K vector data in a structured database, and obtaining the unstructured data from the storage address.
  6. 6. The data query method according to claim 1, wherein inputting the query result into a data management layer for data integration to obtain a data integration result, and outputting the data integration result, comprises: Integrating the received query results based on a preset result integrator of a data management layer to obtain integrated results; And performing natural language processing on the integration result by adopting LLM, obtaining natural language and outputting the natural language.
  7. 7. A data query device, comprising: the intention recognition module is used for receiving the query natural sentences sent by the query user, and carrying out intention recognition on the query natural sentences to obtain the type of the data to be queried and the query conditions of the data to be queried; The data mapping module is used for mapping the type of the data to be queried and the query conditions of the data to be queried by adopting a Schema mapping operation to obtain the query type suitable for database operation and the query conditions suitable for database operation; the query module is used for selecting a query mode based on the query type suitable for database operation, selecting a database adapter based on the query mode, and sending the query condition suitable for database operation to the selected database adapter to obtain a query result obtained by querying the database adapter in a corresponding database according to the query condition suitable for database operation; And the data integration module is used for inputting the query result into the data management layer for data integration to obtain a data integration result and outputting the data integration result.
  8. 8. A computer program product comprising computer readable instructions which, when run on an electronic device, cause the electronic device to implement the data querying method according to any of claims 1 to 6.
  9. 9. An electronic device comprising at least one processor and a memory coupled to the processor, wherein: the memory is used for storing a computer program; The processor is configured to execute the computer program to enable the electronic device to implement the data query method of any one of claims 1 to 6.
  10. 10. A computer storage medium carrying one or more computer programs which, when executed by an electronic device, enable the electronic device to implement a data querying method as claimed in any one of claims 1 to 6.

Description

Data query method and related device Technical Field The present application relates to the field of data processing technologies, and in particular, to a data query method and a related device. Background With the continuous development of information systems, the data scale is continuously increased, the data sources and storage modes are increasingly diversified, and the demands of users on data inquiry also show a trend of high frequency and complexity. In practical applications, a user typically initiates a query request in a natural language or service statement, and the system needs to parse, convert and execute a corresponding data query operation to return a result meeting the query condition. In the existing data query mode, different query sentences and processing flows are needed to be adopted for different types of query data, so that the problem of low query efficiency easily occurs when the requirement of diversified query is met. Therefore, a method for improving data query efficiency is needed. Disclosure of Invention In view of the above problems, the present application provides a data query method and related apparatus, so as to achieve the purpose of improving the data query efficiency. The specific scheme is as follows: The first aspect of the application provides a data query method, which comprises the steps of receiving a query natural sentence sent by a query user, and carrying out intention recognition on the query natural sentence to obtain the type of data to be queried and the query condition of the data to be queried; mapping the type of the data to be queried and the query conditions of the data to be queried by adopting a Schema mapping operation to obtain the query type suitable for database operation and the query conditions suitable for database operation; selecting a query mode based on a query type suitable for database operation, selecting a database adapter based on the query mode, and sending query conditions suitable for database operation to the selected database adapter to obtain a query result obtained by querying the database adapter in a corresponding database according to the query conditions suitable for database operation; And inputting the query result into a data management layer for data integration to obtain a data integration result, and outputting the data integration result. Optionally, performing intent recognition on the query natural sentence to obtain a type of data to be queried and a query condition of the data to be queried, including: performing intention recognition operation on the query natural sentence based on LLM, so as to obtain a recognition result, wherein LLM is a large language model constructed in advance; If the identification result only contains the structuring condition, judging the query type of the data to be queried as the structuring data, and determining the query condition of the queried data based on the identification result; if the identification result only contains the semantic search condition, judging that the query type of the data to be queried is unstructured data, and determining the query condition of the queried data based on the identification result; If the identification result simultaneously contains the structuring condition and the semantic search condition, judging that the query type of the data to be queried is mixed data, and determining the query condition of the data to be queried based on the identification result. Optionally, determining the query condition of the queried data based on the recognition result includes: If the query type of the data to be queried is determined to be the structured data, extracting a target entity and an attribute field for representing the structured data from the identification result, and determining the query condition of the queried data based on the target entity and the attribute field; If the query type of the data to be queried is judged to be unstructured data, extracting text content used for representing the unstructured data from the identification result, and determining the query condition of the queried data based on the text content; If the query type of the data to be queried is judged to be mixed data, respectively extracting a target entity, an attribute field and text content used for representing the structured data and the unstructured data from the identification result, and determining the query condition of the queried data based on the target entity, the attribute field and the text content. Optionally, selecting a query mode based on a query type applicable to database operation, selecting a database adapter based on the query mode, and sending query conditions applicable to database operation to the selected database adapter to obtain a query result obtained by querying the database adapter in a corresponding database according to the query conditions applicable to database operation, where the method includes: if the query type suitabl