A data retrieval method, device, equipment, and storage medium

Through the pre-built search statement template, the combined matching pattern is used to generate search statements, which solves the problem that the ES engine needs to modify the configuration file to support accurate and fuzzy queries, and realizes the support of two query types without modifying the configuration file, reducing the learning and work burden of developers.

CN115309954BActive Publication Date: 2025-05-30CSC FINANCIAL CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211055306.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-30
Publication Date
2025-05-30
Estimated Expiration
2042-08-30

AI Technical Summary

Technical Problem

In the prior art, the ES engine needs to modify the configuration file to support both precise and fuzzy queries, which leads to developers need to master the underlying configuration principles, increasing learning costs and workload.

Method used

Through the pre-constructed search statement template, using the matching pattern combined in or in a way, a search statement can be generated that can meet accurate and fuzzy queries, so as to achieve simultaneously supporting accurate and fuzzy queries without modifying the ES engine configuration file.

Benefits of technology

It implements that it can support both precise queries and fuzzy queries without relying on changing the ES engine configuration file, reducing the learning and work burden of developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115309954B_ABST
    Figure CN115309954B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a data retrieval method, device, equipment, and storage medium, which relates to the technical field of information processing. The specific implementation solution is as follows: in response to receiving a retrieval request for a specified resource type, determine the target retrieval term indicated by the retrieval request; obtain a pre-constructed retrieval statement template; use the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the retrieval term to be retrieved; retrieve each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement; based on each target resource, output the retrieval result corresponding to the retrieval request. It can be seen that through this solution, it is possible to support both precise query and fuzzy query without relying on changing the configuration file of the ES engine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information processing, and particularly to a data retrieval method, apparatus, device, and storage medium. Background Art

[0002] Under the trend of the increasing development of big data, there are more and more retrieval scenarios for big data. As a distributed, highly scalable, and highly real-time search and data analysis engine, the ES (Elasticsearch) engine is widely used in various big data retrieval scenarios.

[0003] In the related art, the common query mechanism of the ES engine only supports exact query or fuzzy query. If it is necessary to use the ES engine to support both exact query and fuzzy query simultaneously, it is necessary to modify the mapping setting in the configuration file of the ES engine, and map the retrieval terms to be retrieved into text (text) or keyword (keyword) types simultaneously to achieve simultaneous support for exact query and fuzzy query. However, this method requires developers to fully master the underlying configuration principle of the ES engine, which has high requirements for developers and results in a large amount of learning costs for developers.

[0004] Therefore, there is an urgent need for a data retrieval method applied to the ES engine to achieve simultaneous support for exact query and fuzzy query without relying on changing the configuration file of the ES engine, which has become an urgent technical problem to be solved. Summary of the Invention

[0005] The purpose of the embodiments of the present invention is to provide a data retrieval method, apparatus, device, and storage medium to achieve simultaneous support for exact query and fuzzy query without relying on changing the configuration file of the ES engine. The specific technical solutions are as follows:

[0006] In a first aspect, the embodiments of the present invention provide a data retrieval method applied to an Elasticsearch (ES) engine. The resource library operated by the ES engine includes resources of multiple resource types, and each resource under the same resource type corresponds to the same first field, and the first field corresponding to each resource is a field used to describe the resource. The method includes:

[0007] In response to receiving a retrieval request for a specified resource type, determine the target retrieval term indicated by the retrieval request;

[0008] Obtain a pre-constructed retrieval statement template; wherein, at least the first matching pattern and the second matching pattern combined in an "or" manner are included in the retrieval statement template; the first matching pattern is a retrieval pattern representing a token matching with the retrieval term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the retrieval term to be retrieved;

[0009] Generate a first retrieval statement using a pre - constructed retrieval statement template, with the target retrieval term as the term to be retrieved.

[0010] Retrieve each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement.

[0011] Output the retrieval result corresponding to the retrieval request based on each target resource.

[0012] Optionally, each resource under each resource type also corresponds to at least one second field; where the second field corresponding to each resource is a field representing the content category to which the resource content of this resource belongs; the retrieval statement template also includes a third matching pattern representing an exact match with the option to be screened.

[0013] After receiving a retrieval request for a specified resource type and determining the target retrieval term indicated by the retrieval request, the method further includes:

[0014] Identify whether the retrieval request carries a target screening option; where the target screening option is a field value of a second field.

[0015] The step of generating a first retrieval statement using a pre - constructed retrieval statement template, with the target retrieval term as the term to be retrieved, includes:

[0016] If the detection request carries a target screening option, use the first matching pattern and the second matching pattern included in the pre - constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved, and use the third matching pattern to generate a second retrieval statement with the target screening option as the option to be screened.

[0017] Correspondingly, the step of retrieving each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement, includes:

[0018] Retrieve each resource to be utilized from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding second field matches the second retrieval statement.

[0019] Retrieve each target resource from each resource to be utilized, where the field value of the corresponding first field matches the first retrieval statement.

[0020] Optionally, the step of outputting the retrieval result corresponding to the retrieval request based on each target resource includes:

[0021] For each of the target resources, score the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource, to obtain a scoring value; wherein, the hit degree corresponding to each field value represents the number of characters of the field value that hits the target search term.

[0022] Sort the target resources in descending order of the scoring values of the target resources.

[0023] Output the sorted target resources.

[0024] Optionally, the scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource to obtain a scoring value includes:

[0025] Score the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, to obtain a scoring value; wherein, the popularity of each resource represents the usage value of the resource.

[0026] Optionally, there are multiple first fields, and each first field corresponds to a first weight value; the popularity corresponds to a second weight value;

[0027] The scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource to obtain a scoring value includes:

[0028] Score the resource respectively based on the hit degree corresponding to the field value of each first field corresponding to the resource, to obtain multiple first scores;

[0029] Score the resource according to the popularity of the resource, to obtain a second score;

[0030] Based on the first weight values corresponding to the respective first fields and the second weight value corresponding to the popularity, perform weighted summation on the first scores and the second score, to obtain the scoring value of the resource.

[0031] In a second aspect, an embodiment of the present invention provides a data retrieval device, which is applied to an Elasticsearch (ES) engine. The resource library operated by the ES engine includes resources of multiple resource types. Each resource under the same resource type corresponds to the same first field, and the first field corresponding to each resource is a field for describing the resource. The device includes:

[0032] A determination module, configured to determine a target search term indicated by the retrieval request in response to receiving a retrieval request for a specified resource type; obtain a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing word segmentation matching with a term to be retrieved, and the second matching pattern is a retrieval pattern representing at least matching with the term to be retrieved;

[0033] A generation module, configured to generate a first retrieval statement with the target search term as the term to be retrieved by using the pre-constructed retrieval statement template;

[0034] A retrieval module, configured to retrieve each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement;

[0035] An output module, configured to output a retrieval result corresponding to the retrieval request based on each target resource.

[0036] Optionally, each resource under each resource type further corresponds to at least one second field; wherein, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs; the retrieval statement template further includes a third matching pattern representing exact matching with a term to be screened;

[0037] The apparatus further includes:

[0038] An identification module, configured to identify whether a target screening option is carried in the retrieval request after the determination module executes the step of determining the target search term indicated by the retrieval request in response to receiving a retrieval request for a specified resource type; wherein, the target screening option is a field value of a second field;

[0039] The generation module is specifically configured to:

[0040] If the detection request carries a target screening option, generate a first retrieval statement with the target search term as the term to be retrieved by using the first matching pattern and the second matching pattern included in the pre-constructed retrieval statement template, and generate a second retrieval statement with the target screening option as the term to be screened by using the third matching pattern;

[0041] Correspondingly, the retrieval module includes:

[0042] A first retrieval sub-module, configured to retrieve each resource to be utilized from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding second field matches the second retrieval statement;

[0043] A second retrieval sub-module, configured to retrieve, from each of the resources to be utilized, each target resource whose field value corresponding to the first field matches the first retrieval statement.

[0044] Optionally, the output module includes:

[0045] A scoring sub-module, configured to score each of the target resources based on the hit degree corresponding to the field value of the first field corresponding to the resource, to obtain a scoring value; wherein, the hit degree corresponding to each field value represents the number of characters of the field value that hits the target retrieval term.

[0046] A sorting sub-module, configured to sort each of the target resources in a descending order of the scoring values of the target resources.

[0047] An output sub-module, configured to output each of the sorted target resources.

[0048] Optionally, the scoring sub-module is specifically configured to:

[0049] Score the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, to obtain a scoring value; wherein, the popularity of each resource represents the usage value of the resource.

[0050] Optionally, there are multiple first fields, and each first field corresponds to a first weight value; the popularity corresponds to a second weight value;

[0051] The scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, to obtain a scoring value includes:

[0052] Score the resource respectively based on the hit degree corresponding to the field value of each first field corresponding to the resource, to obtain multiple first scores;

[0053] Score the resource according to the popularity of the resource, to obtain a second score;

[0054] Perform weighted summation on the first scores and the second score based on the first weight values corresponding to the respective first fields and the second weight value corresponding to the popularity, to obtain the scoring value of the resource.

[0055] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0056] The memory is used to store a computer program;

[0057] A processor, when executing a program stored in a memory, implements the steps of any one of the above-described data retrieval methods.

[0058] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the above-described data retrieval methods are implemented.

[0059] Advantageous effects of the embodiments of the present invention:

[0060] In the solution provided by the embodiment of the present invention, since the pre-constructed retrieval statement template includes a first matching pattern and a second matching pattern combined in an "or" manner, and the first matching pattern is a retrieval pattern representing a token matching with a term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved, and the retrieval result can be returned as long as any one of the matching patterns is satisfied during retrieval. Therefore, after using the pre-constructed retrieval statement template to generate a first retrieval statement with a target retrieval term as the term to be retrieved and using this first retrieval statement to retrieve the resource to be retrieved, among the target resources whose field values of the corresponding first field match this first retrieval statement, there are both resources that are fuzzily matched with the target retrieval term and resources that are precisely matched with the target retrieval term, so that it is possible to support both fuzzy query and precise query simultaneously. It can be seen that through this solution, it is possible to support both precise query and fuzzy query simultaneously without relying on changing the configuration file of the ES engine.

[0061] Of course, when implementing any product or method of the present invention, it is not necessarily required to achieve all the above advantages simultaneously. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other embodiments based on these drawings.

[0063] Figure 1 It is a flowchart of a data retrieval method provided by an embodiment of the present invention;

[0064] Figure 2 It is a flowchart of implementing step S104 provided by an embodiment of the present invention;

[0065] Figure 3 It is a flowchart of implementing step S105 provided by an embodiment of the present invention;

[0066] Figure 4Schematic structural diagram of a data retrieval device provided by an embodiment of the present invention;

[0067] Figure 5 Block diagram of an electronic device for implementing the method provided by an embodiment of the present invention. Specific embodiments

[0068] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art based on this application belong to the scope of protection of the present invention.

[0069] In the related art, if an ES engine is used to implement both precise query and fuzzy query at the same time, it is necessary to modify the mapping settings in the configuration file of the ES engine, and map the retrieval terms to be retrieved into text or keyword types at the same time to support both precise query and fuzzy query. However, this method requires developers to fully master the underlying configuration principle of the ES engine, which has relatively high requirements for developers, resulting in a large amount of learning costs for developers. And when there are many resource types in ES retrieval, it is necessary to modify the mapping settings for each resource type, resulting in a huge modification workload.

