CN112765200A - Data query method and device based on Elasticissearch - Google Patents

Data query method and device based on Elasticissearch Download PDF

Info

Publication number
CN112765200A
CN112765200A CN202110066761.7A CN202110066761A CN112765200A CN 112765200 A CN112765200 A CN 112765200A CN 202110066761 A CN202110066761 A CN 202110066761A CN 112765200 A CN112765200 A CN 112765200A
Authority
CN
China
Prior art keywords
query
sql
data query
aggregation
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110066761.7A
Other languages
Chinese (zh)
Inventor
刘俊佩
付星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Yuexuebang Network Technology Co ltd
Original Assignee
Wuhan Yuexuebang Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Yuexuebang Network Technology Co ltd filed Critical Wuhan Yuexuebang Network Technology Co ltd
Priority to CN202110066761.7A priority Critical patent/CN112765200A/en
Publication of CN112765200A publication Critical patent/CN112765200A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries

Abstract

The embodiment of the application provides a data query method and device based on an elastic search, which relate to the technical field of data query, and the data query method based on the elastic search comprises the following steps: firstly, acquiring an SQL data query instruction input by a user; then determining an aggregation statistical parameter according to the SQL data query instruction, and generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction; and finally, performing Elasticissearch-based query according to the comprehensive query statement to obtain a data query result, realizing multi-dimensional aggregation index statistics by directly writing an SQL data query instruction, and not needing to learn the complex DSL query syntax of Elasticissearch, simplifying the query syntax, reducing the learning cost of service developers, and further being beneficial to improving the retrieval efficiency.

Description

