CN106980619B - Data query method and device - Google Patents

Data query method and device Download PDF

Info

Publication number
CN106980619B
CN106980619B CN201610030714.6A CN201610030714A CN106980619B CN 106980619 B CN106980619 B CN 106980619B CN 201610030714 A CN201610030714 A CN 201610030714A CN 106980619 B CN106980619 B CN 106980619B
Authority
CN
China
Prior art keywords
query
statement
data
data query
query statement
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.)
Active
Application number
CN201610030714.6A
Other languages
Chinese (zh)
Other versions
CN106980619A (en
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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201610030714.6A priority Critical patent/CN106980619B/en
Publication of CN106980619A publication Critical patent/CN106980619A/en
Application granted granted Critical
Publication of CN106980619B publication Critical patent/CN106980619B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/951Indexing; Web crawling techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data query method and a data query device, relates to the technical field of networks, and solves the problems that the existing data query mode is complex in writing format, and is difficult to debug and modify by mistake. The main technical scheme of the invention is as follows: receiving a data query statement, wherein the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language; verifying whether the data query statement is correct or not through a preset XML query framework and the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes; and if the data query statement is verified to be correct, querying the field name according to the data query statement. The invention is mainly used for data query.

Description

Data query method and device
Technical Field
The present invention relates to the field of network technologies, and in particular, to a data query method and apparatus.
Background
The distributed search engine provides various query functions for large-scale data, can facilitate users to classify and count data from different aspects, and is particularly convenient for users to store and quickly query real-time data of various media on a network. However, to build such a real-time data query system, a data collection system needs to be built first, then the collected data is sorted and classified, a distributed search engine is used to index the data with different formats, and finally the data is queried and displayed according to the indexes.
Currently, a data Query function is realized through a full-text search engine (Lucene) retrieval toolkit packaged in a distributed search engine, and although Lucene supports a relatively flexible Query Language (Query Domain Specific Language, abbreviated as Query DSL), Lucene is not well understood in an intuitive sense, and a written format is relatively complex, so that errors are not easily eliminated.
Disclosure of Invention
The present invention has been made in view of the above problems, and aims to provide a data query method and apparatus that overcomes or at least partially solves the above problems.
In order to achieve the purpose, the invention mainly provides the following technical scheme:
in one aspect, an embodiment of the present invention provides a data query method, where the method includes:
receiving a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language;
verifying whether the data query statement is correct or not through a preset XML query framework and the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
and if the data query statement is verified to be correct, querying the field name according to the data query statement.
On the other hand, an embodiment of the present invention further provides a data query apparatus, where the apparatus includes:
the device comprises a receiving unit, a query unit and a query unit, wherein the receiving unit is used for receiving a data query statement, the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language;
the verification unit is used for verifying whether the data query statement is correct or not through a preset XML query framework, the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
and the query unit is used for querying the field name according to the data query statement if the data query statement is verified to be correct.
By the technical scheme, the technical scheme provided by the embodiment of the invention at least has the following advantages:
the data query method and the device provided by the embodiment of the invention firstly receive a data query statement, wherein the data query statement comprises a field name, a field type and a query mode of the data query statement, the data query statement is an XML (extensive makeup language) query statement, and then whether the data query statement is correct is verified through a preset XML query frame, the field name of the data query statement and a basic query frame corresponding to the field name, wherein the preset XML query frame comprises the basic query frame corresponding to each field name respectively, the basic query frame comprises the field type and the query mode, and if the data query statement is verified to be correct, the field name is queried according to the data query statement. Compared with the prior art that the data query is carried out through the encapsulated Lucene retrieval toolkit, the embodiment of the invention restrains and limits the XML data query statement input by the client through the self-defined XML query framework, thereby preventing the client from inputting some illegal parameters. And the data query statement input by the client is a flexible XML label, so that the invention can realize flexible configuration of the query mode, is convenient for increasing the query mode and expanding the query function, avoids complex DSL grammar and Lucene query grammar, and is convenient for error debugging, positioning and modification.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flowchart of a data query method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another data query method provided by the embodiment of the invention;
FIG. 3 is a block diagram of a data query device according to an embodiment of the present invention;
fig. 4 is a block diagram of another data query apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to make the advantages of the technical solutions of the present invention clearer, the present invention is described in detail below with reference to the accompanying drawings and examples.
An embodiment of the present invention provides a data query method, as shown in fig. 1, where the method includes:
101. a data query statement is received.
The data query statement includes a field name, a field type, and a query mode of the data query statement, where the data query statement is a query statement in an XML (Extensible Markup Language), the field name is a field to be queried input by a user, and specifically may be a web content field, an emotion value field, a URL field, and the like, the field type is a data type of a field name specified by a client, and specifically may be a character type, an integer type, a date type, and the like, the query mode may specifically be a full-match query mode (which may be represented as term), that is, a document must include a whole searched vocabulary, and the key data is a query mode (which may be represented as a query _ string) in a string form. It should be noted that, the XML language has the following three features: firstly, the XML tag is easy to read and has a very definite meaning; secondly, XML processing is very convenient, and a plurality of existing tools are all used for processing XML documents; third, XML flexibility is incomparable with many other data formats. Therefore, the self-defined XML tag file is a very suitable data input and output format, so that the data query sentence input by the invention can support complex data query, is easy to understand in the visual sense of the data query sentence, and has a relatively simple writing format.
For example, a data query statement received as input by a client is as follows:
<maincontent>
< Value format ═ string "matchmode ═ term" > < "industry Standard" > < Value >
</maincontent>
The main is a field name, the format is used for limiting the type of the field name to be 'string', and the matchmode is used for displaying that the query mode is 'term' (complete match), namely, the web page documents including the whole search vocabulary 'industry standard' in all the web page contents are searched.
It should be noted that, if the client does not specify the type or query mode corresponding to the field name in the input data query instruction, the field type is a default configuration type, and the query mode is a default query mode. In this embodiment of the present invention, the type of the field may specifically be a character type, an integer type, a date type, and the like, and the query mode may specifically be term, query _ string, and the like, which is not specifically limited in this embodiment of the present invention.
Furthermore, in the present invention, a data query statement in a field name combination mode, that is, a complex query obtained by logical combination operation of "and", "or" and "not" may also be input. The example given below contains two field names, maincontent and sentime, respectively, and these two field names are a combinatorial relationship that operates with "and" logic.
<AndOperator>
<maincontent>
< Value format ═ string "matchmode ═ term" > < "industry Standard" > < Value >
</maincontent>
<sentiment>
<Value format="int"><20></Value>
</sentiment>
</AndOperator>
102. And verifying whether the data query statement is correct or not through a preset XML query framework, the field name of the data query statement and a basic query framework corresponding to the field name.
The preset XML query frame comprises a basic query frame corresponding to each field name, the basic query frame comprises field types and a query mode, the XML query frame is a self-defined extensible markup language mode (which can be expressed as schema) program module, and the preset XML query frame is a legal construction module for defining XML documents because schema can replace document type definition and an XML schema file describes the structure of an extensible markup language document. The XML query framework comprises whether multi-layer nested combination query is allowed or not, each sub-query field comprises specific query details such as data types and query modes, and the preset XML query framework only needs to make one query of a certain type.
For example, an example of a basic query framework corresponding to the field name "maincontent" implemented by an XML schema validation constraint is as follows:
Figure BDA0000908678260000051
Figure BDA0000908678260000061
the field name of the query is "mainontnent", and the query includes search contents of two attributes "attribute": one is "format," which represents the data type of the current field, which may include string, int data type, etc. The other is "matchmode", which represents the query mode adopted by the current field name, and may include: term, query _ string, etc. And "attribute" supports the form of default value or optional value, if the client does not specify the field type or query mode, the field type or query mode will adopt the default form.
With reference to the above example, if the received data query statement is:
<maincontent>
< Value format ═ int ═ matchmode ═ matchModeSet "> <" standard "> < >
</maincontent>
Then the received data query statement is verified through the basic query framework corresponding to the field name "main", and an error prompt message for field type input may occur. Since the field type in the main query frame is defined as "format", and the field type in the received data query statement is "int", the field type in the basic query frame is inconsistent with the field type in the data query statement, and therefore, an error prompt message for inputting the field type occurs.
103. And if the data query statement is verified to be correct, querying the field name according to the data query statement.
For the embodiment of the invention, the received data query statement can be restricted into the input data in the general XML mark format by presetting the XML query framework, so that the query becomes more flexible, and various combined queries can be supported. Even the type of data and the query mode can be constrained in the XML markup format, and the conventional ElasticSearch query can be realized in this mode. Therefore, the invention is convenient to increase the query mode and expand the query function, avoids the complex DSL grammar and Lucene query grammar, is convenient for error debugging, positioning and modification, ensures that the complex ElasticSearch search action becomes transparent, and ensures that the user only concerns the construction of the query XML.
The data query method provided by the embodiment of the invention comprises the steps of firstly receiving a data query statement, wherein the data query statement comprises a field name, a field type and a query mode of the data query statement, the data query statement is an XML (extensive Makeup language) query statement, then verifying whether the data query statement is correct or not through a preset XML query frame, the field name of the data query statement and a basic query frame corresponding to the field name, wherein the preset XML query frame comprises the basic query frame corresponding to each field name, the basic query frame comprises the field type and the query mode, and if the data query statement is verified to be correct, querying the field name according to the data query statement. Compared with the prior art that the data query is carried out through the encapsulated Lucene retrieval toolkit, the embodiment of the invention restrains and limits the XML data query statement input by the client through the self-defined XML query framework, thereby preventing the client from inputting some illegal parameters. And the data query statement input by the client is a flexible XML label, so that the invention can realize flexible configuration of the query mode, is convenient for increasing the query mode and expanding the query function, avoids complex DSL grammar and Lucene query grammar, and is convenient for error debugging, positioning and modification.
An embodiment of the present invention provides another data query method, as shown in fig. 2, the method includes:
201. a data query statement is received.
The data query statement includes a field name, a field type, and a query mode of the data query statement, the data query statement is a query statement in an XML (Extensible Markup Language), the field name is a field to be queried input by a user, specifically may be a web content field, an emotion value field, a URL field, and the like, the field type is a data type of a field name specified by a client, specifically may be a character type, an integer type, a date type, and the like, the query mode may specifically be term, that is, a document must include a whole searched vocabulary, query _ string, and the like. It should be noted that, the XML language has the following three features: firstly, the XML tag is easy to read and has a very definite meaning; secondly, XML processing is very convenient, and a plurality of existing tools are all used for processing XML documents; third, XML flexibility is incomparable with many other data formats. Therefore, the self-defined XML tag file is a very suitable data input and output format, so that the data query sentence input by the invention can support complex data query, is easy to understand in the visual sense of the data query sentence, and has a relatively simple writing format.
202. And verifying whether the data query statement is correct or not through a preset XML query framework, the field name of the data query statement and a basic query framework corresponding to the field name.
The preset XML query frame comprises a basic query frame corresponding to each field name, the basic query frame comprises field types and a query mode, the XML query frame is a self-defined schema (extensible markup language mode) program module, and the preset XML query frame is a legal construction module of a defined XML document because the schema can replace document type definition and one XML schema file describes the structure of the extensible markup language document. The XML query framework comprises whether multi-layer nested combination query is allowed or not, each sub-query field comprises specific query details such as data types and query modes, and the preset XML query framework only needs to make one query of a certain type.
For an embodiment of the present invention, before step 202, the method further comprises: configuring a basic query framework corresponding to each field name in the XML query framework, and configuring a field type and a query mode contained in the basic query framework, wherein the XML query framework is also configured with a logical query relation among the field names. The XML query framework is a self-defined schema, namely a self-defined legal construction module of an XML document.
For example, the preset XML query frame includes a web content field, the query type defined in the basic query frame corresponding to the web content field is a character type, and if the data type of the specified web content field in the data query statement input by the client is an integer type, the data query statement is verified through the basic query frame corresponding to the web content field, and a data query statement verification error prompt message may occur.
203. And if the data query statement is correct, detecting whether a logic operation statement exists in the data query statement.
The logical operation statement may specifically be a data query statement containing a combinational logical relationship such as "and", "or", "not", and the like. For example, a logical operation statement, that is, an "AndOperator" operation exists in the following data query statement, and data including "industry standard" and a webpage emotion value of 20 in the webpage content can be found through the following data query statement.
<AndOperator>
<maincontent>
< Value format ═ string "matchmode ═ term" > < "industry Standard" > < Value >
</maincontent>
<sentiment>
<Value format="int"><20></Value>
</sentiment>
</AndOperator>
204a, if the logical operation statement exists, constructing a document object model dom tree corresponding to the data query statement.
In the embodiment of the invention, after the data query statement input by the client is received, the current data query statement is analyzed, and the data query statement is analyzed into a dom tree form. For example, in the example of step 203, three nodes are formed after parsing, one is an operator node, and the other two are lookup field nodes, representing a specific sub-query. Expressed as Query (main) and Query (sensory) in terms of Query expressions.
205a, converting the dom tree into an inverse wave form.
It should be noted that the form of the dom tree is a form that is well understood by a person, but since many processes of a computer are based on stack operations, the dom tree form is not a computer-friendly process form. Therefore, it is necessary to convert the dom tree into an inverse wave form, that is, the Query expressions Query (main) and Query (sensing) of the dom tree are converted into a form of Query (main) Query (sensing) and inverse wave.
206a, analyzing the inverse Polish to obtain a pool query statement corresponding to the inverse Polish.
For the embodiment of the present invention, the elastic search provides a query mode of combined query, which is called a pool query. When a pool query is created, the query will contain sub-queries that organize the sub-queries into a query according to the specified "and", "or", "not" combination. This characteristic just meets the above requirements. The reverse wave form serves as a bridge between the external user and the internal implementation mechanism of the elastic search. The external XML markup query is converted to inverse Polish storage and then multiple sub-queries are combined into a complex comprehensive query by parsing the inverse Polish.
207a, calling a query interface function of a distributed search engine ElasticSearch to query the field name according to the pool query statement.
204b, if the logical operation statement does not exist, calling a query interface function of a distributed search engine ElasticSearch to query the field name according to the field type in the data query statement and the query mode.
Step 204b is a parallel step of step 204a, if the logical operation statement does not exist, a query interface function of a distributed search engine ElasticSearch is called to query the field name according to the field type and the query mode in the data query statement.
205. And outputting a query result corresponding to the field name queried through the data query statement.
The invention defines the data query statement into the universal XML mark format input data by formulating XML mark constraint, namely presetting an XML query frame through a simple and universal ElasticSearch query mode, so that the query becomes more flexible, and various combined queries can be supported. Even the type of data and the query mode can be constrained in the XML markup format, and the conventional ElasticSearch query can be realized in this mode. Meanwhile, in the process of query conversion from XML mark to ElasticSearch, the inverse wave form is used as the intermediate data storage format, and the pool query function provided by ElasticSearch is fully utilized, so that the inverse wave form is conveniently converted into the corresponding pool query request of ElasticSearch. The design mode is convenient for increasing the query mode and expanding the query function, avoids complicated DSL grammar and Lucene query grammar, is convenient for error debugging, positioning and modification, enables the complex ElasticSearch search action to be transparent, and enables a user to only concern about the construction of the query XML.
The other data query method provided in the embodiments of the present invention includes first receiving a data query statement, where the data query statement includes a field name, a field type, and a query mode of the data query statement, and then verifying whether the data query statement is correct by presetting an XML query frame, the field name of the data query statement, and a basic query frame corresponding to the field name, where the preset XML query frame includes basic query frames corresponding to the field names, respectively, and the basic query frame includes the field type and the query mode, and if the data query statement is verified to be correct, querying the field name according to the data query statement. Compared with the prior art that the data query is carried out through the encapsulated Lucene retrieval toolkit, the embodiment of the invention restrains and limits the XML data query statement input by the client through the self-defined XML query framework, thereby preventing the client from inputting some illegal parameters. And the data query statement input by the client is a flexible XML label, so that the invention can realize flexible configuration of the query mode, is convenient for increasing the query mode and expanding the query function, avoids complex DSL grammar and Lucene query grammar, and is convenient for error debugging, positioning and modification.
Further, an embodiment of the present invention provides a data query apparatus, as shown in fig. 3, the apparatus including: a receiving unit 31, a verification unit 32, and an inquiry unit 33.
A receiving unit 31, configured to receive a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language;
a verification unit 32, configured to verify whether the data query statement is correct by presetting an XML query frame and a field name of the data query statement, and a basic query frame corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
the query unit 33 is configured to query the field name according to the data query statement if the data query statement is verified to be correct.
It should be noted that, for other corresponding descriptions of the functional units related to the data query apparatus provided in the embodiment of the present invention, reference may be made to corresponding descriptions of the method shown in fig. 1, which are not described herein again, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the foregoing method embodiments.
The data query device provided by the embodiment of the invention firstly receives a data query statement, wherein the data query statement comprises a field name, a field type and a query mode of the data query statement, the data query statement is a query statement of an XML language, and then whether the data query statement is correct is verified through a preset XML query frame, the field name of the data query statement and a basic query frame corresponding to the field name, wherein the preset XML query frame comprises the basic query frame corresponding to each field name respectively, the basic query frame comprises the field type and the query mode, and if the data query statement is verified to be correct, the field name is queried according to the data query statement. Compared with the prior art that the data query is carried out through the encapsulated Lucene retrieval toolkit, the embodiment of the invention restrains and limits the XML data query statement input by the client through the self-defined XML query framework, thereby preventing the client from inputting some illegal parameters. And the data query statement input by the client is a flexible XML label, so that the invention can realize flexible configuration of the query mode, is convenient for increasing the query mode and expanding the query function, avoids complex DSL grammar and Lucene query grammar, and is convenient for error debugging, positioning and modification.
Further, another data query apparatus is provided in an embodiment of the present invention, as shown in fig. 4, the apparatus includes: a receiving unit 41, an authentication unit 42, and an inquiry unit 43.
A receiving unit 41, configured to receive a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language;
a verification unit 42, configured to verify whether the data query statement is correct by presetting an XML query frame and a field name of the data query statement, and a basic query frame corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
the query unit 43 is configured to query the field name according to the data query statement if the data query statement is verified to be correct.
For the embodiment of the present invention, the apparatus further includes:
a configuration unit 44, configured to configure a basic query framework corresponding to each field name in the XML query framework, and a field type and a query manner included in the basic query framework, where the XML query framework is further configured with a logical query relationship between the field names.
A detecting unit 45, configured to detect whether a logical operation statement exists in the data query statement;
the query unit 43 is specifically configured to, if the logical operation statement does not exist, call a query interface function of the distributed search engine elastic search to query the field name according to the field type in the data query statement and the query mode.
Further, the querying unit 43 includes:
a building module 431, configured to build a document object model dom tree corresponding to the data query statement if the logical operation statement exists;
a conversion module 432, configured to convert the dom tree into an inverse wave form;
the analysis module 433 is configured to analyze the inverse wave form to obtain a bol query statement corresponding to the inverse wave form;
and the query module 434 is configured to invoke a query interface function of the distributed search engine elastic search to query the field name according to the pool query statement.
Further, the apparatus further comprises:
and an output unit 46, configured to output a query result corresponding to the field name queried by the data query statement.
It should be noted that, for other corresponding descriptions of the functional units related to the data query device provided in the embodiment of the present invention, reference may be made to corresponding descriptions of the method shown in fig. 2, which are not described herein again, but it should be clear that the device in the embodiment can correspondingly implement all the contents in the foregoing method embodiments.
Another data query apparatus provided in an embodiment of the present invention first receives a data query statement, where the data query statement includes a field name, a field type, and a query mode of the data query statement, and the data query statement is an XML query statement, and then verifies whether the data query statement is correct by presetting an XML query frame, the field name of the data query statement, and a basic query frame corresponding to the field name, where the preset XML query frame includes basic query frames corresponding to the field names, respectively, and the basic query frame includes the field type and the query mode, and if the data query statement is verified to be correct, queries the field name according to the data query statement. Compared with the prior art that the data query is carried out through the encapsulated Lucene retrieval toolkit, the embodiment of the invention restrains and limits the XML data query statement input by the client through the self-defined XML query framework, thereby preventing the client from inputting some illegal parameters. And the data query statement input by the client is a flexible XML label, so that the invention can realize flexible configuration of the query mode, is convenient for increasing the query mode and expanding the query function, avoids complex DSL grammar and Lucene query grammar, and is convenient for error debugging, positioning and modification.
The data inquiry device comprises a processor and a memory, wherein the receiving unit, the verifying unit, the inquiring unit, the configuring unit, the detecting unit, the outputting unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the problems of complex writing format, error debugging, difficult modification and the like of the existing data query mode are solved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: receiving a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, and the data query statement is a query statement of an XML language; verifying whether the data query statement is correct or not through a preset XML query framework and the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes; and if the data query statement is verified to be correct, querying the field name according to the data query statement.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for querying data, comprising:
receiving a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, wherein the field type is a data type of the field name, and the data query statement is a query statement of an XML language;
verifying whether the data query statement is correct or not through a preset XML query framework and the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
if the data query statement is verified to be correct, querying the field name according to the data query statement;
the querying the field name according to the data query statement includes:
calling a query interface function of a distributed search engine ElasticSearch to query the field name according to the data query statement;
before verifying whether the data query statement is correct through the preset XML query framework, the field name of the data query statement and the basic query framework corresponding to the field name, the method further comprises the following steps:
configuring a basic query framework corresponding to each field name in the XML query framework, and field types and query modes contained in the basic query framework, wherein the XML query framework is also configured with a logical query relation among the field names;
verifying whether the data query statement is correct or not by presetting an XML query framework and the field name of the data query statement and a basic query framework corresponding to the field name, wherein the verifying comprises the following steps of:
searching a basic query frame corresponding to the field name in the preset XML query frame;
comparing the field type and the query mode contained in the data query statement with the field type and the query mode contained in the basic query framework;
when the comparison result is that the field type contained in the data query statement is the same as the field type contained in the basic query framework, and the query mode contained in the data query statement is the same as the query mode contained in the basic query framework, determining that the data query statement is correctly verified;
determining that the data query statement is verified incorrectly when the comparison result indicates that the field type contained in the data query statement is different from the field type contained in the basic query framework and/or the query mode contained in the data query statement is different from the query mode contained in the basic query framework;
if the data query statement is verified to be wrong, determining a mistake type corresponding to the comparison result, and outputting mistake prompt information corresponding to the mistake type, wherein the mistake type is a field type mistake, a query mode mistake or a field type query mode mistake.
2. The method of claim 1, wherein after the data query statement is correct, before performing a data query according to the data query statement, the method further comprises:
detecting whether a logic operation statement exists in the data query statement;
if the logical operation statement does not exist, the data query according to the data query statement comprises:
and calling a query interface function of the distributed search engine to query the field name through the field type and the query mode in the data query statement.
3. The method of claim 2, wherein if the logical operation statement exists, performing a data query according to the data query statement comprises:
constructing a document object model dom tree corresponding to the data query statement;
converting the dom tree to an inverse wave form;
analyzing the inverse wave form to obtain a pool query statement corresponding to the inverse wave form;
and calling a query interface function of the distributed search engine to query the field name according to the pool query statement.
4. The method according to any one of claims 1-3, wherein after the querying the field name according to the data query statement, the method further comprises:
and outputting a query result corresponding to the field name queried through the data query statement.
5. A data query apparatus, comprising:
a receiving unit, configured to receive a data query statement; the data query statement comprises a field name, a field type and a query mode of the data query statement, wherein the field type is a data type of the field name, and the data query statement is a query statement of an XML language;
the verification unit is used for verifying whether the data query statement is correct or not through a preset XML query framework, the field name of the data query statement and a basic query framework corresponding to the field name; the preset XML query frame comprises a basic query frame corresponding to each field name, and the basic query frame comprises field types and query modes;
the query unit is used for querying the field name according to the data query statement if the data query statement is verified to be correct;
the query unit is specifically configured to invoke a query interface function of a distributed search engine elastic search to query the field name according to the data query statement;
the configuration unit is used for configuring a basic query framework corresponding to each field name in the XML query framework, a field type and a query mode contained in the basic query framework before the verification unit verifies whether the data query statement is correct or not through a preset XML query framework and the field name of the data query statement and the basic query framework corresponding to the field name, and the XML query framework is also configured with a logical query relation among the field names;
the verification unit is specifically configured to search a basic query framework corresponding to the field name in the preset XML query framework; comparing the field type and the query mode contained in the data query statement with the field type and the query mode contained in the basic query framework; when the comparison result is that the field type contained in the data query statement is the same as the field type contained in the basic query framework, and the query mode contained in the data query statement is the same as the query mode contained in the basic query framework, determining that the data query statement is correctly verified; determining that the data query statement is verified incorrectly when the comparison result indicates that the field type contained in the data query statement is different from the field type contained in the basic query framework and/or the query mode contained in the data query statement is different from the query mode contained in the basic query framework; if the data query statement is verified to be wrong, determining a mistake type corresponding to the comparison result, and outputting mistake prompt information corresponding to the mistake type, wherein the mistake type is a field type mistake, a query mode mistake or a field type query mode mistake.
6. The apparatus of claim 5, further comprising:
the detection unit is used for detecting whether a logic operation statement exists in the data query statement;
the query unit is specifically configured to, if the logical operation statement does not exist, call a query interface function of the distributed search engine to query the field name by using the field type and the query mode in the data query statement.
7. The apparatus of claim 6, wherein the query unit comprises:
the building module is used for building a document object model dom tree corresponding to the data query statement if the logical operation statement exists;
the conversion module is used for converting the dom tree into an inverse wave form;
the analysis module is used for analyzing the inverse wave form to obtain a pool query statement corresponding to the inverse wave form;
and the query module is used for calling a query interface function of the distributed search engine to query the field name according to the pool query statement.
8. The apparatus of any of claims 5-7, further comprising:
and the output unit is used for outputting the query result corresponding to the field name queried through the data query statement.
9. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the data query method according to any one of claims 1 to 4.
10. A processor, configured to execute a program, wherein the program executes the data query method according to any one of claims 1 to 4.
CN201610030714.6A 2016-01-18 2016-01-18 Data query method and device Active CN106980619B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610030714.6A CN106980619B (en) 2016-01-18 2016-01-18 Data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610030714.6A CN106980619B (en) 2016-01-18 2016-01-18 Data query method and device

Publications (2)

Publication Number Publication Date
CN106980619A CN106980619A (en) 2017-07-25
CN106980619B true CN106980619B (en) 2021-03-26

Family

ID=59339859

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610030714.6A Active CN106980619B (en) 2016-01-18 2016-01-18 Data query method and device

Country Status (1)

Country Link
CN (1) CN106980619B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110851459B (en) * 2018-07-25 2021-08-13 上海柯林布瑞信息技术有限公司 Searching method and device, storage medium and server
CN110968763A (en) * 2018-09-30 2020-04-07 北京国双科技有限公司 Data processing method and device
CN112527976A (en) * 2019-09-19 2021-03-19 北京国双科技有限公司 Data processing method and device
CN111191106B (en) * 2019-12-30 2023-05-12 上海携程商务有限公司 DSL construction method, system, electronic device and medium
CN111797111B (en) * 2020-05-17 2024-09-20 北京冠群信息技术股份有限公司 Dynamic combination query method based on ES search engine
CN114860998A (en) * 2022-06-08 2022-08-05 中国邮政储蓄银行股份有限公司 Data retrieval method, device, computer readable storage medium and server

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101984434A (en) * 2010-11-16 2011-03-09 东北大学 Webpage data extracting method based on extensible language query
CN103530446A (en) * 2013-09-25 2014-01-22 浪潮电子信息产业股份有限公司 Method for extracting message path information of communication protocol in hybrid language verification system
CN104346332A (en) * 2013-07-23 2015-02-11 北大方正集团有限公司 Full-text retrieval method and system for XML database

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7873645B2 (en) * 2003-09-05 2011-01-18 Oracle International Corporation Method and mechanism for handling arbitrarily-sized XML in SQL operator tree
US8140558B2 (en) * 2009-05-22 2012-03-20 International Business Machines Corporation Generating structured query language/extensible markup language (SQL/XML) statements
CN101561817A (en) * 2009-06-02 2009-10-21 天津大学 Conversion algorithm from XQuery to SQL query language and method for querying relational data
CN101719156B (en) * 2009-12-30 2012-07-25 南开大学 System of seamless integrated pure XML query engine in relational database
US9223833B2 (en) * 2013-12-02 2015-12-29 Qbase, LLC Method for in-loop human validation of disambiguated features

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101984434A (en) * 2010-11-16 2011-03-09 东北大学 Webpage data extracting method based on extensible language query
CN104346332A (en) * 2013-07-23 2015-02-11 北大方正集团有限公司 Full-text retrieval method and system for XML database
CN103530446A (en) * 2013-09-25 2014-01-22 浪潮电子信息产业股份有限公司 Method for extracting message path information of communication protocol in hybrid language verification system

Also Published As

Publication number Publication date
CN106980619A (en) 2017-07-25

Similar Documents

Publication Publication Date Title
CN106980619B (en) Data query method and device
US9495345B2 (en) Methods and systems for modeling complex taxonomies with natural language understanding
US9619448B2 (en) Automated document revision markup and change control
US9852133B2 (en) Scalable, schemaless document query model
US9361317B2 (en) Method for entity enrichment of digital content to enable advanced search functionality in content management systems
US9892191B2 (en) Complex query handling
US20160217121A1 (en) Generating regular expression
CN111176650B (en) Parser generation method, search method, server, and storage medium
US10489024B2 (en) UI rendering based on adaptive label text infrastructure
CN114625732A (en) Query method and system based on Structured Query Language (SQL)
US10503743B2 (en) Integrating search with application analysis
CN110955714A (en) Method and device for converting unstructured text into structured text
US20230290169A1 (en) Information Extraction Method and Apparatus for Text With Layout
CN107766036B (en) Module construction method and device and terminal equipment
TWI686717B (en) Data extraction method, device and terminal equipment
US10133826B2 (en) UDDI based classification system
CN108008947B (en) Intelligent prompting method and device for programming statement, server and storage medium
US20110270862A1 (en) Information processing apparatus and information processing method
CN101727451A (en) Method and device for extracting information
US8719693B2 (en) Method for storing localized XML document values
CN107256260A (en) A kind of intelligent semantic recognition methods, searching method, apparatus and system
US11681862B1 (en) System and method for identifying location of content within an electronic document
CN110618809B (en) Front-end webpage input constraint extraction method and device
Berndt Scaling the ConceptCloud browser to very large semi-structured data sets: architecture and data completion
TWI407372B (en) System and method for automatically generating a website based on pre-defined webpage templates

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
CB02 Change of applicant information

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Applicant before: Beijing Guoshuang Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant