WO2018228034A1 - Method and device for generating elastic search request - Google Patents

Method and device for generating elastic search request Download PDF

Info

Publication number
WO2018228034A1
WO2018228034A1 PCT/CN2018/082283 CN2018082283W WO2018228034A1 WO 2018228034 A1 WO2018228034 A1 WO 2018228034A1 CN 2018082283 W CN2018082283 W CN 2018082283W WO 2018228034 A1 WO2018228034 A1 WO 2018228034A1
Authority
WO
WIPO (PCT)
Prior art keywords
query
keyword
elastic search
request
executable file
Prior art date
Application number
PCT/CN2018/082283
Other languages
French (fr)
Chinese (zh)
Inventor
王英杰
Original Assignee
北京京东尚科信息技术有限公司
北京京东世纪贸易有限公司
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 北京京东尚科信息技术有限公司, 北京京东世纪贸易有限公司 filed Critical 北京京东尚科信息技术有限公司
Publication of WO2018228034A1 publication Critical patent/WO2018228034A1/en

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/245Query processing
    • G06F16/2452Query translation
    • 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/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0623Item investigation

Definitions

  • the present application relates to the field of computer technologies, and in particular, to the field of Internet technologies, and in particular, to a method and apparatus for generating an elastic search request.
  • ElasticSearch is based on the full-text search engine Lucene, which provides a full-text search engine with distributed multi-user capabilities, which is designed for real-time search in the field of big data cloud computing.
  • ES has its own specific grammar, and people who use it need to understand its grammatical structure to be able to control it. It is quite different from the SQL grammar of web developers who are more familiar with relational databases in data retrieval, which leads to increased learning costs for developers. Therefore, the existing ES is less effective.
  • the purpose of the present application is to propose an improved method and apparatus for generating an elastic search request to solve the technical problems mentioned in the background section above.
  • an embodiment of the present application provides a method for generating an elastic search request, where the method includes: in response to detecting a data query request operation of an elastic search, configuring a parameter in a data query request by using an object relationship mapping framework to generate a structure.
  • the query language statement ; according to the mapping relationship between the structured query language command and the executable file object, converting the structured query language statement into an executable file object; replacing the syntax keyword in the executable file object according to a preset conversion rule
  • the grammar keyword in the grammar is searched for; the executable file object after the grammar keyword is replaced to generate an elastic search request.
  • the converting the structured query language statement into the executable file object according to the mapping relationship between the structured query language command and the executable file object includes: detecting a query condition in the data query request, wherein the query is The condition includes querying the keyword and the condition value; the query keyword and the condition value of the above query condition are respectively used as labels and attributes of the executable file object to convert the above structured query language statement into an executable file object.
  • the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
  • configuring the parameter in the data query request by the object relationship mapping framework comprises: responding to the data query request detecting the elastic search
  • the operation according to the data query request operation, detects the query keyword of the data query request; when there are multiple query keywords, the query keywords are spliced by a preset syntax to generate a structured query language statement.
  • the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query keyword of the structured query language statement is The query keywords of the Elastic Search Language statement are consistent.
  • the present application further provides an apparatus for generating an elastic search request, the apparatus comprising: a statement generation module configured to configure a data query request through an object relationship mapping framework in response to detecting a data query request operation of the elastic search
  • the parameter in the structure generates a structured query language statement
  • the conversion module is configured to convert the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object; replacing the module, configuring For replacing a grammar keyword in an executable file object with a grammar keyword in an elastic search grammar according to a preset conversion rule
  • a request generation module configured to generate an elastic search request for the executable file object after replacing the grammar keyword .
  • the foregoing conversion module includes: a detecting unit configured to detect a query condition in the data query request, wherein the query condition includes a query keyword and a condition value; and a converting unit configured to use the query condition
  • the query keyword and the condition value are respectively used as labels and attributes of the executable file object to convert the above structured query language statement into an executable file object.
  • the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
  • the statement generation module is further configured to: in response to detecting the data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request; when there are multiple query keywords
  • the above query keywords are spliced by a preset grammar.
  • the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query keyword of the structured query language statement is The query keywords of the Elastic Search Language statement are consistent.
  • the method and apparatus for generating an elastic search request provided by the present application, in response to detecting a data query request operation of the elastic search, configuring parameters in the data query request through the object relationship mapping framework, generating a structured query language statement, and then according to the structured query
  • the mapping relationship between the language command and the executable file object converting the above structured query language statement into an executable file object, and then replacing the syntax key in the executable file object with the syntax in the elastic search syntax according to a preset conversion rule
  • the keyword then generates an elastic search request by replacing the executable object with the grammar keyword. Since the elastic search request is generated by automatically performing grammar conversion on the basis of the existing file object, the effectiveness of the elastic search can be improved.
  • FIG. 1 is an exemplary system architecture diagram to which the present application can be applied;
  • FIG. 2 is a flow diagram of one embodiment of a method of generating an elastic search request in accordance with the present application
  • 3a and 3b are schematic diagrams of application scenarios of an embodiment of a method for generating an elastic search request according to the present application
  • FIG. 4 is a schematic structural diagram of an embodiment of an apparatus for generating an elastic search request according to the present application
  • FIG. 5 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server of an embodiment of the present application.
  • FIG. 1 illustrates an exemplary system architecture 100 of an embodiment of a method of generating an elastic search request to which the present application may be applied.
  • system architecture 100 can include terminal devices 101, 102, network 103, and server 104.
  • the network 103 is used to provide a medium for communication links between the terminal devices 101, 102 and the server 104.
  • Network 103 may include various types of connections, such as wired, wireless communication links, fiber optic cables, and the like.
  • the user can interact with the server 104 over the network 103 using the terminal devices 101, 102 to receive or transmit messages and the like.
  • Various communication client applications such as a browser application, a shopping application, a search application, an instant communication tool, and the like, can be installed on the terminal devices 101 and 102.
  • the terminal devices 101, 102 may be various electronic devices having communication functions including, but not limited to, smartphones, tablets, e-book readers, laptop portable computers, desktop computers, and the like.
  • the server 104 may be a server that provides various services, such as a background server that supports browser applications on the terminal devices 101, 102, shopping applications, and the like.
  • the server 104 may analyze the received data such as the query or the unlock request, and the like, and feed back the processing result (for example, the queried item payment status information) to the terminal devices 101 and 102.
  • the method for generating an elastic search request provided by the embodiment of the present application is applicable to the terminal devices 101 and 102. Accordingly, the device for generating an elastic search request provided by the embodiment of the present application is disposed in the terminal devices 101 and 102.
  • the server 104 can provide elastic search support, and the terminal devices 101, 102 can receive the user's search request operation and generate an elastic search request to the server 104 to retrieve data from the server 104.
  • terminal devices, networks, and servers in Figure 1 is merely illustrative. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
  • FIG. 2 illustrates one embodiment of a method of generating an elastic search request of the present application.
  • the method for generating an elastic search request includes the following steps:
  • Step 201 In response to detecting the data query request operation of the elastic search, configuring the parameter in the data query request by the object relationship mapping framework to generate a structured query language statement.
  • the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may detect the data query request operation of the user, and when detecting the elastic search server
  • the parameters in the data query request may be first configured by an object relational mapping (such as Object Relational Mapping, ORM) framework to generate a structured query language statement.
  • object relational mapping such as Object Relational Mapping, ORM
  • a user can input or select a keyword through a browser page to perform a data query request operation.
  • These keywords can often generate query statements through object mapping. For example, when the browser page displays the order inquiry page, the user selects the start time as January 01, 2017, and the electronic device can generate a query according to the query condition.
  • the electronic device may first determine that the query scope is an order table (eg, the keyword is t_order), and then determine that the query keyword includes an order time (eg, the keyword is created).
  • the query scope is an order table (eg, the keyword is t_order)
  • the query keyword includes an order time (eg, the keyword is created).
  • the query condition is the order time after January 01, 2017 (eg created> '2017-01-01').
  • SQL Structured Query Language
  • the query keyword and query condition can be generated as: "select*from t_order where created>'2017-01-01')".
  • the electronic device may first detect the query keyword of the data query request according to the data query request, and when there are multiple query keywords, the preset syntax is The query keyword is spliced.
  • the predetermined syntax here may be, for example, the conjunctions "and", "or", "not", and the like.
  • the electronic device may first determine that the query scope is an order table (for example, the keyword is t_order), and then determine that the query keyword includes an order time (such as a keyword created) and a payment status (such as a keyword status), and the query condition is an order.
  • the electronic device may pre-store an Object Relational Mapping (ORM) framework for managing a mapping relationship between a relational database operation statement (such as a SQL query statement) and a Java object, and the java program is used.
  • ORM Object Relational Mapping
  • the executable object in the map is mapped to a relational database.
  • the above electronic device may configure the parameter in the data query request as a structured query language statement according to the object relationship mapping framework.
  • the electronic device uses the injection tool of the relational database (such as sqlMap in the SQL database) to configure parameters as:
  • select id is semi-automatic ORM framework ibatis ORM framework selection syntax
  • id is the unique identifier of the SQL database (such as database name t_order, etc.)
  • parameterClass is the dynamic parameter in the SQL query statement
  • resultClass is the SQL query statement
  • the return value, parameterClass and resultClass are the fixed attributes of the object tag.
  • the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query of the structured query language statement The keyword matches the query keyword of the Elastic Search Language statement. In order to ensure that the elastic search request is generated, it is not necessary to convert the retrieval table name and the query keyword, thereby improving the retrieval efficiency.
  • Step 202 Convert the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object.
  • the electronic device for example, the terminal device 101, 102 shown in FIG. 1 on which the method for generating the elastic search request is run may further according to the mapping relationship between the structured query language command and the executable file object.
  • the commands and parameters in a structured query language statement are converted into tags or attributes of executable file objects such as Java objects.
  • the electronic device may first map the structured query language statement to an execution client object of the executable file, such as an sqlMapClient object, where the electronic device may use a command in the structured query language statement.
  • an object tag such as the command select as a select tag
  • the electronic device can obtain the attribute of the object tag, such as the id attribute of the selecet tag, and the attribute value can be the SQL database to be queried.
  • the electronic device may convert the structured query language statement corresponding to the attribute of the object tag to a mapping declaration object (such as a MappedStatement object).
  • the electronic device may further detect a query condition in the data query request, where the query condition may include a query keyword and a condition value. Then, the electronic device may respectively use the query keyword and the condition value in the query conditions as labels and attributes of the executable file object to convert the structured query language statement into an executable file object.
  • the electronic device may save the key-value in the form of a key-value by using a mapping object, where the key-value pair key may be The query keyword, the value (value) can be the condition value corresponding to the query keyword.
  • the "key” can be the payment status (or status, etc.) of the query keyword, and the "value” can be the condition value. The payment was successful (or a value of 1, etc.).
  • the electronic device can complete the acquisition of the structured query language statement by the executable file.
  • Step 203 Replace the syntax key in the executable file object with the syntax key in the flexible search syntax based on the preset conversion rule.
  • the electronic device for example, the terminal device 101, 102 shown in FIG. 1 on which the method for generating the elastic search request is run may further store a preset conversion rule in advance, further in the executable file object.
  • the grammar keyword is replaced with a grammar keyword in the elastic search grammar.
  • the preset conversion rule may include, but is not limited to, a correspondence relationship between a grammar keyword in the structured query language and a grammar keyword in the elastic search grammar.
  • the grammar keyword may include a command keyword (such as a command keyword select of a selection command), a connection keyword (such as a connection keyword indicating a connection relationship "and", and the like).
  • the syntax keywords "select, where, and, or” in SQL correspond to the grammar keywords "query, bool, must, match" in the elastic search grammar, and so on.
  • the above electronic device can parse the SQL statement into a java object "QueryAction"; and then use the "QueryAction” method to convert the SQL statement to satisfy the ES syntax. Json string.
  • JSON JavaScript Object Notation
  • Step 204 Generate an elastic search request by replacing the executable file object after the grammar keyword.
  • the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may further generate an elastic search request by the executable file object after replacing the grammar keyword.
  • the foregoing electronic device may first create an ES client object (such as HttpClient), and then generate an ES request according to a URL (Uniform Resource Locator) of the ES server.
  • the generated ES request may be sent to the ES server through a transmission protocol such as TCP (Transmission Control Protocol) or HTTP (HyperText Transfer Protocol).
  • the method for generating an elastic search request in this embodiment may be applied to, for example, a shopping application client.
  • the backend server that provides support for the shopping application client can be an ES server.
  • the shopping application client and the ES server can communicate through a transmission protocol such as TCP or HTTP.
  • TCP or HTTP a transmission protocol
  • the shopping application client runs on the terminal 300, and selects the "My Order" option in the pop-up option of the pull-up option box of the tag 301, the shopping application client.
  • the end switch displays the order inquiry page shown in Figure 3b.
  • the order inquiry page shown in Figure 3b shows the partial query keywords "all", "order time”, etc. of the order inquiry.
  • the terminal 300 may first configure a parameter in the data query request through an object relationship mapping framework (such as an ORM framework) to generate a structured query language (such as SQL) statement; then, the terminal 300 may The structured query language statement is converted into an executable file object (such as a Json string) according to a mapping relationship between a structured query language (such as SQL) command and an executable file object (such as a Java object); then, the terminal 300 can be based on a preset The conversion rule replaces the syntax key in the executable file object with the syntax key in the elastic search syntax; then, the terminal 300 may generate an ES request by the executable file object after the replacement syntax keyword, and send the ES request to The ES server performs data query. After receiving the order information fed back by the ES server, the terminal device can further display through the page of the object
  • the method for generating an elastic search request in this embodiment can improve the effectiveness of the elastic search by automatically generating a flexible search request by performing an automatic conversion of the executable file object based on the prior art.
  • the present application provides an embodiment of an apparatus for generating an elastic search request.
  • the apparatus 400 for generating an elastic search request of the present embodiment includes: a statement generation module 401, a conversion module 402, a replacement module 403, and a request generation module 404.
  • the statement generation module 401 can be configured to generate a structured query language statement by configuring a parameter in the data query request by the object relationship mapping framework in response to detecting the data query request operation of the elastic search;
  • the conversion module 402 can be configured to be configured according to The structured query language command is converted into an executable file object by a mapping relationship between the structured query language command and the executable file object;
  • the replacement module 403 can be configured to use the syntax key in the executable file object according to the preset conversion rule.
  • the request generation module 404 can be configured to generate an elastic search request for the executable file object after the replacement grammar keyword.
  • the converting module 402 may further include: a detecting unit (not shown), configured to detect a query condition in the data query request, where the query condition includes a query keyword And a condition value; a conversion unit (not shown), configured to use the query keyword and the condition value of the above query condition as labels and attributes of the executable file object, respectively, to convert the structured query language statement into an executable file File object.
  • the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
  • the statement generating module 401 may be further configured to: in response to detecting the data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request operation; When there are multiple query keywords, the above query keywords are spliced by a preset grammar.
  • the structured query language statement generated by the statement generation module 401 may include a retrieval table name and a query keyword, wherein the retrieval table name is consistent with the elastic search index name, and the structured query language statement is The query keyword is consistent with the query keyword of the Elastic Search Language statement.
  • the apparatus 400 for generating an elastic search request further includes some other well-known structures, such as a processor, a memory, etc., in order to unnecessarily obscure the embodiments of the present disclosure, these well-known structures are not shown in FIG. Out.
  • FIG. 5 there is shown a block diagram of a computer system 500 suitable for use in implementing a terminal device/server of an embodiment of the present application.
  • the terminal device/server shown in FIG. 5 is merely an example, and should not impose any limitation on the function and scope of use of the embodiments of the present application.
  • computer system 500 includes a central processing unit (CPU) 501 that can be loaded into a program in random access memory (RAM) 503 according to a program stored in read only memory (ROM) 502 or from storage portion 508. And perform various appropriate actions and processes.
  • RAM random access memory
  • ROM read only memory
  • RAM 503 various programs and data required for the operation of the system 500 are also stored.
  • the CPU 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504.
  • An input/output (I/O) interface 505 is also coupled to bus 504.
  • the following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a touch screen, a microphone or a scanner, etc.; an output portion 507 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc.; storage including a hard disk or the like Portion 508; and a communication portion 509 including a network interface card such as a LAN card, modem, or the like.
  • the communication section 509 performs communication processing via a network such as the Internet.
  • Driver 510 is also coupled to I/O interface 505 as needed.
  • a removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory or the like is mounted on the drive 510 as needed so that a computer program read therefrom is installed into the storage portion 508 as needed.
  • an embodiment of the present disclosure includes a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for executing the method illustrated in the flowchart.
  • the computer program can be downloaded and installed from the network via the communication portion 509, and/or installed from the removable medium 511.
  • CPU central processing unit
  • non-transitory computer readable medium described herein may be a non-transitory computer readable signal medium or a non-transitory computer readable storage medium or any combination of the two.
  • the non-transitory computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above.
  • non-transitory computer readable storage media may include, but are not limited to, electrical connections having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • a non-transitory computer readable storage medium can be any tangible medium that can contain or store a program, which can be used by or in connection with an instruction execution system, apparatus, or device.
  • a computer readable signal medium may include a data signal that is propagated in the baseband or as part of a carrier, carrying computer readable program code. Such propagated data signals can take a variety of forms including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer readable signal medium can also be any computer readable medium other than a computer readable storage medium, which can transmit, propagate, or transport a program for use by or in connection with the instruction execution system, apparatus, or device.
  • Program code embodied on a computer readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
  • each block of the flowchart or block diagram can represent a module, a program segment, or a portion of code that includes one or more of the logic functions for implementing the specified.
  • Executable instructions can also occur in a different order than that illustrated in the drawings. For example, two successively represented blocks may in fact be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented in a dedicated hardware-based system that performs the specified function or operation. Or it can be implemented by a combination of dedicated hardware and computer instructions.
  • the modules involved in the embodiments of the present application may be implemented by software or by hardware.
  • the described modules may also be provided in the processor, for example, as a processor including a statement generation module, a conversion module, a replacement module, and a request generation module.
  • the names of these modules do not constitute a limitation on the unit itself under certain circumstances.
  • the statement generation module may also be described as "configured to respond to data query request operations that detect elastic search, through object relationships.
  • the mapping framework configures the parameters in the data query request to generate a module for the structured query language statement.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Databases & Information Systems (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A method and device for generating an elastic search request. The method comprises: in response to detection of a data query request operation of elastic search, configuring parameters in a data query request by means of an object relation mapping framework to generate a structured query language statement (201); converting the structured query language statement into an executable file object according to a mapping relation between structured query language commands and executable file objects (202); replacing a syntax keyword in the executable file object with a syntax keyword in an elastic search syntax based on a preset conversion rule (203); and generating an elastic search request from the executable file object subjected to syntax keyword replacement (204). According to the method, the effectiveness of elastic search can be improved.

Description

生成弹性搜索请求的方法和装置Method and apparatus for generating an elastic search request
相关申请的交叉引用Cross-reference to related applications
本专利申请要求于2017年6月15日提交的、申请号为201710451970.7、申请人为北京京东世纪贸易有限公司和北京京东尚科信息技术有限公司、发明名称为“生成弹性搜索请求的方法和装置”的中国专利申请的优先权,该申请的全文以引用的方式并入本申请中。This patent application claims to be submitted on June 15, 2017, the application number is 201710451970.7, the applicant is Beijing Jingdong Century Trading Co., Ltd. and Beijing Jingdong Shangke Information Technology Co., Ltd., and the invention is entitled "Method and Device for Generating Elastic Search Request" Priority of the Chinese Patent Application, the entire contents of which is hereby incorporated by reference.
技术领域Technical field
本申请涉及计算机技术领域,具体涉及互联网技术领域,尤其涉及生成弹性搜索请求的方法和装置。The present application relates to the field of computer technologies, and in particular, to the field of Internet technologies, and in particular, to a method and apparatus for generating an elastic search request.
背景技术Background technique
弹性搜索,ElasticSearch,简称:ES,它基于全文搜索引擎Lucene,提供了分布式多用户能力的全文搜索引擎,它在设计上用于大数据云计算领域能够达到实时搜索。然而,ES具有自己特定的语法,使用它的人需要懂得其语法结构才能驾驭,其与web开发人员在数据检索时较熟悉关系数据库的SQL语法相差较大,导致开发人员的学习成本增加。因此,现有ES的有效性较低。ElasticSearch, referred to as ES, is based on the full-text search engine Lucene, which provides a full-text search engine with distributed multi-user capabilities, which is designed for real-time search in the field of big data cloud computing. However, ES has its own specific grammar, and people who use it need to understand its grammatical structure to be able to control it. It is quite different from the SQL grammar of web developers who are more familiar with relational databases in data retrieval, which leads to increased learning costs for developers. Therefore, the existing ES is less effective.
发明内容Summary of the invention
本申请的目的在于提出一种改进的生成弹性搜索请求的方法和装置,来解决以上背景技术部分提到的技术问题。The purpose of the present application is to propose an improved method and apparatus for generating an elastic search request to solve the technical problems mentioned in the background section above.
第一方面,本申请实施例提供了一种生成弹性搜索请求的方法,该方法包括:响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句;根据结构化查询语言命令与可执行文件对象的映射关系,将上述结构化查询语言语句转换成可执行文件对象;按照预设转换规则将可执行 文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;将替换语法关键字后的可执行文件对象生成弹性搜索请求。In a first aspect, an embodiment of the present application provides a method for generating an elastic search request, where the method includes: in response to detecting a data query request operation of an elastic search, configuring a parameter in a data query request by using an object relationship mapping framework to generate a structure. The query language statement; according to the mapping relationship between the structured query language command and the executable file object, converting the structured query language statement into an executable file object; replacing the syntax keyword in the executable file object according to a preset conversion rule The grammar keyword in the grammar is searched for; the executable file object after the grammar keyword is replaced to generate an elastic search request.
在一些实施例中,上述根据结构化查询语言命令与可执行文件对象的映射关系,将上述结构化查询语言语句转换成可执行文件对象包括:检测数据查询请求中的查询条件,其中,上述查询条件包括查询关键字和条件值;将上述查询条件的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将上述结构化查询语言语句转换成可执行文件对象。In some embodiments, the converting the structured query language statement into the executable file object according to the mapping relationship between the structured query language command and the executable file object includes: detecting a query condition in the data query request, wherein the query is The condition includes querying the keyword and the condition value; the query keyword and the condition value of the above query condition are respectively used as labels and attributes of the executable file object to convert the above structured query language statement into an executable file object.
在一些实施例中,上述查询条件的查询关键字及条件值以键值对的形式传递,其中,上述键值对中键为查询关键字,值为查询关键字对应的条件值。In some embodiments, the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
在一些实施例中,上述响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句包括:响应于检测到弹性搜索的数据查询请求操作,根据数据查询请求操作检测数据查询请求的查询关键字;当上述查询关键字有多个时,通过预设语法将上述查询关键字拼接,生成结构化查询语言语句。In some embodiments, in response to detecting the data query request operation of the elastic search, configuring the parameter in the data query request by the object relationship mapping framework, generating the structured query language statement comprises: responding to the data query request detecting the elastic search The operation, according to the data query request operation, detects the query keyword of the data query request; when there are multiple query keywords, the query keywords are spliced by a preset syntax to generate a structured query language statement.
在一些实施例中,上述结构化查询语言语句包括检索表名和查询关键字,其中,上述结构化查询语言语句的检索表名与弹性搜索索引名称一致,上述结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。In some embodiments, the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query keyword of the structured query language statement is The query keywords of the Elastic Search Language statement are consistent.
第二方面,本申请还提供了一种生成弹性搜索请求的装置,该装置包括:语句生成模块,配置用于响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句;转换模块,配置用于根据结构化查询语言命令与可执行文件对象的映射关系,将上述结构化查询语言语句转换成可执行文件对象;替换模块,配置用于按照预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;请求生成模块,配置用于将替换语法关键字后的可执行文件对象生成弹性搜索请求。In a second aspect, the present application further provides an apparatus for generating an elastic search request, the apparatus comprising: a statement generation module configured to configure a data query request through an object relationship mapping framework in response to detecting a data query request operation of the elastic search The parameter in the structure generates a structured query language statement; the conversion module is configured to convert the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object; replacing the module, configuring For replacing a grammar keyword in an executable file object with a grammar keyword in an elastic search grammar according to a preset conversion rule; a request generation module configured to generate an elastic search request for the executable file object after replacing the grammar keyword .
在一些实施例中,上述转换模块包括:检测单元,配置用于检测数据查询请求中的查询条件,其中,上述查询条件包括查询关键字和条件值;转换单元,配置用于将上述查询条件的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将上述结构化查询语言语句转换成可执行文件对象。In some embodiments, the foregoing conversion module includes: a detecting unit configured to detect a query condition in the data query request, wherein the query condition includes a query keyword and a condition value; and a converting unit configured to use the query condition The query keyword and the condition value are respectively used as labels and attributes of the executable file object to convert the above structured query language statement into an executable file object.
在一些实施例中,上述查询条件的查询关键字及条件值以键值对的形式传递,其中,上述键值对中键为查询关键字,值为查询关键字对应的条件值。In some embodiments, the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
在一些实施例中,上述语句生成模块进一步配置用于:响应于检测到弹性搜索的数据查询请求操作,根据数据查询请求操作检测数据查询请求的查询关键字;当上述查询关键字有多个时,通过预设语法将上述查询关键字拼接。In some embodiments, the statement generation module is further configured to: in response to detecting the data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request; when there are multiple query keywords The above query keywords are spliced by a preset grammar.
在一些实施例中,上述结构化查询语言语句包括检索表名和查询关键字,其中,上述结构化查询语言语句的检索表名与弹性搜索索引名称一致,上述结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。In some embodiments, the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query keyword of the structured query language statement is The query keywords of the Elastic Search Language statement are consistent.
本申请提供的生成弹性搜索请求的方法和装置,响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句,然后根据结构化查询语言命令与可执行文件对象的映射关系,将上述结构化查询语言语句转换成可执行文件对象,接着,按照预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字,然后,将替换语法关键字后的可执行文件对象生成弹性搜索请求。由于通过可执行文件对象在现有技术基础上自动进行语法转换生成弹性搜索请求,从而可以提高弹性搜索的有效性。The method and apparatus for generating an elastic search request provided by the present application, in response to detecting a data query request operation of the elastic search, configuring parameters in the data query request through the object relationship mapping framework, generating a structured query language statement, and then according to the structured query The mapping relationship between the language command and the executable file object, converting the above structured query language statement into an executable file object, and then replacing the syntax key in the executable file object with the syntax in the elastic search syntax according to a preset conversion rule The keyword then generates an elastic search request by replacing the executable object with the grammar keyword. Since the elastic search request is generated by automatically performing grammar conversion on the basis of the existing file object, the effectiveness of the elastic search can be improved.
附图说明DRAWINGS
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:Other features, objects, and advantages of the present application will become more apparent from the detailed description of the accompanying drawings.
图1是本申请可以应用于其中的示例性系统架构图;1 is an exemplary system architecture diagram to which the present application can be applied;
图2是根据本申请的生成弹性搜索请求的方法的一个实施例的流程图;2 is a flow diagram of one embodiment of a method of generating an elastic search request in accordance with the present application;
图3a、图3b是根据本申请生成弹性搜索请求的方法的一个实施例的应用场景示意图;3a and 3b are schematic diagrams of application scenarios of an embodiment of a method for generating an elastic search request according to the present application;
图4是根据本申请的生成弹性搜索请求的装置的一个实施例的结构示意图;4 is a schematic structural diagram of an embodiment of an apparatus for generating an elastic search request according to the present application;
图5适于用来实现本申请实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 5 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server of an embodiment of the present application.
具体实施方式detailed description
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention, rather than the invention. It is also to be noted that, for the convenience of description, only the parts related to the related invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings.
图1示出了可以应用本申请的生成弹性搜索请求的方法的实施例的示例性系统架构100。FIG. 1 illustrates an exemplary system architecture 100 of an embodiment of a method of generating an elastic search request to which the present application may be applied.
如图1所示,系统架构100可以包括终端设备101、102,网络103和服务器104。网络103用以在终端设备101、102和服务器104之间提供通信链路的介质。网络103可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 1, system architecture 100 can include terminal devices 101, 102, network 103, and server 104. The network 103 is used to provide a medium for communication links between the terminal devices 101, 102 and the server 104. Network 103 may include various types of connections, such as wired, wireless communication links, fiber optic cables, and the like.
用户可以使用终端设备101、102通过网络103与服务器104交互,以接收或发送消息等。终端设备101、102上可以安装各种通讯客户端应用,例如浏览器应用、购物类应用、搜索类应用、即时通信工具等。The user can interact with the server 104 over the network 103 using the terminal devices 101, 102 to receive or transmit messages and the like. Various communication client applications, such as a browser application, a shopping application, a search application, an instant communication tool, and the like, can be installed on the terminal devices 101 and 102.
终端设备101、102可以是具有通讯功能的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、膝上型便携计算机和台式计算机等等。The terminal devices 101, 102 may be various electronic devices having communication functions including, but not limited to, smartphones, tablets, e-book readers, laptop portable computers, desktop computers, and the like.
服务器104可以是提供各种服务的服务器,例如对终端设备101、 102上的浏览器应用、购物类应用等提供支持的后台服务器等。服务器104可以对接收到的查询或解锁请求等数据进行分析等处理,并将处理结果(例如所查询的物品支付状态信息)反馈给终端设备101、102。The server 104 may be a server that provides various services, such as a background server that supports browser applications on the terminal devices 101, 102, shopping applications, and the like. The server 104 may analyze the received data such as the query or the unlock request, and the like, and feed back the processing result (for example, the queried item payment status information) to the terminal devices 101 and 102.
一般地,本申请实施例所提供的生成弹性搜索请求的方法适用于终端设备101、102;相应地,本申请实施例所提供的生成弹性搜索请求的装置设置于终端设备101、102。服务器104可以提供弹性搜索支持,终端设备101、102可以接收用户的搜索请求操作,并生成弹性搜索请求发送至服务器104,以从服务器104获取数据。Generally, the method for generating an elastic search request provided by the embodiment of the present application is applicable to the terminal devices 101 and 102. Accordingly, the device for generating an elastic search request provided by the embodiment of the present application is disposed in the terminal devices 101 and 102. The server 104 can provide elastic search support, and the terminal devices 101, 102 can receive the user's search request operation and generate an elastic search request to the server 104 to retrieve data from the server 104.
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the number of terminal devices, networks, and servers in Figure 1 is merely illustrative. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
继续参考图2,图2示出了本申请的生成弹性搜索请求的方法的一个实施例。该生成弹性搜索请求的方法,包括以下步骤:With continued reference to FIG. 2, FIG. 2 illustrates one embodiment of a method of generating an elastic search request of the present application. The method for generating an elastic search request includes the following steps:
步骤201,响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句。Step 201: In response to detecting the data query request operation of the elastic search, configuring the parameter in the data query request by the object relationship mapping framework to generate a structured query language statement.
在本实施例中,生成弹性搜索请求的方法运行于其上的电子设备(例如图1所示的终端设备101、102)可以对用户的数据查询请求操作进行检测,当检测到对弹性搜索服务器进行数据查询的数据查询请求操作时,可以首先通过对象关系映射(如Object Relational Mapping,ORM)框架配置数据查询请求中的参数,生成结构化查询语言语句。In this embodiment, the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may detect the data query request operation of the user, and when detecting the elastic search server When performing a data query request operation for data query, the parameters in the data query request may be first configured by an object relational mapping (such as Object Relational Mapping, ORM) framework to generate a structured query language statement.
通常,用户可以通过浏览器页面输入或者选择关键字进行数据查询请求操作。这些关键字往往可以通过对象映射,生成查询语句。例如,浏览器页面显示订单查询页面时,用户选择起始时间为2017年01月01日,则上述的电子设备可以按照该查询条件生成查询语句。Generally, a user can input or select a keyword through a browser page to perform a data query request operation. These keywords can often generate query statements through object mapping. For example, when the browser page displays the order inquiry page, the user selects the start time as January 01, 2017, and the electronic device can generate a query according to the query condition.
实践中,上述电子设备可以先确定查询范围为订单表(如关键字为t_order),接着确定查询关键字包括下单时间(如关键字为created),In practice, the electronic device may first determine that the query scope is an order table (eg, the keyword is t_order), and then determine that the query keyword includes an order time (eg, the keyword is created).
查询条件为下单时间在2017年01月01日之后(如created>'2017-01-01')。以SQL(Structured Query Language)为例,将查询关键字、查询条件生成查询语句可以为:“select*from t_order where  created>'2017-01-01')”。The query condition is the order time after January 01, 2017 (eg created> '2017-01-01'). Taking SQL (Structured Query Language) as an example, the query keyword and query condition can be generated as: "select*from t_order where created>'2017-01-01')".
可以理解,在一些实现中,查询关键字可以为多个。例如,浏览器页面显示订单查询页面时,用户选择起始时间为2017年01月01日,同时选择限制条件支付成功。此时,响应于检测到弹性搜索的数据查询请求操作,上述电子设备可以先根据数据查询请求操作检测数据查询请求的查询关键字,当所述查询关键字有多个时,通过预设语法将所述查询关键字拼接。这里的预定语法例如可以是连接词“和(and)”、“或(or)”、“非(not)”等。上述电子设备可以先确定查询范围为订单表(如关键字为t_order),接着确定查询关键字包括下单时间(如关键字为created)和支付状态(如关键字status),查询条件为下单时间在2017年01月01日之后(如created>'2017-01-01')以及支付状态为支付成功(如status=1)。以SQL(Structured Query Language)为例,将查询关键字、查询条件生成查询语句可以为:“select*from t_order where created>'2017-01-01'and status=1)”。It will be appreciated that in some implementations, there may be multiple query keywords. For example, when the browser page displays the order inquiry page, the user selects the start time as January 01, 2017, and selects the restriction condition to pay successfully. At this time, in response to detecting the data query request operation of the elastic search, the electronic device may first detect the query keyword of the data query request according to the data query request, and when there are multiple query keywords, the preset syntax is The query keyword is spliced. The predetermined syntax here may be, for example, the conjunctions "and", "or", "not", and the like. The electronic device may first determine that the query scope is an order table (for example, the keyword is t_order), and then determine that the query keyword includes an order time (such as a keyword created) and a payment status (such as a keyword status), and the query condition is an order. The time is after January 01, 2017 (eg created> '2017-01-01') and the payment status is successful (eg status=1). Taking SQL (Structured Query Language) as an example, the query keyword and query condition can be generated as follows: "select*from t_order where created>'2017-01-01'and status=1)".
在本实施例中,上述电子设备可以预先存储有对象关系映射(Object Relational Mapping,简称ORM)框架,用来管理关系数据库的操作语句(如SQL查询语句)与Java对象的映射关系,将java程序中的可执行文件对象映射到关系数据库中。上述电子设备可以根据对象关系映射框架将数据查询请求中的参数配置为结构化查询语言语句。例如在前述的例子中,上述电子设备通过关系数据库的注入工具(如SQL数据库中的sqlMap)配置参数为:In this embodiment, the electronic device may pre-store an Object Relational Mapping (ORM) framework for managing a mapping relationship between a relational database operation statement (such as a SQL query statement) and a Java object, and the java program is used. The executable object in the map is mapped to a relational database. The above electronic device may configure the parameter in the data query request as a structured query language statement according to the object relationship mapping framework. For example, in the foregoing example, the electronic device uses the injection tool of the relational database (such as sqlMap in the SQL database) to configure parameters as:
<select id(选择SQL数据库)="get Order By Condition(通过条件获取订单)",parameterClass(参数类型)="java.util.HashMap",resultClass(结果类型)="java.util.HashMap">;<select id (select SQL database) = "get Order By Condition", parameterClass (parameter type) = "java.util.HashMap", resultClass (result type) = "java.util.HashMap"> ;
配置参数后的结构化查询语言语句可以如下:select*from t_order where created>'2017-01-01'and status=1</select>;The structured query language statement after the configuration parameters can be as follows: select*from t_order where created>'2017-01-01'and status=1</select>;
其中,select id中,select为半自动化ORM框架ibatis ORM框架的选择语法,id是SQL数据库的唯一标识(如数据库名称t_order等)、parameterClass是SQL查询语句中的动态参数、resultClass是SQL查 询语句的返回值,parameterClass和resultClass为对象标签的固定属性。Among them, select id, select is semi-automatic ORM framework ibatis ORM framework selection syntax, id is the unique identifier of the SQL database (such as database name t_order, etc.), parameterClass is the dynamic parameter in the SQL query statement, resultClass is the SQL query statement The return value, parameterClass and resultClass are the fixed attributes of the object tag.
在本实施例的一些可选实现方式中,结构化查询语言语句包括检索表名和查询关键字,其中,结构化查询语言语句的检索表名与弹性搜索索引名称一致,结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。以保证生成弹性搜索请求时不必转换检索表名和查询关键字,从而提高检索效率。In some optional implementations of this embodiment, the structured query language statement includes a search table name and a query keyword, wherein the search table name of the structured query language statement is consistent with the elastic search index name, and the query of the structured query language statement The keyword matches the query keyword of the Elastic Search Language statement. In order to ensure that the elastic search request is generated, it is not necessary to convert the retrieval table name and the query keyword, thereby improving the retrieval efficiency.
步骤202,根据结构化查询语言命令与可执行文件对象的映射关系,将结构化查询语言语句转换成可执行文件对象。Step 202: Convert the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object.
在本实施例中,生成弹性搜索请求的方法运行于其上的电子设备(例如图1所示的终端设备101、102)进一步可以根据结构化查询语言命令与可执行文件对象的映射关系,将结构化查询语言语句中的命令和参数转换成可执行文件对象(如Java对象)的标签或属性。In this embodiment, the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may further according to the mapping relationship between the structured query language command and the executable file object. The commands and parameters in a structured query language statement are converted into tags or attributes of executable file objects such as Java objects.
具体地,上述电子设备首先可以将结构化查询语言语句映射为可执行文件的执行客户端对象,如sqlMapClient对象,在该执行客户端对象中,上述电子设备可以将结构化查询语言语句中的命令作为对象标签,如命令select作为select标签;接着,通过可执行文件的执行客户端对象,上述电子设备可以获取上述对象标签的属性,如selecet标签的id属性,属性值可以为要查询的SQL数据库的标识;然后,上述电子设备可以将上述对象标签的属性对应的结构化查询语言语句转换成映射声明对象(如MappedStatement对象)。Specifically, the electronic device may first map the structured query language statement to an execution client object of the executable file, such as an sqlMapClient object, where the electronic device may use a command in the structured query language statement. As an object tag, such as the command select as a select tag; then, through the executable client object of the executable file, the electronic device can obtain the attribute of the object tag, such as the id attribute of the selecet tag, and the attribute value can be the SQL database to be queried. And the electronic device may convert the structured query language statement corresponding to the attribute of the object tag to a mapping declaration object (such as a MappedStatement object).
在本实施例的一些可选实现方式中,上述电子设备还可以检测数据查询请求中的查询条件,其中,查询条件可以包括查询关键字和条件值。然后,上述电子设备可以将这些查询条件中的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将所述结构化查询语言语句转换成可执行文件对象。可选地,对于结构化查询语言语句的查询条件,上述电子设备可以通过映射对象将其以键值对(key-value)的形式保存,其中,所述键值对中键(key)可以为查询关键字,值(value)可以为查询关键字对应的条件值。例如,对于查询条件“支付状态为支付成功(如status=1)”,以键值对形式存储时,“键”可以为查询关键字支付状态(或status等),“值”可以为条件值支付成功(或数值1 等)。In some optional implementation manners of the embodiment, the electronic device may further detect a query condition in the data query request, where the query condition may include a query keyword and a condition value. Then, the electronic device may respectively use the query keyword and the condition value in the query conditions as labels and attributes of the executable file object to convert the structured query language statement into an executable file object. Optionally, for the query condition of the structured query language statement, the electronic device may save the key-value in the form of a key-value by using a mapping object, where the key-value pair key may be The query keyword, the value (value) can be the condition value corresponding to the query keyword. For example, for the query condition "payment status is payment success (such as status=1)", when stored in the form of a key-value pair, the "key" can be the payment status (or status, etc.) of the query keyword, and the "value" can be the condition value. The payment was successful (or a value of 1, etc.).
通过该步骤,上述电子设备可以完成可执行文件对结构化查询语言语句的获取。Through this step, the electronic device can complete the acquisition of the structured query language statement by the executable file.
步骤203,基于预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字。Step 203: Replace the syntax key in the executable file object with the syntax key in the flexible search syntax based on the preset conversion rule.
在本实施例中,生成弹性搜索请求的方法运行于其上的电子设备(例如图1所示的终端设备101、102)还可以预先存储有预设转换规则,进一步将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字。In this embodiment, the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may further store a preset conversion rule in advance, further in the executable file object. The grammar keyword is replaced with a grammar keyword in the elastic search grammar.
这里,预设转换规则可以包括但不限于结构化查询语言中的语法关键字与弹性搜索语法中的语法关键字的对应关系。其中语法关键字可以包括命令关键字(如选择命令的命令关键字select)、连接关键字(如表示连接关系“和”的连接关键字and)等等。例如SQL中的语法关键字“select、where、and、or”,分别对应弹性搜索语法中的语法关键字“query、bool、must、match”等等。Here, the preset conversion rule may include, but is not limited to, a correspondence relationship between a grammar keyword in the structured query language and a grammar keyword in the elastic search grammar. The grammar keyword may include a command keyword (such as a command keyword select of a selection command), a connection keyword (such as a connection keyword indicating a connection relationship "and", and the like). For example, the syntax keywords "select, where, and, or" in SQL correspond to the grammar keywords "query, bool, must, match" in the elastic search grammar, and so on.
以将SQL语句通过Java对象转换成JSON(JavaScript Object Notation)串为例,上述电子设备可以将SQL语句解析为java对象“QueryAction”;再利用“QueryAction”的方法可将SQL语句转换为满足ES语法的Json串。For example, if the SQL statement is converted into a JSON (JavaScript Object Notation) string by a Java object, the above electronic device can parse the SQL statement into a java object "QueryAction"; and then use the "QueryAction" method to convert the SQL statement to satisfy the ES syntax. Json string.
步骤204,将替换语法关键字后的可执行文件对象生成弹性搜索请求。Step 204: Generate an elastic search request by replacing the executable file object after the grammar keyword.
在本实施例中,生成弹性搜索请求的方法运行于其上的电子设备(例如图1所示的终端设备101、102)进一步可以将替换语法关键字后的可执行文件对象生成弹性搜索请求。例如,上述电子设备可以先创建ES客户端对象(如HttpClient),接着根据ES服务器的URL(Uniform Resource Locator,统一资源定位符)生成ES请求。其中,所生成的ES请求可以通过TCP(Transmission Control Protocol传输控制协议)、HTTP(HyperText Transfer Protocol,超文本传输协议)等传输协议发送给ES服务器。In this embodiment, the electronic device (for example, the terminal device 101, 102 shown in FIG. 1) on which the method for generating the elastic search request is run may further generate an elastic search request by the executable file object after replacing the grammar keyword. For example, the foregoing electronic device may first create an ES client object (such as HttpClient), and then generate an ES request according to a URL (Uniform Resource Locator) of the ES server. The generated ES request may be sent to the ES server through a transmission protocol such as TCP (Transmission Control Protocol) or HTTP (HyperText Transfer Protocol).
作为一个应用场景,本实施例的生成弹性搜索请求的方法例如可 以应用于购物类应用客户端。为购物类应用客户端提供支持的后台服务器可以是ES服务器。该购物类应用客户端与ES服务器可以通过TCP、HTTP等传输协议进行通信。如图3a所示,该购物类应用客户端运行于终端300上,在购物类应用客户端首页,标签301的上拉选项框弹出的选项中选择“我的订单”选项,该购物类应用客户端切换显示图3b所示的订单查询页面。图3b所示的订单查询页面显示了订单查询的部分查询关键字“全部”、“下单时间”等。假设用户选择了查询关键字“下单时间”,并在给出的下拉菜单302中选择下单时间限定进行订单查询。检测到用户通过终端300进行的查询操作后,终端300首先可以通过对象关系映射框架(如ORM框架)配置数据查询请求中的参数,生成结构化查询语言(如SQL)语句;接着,终端300可以根据结构化查询语言(如SQL)命令与可执行文件对象(如Java对象)的映射关系,将结构化查询语言语句转换成可执行文件对象(如Json串);然后,终端300可以基于预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;接着,终端300可以将替换语法关键字后的可执行文件对象生成ES请求,并将该ES请求发送至ES服务器进行数据查询。接收到ES服务器反馈的订单信息后,终端设备进一步可以通过其上运行的购物类应用的页面进行展示。As an application scenario, the method for generating an elastic search request in this embodiment may be applied to, for example, a shopping application client. The backend server that provides support for the shopping application client can be an ES server. The shopping application client and the ES server can communicate through a transmission protocol such as TCP or HTTP. As shown in FIG. 3a, the shopping application client runs on the terminal 300, and selects the "My Order" option in the pop-up option of the pull-up option box of the tag 301, the shopping application client. The end switch displays the order inquiry page shown in Figure 3b. The order inquiry page shown in Figure 3b shows the partial query keywords "all", "order time", etc. of the order inquiry. Assume that the user selects the query keyword "order time" and selects the order time limit in the drop-down menu 302 given to perform the order inquiry. After detecting the query operation performed by the user through the terminal 300, the terminal 300 may first configure a parameter in the data query request through an object relationship mapping framework (such as an ORM framework) to generate a structured query language (such as SQL) statement; then, the terminal 300 may The structured query language statement is converted into an executable file object (such as a Json string) according to a mapping relationship between a structured query language (such as SQL) command and an executable file object (such as a Java object); then, the terminal 300 can be based on a preset The conversion rule replaces the syntax key in the executable file object with the syntax key in the elastic search syntax; then, the terminal 300 may generate an ES request by the executable file object after the replacement syntax keyword, and send the ES request to The ES server performs data query. After receiving the order information fed back by the ES server, the terminal device can further display through the page of the shopping application running on the terminal device.
本实施例的生成弹性搜索请求的方法,由于通过可执行文件对象在现有技术基础上自动进行语法转换生成弹性搜索请求,从而可以提高弹性搜索的有效性。The method for generating an elastic search request in this embodiment can improve the effectiveness of the elastic search by automatically generating a flexible search request by performing an automatic conversion of the executable file object based on the prior art.
进一步参考图4,作为对图2所示实施例对应的生成弹性搜索请求的方法的实现,本申请提供了一种生成弹性搜索请求的装置的一个实施例。With further reference to FIG. 4, as an implementation of the method for generating an elastic search request corresponding to the embodiment shown in FIG. 2, the present application provides an embodiment of an apparatus for generating an elastic search request.
如图4所示,本实施例的生成弹性搜索请求的装置400包括:语句生成模块401、转换模块402、替换模块403和请求生成模块404。其中,语句生成模块401可以配置用于响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句;转换模块402可以配置用于根据结构化查 询语言命令与可执行文件对象的映射关系,将上述结构化查询语言语句转换成可执行文件对象;替换模块403可以配置用于按照预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;请求生成模块404可以配置用于将替换语法关键字后的可执行文件对象生成弹性搜索请求。As shown in FIG. 4, the apparatus 400 for generating an elastic search request of the present embodiment includes: a statement generation module 401, a conversion module 402, a replacement module 403, and a request generation module 404. The statement generation module 401 can be configured to generate a structured query language statement by configuring a parameter in the data query request by the object relationship mapping framework in response to detecting the data query request operation of the elastic search; the conversion module 402 can be configured to be configured according to The structured query language command is converted into an executable file object by a mapping relationship between the structured query language command and the executable file object; the replacement module 403 can be configured to use the syntax key in the executable file object according to the preset conversion rule. Replaced with a grammar keyword in the elastic search grammar; the request generation module 404 can be configured to generate an elastic search request for the executable file object after the replacement grammar keyword.
在本实施例的一些可选实现方式中,上述转换模块402还可以包括:检测单元(未示出),可以配置用于检测数据查询请求中的查询条件,其中,上述查询条件包括查询关键字和条件值;转换单元(未示出),可以配置用于将上述查询条件的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将上述结构化查询语言语句转换成可执行文件对象。在一些实现中,上述查询条件的查询关键字及条件值以键值对的形式传递,其中,上述键值对中键为查询关键字,值为查询关键字对应的条件值。In some optional implementation manners of the embodiment, the converting module 402 may further include: a detecting unit (not shown), configured to detect a query condition in the data query request, where the query condition includes a query keyword And a condition value; a conversion unit (not shown), configured to use the query keyword and the condition value of the above query condition as labels and attributes of the executable file object, respectively, to convert the structured query language statement into an executable file File object. In some implementations, the query keyword and the condition value of the query condition are delivered in the form of a key-value pair, wherein the key-value pair key is a query keyword, and the value is a condition value corresponding to the query keyword.
在本实施例的一些可选实现方式中,上述语句生成模块401进一步可以配置用于:响应于检测到弹性搜索的数据查询请求操作,根据数据查询请求操作检测数据查询请求的查询关键字;当上述查询关键字有多个时,通过预设语法将上述查询关键字拼接。In some optional implementation manners of the embodiment, the statement generating module 401 may be further configured to: in response to detecting the data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request operation; When there are multiple query keywords, the above query keywords are spliced by a preset grammar.
在本实施例的一些可选实现方式中,语句生成模块401生成的结构化查询语言语句可以包括检索表名和查询关键字,其中,检索表名与弹性搜索索引名称一致,上述结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。In some optional implementation manners of the embodiment, the structured query language statement generated by the statement generation module 401 may include a retrieval table name and a query keyword, wherein the retrieval table name is consistent with the elastic search index name, and the structured query language statement is The query keyword is consistent with the query keyword of the Elastic Search Language statement.
本领域技术人员可以理解,上述生成弹性搜索请求的装置400还包括一些其他公知结构,例如处理器、存储器等,为了不必要地模糊本公开的实施例,这些公知的结构在图4中未示出。Those skilled in the art will appreciate that the apparatus 400 for generating an elastic search request further includes some other well-known structures, such as a processor, a memory, etc., in order to unnecessarily obscure the embodiments of the present disclosure, these well-known structures are not shown in FIG. Out.
下面参考图5,其示出了适于用来实现本申请实施例的终端设备/服务器的计算机系统500的结构示意图。图5示出的终端设备/服务器仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Referring now to Figure 5, there is shown a block diagram of a computer system 500 suitable for use in implementing a terminal device/server of an embodiment of the present application. The terminal device/server shown in FIG. 5 is merely an example, and should not impose any limitation on the function and scope of use of the embodiments of the present application.
如图5所示,计算机系统500包括中央处理单元(CPU)501,其可以根据存储在只读存储器(ROM)502中的程序或者从存储部分508 加载到随机访问存储器(RAM)503中的程序而执行各种适当的动作和处理。在RAM503中,还存储有系统500操作所需的各种程序和数据。CPU501、ROM 502以及RAM503通过总线504彼此相连。输入/输出(I/O)接口505也连接至总线504。As shown in FIG. 5, computer system 500 includes a central processing unit (CPU) 501 that can be loaded into a program in random access memory (RAM) 503 according to a program stored in read only memory (ROM) 502 or from storage portion 508. And perform various appropriate actions and processes. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also coupled to bus 504.
以下部件连接至I/O接口505:包括键盘、触摸屏、麦克风或扫描器等的输入部分506;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等的输出部分507;包括硬盘等的存储部分508;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分509。通信部分509经由诸如因特网的网络执行通信处理。驱动器510也根据需要连接至I/O接口505。可拆卸介质511,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器510上,以便于从其上读出的计算机程序根据需要被安装入存储部分508。The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a touch screen, a microphone or a scanner, etc.; an output portion 507 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc.; storage including a hard disk or the like Portion 508; and a communication portion 509 including a network interface card such as a LAN card, modem, or the like. The communication section 509 performs communication processing via a network such as the Internet. Driver 510 is also coupled to I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory or the like is mounted on the drive 510 as needed so that a computer program read therefrom is installed into the storage portion 508 as needed.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分509从网络上被下载和安装,和/或从可拆卸介质511被安装。在该计算机程序被中央处理单元(CPU)501执行时,执行本申请的方法中限定的上述功能。需要说明的是,本申请所述的非易失性计算机可读介质可以是非易失性计算机可读信号介质或者非易失性计算机可读存储介质或者是上述两者的任意组合。非易失性计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。非易失性计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,非易失性计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在 本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。In particular, the processes described above with reference to the flowcharts may be implemented as a computer software program in accordance with an embodiment of the present disclosure. For example, an embodiment of the present disclosure includes a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for executing the method illustrated in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication portion 509, and/or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-described functions defined in the method of the present application are performed. It should be noted that the non-transitory computer readable medium described herein may be a non-transitory computer readable signal medium or a non-transitory computer readable storage medium or any combination of the two. The non-transitory computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of non-transitory computer readable storage media may include, but are not limited to, electrical connections having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing. In the present application, a non-transitory computer readable storage medium can be any tangible medium that can contain or store a program, which can be used by or in connection with an instruction execution system, apparatus, or device. In the present application, a computer readable signal medium may include a data signal that is propagated in the baseband or as part of a carrier, carrying computer readable program code. Such propagated data signals can take a variety of forms including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer readable signal medium can also be any computer readable medium other than a computer readable storage medium, which can transmit, propagate, or transport a program for use by or in connection with the instruction execution system, apparatus, or device. . Program code embodied on a computer readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality and operation of possible implementations of systems, methods and computer program products in accordance with various embodiments of the present application. In this regard, each block of the flowchart or block diagram can represent a module, a program segment, or a portion of code that includes one or more of the logic functions for implementing the specified. Executable instructions. It should also be noted that in some alternative implementations, the functions noted in the blocks may also occur in a different order than that illustrated in the drawings. For example, two successively represented blocks may in fact be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts, can be implemented in a dedicated hardware-based system that performs the specified function or operation. Or it can be implemented by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括语句生成模块、转换模块、替换模块和请求生成模块。其中,这些模块的名称在某种情况下并不构成对该单元本身的限定,例如,语句生成模块还可以被描述为“配置用于响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句的模块”。The modules involved in the embodiments of the present application may be implemented by software or by hardware. The described modules may also be provided in the processor, for example, as a processor including a statement generation module, a conversion module, a replacement module, and a request generation module. The names of these modules do not constitute a limitation on the unit itself under certain circumstances. For example, the statement generation module may also be described as "configured to respond to data query request operations that detect elastic search, through object relationships. The mapping framework configures the parameters in the data query request to generate a module for the structured query language statement.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述 发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and a description of the principles of the applied technology. It should be understood by those skilled in the art that the scope of the invention referred to in the present application is not limited to the specific combination of the above technical features, and should also be covered by the above technical features or without departing from the above inventive concept. Other technical solutions formed by arbitrarily combining the equivalent features. For example, the above features are combined with the technical features disclosed in the present application, but are not limited to the technical features having similar functions.