[0070] To solve the above problems and implement both precise query and fuzzy query without relying on changing the configuration file of the ES engine, the embodiments of the present invention provide a data retrieval method, device, equipment, and storage medium.

[0071] Next, a data retrieval method provided by an embodiment of the present invention will be introduced first.

[0072] A data retrieval method provided by an embodiment of the present invention can be applied to an ES engine, and the ES engine can run on an electronic device. In specific applications, the electronic device can be a server or a terminal device, which is reasonable. In actual applications, the terminal device can be: a mobile phone, a tablet computer, a desktop computer, etc.

[0073] Specifically, the execution subject of the data retrieval method can be a data retrieval device. In actual applications, when the data retrieval method is applied to an ES engine, the data retrieval device can be a functional plugin running in the ES engine, and the functional plugin can be used to implement data retrieval.

[0074] It should be noted that the resource library operated by the ES engine in the present invention includes resources of multiple resource types, and each type of resource is divided according to the data type. For example, the resource type can be a table, a dictionary, a view, and so on. Each resource under the same resource type corresponds to the same first field, and the first field corresponding to each resource is a field used to describe the resource. Exemplarily, if the resource type is a table, the first fields corresponding to the table can be the table name, table description information, and so on. Exemplarily, if the resource type is a dictionary, the first fields corresponding to the dictionary can be the dictionary name, dictionary alias, dictionary description, and so on. In addition, each resource can be set with a field value corresponding to the first field during storage, so that during retrieval, the retrieval term can be matched with the field value of the first field to obtain the retrieval result.

[0075] Among them, a data retrieval method provided by an embodiment of the present invention may include the following steps:

[0076] In response to receiving a retrieval request for a specified resource type, determine the target retrieval term indicated by the retrieval request;

[0077] Obtain a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing a token matching with the term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved;

[0078] Use the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved;

[0079] Retrieve each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement;

[0080] Based on the respective target resources, output the retrieval result corresponding to the retrieval request.

[0081] In the solution provided by the embodiments of the present invention, since the pre-constructed retrieval statement template includes a first matching pattern and a second matching pattern combined in an "or" manner, the first matching pattern is a retrieval pattern representing a token matching with the term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved. When retrieving, as long as any one of the matching patterns is satisfied, the retrieval result can be returned. Therefore, when using the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved and using this first retrieval statement to retrieve the resource to be retrieved, among the various target resources whose field values of the corresponding first field match this first retrieval statement, there are both resources that are vaguely matched with the target retrieval term and resources that are precisely matched with the target retrieval term, so that it is possible to support both fuzzy query and precise query at the same time. It can be seen that through this solution, it is possible to support both precise query and fuzzy query at the same time without relying on changing the configuration file of the ES engine.

[0082] Next, the data retrieval method provided by the embodiments of the present invention will be introduced with reference to the accompanying drawings.

[0083] As Figure 1 shown, the data retrieval method provided by the embodiments of the present invention may include steps S101 - S105:

[0084] S101, in response to receiving a retrieval request for a specified resource type, determine the target retrieval term indicated by the retrieval request;

[0085] In this embodiment, the specified resource type may be one or more of tables, views, dictionaries, etc. Exemplarily, during the retrieval process, one or more resource types may be selected for retrieval, or none may be selected. If no resource type is selected, at this time, the specified resource type may be the default resource type, and the default resource type may be all resource types, or a certain one or more resource types, etc. In the actual retrieval process, the user can input a retrieval term in the client installed with the ES engine to perform a retrieval, generate a retrieval request carrying the retrieval term, and when the ES engine receives the retrieval request, obtain the retrieval term carried in the retrieval request from the retrieval request and determine it as the target retrieval term indicated by the retrieval request.

[0086] S102, obtain a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing a token matching with the term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved;

[0087] In this embodiment, the pre-constructed retrieval statement template may be a retrieval statement template constructed using the basic retrieval syntax of ES. The retrieval statement template includes a first matching pattern and a second matching pattern combined in an "or" manner. Exemplarily, the should operator in the compound filter bool of ES can be used to combine the first matching pattern and the second matching pattern. Since the should operator can be used for selective matching and the result will be returned only when at least one of the matching patterns is satisfied, the first matching pattern and the second matching pattern can be combined in an "or" manner.

[0088] Exemplarily, the first matching pattern may be the match pattern. The match pattern is used to tokenize the term to be retrieved during retrieval and then perform a matching search according to the tokens. The returned result does not need to exactly match the term to be retrieved, but only needs to match the tokens of the term to be retrieved, thereby enabling fuzzy query. In addition, the first field corresponding to each resource may be one or more. Exemplarily, if the first field is multiple, the first matching pattern may be the multi_match pattern, and the multi_match pattern can implement multi-field matching query, which is equivalent to the query of multiple match patterns.

[0089] Exemplarily, the second matching pattern may be the wildcard pattern. The wildcard pattern is used for wildcard retrieval. By setting a specific wildcard retrieval statement, such as "*term to be retrieved*", where "*" is used to match any string, all results containing the term to be retrieved can be returned, thereby enabling precise query.

[0090] It should be noted that the match pattern and the wildcard pattern are only examples of the first matching pattern and the second matching pattern. In practical applications, the first matching pattern may also be other retrieval patterns that represent matching with the tokens of the term to be retrieved, and the second matching pattern may also be other retrieval patterns that represent at least matching with the term to be retrieved. The embodiments of the present invention are not limited thereto.