Data query method and device based on Elasticissearch
Technical Field
The application relates to the technical field of data query, in particular to a data query method and device based on an elastic search.
Background
The ElasticSearch is a distributed, high-expansion and high-real-time search and data analysis engine, and is used for analyzing mass log data. The existing data query method based on the ElasticSearch is usually implemented by a DSL (Domain Specific language) query statement. However, it is found in practice that the existing data query method based on the elastic search needs to learn a relatively complex DSL language first, which is too professional for most users, and is not easy to use, and when the professional query grammar is not familiar, the efficiency of retrieving by using the professional grammar is very low. Therefore, the existing data query method based on the ElasticSearch needs to learn the DSL language, the learning cost is high, and the retrieval efficiency is reduced.
Disclosure of Invention
An object of the embodiments of the present application is to provide a data query method and apparatus based on an Elasticsearch, which can simplify query syntax, and thus are beneficial to improving retrieval efficiency.
A first aspect of the embodiments of the present application provides a data query method based on an Elasticsearch, including:
acquiring an SQL data query instruction input by a user;
determining an aggregation statistical parameter according to the SQL data query instruction;
generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction;
and performing Elasticissearch-based query according to the comprehensive query statement to obtain a data query result.
In the implementation process, when data query based on the elastic search is carried out, an SQL data query instruction input by a user is firstly obtained; then determining an aggregation statistical parameter according to the SQL data query instruction, and generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction; and finally, performing Elasticissearch-based query according to the comprehensive query statement to obtain a data query result, realizing multi-dimensional aggregation index statistics by directly writing an SQL data query instruction, and not needing to learn the complex DSL query syntax of Elasticissearch, simplifying the query syntax, reducing the learning cost of service developers, and further being beneficial to improving the retrieval efficiency.
Further, the SQL data query instruction comprises an SQL query statement and a query parameter, wherein the query parameter comprises a time field identifier and a metric value field identifier.
In the implementation process, when a user inputs an SQL query instruction, the corresponding time field identifier and the corresponding metric value field identifier are determined according to the time field identifier and the metric value field identifier only by simultaneously inputting the corresponding time field identifier and the metric value field identifier, so that query grammar is simplified, and further retrieval efficiency is favorably improved.
Further, the aggregation statistical parameter comprises an aggregation statistical function and an aggregation statistical time;
the determining of the aggregation statistical parameters according to the SQL data query instruction comprises the following steps:
analyzing the SQL query statement to obtain a statistical function in the SQL query statement;
generating the aggregation statistical function according to the statistical function and the metric field identifier;
and determining the aggregation statistical time according to the time field identification.
In the implementation process, after the SQL query statement is obtained, the SQL query statement is analyzed to obtain a statistical function in the SQL query statement, then an aggregation statistical function is generated according to the statistical function and the field identifier of the metric value, and finally aggregation statistical time is determined according to the field identifier of the time, so as to obtain an aggregation statistical parameter.
Further, the generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction includes:
adding the aggregation statistical function to the SQL query statement to obtain a preliminary query statement;
and generating a comprehensive query statement according to the aggregation statistical time and the preliminary query statement.
In the implementation process, the aggregation statistical function is added to the SQL query statement to obtain a preliminary query statement, and the finally obtained comprehensive query statement comprises the preliminary query statement and the aggregation statistical time.
Further, the performing an Elasticsearch-based query according to the comprehensive query statement to obtain a data query result includes:
acquiring a service address of the Elasticissearch;
creating a service calling object according to the service address;
constructing query request data according to the comprehensive query statement;
configuring the query request data to the service calling object to obtain a target service calling object;
and performing aggregation statistical query in the Elasticissearch according to the target service calling object to obtain a data query result.
In the implementation process, when aggregation query is carried out, a service address of an Elasticsearch is obtained first, and a service calling object is created according to the service address; then, query request data are constructed according to the comprehensive query statement, and further, the query request data are configured to the service call object to obtain a target service call object; and finally, performing aggregation statistical query in the Elasticissearch according to the target service call object to obtain a data query result. The query process based on the Elasticissearch is realized by using the data source connection pool management of the SQL JDBC based on the Elasticissearch, so that the network consumption of the query is reduced, and the query performance is improved.
A second aspect of the embodiments of the present application provides an Elasticsearch-based data query apparatus, where the Elasticsearch-based data query apparatus includes:
the acquisition unit is used for acquiring an SQL data query instruction input by a user;
the determining unit is used for determining the aggregation statistical parameters according to the SQL data query instruction;
the generating unit is used for generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction;
and the query unit is used for performing query based on the elastic search according to the comprehensive query statement to obtain a data query result.
In the implementation process, when data query based on the elastic search is carried out, the acquisition unit firstly acquires an SQL data query instruction input by a user; then the determining unit determines an aggregation statistical parameter according to the SQL data query instruction, and the generating unit generates a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction; and finally, the query unit performs Elasticissearch-based query according to the comprehensive query statement to obtain a data query result, so that multidimensional aggregation index statistics can be realized by directly writing an SQL data query instruction without learning the complex DSL query syntax of Elasticissearch, the query syntax is simplified, the learning cost of service developers is reduced, and the retrieval efficiency is favorably improved.
Further, the SQL data query instruction comprises an SQL query statement and a query parameter, wherein the query parameter comprises a time field identifier and a metric value field identifier.
In the implementation process, when a user inputs an SQL query instruction, the corresponding time field identifier and the corresponding metric value field identifier are determined according to the time field identifier and the metric value field identifier only by simultaneously inputting the corresponding time field identifier and the metric value field identifier, so that query grammar is simplified, and further retrieval efficiency is favorably improved.
Further, the aggregation statistical parameter comprises an aggregation statistical function and an aggregation statistical time;
the determination unit includes:
the analysis subunit is used for carrying out analysis processing on the SQL query statement to obtain a statistical function in the SQL query statement;
a function generating subunit, configured to generate the aggregation statistical function according to the statistical function and the metric field identifier;
and the time determining subunit is used for determining the aggregation statistical time according to the time field identifier.
In the implementation process, after the SQL query statement is obtained, the parsing subunit first parses the SQL query statement to obtain a statistical function in the SQL query statement, then the function generation subunit generates an aggregation statistical function according to the statistical function and the metric field identifier, and finally the time determination subunit determines aggregation statistical time according to the time field identifier, thereby obtaining an aggregation statistical parameter.
A third aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the method for querying data based on Elasticsearch according to any one of the first aspect of the embodiments of the present application.
A fourth aspect of the present embodiment provides a computer-readable storage medium, which stores computer program instructions, where the computer program instructions, when read and executed by a processor, perform the method for querying data based on Elasticsearch according to any of the first aspect of the present embodiment.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a data query method based on an Elasticsearch according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another data query method based on an Elasticsearch according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a data query device based on an Elasticsearch according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of another data query device based on an Elasticsearch according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Referring to fig. 1, fig. 1 is a schematic flowchart of a data query method based on an Elasticsearch according to an embodiment of the present application. The method is applied to a scene of aggregate data query based on the Elasticissearch. The data query method based on the Elasticissearch comprises the following steps:
s101, acquiring an SQL data query instruction input by a user.
In the embodiment of the present application, the SQL data Query command at least includes an SQL Query statement, where the SQL Query statement is a Structured Query Language (Structured Query Language), and the Structured Query Language is a database Query and programming Language, and is used to access data and Query, update, and manage a relational database system.
And S102, determining the aggregation statistical parameters according to the SQL data query instruction.
According to the embodiment of the application, the aggregation statistical parameters can be automatically determined according to the SQL data query instruction, and a user does not need to learn an aggregation statistical function, a time screening filtering condition, a statistical grouping function and the like in advance.
S103, generating a comprehensive query statement according to the aggregation statistical parameters and the SQL data query instruction.
In the embodiment of the application, the SQL data query instruction cannot be directly used for data query of the Elasticsearch, and therefore, the SQL data query instruction needs to be processed through steps S102 to S103, and converted into the comprehensive query statement, so that data query based on the Elasticsearch can be performed according to the comprehensive query statement. In the process, a user does not need to learn a complex DSL query grammar, so that the learning cost of service developers is reduced, and the retrieval efficiency is improved.
And S104, performing Elasticissearch-based query according to the comprehensive query statement to obtain a data query result.
In the embodiment of the present application, the Elastic search is a distributed search and analysis engine of an Elastic Stack core.
In the embodiment of the application, the data source connection pool management of the SQL JDBC based on the elastic search can be used for realizing the query process based on the elastic search, which is beneficial to reducing the network consumption of the query and further improving the query performance.
In this embodiment, an execution subject of the method may be an electronic device such as a computer, a server, a smart phone, a tablet computer, and the like, which is not limited in this embodiment.
It can be seen that, by implementing the data query method based on the Elasticsearch described in fig. 1, the multidimensional aggregation index statistics can be realized by directly writing the SQL data query instruction, so as to obtain the data query result based on the Elasticsearch, and it is not necessary to learn a relatively complex DSL query syntax, thereby simplifying the query syntax, reducing the learning cost of service developers, and further facilitating the improvement of the retrieval efficiency.
Referring to fig. 2, fig. 2 is a schematic flowchart of another data query method based on an Elasticsearch according to an embodiment of the present application. As shown in fig. 2, the data query method based on the Elasticsearch includes:
s201, acquiring an SQL data query instruction input by a user.
In the embodiment of the application, the SQL data query instruction comprises an SQL query statement and query parameters, wherein the query parameters comprise a time field identifier and a metric value field identifier.
In the embodiment of the application, the time field identifier is a time field name used when aggregation statistics is performed and specified by a user.
In the embodiment of the application, the measurement value field is identified as the name of the measurement value field which is specified by the user and needs to be statistically calculated.
S202, analyzing the SQL query statement to obtain a statistical function in the SQL query statement.
As an alternative implementation, the managed SQL-Parser may be used to parse the SQL query statement to obtain a statistical function (e.g., count (), sum (), etc.) written in the SQL query statement by the user.
As an optional implementation manner, the SQL query statement is parsed to obtain a select field list, a group by field list, and the like, so that a statistical function written by the user in the SQL query statement can be obtained.
And S203, generating an aggregation statistical function according to the statistical function and the metric field identifier.
As an alternative implementation, generating the aggregation statistical function according to the statistical function and the metric value field identification may include the following steps:
obtaining a metric value field according to the metric value field identification;
and combining the metric value field and the statistical function to obtain an aggregation statistical function of the metric value field.
In the above embodiment, the metric field and the statistical function may be combined by using a drive SQL-Parser, so as to obtain an aggregate statistical function of the metric field.
In the above embodiments, the aggregation statistical function may include a count () count function, a sum () summation function, an avg () average calculation function, and the like, and this embodiment of the present application is not limited thereto.
After step S203, the following steps are also included:
and S204, determining the aggregation statistical time according to the time field identification.
As an alternative implementation, determining the aggregation statistical time according to the time field identifier may include the following steps:
acquiring a corresponding time field according to the time field identifier;
determining query starting time and query ending time according to the time field;
and calculating the aggregation statistical time according to the query starting time and the query ending time.
In the above embodiment, for the demand of index time trend query, the aggregation statistical time bucket is calculated according to the query start time and the query end time, for example, the aggregation statistical result is one value point every 1 minute, one value point every 5 minutes, one value point every 30 minutes, and the like, and the maximum time does not exceed 24 hours.
In the embodiment of the present application, by implementing the steps S202 to S204, the aggregation statistical parameter can be determined according to the SQL data query instruction. The aggregation statistical parameters comprise an aggregation statistical function and an aggregation statistical time.
After step S204, the method further includes the following steps:
s205, adding the aggregation statistical function to the SQL query statement to obtain a preliminary query statement; and generating a comprehensive query statement according to the aggregation statistical time and the preliminary query statement.
In the embodiment of the present application, by implementing the step S205, a comprehensive query statement can be generated according to the aggregation statistical parameter and the SQL data query instruction.
S206, acquiring the service address of the Elasticissearch.
In this embodiment, the service address of the Elasticsearch is the address of the Elasticsearch server.
And S207, creating a service calling object according to the service address.
In the embodiment of the present application, the service call object includes an okhtttpclient object, and the okhtttpclient object may be created by using SQL JDBC based on Elasticsearch.
In the embodiment of the present application, JDBC (Java Database Connectivity), which is an application program interface in Java language used to specify how a client program accesses a Database, provides methods such as querying and updating data in a Database.
And S208, constructing query request data according to the comprehensive query statement.
In the embodiment of the present application, after the okhtttpclient object is created, query request data is constructed according to the comprehensive query statement, where the query request data includes an http query request body and the like, and the embodiment of the present application is not limited.
S209, configuring the query request data to the service call object to obtain the target service call object.
In the embodiment of the application, the query request data is configured to the service calling object, that is, the http query request body is set to the OKHttpClient object, so as to obtain the target service calling object. The target service calling object is an OKHttpClient object with the http query request body set.
S210, performing aggregation statistical query in the Elasticissearch according to the target service call object to obtain a data query result.
In the embodiment of the application, when aggregation statistical query is performed in the Elasticsearch according to the target service call object, a newCall method of the OKHttpClient object is called to complete aggregation statistical query on the Elasticsearch, and a data query result is obtained.
In the embodiment of the application, the data source connection pool management of the SQL JDBC based on the Elasticissearch is used for realizing the query process based on the Elasticissearch, which is beneficial to reducing the network consumption of the query and further improving the query performance.
In the embodiment of the present application, by implementing the steps S206 to S210, an Elasticsearch-based query can be performed according to the integrated query statement, so as to obtain a data query result.
In the embodiment of the present application, the steps S206 to S210 are implemented, and by introducing the SQL JDBC based on the Elasticsearch, the single query response speed is improved under the condition that the network bandwidth is the same and the query request and the response data are also the same; meanwhile, when the concurrency of the query requests is large, the response speed is much higher than the speed of querying by directly using the DSL language, and after the concurrency of the query requests reaches 100tps, the response speed is improved by over 50% compared with that of the DSL language which is directly used.
Therefore, by implementing the data query method based on the elastic search described in fig. 2, the query syntax can be simplified, thereby being beneficial to improving the retrieval efficiency.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an Elasticsearch-based data query apparatus according to an embodiment of the present application. As shown in fig. 3, the data query apparatus based on the Elasticsearch includes:
the obtaining unit 310 is configured to obtain an SQL data query instruction input by a user.
The determining unit 320 is configured to determine the aggregation statistical parameter according to the SQL data query instruction.
The generating unit 330 is configured to generate a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction.
And the query unit 340 is configured to perform an Elasticsearch-based query according to the integrated query statement to obtain a data query result.
It can be seen that, by implementing the data query device based on the Elasticsearch described in this embodiment, query syntax can be simplified, thereby being beneficial to improving retrieval efficiency.
Referring to fig. 4, fig. 4 is a schematic structural diagram of another data query device based on an Elasticsearch according to an embodiment of the present application. The data query device based on the Elasticsearch shown in fig. 4 is obtained by optimizing the data query device based on the Elasticsearch shown in fig. 3. As shown in fig. 4, the determining unit 320 includes:
the parsing subunit 321 is configured to parse the SQL query statement to obtain a statistical function in the SQL query statement.
And a function generating subunit 322, configured to generate an aggregation statistical function according to the statistical function and the metric field identifier.
In this embodiment, after the function generating subunit 322 generates the aggregation statistic function, the function generating subunit may further trigger the time determining subunit 323 to determine the aggregation statistic time according to the time field identifier.
A time determining subunit 323, configured to determine an aggregation statistic time according to the time field identifier.
In the embodiment of the application, the SQL data query instruction comprises an SQL query statement and query parameters, wherein the query parameters comprise a time field identifier and a metric value field identifier.
In the embodiment of the present application, the aggregation statistical parameter includes an aggregation statistical function and an aggregation statistical time.
As an optional implementation, the generating unit 330 includes:
the adding subunit 331 is configured to add the aggregation statistical function to the SQL query statement to obtain a preliminary query statement.
And a statement generating subunit 332, configured to generate a comprehensive query statement according to the aggregation statistics time and the preliminary query statement.
As an alternative embodiment, the query unit 340 includes:
the obtaining subunit 341 is configured to obtain a service address of the Elasticsearch.
A creating subunit 342 is configured to create a service invocation object according to the service address.
A constructing subunit 343, configured to construct query request data according to the comprehensive query statement.
And the setting subunit 344 is configured to configure the query request data to the service invocation object, so as to obtain the target service invocation object.
The query subunit 345 is configured to perform aggregate statistical query in the Elasticsearch according to the target service invocation object, so as to obtain a data query result.
It can be seen that, by implementing the data query device based on the Elasticsearch described in this embodiment, query syntax can be simplified, thereby being beneficial to improving retrieval efficiency.
The embodiment of the present application provides an electronic device, which includes a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the data query method based on the Elasticsearch in the embodiment of the present application.
The embodiment of the present application provides a computer-readable storage medium, which stores computer program instructions, and when the computer program instructions are read and executed by a processor, the method for querying data based on an Elasticsearch in the embodiment of the present application is executed.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A data query method based on an elastic search is characterized by comprising the following steps:
acquiring an SQL data query instruction input by a user;
determining an aggregation statistical parameter according to the SQL data query instruction;
generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction;
and performing Elasticissearch-based query according to the comprehensive query statement to obtain a data query result.
2. The Elasticsearch-based data query method of claim 1, wherein the SQL data query instruction comprises an SQL query statement and query parameters, wherein the query parameters comprise a time field identification and a metric value field identification.
3. The Elasticsearch-based data query method of claim 2, wherein the aggregation statistical parameters comprise an aggregation statistical function and an aggregation statistical time;
the determining of the aggregation statistical parameters according to the SQL data query instruction comprises the following steps:
analyzing the SQL query statement to obtain a statistical function in the SQL query statement;
generating the aggregation statistical function according to the statistical function and the metric field identifier;
and determining the aggregation statistical time according to the time field identification.
4. The Elasticissearch-based data query method according to claim 3, wherein the generating of the comprehensive query statement according to the aggregated statistical parameter and the SQL data query instruction comprises:
adding the aggregation statistical function to the SQL query statement to obtain a preliminary query statement;
and generating a comprehensive query statement according to the aggregation statistical time and the preliminary query statement.
5. The method for querying data based on the elastic search according to claim 1, wherein the querying based on the elastic search according to the comprehensive query statement to obtain a data query result comprises:
acquiring a service address of the Elasticissearch;
creating a service calling object according to the service address;
constructing query request data according to the comprehensive query statement;
configuring the query request data to the service calling object to obtain a target service calling object;
and performing aggregation statistical query in the Elasticissearch according to the target service calling object to obtain a data query result.
6. An elastic search based data query device, comprising:
the acquisition unit is used for acquiring an SQL data query instruction input by a user;
the determining unit is used for determining the aggregation statistical parameters according to the SQL data query instruction;
the generating unit is used for generating a comprehensive query statement according to the aggregation statistical parameter and the SQL data query instruction;
and the query unit is used for performing query based on the elastic search according to the comprehensive query statement to obtain a data query result.
7. The Elasticsearch-based data query device of claim 6, wherein the SQL data query instruction comprises an SQL query statement and query parameters, wherein the query parameters comprise a time field identification and a metric value field identification.
8. The Elasticsearch-based data query device of claim 7, wherein the aggregation statistical parameters comprise an aggregation statistical function and an aggregation statistical time;
the determination unit includes:
the analysis subunit is used for carrying out analysis processing on the SQL query statement to obtain a statistical function in the SQL query statement;
a function generating subunit, configured to generate the aggregation statistical function according to the statistical function and the metric field identifier;
and the time determining subunit is used for determining the aggregation statistical time according to the time field identifier.
9. An electronic device, characterized in that the electronic device comprises a memory for storing a computer program and a processor for executing the computer program to make the electronic device execute the Elasticsearch based data query method of any of claims 1 to 5.
10. A readable storage medium, wherein computer program instructions are stored in the readable storage medium, and when the computer program instructions are read and executed by a processor, the method for querying data based on Elasticsearch according to any of claims 1 to 5 is executed.
CN202110066761.7A 2021-01-18 2021-01-18 Data query method and device based on Elasticissearch Pending CN112765200A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110066761.7A CN112765200A (en) 2021-01-18 2021-01-18 Data query method and device based on Elasticissearch

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110066761.7A CN112765200A (en) 2021-01-18 2021-01-18 Data query method and device based on Elasticissearch

