Lightweight search engine prompting method and system

By combining the jieba word segmenter and Redis database, the problem of high deployment and operation and maintenance costs of lightweight search engines is solved, efficient Chinese word segmentation support and fast response speed is achieved, lightweight search engine functions are provided, and the cost is reduced. Improved performance.

CN119201969APending Publication Date: 2024-12-27INSPUR SOFTWARE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411233182.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

When implementing lightweight search engines, the existing technology has high deployment and operation and maintenance costs, especially in the case of shortage of server resources, and insufficient support for Chinese word segmentation.

Method used

The jieba word segmenter is used to combine with the Redis database, and the search content is processed through the jieba word segmentation and stored in Redis, which realizes rapid query and sorting, reduces deployment and operation and maintenance costs, and provides Chinese word segmentation support.

Benefits of technology

It realizes lightweight search engine functions, reduces deployment and operation and maintenance costs, provides efficient search speed and excellent Chinese word segmentation support, and controls the response speed within 0.5 seconds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201969A_ABST
    Figure CN119201969A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight search engine prompting method and system, and belongs to the technical field of back-end development.The method comprises the steps that a jieba word segmentation device is introduced into a program; querying a set needing to be searched, and storing the set in a redis database to increase the speed; performing word segmentation on the searched content by using a jieba word segmentation device, filtering out a part containing segmented words from the searched content, and grouping according to the segmented words; traversing the groups of the segmented words, counting the occurrence times of each searched content, sorting, and intercepting the maximum N content as required; traversing the intercepted result, processing the result, packaging the result into a list and returning the result to the front end; and the front end receives the result and then directly renders the result into a list. According to the method, on the premise that the cost is reduced, a lightweight search engine is realized, the deployment and operation and maintenance cost is reduced, and an extremely high search speed is provided based on a redis query function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of backend development, and in particular to a lightweight search engine prompting method and system. Background Art

[0002] The implementation principle of Elasticsearch is mainly divided into the following steps: first, the user submits the data to the Elasticsearch database, and then the corresponding sentence is segmented through the word segmentation controller, and its weight and word segmentation results are stored in the data together. When the user searches for data, the results are ranked and scored according to the weight, and then the returned results are presented to the user. Such rich functions bring additional deployment costs and maintenance costs. If it is a lightweight application, there is no need to pay these additional costs to implement the search prompt function. RedisSearch is a powerful text search and secondary indexing engine built on Redis as one of the modules of Redis. Reids search is written in C language and is extremely fast compared to other open source search engines. It implements a variety of data types and commands, which fundamentally changes what can be done with Redis. Redis search supports search and filtering functions, such as geospatial queries, retrieving only IDs (rather than entire documents), and custom document scoring. Aggregation can combine map, filter, and deuce / group-by operations in custom pipelines, which can run millions of elements in an instant. The Chinese word segmenter used by Redissearch is Friso, but its support for Chinese is not as good as the jieba word segmenter used by Elasticsearch.

[0003] Using Elasticsearch for lightweight services will greatly increase the deployment cost and operation and maintenance cost. It is not a good choice to use Elasticsearch when server resources are scarce. Using redissearch to segment Chinese words will not achieve the desired effect. Summary of the invention

[0004] The technical task of the present invention is to address the above shortcomings and provide a lightweight search engine prompt method and system, which can realize a lightweight search engine while reducing costs, without the need to introduce additional tools or middleware, greatly reducing deployment and operation and maintenance costs, and providing extremely high search speed based on the query function of redis.

[0005] The technical solution adopted by the present invention to solve its technical problem is:

[0006] A lightweight search engine prompt method, the implementation of which includes:

[0007] 1) Introduce the jieba word segmenter into the program;

[0008] 2) Query the collection that needs to be searched and store it in the redis database to increase the speed;

[0009] 3) Use the Jieba word segmenter to segment the searched content, filter out the parts containing the segmented words from the searched content, and group them according to the segmented words;

[0010] 4) Traverse the word grouping, count the number of occurrences of each searched content, sort them, and intercept the largest N as needed;

[0011] 5) Traverse the interception results, process the results, encapsulate the results into a list and return them to the front end;

[0012] 6) After receiving the results, the front end renders them directly into the list.

[0013] The lightweight search engine prompt function based on redis itself and jieba word segmenter only uses redis itself and jieba word segmenter to achieve lightweight search engine function, realize lightweight deployment and lightweight operation and maintenance, and provide good support for Chinese word segmentation. Based only on redis itself, there is no need to install other modules, introduce other tools or middleware, which greatly reduces the deployment and operation and maintenance costs, and the query function based on redis provides extremely high search speed.

[0014] Furthermore, the query requires a collection to be searched, and the collection includes a name and details.