[0091] In addition, after the retrieval statement template is constructed, it can be saved in the ES engine so that when subsequent retrieval is performed, the pre-constructed retrieval statement template can be called to generate a retrieval statement for data retrieval.

[0092] S103, use the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved;

[0093] In this embodiment, after obtaining the pre-constructed retrieval statement template in step S102, the target retrieval term can be used as the retrieval term to be retrieved in the retrieval statement template and filled into the retrieval statement template, so as to generate a first retrieval statement corresponding to the target retrieval term. It can be understood that since the retrieval statement template includes a first matching pattern and a second matching pattern combined in an "or" manner, the first retrieval statement is a retrieval statement representing satisfaction of the first matching pattern or the second matching pattern.

[0094] S104. Retrieve each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement;

[0095] It can be understood that since the retrieval request is a retrieval request for a specified resource type, after generating the first retrieval statement, retrieval can be performed from the resources to be retrieved of the specified resource type in the resource library. Moreover, since each type of resource in the resource library corresponds to a first field, which is a field used to describe the resource, during retrieval, each target resource whose corresponding first field's field value matches the first retrieval statement can be retrieved.

[0096] Among them, the field value of the first field matching the first retrieval statement means that the field value of the first field is segmented and matched with the target retrieval term, or at least matches the target retrieval term. It can be understood that since the retrieval result can be returned as long as the field value of the first field meets any matching condition, each target resource whose corresponding first field's field value matches the first retrieval statement includes both resources that are fuzzy-matched with the target retrieval term and resources that are precisely matched with the target retrieval term, so that both fuzzy query and precise query can be supported simultaneously. Moreover, since the target resources include the query results of both fuzzy query and precise query, the number of query results is greatly increased, thus meeting the retrieval requirements in the big data scenario.

[0097] S105. Output the retrieval result corresponding to the retrieval request based on each of the target resources.

[0098] In this embodiment, after retrieving each target resource that matches the first retrieval statement, each of the target resources can be output, and the output target resources are the retrieval results corresponding to the retrieval request. When the target resources are output, they can be output in a random order, or scored for each of the target resources and output in the order of the scores of each of the target resources, and so on. It should be noted that the embodiment of the present invention does not limit the output manner of each of the target resources.

[0099] In the solution provided by the embodiments of the present invention, since the pre-constructed retrieval statement template includes a first matching pattern and a second matching pattern combined in an "or" manner, the first matching pattern is a retrieval pattern representing a token matching with the term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved. When retrieving, as long as any one of the matching patterns is satisfied, the retrieval result can be returned. Therefore, after using the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved and using this first retrieval statement to retrieve the resource to be retrieved, among the various target resources whose field values of the corresponding first field match this first retrieval statement, there are both resources that are vaguely matched with the target retrieval term and resources that are precisely matched with the target retrieval term, so that it is possible to support both fuzzy query and precise query simultaneously. It can be seen that through this solution, it is possible to support both precise query and fuzzy query simultaneously without relying on changing the configuration file of the ES engine.

[0100] Optionally, in another embodiment of the present invention, each resource under each resource type further corresponds to at least one second field; wherein, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs; the retrieval statement template further includes a third matching pattern representing a precise match with the option to be screened.

[0101] In this embodiment, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs. Exemplarily, if the resource type is a table, the second field corresponding to the table may be a field representing the content category to which the content in the table belongs. For example, the content category may be the competent department to which the table belongs, the information system, the business classification, and so on. Exemplarily, if the resource type is a dictionary, the second field corresponding to the dictionary may be a field representing the content category to which the content in the dictionary belongs. For example, the content category may be the business classification to which the dictionary belongs, the source system, and so on. Additionally, each resource may be set with a field value corresponding to the second field during storage, so that during retrieval, it is possible to match the target retrieval term with the field value of the second field to obtain a retrieval result that matches the field value of the second field.

[0102] In addition, the retrieval statement template further includes a third matching pattern representing an exact match with the option to be screened. Exemplarily, the compound filter bool query of ES can be used to combine the third matching pattern with the first and second matching patterns combined in the above-mentioned OR manner, so that when generating a retrieval statement using the retrieval statement template for retrieval later, it is also possible to perform a retrieval on the option to be screened. Exemplarily, the filter query of the third matching pattern can be implemented using the filter operator in bool. Since the filter operator only returns a result when the condition must be met, and the query operation only determines whether the query condition is met, that is, the third matching pattern is satisfied, but does not calculate the score and does not care about the returned sorting problem, the query efficiency will be higher. Therefore, the advantage of the filter query can be utilized to perform a preliminary and exact screening of the resources according to the option to be screened, thereby improving the query efficiency.

[0103] Exemplarily, the third matching pattern can be the term pattern. Before the term pattern performs a retrieval, it does not perform word segmentation on the option to be screened, and the retrieval result must include the complete option to be screened, so that an exact query on the option to be screened can be performed during the retrieval. It should be noted that the term pattern is only an example of the third matching pattern. In practical applications, the third matching pattern can also be other retrieval patterns representing an exact match with the option to be screened. The embodiments of the present invention are not limited thereto.

[0104] Correspondingly, in this embodiment, after determining the target retrieval term indicated by the retrieval request in step S101 in response to receiving a retrieval request for a specified resource type, the method further includes:

[0105] Identifying whether the target option to be screened is carried in the retrieval request; wherein the target option to be screened is the field value of a second field;

[0106] In this embodiment, the field values of the second field corresponding to each resource can all be used as options to be screened. When the user performs a retrieval, an option to be screened can be selected for the retrieval, and this option to be screened is the target option to be screened. When the ES engine receives the retrieval request, it can identify whether the target option to be screened is carried in the retrieval request, so that if so, a preliminary and exact screening of the resources to be retrieved can be performed according to the target option to be screened.