Publications (1)

Publication Number Publication Date
CN112765200A true CN112765200A (en) 2021-05-07

Family

ID=75702984

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110066761.7A Pending CN112765200A (en) 2021-01-18 2021-01-18 Data query method and device based on Elasticissearch

Country Status (1)

Country Link
CN (1) CN112765200A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113254470A (en) * 2021-05-28 2021-08-13 武汉悦学帮网络技术有限公司 Data change method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107133267A (en) * 2017-04-01 2017-09-05 北京京东尚科信息技术有限公司 Inquire about method, device, electronic equipment and the readable storage medium storing program for executing of elasticsearch clusters
CN108520019A (en) * 2018-03-22 2018-09-11 平安好房(上海)电子商务有限公司 Data managing method, device, equipment and computer readable storage medium
CN109145014A (en) * 2017-06-15 2019-01-04 北京京东尚科信息技术有限公司 The method and apparatus for generating elastic searching request
CN109299102A (en) * 2018-10-23 2019-02-01 中国电子科技集团公司第二十八研究所 A kind of HBase secondary index system and method based on Elastcisearch

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107133267A (en) * 2017-04-01 2017-09-05 北京京东尚科信息技术有限公司 Inquire about method, device, electronic equipment and the readable storage medium storing program for executing of elasticsearch clusters
CN109145014A (en) * 2017-06-15 2019-01-04 北京京东尚科信息技术有限公司 The method and apparatus for generating elastic searching request
CN108520019A (en) * 2018-03-22 2018-09-11 平安好房(上海)电子商务有限公司 Data managing method, device, equipment and computer readable storage medium
CN109299102A (en) * 2018-10-23 2019-02-01 中国电子科技集团公司第二十八研究所 A kind of HBase secondary index system and method based on Elastcisearch

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113254470A (en) * 2021-05-28 2021-08-13 武汉悦学帮网络技术有限公司 Data change method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110795455B (en) Dependency analysis method, electronic device, computer apparatus, and readable storage medium
CN106293891B (en) Multidimensional investment index monitoring method
JP2002244898A (en) Database managing program and database system
CN111241059B (en) Database optimization method and device based on database
CN111046041B (en) Data processing method and device, storage medium and processor
US20120158714A1 (en) Storage and searching of temporal entity information
CN109408541A (en) Report decomposes statistical method, system, computer equipment and storage medium
CN112084249A (en) Access record extraction method and device
CN111813803B (en) Method, device, equipment and storage medium for generating statement block execution plan
CN110909010B (en) Data intelligent analysis configuration management method, device, equipment and storage medium
CN108415998B (en) Application dependency relationship updating method, terminal, device and storage medium
CN110704472A (en) Data query statistical method and device
CN110659294A (en) Space-time data ad hoc query method, system, electronic device and storage medium
CN107330031B (en) Data storage method and device and electronic equipment
CN112765200A (en) Data query method and device based on Elasticissearch
CN112434037A (en) Data processing method, processing device, data processing apparatus, and storage medium
CN113010539A (en) Data processing method and device
US11244000B2 (en) Information processing apparatus and non-transitory computer readable medium storing program for creating index for document retrieval
CN110888909B (en) Data statistical processing method and device for evaluation content
CN104317820B (en) Statistical method and device for report forms
CN111125129A (en) Data processing method and device, storage medium and processor
US8090750B2 (en) Prompting of an end user with commands
CN113448985A (en) API (application program interface) interface generation method, calling method and device and electronic equipment
CN112182177A (en) User problem processing method and device, electronic equipment and storage medium
CN113297245A (en) Method and device for acquiring execution information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210507

RJ01 Rejection of invention patent application after publication