Claims (12)

  1. 一种生成弹性搜索请求的方法,其特征在于,所述方法包括:A method for generating an elastic search request, the method comprising:
    响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句;In response to detecting the data query request operation of the elastic search, configuring the parameter in the data query request through the object relationship mapping framework to generate a structured query language statement;
    根据结构化查询语言命令与可执行文件对象的映射关系,将所述结构化查询语言语句转换成可执行文件对象;Converting the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object;
    按照预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;Replace the grammar keyword in the executable file object with the grammar keyword in the elastic search grammar according to the default conversion rule;
    将替换语法关键字后的可执行文件对象生成弹性搜索请求。An elastic search request is generated from the executable object after replacing the grammar keyword.
  2. 根据权利要求1所述的方法,其特征在于,所述根据结构化查询语言命令与可执行文件对象的映射关系,将所述结构化查询语言语句转换成可执行文件对象包括:The method according to claim 1, wherein the converting the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object comprises:
    检测数据查询请求中的查询条件,其中,所述查询条件包括查询关键字和条件值;Detecting a query condition in the data query request, wherein the query condition includes a query keyword and a condition value;
    将所述查询条件的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将所述结构化查询语言语句转换成可执行文件对象。The query key and the condition value of the query condition are respectively used as tags and attributes of the executable file object to convert the structured query language statement into an executable file object.
  3. 根据权利要求2所述的方法,其特征在于,所述查询条件的查询关键字及条件值以键值对的形式传递,其中,所述键值对中键为查询关键字,值为查询关键字对应的条件值。The method according to claim 2, wherein the query keyword and the condition value of the query condition are transmitted in the form of a key value pair, wherein the key value centering key is a query key, and the value is a query key The condition value corresponding to the word.
  4. 根据权利要求1所述的方法,其特征在于,所述响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句包括:The method according to claim 1, wherein in response to detecting the data query request operation of the elastic search, configuring the parameter in the data query request by the object relationship mapping framework, and generating the structured query language statement comprises:
    响应于检测到弹性搜索的数据查询请求操作,根据数据查询请求操作检测数据查询请求的查询关键字;Responsive to detecting a data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request operation;
    当所述查询关键字有多个时,通过预设语法将所述查询关键字拼接,生成结构化查询语言语句。When there are multiple query keywords, the query keywords are spliced by a preset grammar to generate a structured query language statement.
  5. 根据权利要求1所述的方法,其特征在于,所述结构化查询语言语句包括检索表名和查询关键字,其中,所述结构化查询语言语句的检索表名与弹性搜索索引名称一致,所述结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。The method of claim 1, wherein the structured query language statement comprises a retrieval table name and a query key, wherein the retrieval table name of the structured query language statement is consistent with an elastic search index name, The query keyword of the structured query language statement is consistent with the query keyword of the elastic search language statement.
  6. 一种生成弹性搜索请求的装置,其特征在于,所述装置包括:An apparatus for generating an elastic search request, the apparatus comprising:
    语句生成模块,配置用于响应于检测到弹性搜索的数据查询请求操作,通过对象关系映射框架配置数据查询请求中的参数,生成结构化查询语言语句;a statement generation module configured to, in response to detecting a data query request operation of the elastic search, configuring a parameter in the data query request through the object relationship mapping framework to generate a structured query language statement;
    转换模块,配置用于根据结构化查询语言命令与可执行文件对象的映射关系,将所述结构化查询语言语句转换成可执行文件对象;a conversion module configured to convert the structured query language statement into an executable file object according to a mapping relationship between the structured query language command and the executable file object;
    替换模块,配置用于按照预设转换规则将可执行文件对象中的语法关键字替换为弹性搜索语法中的语法关键字;a replacement module configured to replace a syntax keyword in an executable file object with a syntax keyword in an elastic search syntax according to a preset conversion rule;
    请求生成模块,配置用于将替换语法关键字后的可执行文件对象生成弹性搜索请求。The request generation module is configured to generate an elastic search request for the executable file object after replacing the syntax keyword.
  7. 根据权利要求6所述的装置,其特征在于,所述转换模块包括:The apparatus according to claim 6, wherein the conversion module comprises:
    检测单元,配置用于检测数据查询请求中的查询条件,其中,所述查询条件包括查询关键字和条件值;a detecting unit, configured to detect a query condition in the data query request, where the query condition includes a query keyword and a condition value;
    转换单元,配置用于将所述查询条件的查询关键字及条件值分别作为可执行文件对象的标签和属性,以将所述结构化查询语言语句转换成可执行文件对象。And a conversion unit configured to use the query keyword and the condition value of the query condition as labels and attributes of the executable file object, respectively, to convert the structured query language statement into an executable file object.
  8. 根据权利要求7所述的装置,其特征在于,所述查询条件的查询关键字及条件值以键值对的形式传递,其中,所述键值对中键为查询关键字,值为查询关键字对应的条件值。The apparatus according to claim 7, wherein the query keyword and the condition value of the query condition are transmitted in the form of a key value pair, wherein the key value centering key is a query key, and the value is a query key. The condition value corresponding to the word.
  9. 根据权利要求6所述的装置,其特征在于,所述语句生成模块进一步配置用于:The apparatus according to claim 6, wherein the statement generation module is further configured to:
    响应于检测到弹性搜索的数据查询请求操作,根据数据查询请求操作检测数据查询请求的查询关键字;Responsive to detecting a data query request operation of the elastic search, detecting a query keyword of the data query request according to the data query request operation;
    当所述查询关键字有多个时,通过预设语法将所述查询关键字拼接。When there are multiple query keywords, the query keywords are spliced by a preset grammar.
  10. 根据权利要求6所述的装置,其特征在于,所述结构化查询语言语句包括检索表名和查询关键字,其中,所述结构化查询语言语句的检索表名与弹性搜索索引名称一致,所述结构化查询语言语句的查询关键字与弹性搜索语言语句的查询关键字一致。The apparatus according to claim 6, wherein the structured query language statement comprises a retrieval table name and a query key, wherein the retrieval table name of the structured query language statement is consistent with the elastic search index name, The query keyword of the structured query language statement is consistent with the query keyword of the elastic search language statement.
  11. 一种计算设备,包括:A computing device comprising:
    一个或多个处理器;One or more processors;
    存储装置,用于存储一个或多个程序;a storage device for storing one or more programs;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-5中任一所述的方法。The one or more programs are executed by the one or more processors such that the one or more processors implement the method of any of claims 1-5.
  12. 一种非易失性计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1-5中任一所述的方法。A non-transitory computer readable storage medium having stored thereon a computer program, characterized in that the program, when executed by a processor, implements the method of any of claims 1-5.