[0107] Correspondingly, in this embodiment, in step S103, generating a first retrieval statement using the pre-constructed retrieval statement template with the target retrieval term as the term to be retrieved may include:

[0108] If the detection request carries a target screening option, use the first matching pattern and the second matching pattern included in the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the retrieval term to be retrieved, and use the third matching pattern to generate a second retrieval statement with the target screening option as the screening option to be screened;

[0109] In this embodiment, if the retrieval request carries a target screening option, when generating the retrieval statement, a first retrieval statement with the target retrieval term as the retrieval term to be retrieved can be generated, and a second retrieval statement with the target screening option as the screening option to be screened can be generated. That is, use the target retrieval term to replace the retrieval term in the first matching pattern and the second matching pattern, and use the target screening option to replace the screening option in the third matching pattern.

[0110] Correspondingly, in this embodiment, as Figure 2 shown, in the above step S104, retrieving each target resource from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding first field matches the first retrieval statement, may include steps S1041 - S1042:

[0111] S1041, retrieve each resource to be utilized from the resources to be retrieved of the specified resource type in the resource library, where the field value of the corresponding second field matches the second retrieval statement;

[0112] S1042, retrieve each target resource from each of the resources to be utilized, where the field value of the corresponding first field matches the first retrieval statement.

[0113] In this embodiment, the field value of the second field matches the second retrieval statement, that is, the field value of the second field exactly matches the target screening option. The field value of the first field value matches the first retrieval statement, that is, the field value of the first field is segmented and matched with the target retrieval term, or at least matches the target retrieval term.

[0114] It can be understood that since each type of resource in the resource library corresponds to a first field and a second field, and the second field is a field representing the content category to which the resource content of the resource belongs, and the first field is a field used to describe the resource, therefore, when retrieving, by first retrieving each resource to be utilized whose field value of the corresponding second field matches the second retrieval statement, and then retrieving each target resource whose field value of the corresponding first field matches the first retrieval statement from each of the resources to be utilized, after a preliminary precise retrieval of the resources in the resource library using the target screening option, a further precise query and fuzzy query for the target retrieval term can be performed on the obtained resources to be utilized, thereby accelerating the retrieval speed.

[0115] It can be seen that through this solution, fast retrieval can be achieved on the basis of supporting both fuzzy query and precise query.

[0116] Alternatively, in another embodiment of the present invention, Figure 3 As shown, the above step S105 finds the search result corresponding to the search request based on each target resource, and may include steps S1051-S1053:

[0117] S1051, for each of the target resources, scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource to obtain a score; wherein the hit degree corresponding to each field value represents the number of characters of the field value that hits the target search term;

[0118] In this embodiment, each target resource can be scored based on the field value of the first field corresponding to each target resource and the number of characters that hit the target search term, so that the target resources with more hit characters have higher scores, thereby making the score of the precise query higher than the score of the fuzzy query.

[0119] It should be noted that, in the actual retrieval process, a custom scoring mechanism can be used to score each target resource, or the default relevance scoring mechanism of the ES engine can be used, such as the TF-IDF (term frequency-inverse document frequency) scoring mechanism to score each target resource. The embodiment of the present invention does not limit the scoring mechanism.

[0120] S1052, sorting the target resources in descending order of their scoring values;

[0121] It can be understood that after scoring the target resources according to the hit degree corresponding to the field value of the first field of each target resource in step S1051, the target resources with a high hit degree have a higher score, so that the score of the precise query is higher than the score of the fuzzy query. Therefore, by sorting the target resources in descending order according to the score, the query results of the precise query with a high hit degree can be ranked higher.

[0122] S1053, outputting the sorted target resources.

[0123] It can be understood that by sorting and outputting each target resource in descending order, resources with high scores can be sorted first, that is, the query results of precise queries are sorted first when output, so that the sorting of the output target resources meets the user's usage needs.

[0124] It can be seen that through this solution, each target resource is scored and sorted before output, so that the query results of the precise query can be sorted first when output, so that the sorting of the output target resources meets the user's usage needs.

[0125] Optionally, in another embodiment of the present invention, scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource in the above step S1051 to obtain the scoring value may include:

[0126] Based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, the resource is scored to obtain a score; wherein the popularity of each resource represents the use value of the resource.

[0127] In this embodiment, the popularity of a resource can be calculated based on the number of visits, favorites, subscriptions, applications, and evaluations of the resource. The higher the popularity of a resource, the more likely it is that the resource is used by most users. It is understandable that since resources with higher popularity are usually frequently visited and used, for most users, resources with higher popularity should be ranked higher than other resources with the same hit degree. Therefore, by adding the popularity of the resource to the score, the resource hit degree and popularity can be comprehensively considered when the score is used for descending sorting, so that the sorting of the search results is more in line with the user's usage needs.

[0128] Optionally, in one implementation, the first field is multiple, and each first field corresponds to a first weight value; the heat corresponds to a second weight value;

[0129] It should be noted that the weight values ​​corresponding to the first fields and the weight values ​​corresponding to the heat can be set by relevant technicians based on experience, and the embodiments of the present invention do not limit this. For example, if a resource type is a table, and the first field corresponding to the resource type of the table is the table name and table description information, the weight values ​​of the table name, table description information and heat can be set to 5, 4, 3, or 4, 3, 5, etc., respectively, which are all reasonable.

[0130] Accordingly, in this implementation, scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource to obtain a scoring value may include steps A1-A3:

[0131] A1, scoring the resource based on the hit degree corresponding to the field value of each first field corresponding to the resource, to obtain multiple first scores;

