ES server query method, device and computer-readable storage medium
By analyzing and building an ES query configuration by querying the ES API, we call the ES API to query the ES server, solving the problems of complex encoding and heavy workload when building the ES query interface, and achieving a more efficient development process.
Patent Information
- Application Number
- CN202111597593.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In the era of big data, building a business interface based on Elasticsearch (ES) query requires direct operation of the ES API, resulting in large and complex coding work.
Provides an ES server query method, which receives query configuration through the query object builder, parses and constructs content query conditions, and finally calls the ES application program interface to query the ES server for content to avoid directly operating the ES API.
Reduces coding workload, simplifies the query request construction process, improves development efficiency, and reduces the possibility of errors.
Smart Images

Figure CN114297228B_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the field of data search technology, and in particular to an ES server query method, device and computer-readable storage medium. Background Art
[0002] In the era of big data, people are faced with the problem of searching for key information from massive amounts of data quickly and accurately. Elasticsearch (ES for short) is a distributed, RESTful-style search and data analysis engine with the advantages of real-time search, stability, and reliability.
[0003] ES itself provides structured queries based on JSON. This JSON structure is relatively complex to describe in Java, and most of the actual business scenarios are based on individual field input. Currently, building a business interface based on ES queries requires a series of development in conjunction with the ES API (application programming interface). Developers need to have a full understanding of the API to avoid errors, and the coding workload is very large. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an ES server query method, device and computer-readable storage medium, which can avoid directly operating the ES API to construct a query request, thereby reducing coding work.
[0005] To solve the above technical problems, the present invention provides an ES server query method, comprising the following steps: receiving a query configuration, the query configuration including a query object, a query behavior and input parameters; using a query object builder to parse the query configuration and construct a content query condition, wherein when the input parameter includes a specific parameter carrying an update query behavior for the query object or its attributes, the update query behavior is used to construct the content query condition; and using the query object builder to call an ES application program interface to perform a content query on the ES server according to the content query condition.
[0006] In an embodiment of the present invention, the method further comprises pre-packaging the query object builder and the ES application program interface into a query unit.
[0007] In one embodiment of the present invention, the step of calling the ES application program interface to perform content query on the ES server according to the content query condition includes: when the type of the content query condition is an aggregate query, executing the aggregate query according to the content query condition to obtain a first query result; parsing the first query result; determining whether to perform a second query, and if so, performing a normal query based on specific items of the first query result to obtain a second query result; and combining the first query result and the second query result as an aggregate query result.
[0008] In one embodiment of the present invention, the step of performing an ES general query based on a specific item of the first query result includes: using a key list of a primary bucket as an input parameter ID list of the general query.
[0009] In an embodiment of the present invention, the step of calling the ES application program interface to perform content query on the ES server according to the content query condition includes: when the type of the content query condition is a common query, executing the common query according to the content query condition to obtain a common query result.
[0010] In an embodiment of the present invention, the method further comprises: using a query object builder to perform a quantity query based on the content query condition, assembling the results of the content query and the quantity query, and constructing a return result.
[0011] In an embodiment of the present invention, the step of parsing the query configuration includes: parsing the query configuration to generate an object query array based on an annotation description of the query behavior.
[0012] In one embodiment of the present invention, the step of constructing the content query condition includes: standardizing the input parameters of the query configuration to inherit one or more common parameters, and the specific parameters are included in the common parameters; determining whether the input parameters include the specific parameters, and if so, using the update query behavior in the specific parameters to replace the query behavior in the object query array; and assembling the query condition based on the object query array.
[0013] In an embodiment of the present invention, the step of constructing the content query condition includes: determining whether the query object contains a search behavior attribute configuration of a parent-child index, and if so, determining the attribute settings of the parent-child index.
[0014] The present invention also proposes an ES server query device, comprising a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the method as described above.
[0015] The present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned method when executed by a processor.
[0016] Compared with the prior art, the present invention configures the query object builder to parse the query configuration and construct content query conditions, and then calls the ES API according to the content query conditions to perform content query on the ES server to obtain query results. Since the code of the query object builder is fixed and does not need to be changed according to different query requirements, the code writing work can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are included to provide a further understanding of the present application. They are included and constitute a part of the present application. The accompanying drawings illustrate embodiments of the present application and together with the present specification serve to explain the principles of the present invention. In the accompanying drawings:
[0018] Figure 1 It is an exemplary implementation environment according to an embodiment of the present application.
[0019] Figure 2 It is a flow chart of a query method according to an embodiment of the present application.
[0020] Figure 3 This is a flowchart of performing an ES query on an ES server according to an embodiment of the present application.
[0021] Figure 4 It is a flowchart of constructing content query conditions according to an embodiment of the present application.
[0022] Figure 5 4 is a hardware structure diagram of a query device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for the description of the embodiments. Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. Unless it is obvious from the language environment or otherwise explained, the same reference numerals in the figures represent the same structure or operation.
[0024] As shown in this application and claims, unless the context clearly indicates an exception, the words "a", "an", "an" and / or "the" do not refer to the singular and may also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.
[0025] Unless otherwise specifically stated, the relative arrangement of the parts and steps set forth in these embodiments, numerical expressions and numerical values do not limit the scope of the application. The technology, method and equipment known to those of ordinary skill in the relevant art may not be discussed in detail, but in appropriate cases, the technology, method and equipment should be considered as a part of the authorization specification. In all examples shown and discussed here, any specific value should be interpreted as being merely exemplary, rather than as a limitation. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar reference numerals and letters represent similar items in the following drawings, and therefore, once a certain item is defined in an accompanying drawing, it does not need to be further discussed in subsequent drawings.
[0026] In addition, it should be noted that the use of words such as "first" and "second" to define components is only for the convenience of distinguishing the corresponding components. If not otherwise stated, the above words have no special meaning and cannot be understood as limiting the scope of protection of this application. In addition, although the terms used in this application are selected from well-known and commonly used terms, some terms mentioned in the specification of this application may be selected by the applicant at his or her discretion, and their detailed meanings are explained in the relevant parts of the description of this article. In addition, it is required to understand this application not only by the actual terms used, but also by the meaning implied by each term.
[0027] The embodiments of the present application describe an ES server query method and apparatus. According to the embodiments of the present application, taking into account the relative certainty of ES query fields and scenarios, a descriptive query interface is provided for query configuration. The query configuration can be passed to a query object builder to construct a specific query request. The query object builder can call the ES API to query the ES server and obtain query results.
[0028] Figure 1 is an exemplary implementation environment according to an embodiment of the present application. Figure 1 As shown, the exemplary implementation environment includes a client 100, an ES server 200, and a network 300. The client 100 may be a smart phone, a tablet computer, a laptop, a personal computer (PC), and various smart devices. The client 100 may be connected to the ES server 200 through the network 300, and the network 300 may be a local area network or a wide area network. The ES server 200 may be a public cloud server or a private cloud server. The client 100 is equipped with a program required to access the ES server 200, such as the ES API 121. One or more query interfaces, such as Figure 1The query interfaces 110a, 110b and 110c shown are constructed to provide users with the required query services. The query interface may include query objects, query behaviors and input parameters, and these query configurations can be written by users when defining the query interface. The query object is the data that needs to be queried. The query behavior is a description of the query attributes, and the specific behaviors include: multi-attribute combination method MUST / SHOULD / MUST_NOT / FILTER, ES index fields and index field types corresponding to the attributes, word segmentation methods for performing searches, search types (fuzzy queries / precise queries / range queries / term queries / regular matches / multi-field matches / id queries / geographic distances / …), nested paths, CharFilter (pre-processing of search inputs), multi-field queries, aggregate query tags, etc. The input parameters are the attributes of the query object. For example, for the hospital object, the input parameters include but are not limited to address, name, grade, indications, etc. An exemplary query interface, the code is as follows:
[0029] @PostMapping(" / search")
[0030] @AntiReptile
[0031] @ApiOperation(value = " / Search site records", tags = {"search"})
[0032] public PageInfo searchSite(@RequestBody SearchInstDTO searchInstDT
[0033] O){
[0034] return searchInstitutionService.searchByAnnotation(searchInstDTO);
[0035] }
[0036] Among them, searchInstDTO is the query object, and its exemplary content is as follows:
[0037] @QueryField(columnType="text",
[0038] charFilters={@CharFilter()},
[0039] multiQuery={@QueryDSL(queryType=ESQueryTypeEnum.MULTI_M
[0040] ATCH,analyzer=EsAnalyzerEnum.STANDARD,op=OperatorEnum.AN
[0041] D,fields={"institutionName^3.0","institutionNames"}),
[0042] @QueryDSL(queryType=ESQueryTypeEnum.REGEX,fieldName="advantages")},
[0043] matchFactor = @Factor()
[0044] private String keyword;
[0045] / **
[0046] *projectIndications is the multiple structured original indications in the project table
[0047] Indications Summary
[0048] * /
[0049] The query behavior includes multi-field query (multiQuery). In this example, the query behavior is described by JAVA annotation. The input parameters include keyword.
[0050] @QueryField(value="projectIndications",columnType="text",type="In
[0051] dexRegister.JoinConstants.INST_PROJECT_CHILD,queryType=ESQue
[0052] ryTypeEnum.REGEX,matchFactor=@Factor(target="indications"))
[0053] @ApiModelProperty("Indication name, multiple names separated by commas")
[0054] private String indicationName;
[0055] The query behavior includes a common query. In this example, the query behavior is described by JAVA annotations. The input parameters include indicationName.
[0056] The query configuration may be passed by the query interface to the query object builder 122. For example, the query interface may call the query object builder 122 through the following interface.
[0057] / **
[0058] * Aggregate paging query
[0059] *@param indexInfo
[0060] *@param searchBaseDTO
[0061] * @return
[0062] * /
[0063] PageInfo <Map<String,Object> >aggregatePage(IndexInfo indexInfo,SearchBaseDTO searchBaseDTO);
[0064] / **
[0065] *Normal paging query
[0066] *@param indexInfo
[0067] *@param searchBaseDTO
[0068] * @param clazz
[0069] * @param <t>
[0070] *@return
[0071] * /
[0072] <T extends IndexBaseDTO>PageInfo <t>page(IndexInfo indexInfo,SearchBaseDTO searchBaseDTO,Class <t>clazz);
[0073] / **
[0074] *Query based on IdList
[0075] *@param indexInfo
[0076] * @param ids
[0077] * @return
[0078] * /
[0079] List <Map<String,Object> >getByIds(IndexInfo indexInfo,List <string>ids);
[0080] The query object builder 122 is included in the aggregatePage, page and getByIds instances. searchBaseDTO is the query object.
[0081] The query object builder 122 is configured to parse the query configuration and construct the content query conditions, and then call the ES application program interface 121 according to the content query conditions to perform a content query on the ES server 200 to obtain the query results. Advantageously, the code of the query object builder 122 is fixed and does not need to be changed according to different query requirements, thereby reducing the code writing work. Moreover, the content query conditions required for the query request are constructed by the object builder 122 rather than the ES application program interface 121, avoiding the direct operation of the ES application program interface 121 to construct the query request.
[0082] In one embodiment, the query object builder 122 and the ES application program interface 121 are pre-packaged as a query unit 120. In this way, each query interface can directly call the query unit 120 to implement the required query request.
[0083] In one embodiment, the input parameters can be changed dynamically and passed to the query object builder 122, so as to dynamically generate different content query conditions. In an exemplary manner, the input parameters include a specific parameter that carries the update query behavior for the query object or its attributes. For example, this specific parameter is a hint parameter. Some exemplary codes of the hint parameter are as follows:
[0084] / **
[0085] *Field Name
[0086] * /
[0087] private String fieldName;
[0088] / **
[0089] *bool query method
[0090] * /
[0091] private EsBoolEnum boolManner;
[0092] / **
[0093] *
[0094] * /
[0095] private MultiField multiField;
[0096] / **
[0097] *Query method, when queryTypeAppend=false, replace the default query method, set to true to query in parallel
[0098] * /
[0099] private ESQueryTypeEnum queryType;
[0100] / **
[0101] *Fuzzy query operators OR AND
[0102] * /
[0103] private OperatorEnum operator;
[0104] / **
[0105] *Multiple queries
[0106] * /
[0107] private List <multiquery>multiQueries;
[0108] / **
[0109] *When multiple queries exist, it is suitable to merge with the default single query configuration, the default value is false
[0110] * /
[0111] private boolean mergeSingleQuery;
[0112] / **
[0113] *When multiple queries exist, if the default query also defines multiple queries, whether to replace the default multiple queries, the default is false, that is, merged into the default multiple queries
[0114] * /
[0115] private boolean replaceDefaultMultiQuery;
[0116] In the above code, fieldName is the property of the query object, and the other parts are the update query behavior for the property.
[0117] The hint parameter may be included in some common parameters inherited by the query object and obtained by the query object builder 122 when normalizing the input parameters. When the input parameters include the hint parameter, the query object builder 122 may use the update query behavior for the query object or its attributes in the hint parameter to build the content query condition. For example, the query object builder 122 replaces the query behavior in the object query array generated conventionally with the update query behavior in the hint parameter.
[0118] In the embodiments of the present application, content query types include aggregated queries and ordinary queries (or basic queries). Ordinary queries only need to complete the query result parsing to generate ordinary query results. Aggregate queries perform secondary queries based on the configured primary bucket (bucket, a storage space) key list as the input parameter ID list of the secondary query, and combine the two query results to construct an aggregated query result.
[0119] In addition, quantity query can be performed for paging and pre-arranging pages. Quantity query can obtain the number of results that meet the conditions of aggregate query or general query. The general query result or aggregate query result plus quantity query can complete the data assembly of paging interface.
[0120] Figure 2 is a flow chart of a query method according to an embodiment of the present application. Figure 2 As shown, the method of one embodiment of the present application includes the following steps.
[0121] In step 201, a query configuration is received.
[0122] In this step, for example, Figure 1 Each query interface shown receives a query configuration from a user (e.g., a definer of the query interface). As mentioned above, the query configuration includes a query object, a query behavior, and input parameters. Among them, the input parameters may include an update query behavior predefined by the user for the query object or one or more attributes thereof. This update query behavior is different from the original corresponding query behavior in its corresponding query interface.
[0123] In step 202, a query object builder is used to parse the query configuration and construct content query conditions.
[0124] In this step, for example, Figure 1 The query object builder 122 parses the query configuration and builds content query conditions according to the parsing result. The step of parsing the query configuration may include parsing the query configuration, especially the query behavior, to generate an object query array based on the annotation description of the query behavior.
[0125] Here, when the input parameters include a specific parameter (such as the hint parameter mentioned above) carrying an update query behavior of a query object or its attributes, the query object builder 121 further uses the update query behavior to build a content query condition.
[0126] In one embodiment, this step 202 also includes determining whether the query object contains a search behavior attribute configuration of a parent-child index, and if so, determining the attribute settings of the parent-child index. For example, when the query object is a parent-child index, the query condition needs to include a description of querying the parent index or the child index.
[0127] In step 203, the query object builder is used to call the ES application program interface to perform content query on the ES server according to the content query condition.
[0128] In this step, for example, Figure 1 The query object builder 122 calls the ES API 121 to perform a content query on the ES server 200 according to the constructed content query condition, thereby obtaining a query result.
[0129] Figure 3 1 is a flowchart of performing an ES query on an ES server according to an embodiment of the present application. Figure 3 As shown, the query process of this embodiment can be executed by the object builder 122 and includes the following steps.
[0130] In step 301 , it is determined whether the type of the content query condition is an aggregate query. If the result is yes, step 302 is executed; otherwise, step 307 is executed.
[0131] In step 302, an aggregate query is performed according to the content query condition to obtain a first query result.
[0132] In this step, the object builder 122 needs to call the ES API 121 to query the ES server 200 and obtain the query result returned by the ES server 200.
[0133] In step 303, the first query result is parsed.
[0134] Aggregate query can include Metric, Bucketing, Matrix, Pipeline and other query methods, the first two of which are commonly used. The result of aggregate query includes a result set that meets the conditions.
[0135] In step 304 , it is determined whether to perform a second query. If so, the process proceeds to step 305 ; otherwise, the process proceeds to step 308 .
[0136] In step 305, a general query is performed based on the specific items of the first query result to obtain a second query result.
[0137] Typically, an aggregate query requires a second query to query the properties of each item in the result set. A normal query can be performed based on an item in the first query result as a condition to obtain the aforementioned properties. For example, the key list of the primary bucket is used as the input parameter ID list of the normal query. This query does not require the object builder 122 to reconstruct the content query condition, but directly calls the ID query function of the ES API 121 to perform an ES query.
[0138] In step 306, the first query result and the second query result are combined as an aggregated query result.
[0139] In step 307, a common query is performed according to the content query condition to obtain a common query result.
[0140] In step 308, the query results are parsed and assembled, and serialized into objects.
[0141] As a supplement, the aforementioned process also includes performing an ES quantity query based on the constructed content query condition using the query object builder 122. After obtaining the quantity query result, the results of the content query and the quantity query are assembled to construct a return result.
[0142] Based on the structure of content query and quantity query, the query results can be displayed in pages on the page of the client 100. In addition, the number of pages can be determined according to the total number of results and the number of results per page.
[0143] Figure 4 is a flowchart of constructing content query conditions according to an embodiment of the present application. Figure 4 As shown, the query process of this embodiment can be executed by the object builder 122 and includes the following steps.
[0144] In step 401, input parameters of the query configuration are standardized.
[0145] In this step, one or more common parameters inherited by the query object may be obtained through input parameter standardization.
[0146] In step 402 , it is determined whether the input parameters include specific parameters. If yes, the process proceeds to step 403 , otherwise, the process proceeds to step 404 .
[0147] Here, the specific parameter is a parameter that carries an update query behavior for the query object or its attribute, and a hint parameter is usually selected.
[0148] In step 403, the query behavior in the object query array is replaced with the update query behavior in the specific parameter.
[0149] Here, the object query array is generated by parsing the query configuration. In this step, the query behavior in the object query array is replaced.
[0150] At step 404, query conditions are assembled based on the object query array.
[0151] Here, if step 403 is followed to step 404, then the query condition with the query behavior replaced is obtained. Thus, the query condition changed by the specific parameter input by the user can be obtained.
[0152] In step 405 , it is determined whether it is an aggregate query, if so, proceed to step 406 , otherwise it is a common query and proceed to step 407 .
[0153] At step 406, polymerization conditions are assembled.
[0154] In step 407, a content query condition is constructed.
[0155] Here, the content query condition may be the common query condition obtained in step 404 , or may be the aggregate query condition obtained in step 406 .
[0156] Flowcharts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, various steps may be processed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or more operations may be removed from these processes.
[0157] The ES server query method described above in this application can be instantiated as a computer program code and used in, for example, Figure 5 The device shown is maintained and executed to implement the ES server query device of the present application. Figure 5 As shown, the client 100 includes an internal communication bus 101, a processor 102, a hard disk 103, a read-only memory (ROM) 104, a random access memory (RAM) 106 and a communication port 107. The internal communication bus 101 can realize data communication between query device components. The processor 102 can execute programs to control the device workflow. In some embodiments, the processor 102 can be composed of one or more processors. When implemented as a personal computer, the client 100 may include a hard disk 103. The communication port 107 can realize data communication between the client 100 and the outside. In some embodiments, the client 100 can send and receive information and data from the network through the communication port 107. The client 100 may also include different forms of program storage units and data storage units, such as a read-only memory 104 and a random access memory 106, which can store various data files used for computer processing and / or communication, and possible program instructions executed by the processor 102, such as a query interface and a query unit.
[0158] The basic concepts have been described above. Obviously, for those skilled in the art, the above invention disclosure is only used as an example and does not constitute a limitation of the present application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements and amendments to the present application. Such modifications, improvements and amendments are suggested in the present application, so such modifications, improvements and amendments still belong to the spirit and scope of the exemplary embodiments of the present application.
[0159] At the same time, the present application uses specific words to describe the embodiments of the present application. For example, "one embodiment", "an embodiment", and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of the present application. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more in different positions in this specification does not necessarily refer to the same embodiment. In addition, some features, structures or characteristics in one or more embodiments of the present application can be appropriately combined.
[0160] Some aspects of the present application may be performed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The above hardware or software may be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". The processor may be one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or combinations thereof. In addition, various aspects of the present application may be represented as computer products located in one or more computer-readable media, which include computer-readable program codes. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disks, floppy disks, tapes, etc.), optical disks (e.g., compact disks CDs, digital versatile disks DVDs, etc.), smart cards, and flash memory devices (e.g., cards, sticks, key drives, etc.).
[0161] A computer-readable medium may include a propagated data signal containing computer program code, such as in baseband or as part of a carrier wave. The propagated signal may have a variety of manifestations, including electromagnetic, optical, etc., or a suitable combination. A computer-readable medium may be any computer-readable medium other than a computer-readable storage medium, which may be connected to an instruction execution system, device or apparatus to communicate, propagate or transmit a program for use. The program code on the computer-readable medium may be propagated via any suitable medium, including radio, cable, fiber optic cable, radio frequency signal, or similar medium, or any combination of the above mediums.
[0162] Similarly, it should be noted that in order to simplify the description of the disclosure of this application and thus help understand one or more embodiments of the invention, in the above description of the embodiments of this application, multiple features are sometimes combined into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the object of this application are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.
[0163] In some embodiments, numbers are used to describe the quantity of components and attributes. It should be understood that such numbers used to describe the embodiments are modified by the modifiers "about", "approximately" or "substantially" in some examples. Unless otherwise specified, "about", "approximately" or "substantially" indicate that the numbers are allowed to vary by ±20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximate values, which may change according to the required features of individual embodiments. In some embodiments, numerical parameters should take into account the specified significant digits and adopt the general method of retaining digits. Although the numerical domains and parameters used to confirm the breadth of their range in some embodiments of the present application are approximate values, in specific embodiments, such numerical values are set as accurately as possible within the feasible range.
[0164] Although the present application has been described with reference to the current specific embodiments, ordinary technicians in this technical field should recognize that the above embodiments are only used to illustrate the present application, and various equivalent changes or substitutions may be made without departing from the spirit of the present application. Therefore, as long as the changes and modifications to the above embodiments are within the essential spirit of the present application, they will fall within the scope of the claims of the present application.< / multiquery> < / string> < / t> < / t> < / t>
Claims
1. A method for querying an ES server, comprising the following steps: receiving a query configuration, wherein the query configuration includes a query object, a query behavior, and input parameters; Parsing the query configuration and constructing content query conditions using a query object builder, wherein when the input parameter includes a specific parameter of an update query behavior carrying the query object or its attributes, constructing the content query condition using the update query behavior; as well as Using the query object builder to call the ES application program interface to query the ES server for content according to the content query conditions, including the following steps: When the type of the content query condition is an aggregate query, performing an aggregate query according to the content query condition to obtain a first query result; parsing the first query result; Determine whether to perform a second query, and if so, perform a common query based on the specific items of the first query result to obtain the second query result; Combining the first query result and the second query result as an aggregated query result; When the type of the content query condition is a common query, a common query is performed according to the content query condition to obtain a common query result.
2. The method according to claim 1, characterized in that The method also includes pre-packaging the query object builder and the ES application program interface into a query unit.
3. The method according to claim 1, characterized in that The step of performing an ES general query based on a specific item of the first query result includes: using the key list of the primary bucket as an input parameter ID list of the general query.
4. The method according to claim 1, characterized in that Also includes: Use the query object builder to perform a quantity query based on the content query condition, assemble the results of the content query and the quantity query, and construct a return result.
5. The method according to claim 1, characterized in that The steps of parsing the query configuration include: Based on the annotation description of the query behavior, the query configuration is parsed to generate an object query array.
6. The method according to claim 5, characterized in that The steps of constructing the content query condition include: normalizing input parameters of the query configuration to inherit one or more common parameters, the specific parameters being included in the common parameters; Determine whether the input parameters include the specific parameter, and if so, use the update query behavior in the specific parameter to replace the query behavior in the object query array; Assemble query conditions based on the object query array.
7. The method according to claim 1 or 5, characterized in that The steps of constructing the content query condition include: It is determined whether the query object contains the search behavior attribute configuration of the parent-child index, and if so, the attribute settings of the parent-child index are determined.
8. An ES server query device, comprising: a memory for storing instructions executable by a processor; as well as A processor, configured to execute the instructions to implement the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
An information display method and device
CN109918594A
Data query method and device, equipment and medium
CN111259044A