[0015] Furthermore, the query needs to search the collection, store it in the redis database, and store it in the local cache at the same time.

[0016] Furthermore, the number of occurrences of each searched content is sorted from largest to smallest.

[0017] Furthermore, the result is processed to change the color of the segmented words therein.

[0018] Furthermore, the specific implementation steps of this method are as follows:

[0019] S1. Initialize the searched collection, query it from the database for the first time, and then put it into the cache; get the searched collection from the cache;

[0020] Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results;

[0021] S2, filter the data containing the word from the collection and put it into a new collection;

[0022] S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences;

[0023] S4, intercept the first n pieces of data as needed;

[0024] S5, processing the results;

[0025] S6. Return the result.

[0026] The present invention also claims a lightweight search engine prompt system, comprising:

[0027] jieba word segmenter;

[0028] The redis database contains the collection to be searched. The collection to be searched is initialized at the beginning and queried from the redis database for the first time, and can be put into the local cache afterwards;

[0029] The word segmentation module is used to segment the searched content using the Jieba word segmenter, filter out the parts containing the words from the searched content, and group them according to the words;

[0030] A data interception module is used to traverse the word segmentation groups, count the number of occurrences of each searched content, sort them, and intercept the largest N data as needed;

[0031] The word segmentation result processing module is used to traverse the interception results, process the results, encapsulate the results into a list and return them to the front end;

[0032] The front-end display module directly renders the results into a list after receiving them.

[0033] Furthermore, the process of implementing the search prompt in the system is as follows:

[0034] S1. Initialize the searched collection, query it from the redis database for the first time, and then put it into the cache; get the searched collection from the cache;

[0035] Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results;

[0036] S2, filter the data containing the word from the collection and put it into a new collection;

[0037] S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences;

[0038] S4, intercept the first n pieces of data as needed;

[0039] S5, processing the results;

[0040] S6. Return the result.

[0041] The present invention also claims a lightweight search engine prompting device, comprising at least one memory and a processor;

[0042] The at least one memory is used to store a machine-readable program;

[0043] The at least one processor is used to call the machine-readable program to implement the above method.

[0044] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which implement the above method when executed by a processor.

[0045] Compared with the prior art, the lightweight search engine prompt method and system of the present invention has the following advantages:

[0046] Beneficial effects:

[0047] Because the present invention only uses redis, the deployment is extremely lightweight, and only the operation and maintenance cost of redis itself needs to be paid. Java stream operations are used to process data, so the response speed can be controlled within 0.5 seconds in a lightweight system. At the same time, because the Jieba word segmenter is used, the support for Chinese is also excellent enough. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a flowchart of implementing the lightweight search engine prompt method provided by an embodiment of the present invention;

[0049] Figure 2 This is an example diagram of an application effect page of the lightweight search engine prompt method provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0050] An embodiment of the present invention provides a lightweight search engine prompt method, the implementation of which includes:

[0051] 1. Introduce the jieba word segmenter into the program;

[0052] 2. Query the collection that needs to be searched, such as name and details, and store it in the redis database to increase the speed; you can also store it in the local cache.

[0053] 3. Use the Jieba word segmenter to segment the searched content, filter out the parts containing the segmented words from the searched content, and group them according to the segmented words;

[0054] 4. Traverse the word grouping, count the number of times each searched content appears, and sort them from large to small according to the number of times, and intercept the largest N data as needed;

[0055] 5. Traverse the interception results, change the colors of the segmented words, encapsulate the results into a list and return them to the front end;

[0056] 6. After receiving the results, the front end renders them directly into the list.

[0057] like Figure 1 As shown, the specific implementation steps of this method are as follows:

[0058] S1. Initialize the searched collection, query it from the database for the first time, and then put it into the cache; get the searched collection from the cache;

[0059] Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results;

[0060] S2, filter the data containing the word from the collection and put it into a new collection;

[0061] S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences;

[0062] S4, intercept the first n pieces of data as needed;

[0063] S5, processing the results;

[0064] S6. Return the result.

[0065] like Figure 2 As shown, by entering the text "test" in the search box, the five most matching data can be found within 0.5 seconds. After the result processing, the matching Chinese characters can be dyed blue.

[0066] This method is based on the lightweight search engine prompt function of redis itself and jieba word segmenter. It only uses redis itself and jieba word segmenter to achieve lightweight search engine function, lightweight deployment and lightweight operation and maintenance, and provides good support for Chinese word segmentation. It is only based on redis itself, without the need to install other modules, or introduce other tools or middleware, which greatly reduces the deployment and operation and maintenance costs, and provides extremely high search speed based on the query function of redis.

[0067] The embodiment of the present invention also provides a lightweight search engine prompt system, including:

[0068] jieba word segmenter;

[0069] The redis database contains the collection to be searched, such as name and details. The collection to be searched is initialized at the beginning and queried from the redis database for the first time, and can be put into the local cache afterwards;

[0070] The word segmentation module is used to segment the searched content using the Jieba word segmenter, filter out the parts containing the words from the searched content, and group them according to the words;

[0071] A data interception module is used to traverse the word grouping, count the number of occurrences of each searched content, sort the data from large to small according to the number of occurrences, and intercept the largest N data as needed;

[0072] The word segmentation result processing module is used to traverse the interception results and process the results, such as changing the color of the word segmentation, encapsulating the results into a list and returning them to the front end;

[0073] The front-end display module directly renders the results into a list after receiving them.

[0074] The process of implementing search prompts in this system is as follows:

[0075] S1. Initialize the searched collection, query it from the redis database for the first time, and then put it into the cache; get the searched collection from the cache;

[0076] Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results;

[0077] S2, filter the data containing the word from the collection and put it into a new collection;

[0078] S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences;

[0079] S4, intercept the first n pieces of data as needed;

[0080] S5, processing the results;

[0081] S6. Return the result.

[0082] The embodiment of the present invention also provides a lightweight search engine prompt device, comprising at least one memory and a processor;

[0083] The at least one memory is used to store a machine-readable program;

[0084] The at least one processor is used to call the machine-readable program to implement the lightweight search engine prompt method described in the above embodiment.

[0085] The embodiment of the present invention also provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the lightweight search engine prompt method described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which software program codes implementing the functions of any of the above embodiments are stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.

[0086] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0087] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0088] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0089] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0090] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A lightweight search engine prompt method, characterized in that: The implementation of this method includes: 1) Introduce the jieba word segmenter into the program; 2) Query the collection that needs to be searched and store it in the redis database to increase the speed; 3) Use the Jieba word segmenter to segment the searched content, filter out the parts containing the segmented words from the searched content, and group them according to the segmented words; 4) Traverse the word grouping, count the number of occurrences of each searched content, sort them, and intercept the largest N as needed; 5) Traverse the interception results, process the results, encapsulate the results into a list and return them to the front end; 6) After receiving the results, the front end renders them directly into the list.

2. A lightweight search engine prompt method according to claim 1, characterized in that: The query requires a collection to be searched, the collection includes a name and details.

3. A lightweight search engine prompt method according to claim 2, characterized in that: The query requires searching the collection and storing it in the local cache.

4. A lightweight search engine prompt method according to claim 1, characterized in that: The number of times each searched content appears is sorted from largest to smallest.

5. A lightweight search engine prompt method according to claim 1, characterized in that: The result is processed to change the color of the segmented words therein.

6. A lightweight search engine prompt method according to claim 6, characterized in that: The specific implementation steps of this method are as follows: S1. Initialize the searched collection, query it from the database for the first time, and then put it into the cache; get the searched collection from the cache; Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results; S2, filter the data containing the word from the collection and put it into a new collection; S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences; S4, intercept the first n pieces of data as needed; S5, processing the results; S6. Return the result.

7. A lightweight search engine prompt system, characterized in that: include: jieba word segmenter; The redis database contains the collection to be searched. The collection to be searched is initialized at the beginning and queried from the redis database for the first time, and can be put into the local cache afterwards; The word segmentation module is used to segment the searched content using the Jieba word segmenter, filter out the parts containing the words from the searched content, and group them according to the words; A data interception module is used to traverse the word segmentation groups, count the number of occurrences of each searched content, sort them, and intercept the largest N data as needed; The word segmentation result processing module is used to traverse the interception results, process the results, encapsulate the results into a list and return them to the front end; The front-end display module directly renders the results into a list after receiving them.

8. A lightweight search engine prompt system according to claim 7, characterized in that: The process of implementing search prompts in this system is as follows: S1. Initialize the searched collection, query it from the redis database for the first time, and then put it into the cache; get the searched collection from the cache; Enter the search content and use the jieba word segmenter to segment the search content; then traverse the word segmentation results; S2, filter the data containing the word from the collection and put it into a new collection; S3. Determine the number of occurrences of each piece of data through the unique key, and sort the data in descending order according to the number of occurrences; S4, intercept the first n pieces of data as needed; S5, processing the results; S6. Return the result.

9. A lightweight search engine prompt device, characterized in that: comprising at least one memory and a processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 6.

10. A computer readable medium, characterized in that The computer readable medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Search method and device based on query word

    CN102043833A

  • Industry data matching method and device

    CN105045853A

  • Retrieval method and related equipment

    CN115827672A

  • Dynamic contextual re-ordering of suggested query hints

    WO2017116259A1