[0132] That is, the resource is scored according to the hit degree corresponding to the field value of each first field of the resource to obtain multiple first scores. The higher the first score, the higher the degree to which the field value of the first field hits the target search term.

[0133] A2, scoring the resource according to the popularity of the resource to obtain a second score;

[0134] Exemplarily, the popularity of the resource may be directly used as the second score of the resource, or the popularity of the resource may be mapped to a value in a score range of the first score as the second score, and so on.

[0135] A3, based on the first weight value corresponding to each first field and the second weight value corresponding to the popularity, perform weighted summation on the first score and the second score to obtain a scoring value for the resource.

[0136] It can be understood that by setting different weights for different first fields and setting a second weight value for popularity, and performing weighted summation of the first score and the second score according to the first weight value and the second weight value, the scoring value of the resource can be obtained. This allows the scoring value to be used for subsequent descending sorting. Resources with higher popularity can be ranked higher than other resources with the same hit degree, or even higher than other resources with a higher hit degree, thereby making the sorting of retrieval results more in line with user needs.

[0137] It can be seen that through this scheme, by adding popularity to the scoring, when the target resources are subsequently output in descending order of the scoring values, resources with higher popularity are ranked higher than other resources with the same hit degree, thereby making the ranking of the search results closer to the user's needs, thereby improving the user's satisfaction with the resource search.

[0138] In order to better understand the content of the embodiment of the present invention, a specific example of the embodiment of the present invention is introduced below.

[0139] Currently, there are two main solutions based on ES retrieval:

[0140] (I) Using the common query mechanism of the ES engine, all resource types are considered uniformly, different weight values ​​are set for different matching fields (corresponding to the first field above), and the resources to be retrieved in the resource library are sorted according to the hit conditions and scoring values ​​and then output. This retrieval scheme has the following disadvantages:

[0141] (1) It only supports precise query or fuzzy query, but cannot achieve compatibility between the two, resulting in a low number of search results, which is difficult to meet user needs;

[0142] (2) The search results are not sorted and output according to the actual resource usage.

[0143] (2) By modifying the configuration file of ES, precise query and fuzzy query are supported. By modifying the mapping settings, the search terms to be retrieved are mapped into text or keyword types simultaneously to support both precise query and fuzzy query. However, this method requires developers to fully master the underlying configuration principle of the ES engine, which has relatively high requirements for developers, resulting in a large amount of learning cost for developers. Moreover, when there are many resource types retrieved by ES, the mapping settings need to be modified for each resource type, resulting in a huge workload of modification. And even if both types of queries are supported, it cannot guarantee that the results of the precise query are output first, often making users feel that the search is inaccurate.

[0144] In order to quickly meet the user's search expectations through the use of the basic syntax of the ES engine during the ES search process, that is, to output as many search results as possible, and the sorting of the output search results meets the user's daily usage habits, the following solution is adopted in this example:

[0145] First, different resources are divided according to types, and the filtering fields (corresponding to the second field in the above text) and matching fields corresponding to each resource type are confirmed, and weights are set for each matching field. As shown in Table 1 below, the resources to be retrieved in the resource library are divided into multiple resource types, each resource type has different filtering fields and matching fields, weights are set for each matching field, and a heat item indicating whether to participate in scoring is added. Among them, the heat is calculated by weighted calculation based on the access volume, collection volume, subscription volume, application volume, evaluation quantity, etc. of the resource. The higher the heat, the more the resource tends to be the resource used by most users.

[0146]

[0147] Table 1

[0148] Secondly, for different fields, different ES modes are used for matching or scoring. As shown in Table 2 below, for filtering fields, during the actual retrieval process, they are equivalent to the screening options in the retrieval, and the term mode is used for precise matching; for matching fields, usually there is more than one matching field to be retrieved. For example, resource names, resource text descriptions, etc. may all contain the content to be retrieved, and it is very difficult to achieve a complete match at this time. Therefore, a fuzzy matching method is used here, and this fuzzy matching method includes the match mode and the wildcard mode. Among them, the match mode realizes the token matching with the term to be retrieved, and the wildcard mode realizes at least the matching with the term to be retrieved; for numerical scoring fields, the Function_score mode is used for scoring. This Function_score mode considers the weights and popularity of the matching fields of the resources hit together through a custom scoring mechanism.

[0149]

[0150] Table 2

[0151] Thirdly, the modes of various fields are combined by constructing a retrieval statement template. When constructing the retrieval statement template, a bool query is included in the query query. Bool is a composite filter in ES, which can combine multiple query conditions together in a certain logic. The bool filter includes four operators: the must operator: the condition must be matched and contribute to the scoring; the should operator: at least one of the conditions is satisfied and contributes to the scoring; the must_not operator: all conditions are not satisfied and do not contribute to the scoring; the filter operator: the condition must be satisfied, the query result is cached, and the execution efficiency is high, but it does not contribute to the scoring. This solution uses a combined mode of the filter operator and the should operator to achieve the initial precise screening of the screening options, as well as the fuzzy query and precise query of the retrieval term. The program code example of the retrieval statement template is as follows:

[0152]

[0153] Among them, the filtering fields included in the filter are combinations of various term modes. By leveraging the query advantages of the filter, the field values of the filtering fields are queried to match the resources to be utilized with the screening options to be screened, and the resources to be retrieved are initially precisely screened.

[0154] The should mode sets the value of minimum_should_match to 1, that is, sets the minimum match degree to 1, indicating that at least one of the conditions is met and the result is returned, and the search is performed in an or manner. In the should mode, you can configure the multi_match mode and several wildcard modes to query each matching field. Among them, the multi_match mode can realize multi-field matching query, which is equivalent to the query of multiple match modes. In addition, each matching field has a pre-set weight and participates in the hit scoring. The multi_match mode's word segmentation and support for multiple fields can meet the effect of fuzzy query. The wildcard search of the wildcard mode includes complete matching, thereby supporting both precise query and fuzzy query. In addition, the query query will output the score (corresponding to the first score above). When the field value of the matching field is completely hit, or when the field values ​​of multiple matching fields are hit, the higher the calculated score is, the higher it will be when sorting.