PCT/CN2018/082283 2017-06-15 2018-04-09 Method and device for generating elastic search request WO2018228034A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710451970.7 2017-06-15
CN201710451970.7A CN109145014A (en) 2017-06-15 2017-06-15 The method and apparatus for generating elastic searching request

Publications (1)

Publication Number Publication Date
WO2018228034A1 true WO2018228034A1 (en) 2018-12-20

Family

ID=64659423

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082283 WO2018228034A1 (en) 2017-06-15 2018-04-09 Method and device for generating elastic search request

Country Status (2)

Country Link
CN (1) CN109145014A (en)
WO (1) WO2018228034A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988132A (en) * 2021-02-25 2021-06-18 平安科技(深圳)有限公司 Automatic generation method and device of data interface, computer equipment and storage medium

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110888876A (en) * 2019-10-31 2020-03-17 平安科技(深圳)有限公司 Method and device for generating database script, storage medium and computer equipment
CN111026931A (en) * 2019-12-09 2020-04-17 中国建设银行股份有限公司 Data query method, device, equipment and medium
CN111460241B (en) * 2020-04-26 2024-01-23 甬矽电子(宁波)股份有限公司 Data query method and device, electronic equipment and storage medium
CN111522840B (en) * 2020-04-27 2023-08-11 平安科技(深圳)有限公司 Label configuration method, device, equipment and computer readable storage medium
CN112765200A (en) * 2021-01-18 2021-05-07 武汉悦学帮网络技术有限公司 Data query method and device based on Elasticissearch
CN113111356A (en) * 2021-03-09 2021-07-13 深圳市教育信息技术中心(深圳市教育装备中心) Data encryption method, device, equipment and medium
CN114168565B (en) * 2021-12-10 2022-07-08 北京宇信科技集团股份有限公司 Backtracking test method, device and system of business rule model and decision engine

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103399887A (en) * 2013-07-19 2013-11-20 蓝盾信息安全技术股份有限公司 Query and statistical analysis system for mass logs
CN105224633A (en) * 2015-09-24 2016-01-06 北京锐安科技有限公司 Based on solr querying method and the device of sql like language
CN106528797A (en) * 2016-11-10 2017-03-22 上海轻维软件有限公司 DSL query method based on Elasticsearch
CN106649630A (en) * 2016-12-07 2017-05-10 乐视控股(北京)有限公司 Data query method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102004634A (en) * 2009-09-01 2011-04-06 上海杉达学院 Hierarchical business management system
CN102932474B (en) * 2012-11-14 2015-06-17 北京星网锐捷网络技术有限公司 Method, device and system for analyzing message
CN104317964A (en) * 2014-11-14 2015-01-28 中国建设银行股份有限公司 Object-relational mapping method and system based on iBatis
CN104881490B (en) * 2015-06-10 2019-11-22 中科宇图天下科技有限公司 A kind of WEB form data access method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103399887A (en) * 2013-07-19 2013-11-20 蓝盾信息安全技术股份有限公司 Query and statistical analysis system for mass logs
CN105224633A (en) * 2015-09-24 2016-01-06 北京锐安科技有限公司 Based on solr querying method and the device of sql like language
CN106528797A (en) * 2016-11-10 2017-03-22 上海轻维软件有限公司 DSL query method based on Elasticsearch
CN106649630A (en) * 2016-12-07 2017-05-10 乐视控股(北京)有限公司 Data query method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988132A (en) * 2021-02-25 2021-06-18 平安科技(深圳)有限公司 Automatic generation method and device of data interface, computer equipment and storage medium
CN112988132B (en) * 2021-02-25 2021-12-21 平安科技(深圳)有限公司 Automatic generation method and device of data interface, computer equipment and storage medium

