Searching method and device
By analyzing user search requests and building starting path parameters, traversing the directory tree to locate data, the problem of unintuitive search results is solved, flat display is achieved, and user experience is improved.
Patent Information
- Application Number
- CN202411605087.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the display of search results is not intuitive, especially the data display method at different levels makes it difficult for users to quickly find the required materials.
By analyzing the search request from the user side, building the starting path parameters, traversing the directory tree to locate the corresponding data, and processing it into flattened list data to the user side, realizing the display of the same level.
It realizes the intuitive display of search results, and users can view different levels and types of data at the same level, improving the search experience.
Smart Images

Figure CN119311951A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a search method and device. Background Art
[0002] When a material-related usage website is provided to users, if the user needs to search for the required material, the user can enter the search content in the search box or search area to search for related data, such as files, folders, shortcuts and other data. However, the display of such data is usually displayed in different levels, and the search results are not intuitive. Summary of the invention
[0003] The main purpose of the present invention is to provide a search method and device to overcome the deficiencies in the related art.
[0004] In order to achieve the above-mentioned purpose, according to the first aspect of the present invention, a search method is provided, comprising: parsing a search request obtained from a user terminal to obtain search request information; determining data that matches the search request information from a specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels; and processing the data and sending it to the user terminal so that the user terminal can display the data in a same-level manner.
[0005] Optionally, determining data that matches the search request information from a pre-constructed directory tree based on the search request information includes: constructing a starting path parameter based on the search request information, wherein the starting path parameter includes a start character and a keyword indicated by the search request information; passing the path parameter to a predefined function, so as to traverse the directory tree based on the parameter through the function to obtain data that matches the search request information, wherein the specified directory tree is located through the start character, and the data is located by traversing the specified directory tree through the keyword; and obtaining the name and path of the located data.
[0006] Optionally, sending the processed data to the user end includes: splicing the name and path of the positioning data to obtain spliced data; rendering the spliced data into list data; rendering the list data in the order of traversal; and sending the list data to the user end for the user end to render based on the list data.
[0007] Optionally, rendering the spliced data into list data includes: directly rendering the spliced data into list data.
[0008] Optionally, rendering the spliced data into list data includes: adding the spliced data into a queue; and rendering the spliced data into list data according to the order of the spliced data in the queue.
[0009] According to a second aspect of the present invention, a search device is provided, comprising: a parsing unit, used to parse a search request obtained from a user terminal to obtain search request information; a search unit, used to determine data that matches the search request information from a specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels and types; a sending unit, used to process the data and then send it to the user terminal, so that the user terminal can display the data in a same-level manner.
[0010] Optionally, the search unit includes: a parameter determination module, used to construct a starting path parameter based on the search request information, wherein the starting path parameter includes a start character and a keyword indicated by the search request information; a data positioning module, used to pass the path parameter to a predefined function, so as to traverse the directory tree based on the parameters through the function to obtain data that matches the search request information, wherein the specified directory tree is located by the start character, and the data is located by traversing the specified directory tree through the keyword; and the name and path of the located data are obtained.
[0011] According to a third aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute any one of the methods described in the first aspect.
[0012] According to a fourth aspect of the present invention, there is provided an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor executes the method described in any one implementation of the first aspect.
[0013] According to a fifth aspect of the present invention, there is provided a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method described in any one of the implementation modes of the first aspect is implemented.
[0014] The search method and device of this embodiment include parsing the search request obtained from the user end to obtain the search request information; determining the data that matches the search request information from the specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels; and sending the data to the user end after processing, so that the user end can display the data in a peer-level manner. By constructing a flat processing search engine for stored data, the search engine can display the data in a peer-level manner on the web page in real time, thereby overcoming the defects of displaying the data in a different-level manner and the search results not being intuitive in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 is a flow chart of a search method according to an embodiment of the present invention;
[0017] Figure 2 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0019] It should be noted that the terms "first", "second", etc. in the specification of the present invention are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0020] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0021] According to an embodiment of the present invention, a search method is provided, such as Figure 1 As shown, it includes the following steps 101 to 103:
[0022] Step 101: parse the search request obtained from the user end to obtain search request information.
[0023] In this step, the user can enter search information in the web page, and after triggering the search component of the page, a search request is generated and sent to the server. After receiving the search request, the server parses it and obtains keyword information, such as "wood".
[0024] Step 102: Based on the search request information, determine data that matches the search request information from a specified directory tree, wherein the data that matches the request information includes data of different levels.
[0025] Step 103: The data is processed and sent to the user terminal, so that the user terminal can display the data in a peer manner.
[0026] In the above steps, data such as files, folders, shortcuts, etc. are stored in advance in the form of a directory tree, and the corresponding data is determined from the directory tree based on the keyword information. The data can be sent to the user end for peer display after peer processing, that is, displayed in a non-directory tree manner.
[0027] As an optional implementation method of this embodiment, determining data that matches the search request information from a pre-constructed directory tree based on the search request information includes: constructing a starting path parameter based on the search request information, wherein the starting path parameter includes a start character and a keyword indicated by the search request information; passing the path parameter to a predefined function, so as to traverse the directory tree based on the parameter through the function to obtain data that matches the search request information, wherein the specified directory tree is located through the start character, and the data is located by traversing the specified directory tree through the keyword; and obtaining the name and path of the located data.
[0028] In this optional implementation, the path parameters are constructed based on the keyword information. Specifically, the path parameters can be constructed based on the preset start character combined with the keyword information. The start character is an identifier for identifying different directories. When storing materials, multiple directories can be constructed based on storage needs, and the start character is used to indicate the storage location of the directory. Since the directory is designed on demand when it is stored, the start character can be given on demand when constructing the path parameters. The start character can be first determined based on the keyword information, and then the start path parameters can be constructed based on the start character and the keyword information.
[0029] After constructing the starting path parameter, the parameter is transferred to a predefined function, which receives a starting path as a parameter and traverses all files and directories under the path. The starting path parameter is used to walk (up or down) through the directory tree to traverse the data names in the directory tree, and then locate the names that match the keyword information, such as the same or similar names, and obtain the name and the path corresponding to the data of the name.
[0030] As an optional implementation method of this embodiment, sending the data to the user end after processing includes: splicing the name and path of the positioning data to obtain spliced data; rendering the spliced data into list data; rendering it into list data in the order of traversal; and sending the list data to the user end for the user end to render based on the list data.
[0031] In this optional implementation, the name and path of the acquired data are concatenated to obtain a complete data path. Furthermore, after obtaining the data path, the data can be flattened and rendered, and the data path can be stored in a top-level list through the rendering. During implementation, each data is checked recursively, including checking the integrity of the data path and whether there is nesting. If it is complete or not, it is added to the list. If there is nesting, the nested content is recursively processed until it is stored in the list. If it is incomplete, the content is discarded. After flattened rendering, the list data can be sent to the user end for rendering and display by the user end.
[0032] As an optional implementation manner of this embodiment, rendering the spliced data into list data includes: directly rendering the spliced data into list data.
[0033] As an optional implementation manner of this embodiment, rendering the spliced data into list data includes: adding the spliced data to a queue; and rendering the spliced data into list data according to the order of the spliced data in the queue.
[0034] In this optional implementation, when rendering, direct rendering can be performed as described above. However, in the actual rendering process, if the directory is large, the direct rendering method is inefficient, so the rendering is completed using a multi-threaded method. Specifically, after splicing the data, the spliced data is inserted into a queue, and the spliced data in the queue is rendered asynchronously when rendering.
[0035] Furthermore, the data includes different types of data, such as shortcuts, files, folders, etc. The rendered list data is sent to the user end, where the different types of data can be embedded into an HTML page.
[0036] This embodiment realizes the flattening and same-level display of material data by establishing a specific data search engine.
[0037] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0038] According to an embodiment of the present invention, a search device is also provided, including a parsing unit, used to parse a search request obtained from a user terminal to obtain search request information; a search unit, used to determine data that matches the search request information from a specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels and types; and a sending unit, used to process the data and send it to the user terminal so that the user terminal can display the data in a same-level manner.
[0039] As an optional implementation method of this embodiment, the search unit includes: a parameter determination module, used to construct a starting path parameter based on the search request information, wherein the starting path parameter includes a start character and a keyword indicated by the search request information; a data positioning module, used to pass the path parameter to a predefined function, so as to traverse the directory tree based on the parameters through the function to obtain data that matches the search request information, wherein the specified directory tree is located by the start character, and the data is located by traversing the specified directory tree through the keyword; and the name and path of the located data are obtained.
[0040] As an optional implementation method of this embodiment, sending the data to the user end after processing includes: splicing the name and path of the positioning data to obtain spliced data; rendering the spliced data into list data; rendering it into list data in the order of traversal; and sending the list data to the user end for the user end to render based on the list data.
[0041] As an optional implementation manner of this embodiment, rendering the spliced data into list data includes: directly rendering the spliced data into list data.
[0042] As an optional implementation manner of this embodiment, rendering the spliced data into list data includes: adding the spliced data to a queue; and rendering the spliced data into list data according to the order of the spliced data in the queue.
[0043] According to an embodiment of the present invention, the present invention also provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the method described in any of the above embodiments when executing.
[0044] According to an embodiment of the present invention, the present invention further provides a readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to implement the method described in any of the above embodiments when executed.
[0045] According to an embodiment of the present invention, the present invention further provides a computer program product, which can implement the method described in any of the above embodiments when executed by a processor.
[0046] Figure 2 A schematic block diagram of an example electronic device 300 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices.
[0047] like Figure 2 As shown, the electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0048] A number of components in the electronic device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the electronic device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0049] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above, such as the object matching method. For example, in some embodiments, the object matching method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into the RAM 303 and executed by the computing unit 301, one or more steps of the method described above may be performed.
[0050] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general programmable processor, which may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0051] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0052] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Claims
1. A search method, characterized in that: include: Parse the search request obtained from the user end to obtain the search request information; Determining data that matches the search request information from a specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels; The data is processed and sent to the user terminal so that the user terminal can display the data in a peer manner.
2. The search method according to claim 1, characterized in that: Determining data that matches the search request information from a pre-built directory tree based on the search request information includes: Constructing a start path parameter based on the search request information, wherein the start path parameter includes a start symbol and a keyword indicated by the search request information; Passing the path parameter to a predefined function, so that the function traverses the directory tree based on the parameter to obtain data that matches the search request information, wherein the specified directory tree is located by the start character, and the data is located by traversing the specified directory tree by the keyword; Get the name and path of the located data.
3. The search method according to claim 2, characterized in that: Processing the data and sending it to the user end includes: Splicing the name and path of the positioning data to obtain spliced data; Render the concatenated data into list data; render it into list data in the order of traversal; The list data is sent to a user terminal, so that the user terminal performs rendering based on the list data.
4. The search method according to claim 3, characterized in that: Rendering the spliced data into list data includes: directly rendering the spliced data into list data.
5. The search method according to claim 3, characterized in that: Rendering the concatenated data into list data includes: Add the spliced data to the queue; Render the spliced data into list data according to the order of the spliced data in the queue.
6. A search device, characterized in that: include: A parsing unit, used to parse the search request obtained from the user end to obtain search request information; A search unit, configured to determine data that matches the search request information from a specified directory tree based on the search request information, wherein the data that matches the request information includes data of different levels and types; The sending unit is used to process the data and send the processed data to the user terminal, so that the user terminal can display the data in a peer manner.
7. The search device according to claim 6, characterized in that: The search unit comprises: A parameter determination module, configured to construct a start path parameter based on the search request information, wherein the start path parameter includes a start symbol and a keyword indicated by the search request information; A data locating module is used to pass the path parameter to a predefined function so that the function can traverse the directory tree based on the parameter to obtain data that matches the search request information, wherein the specified directory tree is located by the start character, and the data is located by traversing the specified directory tree using the keyword; and the name and path of the located data are obtained.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 5.
9. An electronic device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor executes the method described in any one of claims 1-5.
10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Item type specific structured search
CN101432727A
Method and device for organizing network knowledge points based on directory tree
CN113377895A