[0155] Finally, add the influence factor of popularity and weight the popularity for scoring. The weight value of popularity depends on the specific scenario. Generally, resources with higher popularity represent higher frequency of user use and will be frequently accessed and used. Therefore, for most users, resources with higher popularity should be ranked higher than other resources with the same hit degree, or even higher than other resources with a high hit degree. In the actual retrieval process, you can use the custom scoring mechanism function_score, add the influence factor of popularity and set the weight value of popularity to achieve scoring by adding popularity and obtain the score corresponding to the popularity (corresponding to the second score above). And perform weighted summation of the popularity score and the score output by the above query to obtain the final score.

[0156] It can be seen that through this solution, the search resources are divided into fine-grained categories according to the resource types. Different ES modes are used to match and score different fields. Through simple syntax combinations, fast search that combines fuzzy query and precise query can be achieved with only low-cost ES learning cost. In addition, the search result sorting supports sorting based on popularity, so that the sorting of search results is more in line with the user's usage needs, which can improve the user's satisfaction with resource searches.

[0157] Corresponding to the embodiment of the above method, the embodiment of the present invention further provides a data retrieval device, which is applied to the elastic search ES engine. The resource library operated by the ES engine includes resources of multiple resource types. Each resource under the same resource type has the same first field. The first field corresponding to each resource is a field used to describe the resource; Figure 4 As shown, the device comprises:

[0158] A determination module 410, configured to determine a target search term indicated by the retrieval request in response to receiving a retrieval request for a specified resource type.

[0159] An acquisition module 420, configured to acquire a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing a word segmentation match with a term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved.

[0160] A generation module 430, configured to generate a first retrieval statement with the target search term as the term to be retrieved by using the pre-constructed retrieval statement template.

[0161] A retrieval module 440, configured to retrieve each target resource whose field value of the corresponding first field matches the first retrieval statement from the resources to be retrieved of the specified resource type in the resource library.

[0162] An output module 450, configured to output a retrieval result corresponding to the retrieval request based on each target resource.

[0163] Optionally, each resource under each resource type further corresponds to at least one second field; wherein, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs; the retrieval statement template further includes a third matching pattern representing an exact match with an option to be screened.

[0164] The apparatus further includes:

[0165] An identification module, configured to identify whether a target screening option is carried in the retrieval request after the determination module executes the step of determining a target search term indicated by the retrieval request in response to receiving a retrieval request for a specified resource type; wherein, the target screening option is a field value of a second field.

[0166] The generation module is specifically configured to:

[0167] If the detection request carries a target screening option, generate a first retrieval statement with the target search term as the term to be retrieved by using the first matching pattern and the second matching pattern included in the pre-constructed retrieval statement template, and generate a second retrieval statement with the target screening option as the option to be screened by using the third matching pattern.

[0168] Correspondingly, the retrieval module includes:

[0169] The first retrieval sub-module is used to retrieve each resource to be utilized whose field value of the corresponding second field matches the second retrieval statement from the resources to be retrieved of the specified resource type in the resource library;

[0170] The second retrieval sub-module is used to retrieve each target resource whose field value of the corresponding first field matches the first retrieval statement from each resource to be utilized.

[0171] Optionally, the output module includes:

[0172] The scoring sub-module is used to score each of the target resources based on the hit degree corresponding to the field value of the first field corresponding to the resource, so as to obtain a scoring value; wherein, the hit degree corresponding to each field value represents the number of characters in which the field value hits the target retrieval term.

[0173] The sorting sub-module is used to sort each of the target resources in a descending order of the scoring values of the target resources.

[0174] The output sub-module is used to output each of the sorted target resources.

[0175] Optionally, the scoring sub-module is specifically used for:

[0176] Scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, so as to obtain a scoring value; wherein, the popularity of each resource represents the usage value of the resource.

[0177] Optionally, there are multiple first fields, and each first field corresponds to a first weight value; the popularity corresponds to a second weight value;

[0178] The scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, so as to obtain a scoring value includes:

[0179] Scoring the resource respectively based on the hit degree corresponding to the field value of each first field corresponding to the resource, so as to obtain multiple first scores;

[0180] Scoring the resource according to the popularity of the resource, so as to obtain a second score;

[0181] Performing weighted summation on the first scores and the second score based on the first weight values corresponding to the first fields and the second weight value corresponding to the popularity, so as to obtain the scoring value of the resource.

[0182] An embodiment of the present invention also provides an electronic device, such as Figure 5As shown in the figure, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.

[0183] The memory 503 is used to store computer programs.

[0184] When the processor 501 is used to execute the program stored in the memory 503, it implements the steps of any of the above data retrieval methods.

[0185] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0186] The communication interface is used for communication between the above electronic device and other devices.

[0187] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0188] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0189] In another embodiment provided by the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of any of the above data retrieval methods.

[0190] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, which when running on a computer, causes the computer to execute any one of the data retrieval methods in the above embodiments.

[0191] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).

[0192] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including the element.

[0193] Each embodiment in this specification is described in a related manner. The same or similar parts between the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments.

[0194] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.

Claims