Also Published As

Publication number Publication date
CN109145014A (en) 2019-01-04

Similar Documents

Publication Publication Date Title
WO2018228034A1 (en) Method and device for generating elastic search request
CN110019350B (en) Data query method and device based on configuration information
JP7146963B2 (en) APPLET EXECUTION METHOD, APPARATUS, ELECTRONIC DEVICE, AND STORAGE MEDIUM
US9952899B2 (en) Automatically generating execution sequences for workflows
US10318595B2 (en) Analytics based on pipes programming model
US9940396B1 (en) Mining potential user actions from a web page
US11561972B2 (en) Query conversion for querying disparate data sources
US9600567B2 (en) Local context search results improvements
US11689626B2 (en) Transport channel via web socket for ODATA
US20200278969A1 (en) Unified metrics computation platform
CN110109983B (en) Method and device for operating Redis database
CN108959294B (en) Method and device for accessing search engine
CN110806967A (en) Unit testing method and device
CN113515285A (en) Method and device for generating real-time calculation logic data
Li et al. A fast big data collection system using MapReduce framework
US8527580B2 (en) Saving multiple data items using partial-order planning
CN113760240A (en) Method and device for generating data model
CN113779018A (en) Data processing method and device
US11038765B2 (en) Cloud software defined networking application programming interface converter
CN114268558B (en) Method, device, equipment and medium for generating monitoring graph
US20210342400A1 (en) Information search method and apparatus
US10496455B1 (en) Enabling synchronous editable signals in process modeling
CN112181937B (en) Method and device for transferring data
CN112860268B (en) Method and device for hot deployment of templates
CN110807089B (en) Question answering method and device and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18818216

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC , EPO FORM 1205A DATED 20.03.2020.

122 Ep: pct application non-entry in european phase

Ref document number: 18818216

Country of ref document: EP

Kind code of ref document: A1