1. A data retrieval method, characterized in that, it is applied to an Elasticsearch (ES) engine, and the resource library operated by the ES engine includes resources of multiple resource types. Each resource under the same resource type corresponds to the same first field, and the first field corresponding to each resource is a field used to describe the resource; the method includes: responding to receiving a retrieval request for a specified resource type, and determining a target retrieval term indicated by the retrieval request; obtaining a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing a token matching with a term to be retrieved, and the second matching pattern is a retrieval pattern representing at least a match with the term to be retrieved; using the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved; retrieving, from the resources to be retrieved of the specified resource type in the resource library, each target resource whose field value of the corresponding first field matches the first retrieval statement; outputting a retrieval result corresponding to the retrieval request based on each target resource; each resource under each resource type further corresponds to at least one second field; wherein, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs; the retrieval statement template further includes a third matching pattern representing an exact match with an option to be screened; after the step of responding to receiving a retrieval request for a specified resource type and determining a target retrieval term indicated by the retrieval request, the method further includes: identifying whether a target screening option is carried in the retrieval request; wherein, the target screening option is a field value of a second field; the step of using the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved includes: if the target screening option is carried in the retrieval request, using the first matching pattern and the second matching pattern included in the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the term to be retrieved, and using the third matching pattern to generate a second retrieval statement with the target screening option as the option to be screened; correspondingly, the step of retrieving, from the resources to be retrieved of the specified resource type in the resource library, each target resource whose field value of the corresponding first field matches the first retrieval statement includes: retrieving, from the resources to be retrieved of the specified resource type in the resource library, each resource to be utilized whose field value of the corresponding second field matches the second retrieval statement; retrieving, from each resource to be utilized, each target resource whose field value of the corresponding first field matches the first retrieval statement.

2. The method according to claim 1, characterized in that, the step of outputting a retrieval result corresponding to the retrieval request based on each target resource includes: For each of the target resources, score the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource, to obtain a score value; wherein, the hit degree corresponding to each field value represents the number of characters in which the field value hits the target search term. Sort the target resources in descending order according to the score values of the target resources. Output the sorted target resources.

3. The method according to claim 2, wherein, the scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource to obtain a score value includes: scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource, to obtain a score value; wherein, the popularity of each resource represents the usage value of the resource.

4. The method according to claim 3, wherein, there are multiple first fields, and each first field corresponds to a first weight value; the popularity corresponds to a second weight value; the scoring the resource based on the hit degree corresponding to the field value of the first field corresponding to the resource and the popularity of the resource to obtain a score value includes: scoring the resource respectively based on the hit degree corresponding to the field value of each first field corresponding to the resource, to obtain multiple first score values; scoring the resource according to the popularity of the resource, to obtain a second score value; performing weighted summation on the first score values and the second score value based on the first weight values corresponding to the respective first fields and the second weight value corresponding to the popularity, to obtain the score value of the resource.

5. A data retrieval device, wherein, applied to an Elasticsearch (ES) engine, the resource library operated by the ES engine includes resources of multiple resource types, each resource under the same resource type corresponds to the same first field, and the first field corresponding to each resource is a field for describing the resource; the device includes: a determination module, configured to, in response to receiving a retrieval request for a specified resource type, determine the target search term indicated by the retrieval request; and obtain a pre-constructed retrieval statement template; wherein, the retrieval statement template at least includes a first matching pattern and a second matching pattern combined in an "or" manner; the first matching pattern is a retrieval pattern representing word segmentation matching with the term to be retrieved, and the second matching pattern is a retrieval pattern representing at least matching with the term to be retrieved; a generation module, configured to generate a first retrieval statement using the pre-constructed retrieval statement template with the target search term as the term to be retrieved; a retrieval module, configured to retrieve, from the resources to be retrieved of the specified resource type in the resource library, each target resource whose field value of the corresponding first field matches the first retrieval statement; an output module, configured to output a retrieval result corresponding to the retrieval request based on the target resources. Each resource under each resource type also corresponds to at least one second field; wherein, the second field corresponding to each resource is a field representing the content category to which the resource content of the resource belongs; the retrieval statement template further includes a third matching pattern representing an exact match with the to-be-screened option; The apparatus further includes: An identification module, configured to, after the determination module executes the step of determining a target retrieval term indicated by the retrieval request in response to receiving a retrieval request for a specified resource type, identify whether a target screening option is carried in the retrieval request; wherein, the target screening option is a field value of a second field; The generation module is specifically configured to: If the retrieval request carries a target screening option, use the first matching pattern and the second matching pattern included in the pre-constructed retrieval statement template to generate a first retrieval statement with the target retrieval term as the to-be-retrieved term, and use the third matching pattern to generate a second retrieval statement with the target screening option as the to-be-screened option; Correspondingly, the retrieval module includes: A first retrieval sub-module, configured to retrieve, from the to-be-retrieved resources of the specified resource type in the resource library, each to-be-utilized resource whose field value of the corresponding second field matches the second retrieval statement; A second retrieval sub-module, configured to retrieve, from each of the to-be-utilized resources, each target resource whose field value of the corresponding first field matches the first retrieval statement.

6. The apparatus according to claim 5, wherein, The output module includes: A scoring sub-module, configured to score each resource among the target resources based on the hit degree corresponding to the field value of the first field corresponding to the resource, to obtain a scoring value; wherein, the hit degree corresponding to each field value represents the number of characters of the field value that hits the target retrieval term; A sorting sub-module, configured to sort the target resources in a descending order of the scoring values of the target resources; An output sub-module, configured to output the sorted target resources.

7. An electronic device, wherein, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used for storing a computer program; The processor, when executing the program stored on the memory, implements the method steps of any one of claims 1-4.

8. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method steps of any one of claims 1-4.

Citation Information

Patent Citations

  • Diversified data searching method

    CN109918396A

  • Query method and device for legal provision content in judgment document

    CN112559674A