File search method and device, electronic equipment and storage medium

By recording file changes to log information during the service offline and updating file indexes when switching to online status, the problem of inaccurate file search is solved, and efficient file index updates and searches are achieved.

CN120295974APending Publication Date: 2025-07-11BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410044507.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-11
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

In the prior art, when the file indexing service is offline, the file changes cannot be updated, resulting in inaccurate file search, or the need to re-establish indexes after online, resulting in large processing volume.

Method used

When the preset service is offline, record file changes to log information. When switching to online status, update the file index based on the log information, and use the latest historical identifier to update the file index information to avoid re-establishing the index.

Benefits of technology

Ensure the accuracy of file searches, reduce processing volume, and avoid the need to repeatedly update indexes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295974A_ABST
    Figure CN120295974A_ABST
Patent Text Reader

Abstract

The invention relates to a file searching method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring log information, wherein the log information comprises a plurality of file change records and a first identifier corresponding to each file change record; when the preset service is switched from the offline state to the online state, updating the file index information based on a file change record corresponding to a first identifier recorded after a first historical identifier in the log information, the first historical identifier being the newest first identifier stored before the preset service is switched to the offline state, and the first identifier being the newest first identifier stored before the preset service is switched to the online state; the file index information is used for representing the relationship between the attribute information of the file and the file identifier; and in response to the file search request, performing file search based on the file index information. According to the method, the file change condition is updated to the file index information during the offline period of the preset service, so that the accurate search of the file is ensured, the existing index does not need to be repeatedly updated, and the handling capacity is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of file search, and in particular, to a file search method, apparatus, electronic device, and storage medium. Background Art

[0002] With the development of random computer technology, the storage capacity of electronic devices has become larger and larger. At the same time, the amount of information that people need to process has also increased, and the number of files stored in electronic devices has become larger and larger. To help users quickly and accurately find the required files from a large number of files, the file search function has emerged accordingly.

[0003] In the related art, for the file search function, file index information is established in advance to facilitate users to search for files based on the file index information. However, when the service supporting the file index information goes offline, the file index information cannot update the changes of files during the offline period, resulting in inaccurate file search. Or, after the service goes offline and then comes back online, the file index information is re-established, resulting in an increased processing volume. Summary of the Invention

[0004] To overcome the problems in the related art, the present disclosure provides a file search method, apparatus, electronic device, and storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, a file search method is provided. The method includes:

[0006] Obtain log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record;

[0007] When a preset service switches from an offline state to an online state, update file index information based on the file change records corresponding to the first identifiers recorded after a first historical identifier in the log information, where the first historical identifier is the latest first identifier saved before the preset service switches to the offline state;

[0008] Perform file search based on the file index information.

[0009] In some embodiments, the first identifier in the log information increases as the number of file change records increases. The updating the file index information based on the file change records corresponding to the first identifiers recorded after the first historical identifier in the log information includes:

[0010] Query the first historical identifier from the log information;

[0011] Update the file index information based on the file change records corresponding to the first identifiers greater than the first historical identifier in the log information.

[0012] In some embodiments, the log information includes a plurality of change logs and a second identifier corresponding to each change log, and each change log includes at least one of the file change records and a first identifier corresponding to each file change record;

[0013] Querying the first historical identifier from the log information includes:

[0014] Querying the change log corresponding to the second historical identifier from the log information, where the second historical identifier is the latest second identifier saved before the preset service switches to the offline state;

[0015] Querying the first historical identifier from the change log corresponding to the second historical identifier.

[0016] In some embodiments, performing a file search based on the file index information includes:

[0017] In response to a file search request, obtaining search parameters corresponding to the file search request, where the search parameters are obtained by parsing the search information carried in the file search request;

[0018] Based on the file index information, determining a file identifier corresponding to the search parameters;

[0019] Determining the file corresponding to the file identifier as the searched file.

[0020] In some embodiments, in response to the file search request, obtaining the search parameters corresponding to the file search request includes:

[0021] In response to the file search request, sending the file search request to the cloud, where the cloud is used to parse the search information to obtain search parameters;

[0022] Receiving the search parameters returned by the cloud.

[0023] In some embodiments, the method further includes:

[0024] Establishing the file index information, where the file index information includes a first list and a second list, the first list is used to store the attribute information of the file and the file identifier of the file, and the second list is used to store the word segmentation index of the file and the file identifier of the file.

[0025] In some embodiments, establishing the file index information includes:

[0026] Reading the attribute information, file name, and file identifier of the file;

[0027] Save the attribute information and the file identifier correspondingly to the first list;

[0028] Call a target tokenizer to perform tokenization on the file name to obtain the tokenization index;

[0029] Save the tokenization index and the file identifier correspondingly to the second list;

[0030] Determine the file index information based on the first list and the second list.

[0031] In some embodiments, before the step of calling a target tokenizer to perform tokenization on the file name to obtain the tokenization index, the method further includes:

[0032] Obtain the target tokenizer indicated by the indication information based on the indication information saved in the second list;

[0033] Wherein, the target tokenizer supports tokenization of text containing multiple languages, and the target tokenizer is further used to convert Chinese text into pinyin text.

[0034] In some embodiments, the method further includes:

[0035] Receive a file change instruction within an accumulated duration, where the file change instruction is used to indicate the file change situation;

[0036] When the duration of receiving the file change instruction reaches the accumulated duration, update the file index information;

[0037] When the execution of the file change instructions received within the accumulated duration ends, adjust the accumulated duration;

[0038] Continue to receive file change instructions based on the adjusted accumulated duration and update the file index information.

[0039] In some embodiments, the adjusting the accumulated duration includes:

[0040] When the number of file change instructions received within the accumulated duration is greater than a preset threshold, decrease the accumulated duration; or,

[0041] When the number of file change instructions received within the accumulated duration is less than a preset threshold, increase the accumulated duration.

[0042] In some embodiments, the updating the file index information when the duration of receiving the file change instruction reaches the accumulated duration includes:

[0043] When the duration of receiving the file change instruction reaches the cumulative duration and no file change instruction is received, continue to receive the file change instruction until a file change instruction is received, and update the file index information.

[0044] According to a second aspect of the present disclosure, there is provided a file search device, the device comprising:

[0045] A log acquisition module configured to acquire log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record;

[0046] An index update module configured to, when a preset service switches from an offline state to an online state, update file index information based on file change records corresponding to first identifiers recorded after a first historical identifier in the log information, where the first historical identifier is the latest first identifier saved before the preset service switches to the offline state;

[0047] A file search module configured to perform file search based on the file index information.

[0048] In some embodiments, the first identifier in the log information increases as the number of file change records increases, and the index update module is configured to:

[0049] Query the first historical identifier from the log information;

[0050] Update the file index information based on file change records corresponding to first identifiers greater than the first historical identifier in the log information.

[0051] In some embodiments, the log information includes multiple change logs and a second identifier corresponding to each change log, and each change log includes at least one file change record and a first identifier corresponding to each file change record;

[0052] The index update module is configured to:

[0053] Query the change log corresponding to a second historical identifier from the log information, where the second historical identifier is the latest second identifier saved before the preset service switches to the offline state;

[0054] Query the first historical identifier from the change log corresponding to the second historical identifier.

[0055] In some embodiments, the file search module is configured to:

[0056] In response to a file search request, obtain search parameters corresponding to the file search request, where the search parameters are obtained by parsing the search information carried in the file search request;

[0057] Based on the file index information, determine a file identifier corresponding to the search parameters;

[0058] Determine the file corresponding to the file identifier as the searched file.

[0059] In some embodiments, the file search module is configured to:

[0060] In response to the file search request, send the file search request to the cloud, where the cloud is used to parse the search information to obtain search parameters;

[0061] Receive the search parameters returned by the cloud.

[0062] In some embodiments, the device further includes:

[0063] An index establishment module configured to establish the file index information, where the file index information includes a first list and a second list. The first list is used to store the attribute information of the file and the file identifier of the file, and the second list is used to store the word segmentation index of the file and the file identifier of the file.

[0064] In some embodiments, the index establishment module is configured to:

[0065] Read the attribute information, file name, and file identifier of the file;

[0066] Correspondingly store the attribute information and the file identifier into the first list;

[0067] Call a target word segmenter to perform word segmentation on the file name to obtain the word segmentation index;

[0068] Correspondingly store the word segmentation index and the file identifier into the second list;

[0069] Based on the first list and the second list, determine the file index information.

[0070] In some embodiments, the index establishment module is further configured to:

[0071] Based on the indication information stored in the second list, obtain the target word segmenter indicated by the indication information;

[0072] Wherein, the target word segmenter supports word segmentation of text containing multiple languages, and the target word segmenter is further used to convert Chinese text into pinyin text.

[0073] In some embodiments, the device further includes a file monitoring module, which is configured to:

[0074] Receive a file change instruction within an accumulated duration, where the file change instruction is used to indicate the file change situation;

[0075] When the duration of receiving the file change instruction reaches the accumulated duration, update the file index information;

[0076] When the execution of the file change instructions received within the accumulated duration ends, adjust the accumulated duration;

[0077] Continue to receive file change instructions based on the adjusted accumulated duration and update the file index information.

[0078] In some embodiments, the file monitoring module is configured to:

[0079] When the number of file change instructions received within the accumulated duration is greater than a preset threshold, decrease the accumulated duration; or,

[0080] When the number of file change instructions received within the accumulated duration is less than a preset threshold, increase the accumulated duration.

[0081] In some embodiments, the file monitoring module is configured to:

[0082] When the duration of receiving the file change instruction reaches the accumulated duration and no file change instruction is received, continue to receive file change instructions until a file change instruction is received, and update the file index information.

[0083] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:

[0084] A processor;

[0085] A memory for storing instructions executable by the processor;

[0086] Wherein, the processor is configured to execute the method in the first aspect of the embodiments of the present disclosure.

[0087] According to a fourth aspect of the embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method in the first aspect of the embodiments of the present disclosure.

[0088] Adopting the above method of the present disclosure has the following beneficial effects:

[0089] In the method provided by the embodiments of the present disclosure, when the preset service is in an offline state, the file change situation is recorded in the log information. When the preset service switches from the offline state to the online state, the file change situation recorded in the log information during the offline period of the preset service can be updated to the file index information, so as to ensure accurate file search. Moreover, since the latest first identifier before the preset service switches to the offline state, that is, the first historical identifier, is saved, when updating, only the file change records corresponding to the first identifier recorded after the first historical identifier in the log information need to be used to update the file index information, without re-establishing the file index information, that is, without repeatedly updating the existing index, reducing the processing amount.

[0090] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0091] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0092] Figure 1 is a flowchart of a file search method shown according to an exemplary embodiment;

[0093] Figure 2 is a flowchart of a file search method shown according to an exemplary embodiment;

[0094] Figure 3 is a flowchart of a process for establishing file index information shown according to an exemplary embodiment;

[0095] Figure 4 is a flowchart of a process for updating file index information shown according to an exemplary embodiment;

[0096] Figure 5 is a schematic diagram of a process for updating file index information shown according to an exemplary embodiment;

[0097] Figure 6 is a block diagram of a file search device shown according to an exemplary embodiment;

[0098] Figure 7 is a block diagram of an electronic device shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0099] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0100] The method provided by the embodiments of the present disclosure is executed by an electronic device, which may be a mobile phone, a tablet computer, a laptop computer, a wearable device, a vehicle-mounted terminal, a smart home device, etc.

[0101] Figure 1 is a flowchart of a file search method shown according to an exemplary embodiment and is executed by an electronic device. Refer to Figure 1 The method includes the following steps:

[0102] Step S101, obtain log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record.

[0103] In the embodiments of the present disclosure, during the operation of the electronic device, the log system will record the operations performed by the electronic device. Therefore, the file change situation is recorded in the log information, that is, the log information includes multiple file change records and a first identifier corresponding to each file change record. The first identifier is a unique identifier representing the file change record, and different file change records correspond to different first identifiers. Among them, the file change situation may be change situations such as adding a new file, deleting a file, modifying a file, etc. Each file change record is used to record a file change situation.

[0104] Step S102, when the preset service switches from the offline state to the online state, update the file index information based on the file change records corresponding to the first identifiers recorded after the first historical identifier in the log information. The first historical identifier is the latest first identifier saved before the preset service switches to the offline state.

[0105] Among them, the file index information is used to save the relevant information and file identifier of a file. The file identifier of a file is the unique identifier representing the file. When a certain file changes, the relevant information of the file in the file index information also changes accordingly. The relevant information can be the attribute information of the file, the file name, etc. The attribute information of the file includes information such as file type, file size, file modification time, file storage path, etc. The preset service is a service that supports file index information and file search. When the preset service is switched to the offline state, the preset service cannot be used. At the same time, the file index information no longer updates the file change situation. When the preset service is switched from the offline state to the online state, the preset service can be used, and the file index information can continue to update the file change situation. Moreover, the file change situation during the offline period of the preset service also needs to be updated to the file index information.

[0106] In the embodiments of the present disclosure, since the log system is still in the working state during the offline period of the preset service, the log information will record the file change situation during the offline period of the preset service. Therefore, when updating the file index information, based on the saved first historical identifier, the file change record corresponding to the first identifier recorded in the log information after the first historical identifier is used to update the file index information. Among them, the first historical identifier is the latest first identifier saved before the preset service is switched to the offline state, that is, the file change situation corresponding to the first identifier after the first historical identifier is not saved in the file index information. The first historical identifier can be saved in the file index information or in other storage areas of the electronic device.

[0107] Step S103, perform a file search based on the file index information.

[0108] When the file index information saves the latest relevant information and file identifier of the file, a file search can be performed based on the file index information, so as to achieve accurate file search and avoid file search errors.

[0109] The method provided by the embodiments of the present disclosure can record the file change situation in the log information when the preset service is in the offline state. When the preset service is switched from the offline state to the online state, the file change situation recorded in the log information during the offline period of the preset service can be updated to the file index information, so as to ensure accurate file search. Moreover, since the latest first identifier, that is, the first historical identifier, saved before the preset service is switched to the offline state is saved, when updating, only the file change record corresponding to the first identifier recorded in the log information after the first historical identifier needs to be used to update the file index information, without re-establishing the file index information, that is, without repeatedly updating the existing index, reducing the processing amount.

[0110] Figure 2is a flowchart of a file search method shown according to an exemplary embodiment, which is executed by an electronic device. Refer to Figure 2 , the method includes the following steps:

[0111] Step S201, establish file index information.

[0112] In the embodiments of the present disclosure, before updating the file index information and performing file search, it is necessary to first establish the file index information. Among them, the file index information includes a first list and a second list. The first list is used to save the attribute information of the file and the file identifier of the file, and the second list is used to save the word segmentation index of the file and the file identifier of the file. For the implementation manner of establishing the file index information, refer to the embodiments shown below Figure 3 , which will not be elaborated here.

[0113] Step S202, obtain log information.

[0114] During the operation of the electronic device, the log system will record the operations performed by the electronic device. Therefore, the file change situation is recorded in the log information, that is, the log information includes multiple file change records and the first identifier corresponding to each file change record.

[0115] In some embodiments, the first identifier in the log information increases as the number of file change records increases, that is, the first identifier is self-increasing. For example, the first identifier can also be referred to as USN (Update Sequence Number).

[0116] In some embodiments, in the log information, multiple file change records are partitioned, that is, the log information includes multiple change logs and the second identifier corresponding to each change log. The change log includes at least one file change record and the first identifier corresponding to each file change record. Among them, the second identifier corresponding to the change log is the unique identifier representing the change log. For example, the second identifier can also be referred to as USN Journal ID.

[0117] Step S203, when the preset service switches from the offline state to the online state, query the change log corresponding to the second historical identifier from the log information. The second historical identifier is the latest second identifier saved before the preset service switches to the offline state.

[0118] After the preset service switches from the offline state to the online state, in order to quickly update the file index information, it is necessary to first locate the first historical identifier in the log information. When there are many file change records in the log information, it may take a long time to search for the first historical identifier in reverse order. Since the number of change logs is less than the number of file change records, the speed of searching for the second historical identifier in reverse order is faster than that of searching for the first historical identifier. Therefore, first locate the change log corresponding to the second historical identifier.

[0119] Among them, the second historical identifier is the latest second identifier saved before the preset service switches to the offline state. This second historical identifier can be saved in the file index information or in other storage areas of the electronic device. Optionally, the second historical identifier and the first historical identifier can be saved together or separately.

[0120] Step S204, query the first historical identifier from the change log corresponding to the second historical identifier.

[0121] The number of file change records in the change log is much smaller than the number of file change records in the entire log information. Therefore, the speed of querying the first historical identifier from the change log corresponding to the second historical identifier is much faster than the speed of querying the first historical identifier from the entire log information.

[0122] It should be noted that steps S203 and S204 are a way to query the first historical identifier from the log information. In some embodiments, the first historical identifier can also be queried from the log information.

[0123] Step S205, update the file index information based on the file change records corresponding to the first identifier greater than the first historical identifier in the log information.

[0124] In the embodiments of the present disclosure, when the first identifier in the log information increases as the number of file change records increases, update the file index information based on the file change records corresponding to the first identifier greater than the first historical identifier in the log information.

[0125] Updating the file index information includes: when the file change record indicates adding a new file, adding a new index in the file index information, that is, storing the relevant information of the new file and the file identifier correspondingly in the file index information; when the file change record indicates deleting a file, deleting the relevant information of the file indicated by the file change record and the file identifier in the file index information; when the file change record indicates modifying a file, modifying the relevant information of the file indicated by the file change record in the file index information.

[0126] Step S206, in response to a file search request, obtain the search parameters corresponding to the file search request.

[0127] Among them, the file search request is used to request a file search. The file search request carries search information, and the search parameters are obtained by parsing the search information carried in the file search request. For example, if the search information is "search for pdf files in the database on this computer", after parsing the search information, the obtained search parameters include but are not limited to the content shown in Table 1 below:

[0128] Table 1

[0129] Position Name Type Modification Time Size null Database Pdf 0 0

[0130] Optionally, the search information can be text information, voice information, or other forms of information. For example, when the electronic device detects the user input of "search for pdf files in the database on this computer", a file search request is generated; or when the electronic device detects the voice of the user saying "search for pdf files in the database on this computer", a file search request is generated.

[0131] In some embodiments, in response to the file search request, the file search request is sent to the cloud. The cloud is used to parse the search information to obtain search parameters; the search parameters returned by the cloud are received. That is, the search information is parsed in the cloud. Of course, in another embodiment, the electronic device can also parse the search information locally, and the embodiments of the present disclosure do not limit this.

[0132] Step S207: Based on the file index information, determine the file identifier corresponding to the search parameter.

[0133] According to the search parameters and the attribute information of each file in the file index information, search for the corresponding word segmentation index in the file index information, and determine the file identifier corresponding to the searched word segmentation index as the file identifier corresponding to the search parameter. For example, for the search parameters shown in Table 1, this search parameter indicates that this search is to search for pdf files named "database" in the entire disk, and the size and modification time are not restricted. That is, according to the attribute information of the file, it can be determined whether the file is a pdf file. At the same time, based on the keyword "database", it can be determined whether the word segmentation index contains "database". The file identifier corresponding to the case where the word segmentation index contains "database" and the file type is pdf is determined as the file identifier corresponding to the search parameter.

[0134] Step S208: Determine the file corresponding to the file identifier as the searched file.

[0135] In the method provided by the embodiments of the present disclosure, when the preset service is in the offline state, the file change situation is recorded in the log information. When the preset service switches from the offline state to the online state, the file change situation recorded in the log information during the offline period of the preset service can be updated to the file index information, so as to ensure accurate file search. Moreover, since the latest first identifier before the preset service switches to the offline state, that is, the first historical identifier, is saved, when updating, only the file change records corresponding to the first identifier recorded after the first historical identifier in the log information need to be used to update the file index information, without having to rebuild the file index information, that is, without repeatedly updating the existing index, reducing the processing volume.

[0136] In the embodiments of the present disclosure, taking the file index information including a first list and a second list as an example, the process of establishing the file index information is described.

[0137] Figure 3 is a flowchart of a process for establishing file index information shown according to an exemplary embodiment, which is executed by an electronic device. Refer to Figure 3 This method includes the following steps:

[0138] Step S301, read the attribute information, file name, and file identifier of the file.

[0139] In the embodiments of the present disclosure, when the search system is started for the first time and it is found that no index has been established, the file index information is first established. The file index information includes a first list and a second list, where the first list and the second list are empty. For example, the file index information can be a database, the first list can be the main table, and the second list can be the virtual table. Then, the attribute information, file name, and file identifier of the files stored in the electronic device are saved to the file index information.

[0140] In some embodiments, read the MFT (Master File Table) of each disk partition in the electronic device, and then sequentially traverse and read the attribute information, file name, and file identifier of each file.

[0141] Step S302, save the attribute information and the file identifier correspondingly to the first list.

[0142] Save the attribute information and the file identifier in the first list.

[0143] Step S303, call the target tokenizer to perform tokenization processing on the file name to obtain a tokenization index.

[0144] The target tokenizer is used to perform tokenization processing on the file name, and the tokenization index is the tokenization result obtained by performing tokenization processing on the file name.

[0145] In some embodiments, based on the indication information saved in the second list, obtain the target tokenizer indicated by the indication information; wherein, the indication information is used to indicate the target tokenizer, and the indication information may be the name of the target tokenizer, the acquisition method, or the target tokenizer itself. The target tokenizer supports tokenizing text containing multiple languages, and the target tokenizer is also used to convert Chinese text into pinyin text. For example, the target tokenizer is a tokenizer that supports mixed Chinese-English tokenization, and this target tokenizer will also convert Chinese into pinyin text. Such a target tokenizer can tokenize file names to obtain as many words as possible that users may use during searches, thereby supporting mixed-language searches, improving the convenience during searches, and enhancing the user experience.

[0146] Step S304, save the tokenization index and the file identifier corresponding to each other in the second list.

[0147] It should be noted that the second list will also save the file name and the file identifier corresponding to each other.

[0148] Step S305, determine the file index information based on the first list and the second list.

[0149] It should be noted that the embodiments of the present disclosure take the creation of the first list and the second list as examples for illustration. In another embodiment, a single list may be created, in which the file identifier, the attribute information, and the tokenization index are saved corresponding to each other.

[0150] In a related technology, when performing a file search, it is necessary to first read the first search result from the file database, then read the second index result from the system index service, and then determine the final search result based on the first index result and the second index result. In the embodiments of the present disclosure, the file index information includes various relevant information of the file and the file identifier. Therefore, only by performing a file search based on this file index information can the search result be obtained, and the search speed can reach the millisecond level, improving the file search speed. Moreover, since the file name is processed into a tokenization index, users can search for the corresponding file using text in various languages or using pinyin, rather than being limited to searching for the corresponding file only using the information contained in the file name.

[0151] The above Figure 2 In the embodiments shown, when the preset service switches from the offline state to the online state, the file index information is updated. When the preset service is in the online state, the file index information will be updated normally. The following uses Figure 4 the embodiments shown to illustrate the update process of the file index information when the preset service is in the online state.

[0152] Figure 4It is a flowchart of a process for updating file index information shown according to an exemplary embodiment, which is executed by an electronic device. Refer to Figure 4 , and the method includes the following steps:

[0153] Step S401, receive a file change instruction within an accumulated duration, where the file change instruction is used to indicate the file change situation.

[0154] Among them, the accumulated duration can be a preset duration. For example, the accumulated duration is 32 seconds, 16 seconds, or other durations.

[0155] Step S402, when the duration of receiving the file change instruction reaches the accumulated duration, update the file index information.

[0156] In the embodiments of the present disclosure, considering that file changes may occur continuously within a certain time period and there is no change in some time periods, if the timeliness of processing file change instructions is relatively high, it will lead to frequent processing of file change instructions, resulting in low utilization rate. If the utilization rate is increased, a relatively large number of file change instructions will be accumulated, resulting in low timeliness. To balance the utilization rate and timeliness, an appropriate accumulated duration will be set. File change instructions are continuously received within the accumulated duration, but the received file change instructions are not processed until the duration of receiving the file change instruction reaches the accumulated duration, and then the file index information is updated, that is, the received file change instructions are processed.

[0157] In some embodiments, when the duration of receiving the file change instruction reaches the accumulated duration and no file change instruction is received, continue to receive the file change instruction until a file change instruction is received, and then update the file index information, so as to ensure that the file index information is updated each time a file change instruction is received.

[0158] Step S403, when the execution of the file change instruction received within the accumulated duration ends, adjust the accumulated duration.

[0159] In the embodiments of the present disclosure, when a file change instruction is received within the accumulated duration, the accumulated duration can be adjusted according to the reception situation of this file change instruction, so as to receive file change instructions within an appropriate accumulated duration.

[0160] In some embodiments, when the number of file change instructions received within the cumulative duration is greater than a preset threshold, the cumulative duration is decreased; or when the number of file change instructions received within the cumulative duration is less than the preset threshold, the cumulative duration is increased. That is to say, when the number of received file change instructions is relatively large, it indicates that current file changes may break out intensively, and there may be more file change instructions in the next period of time. Therefore, the cumulative duration is decreased so that the subsequent received file change instructions can be processed more timely. When the number of received file change instructions is relatively small, it indicates that current file changes may be relatively few, and there may be fewer file change instructions in the next period of time. Therefore, the cumulative duration is increased so that more subsequent received file change instructions can be processed. By dynamically adjusting the cumulative duration, the timeliness and utilization rate of processing file change instructions are effectively balanced.

[0161] In some embodiments, regardless of the number of file change instructions received within the cumulative duration, half of the cumulative duration is determined as the adjusted cumulative duration.

[0162] Step S404, continue to receive file change instructions based on the adjusted cumulative duration and update the file index information.

[0163] Based on the adjusted cumulative duration, repeat the above steps S401 - S404.

[0164] In an example, referring to Figure 5 the schematic diagram of the file index information update process shown, the abscissa is the execution round, which refers to the round of processing file reception instructions, and the ordinate is the cumulative duration. The cumulative duration of the first transaction accumulation stage is 32 seconds. When the cumulative duration reaches 32 seconds and the execution round is the 21st execution round, the transaction is executed, that is, the file change instructions received in the first transaction accumulation stage are executed. Then the cumulative duration of the second transaction accumulation stage is 16 seconds. However, as can be seen from Figure 5 it, when the cumulative duration reaches 16 seconds, no file change instruction is received, so file change instructions continue to be received until the cumulative duration reaches 22 seconds. When a file change instruction is received at the 22nd second, the actual cumulative duration of the second transaction accumulation stage is 22 seconds. That is, when the cumulative duration reaches 22 seconds and the execution round is the 27th execution round, the transaction is executed, that is, the file change instructions received in the second transaction accumulation stage are executed. Then the cumulative duration of the third transaction accumulation stage is 11 seconds. The processing process of the third transaction accumulation stage is the same as that of the first and second transaction accumulation stages and will not be elaborated here.

[0165] Embodiments of the present disclosure provide an update method with fast startup and full accumulation, which online monitors file change situations and effectively balances the timeliness and utilization rate of processing file change instructions by dynamically adjusting the accumulation duration.

[0166] Figure 6 is a block diagram of a file search device shown according to an exemplary embodiment, which is configured in an electronic device. Refer to Figure 6 The device includes:

[0167] A log acquisition module 601, configured to acquire log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record;

[0168] An index update module 602, configured to update file index information based on the file change records corresponding to the first identifiers recorded after the first historical identifier in the log information when a preset service switches from an offline state to an online state, where the first historical identifier is the latest first identifier saved before the preset service switches to the offline state;

[0169] A file search module 603, configured to perform a file search based on the file index information in response to a file search request.

[0170] In some embodiments, the first identifier in the log information increases as the number of file change records increases. The index update module 602 is configured to:

[0171] Query the first historical identifier from the log information;

[0172] Update the file index information based on the file change records corresponding to the first identifiers greater than the first historical identifier in the log information.

[0173] In some embodiments, the log information includes multiple change logs and a second identifier corresponding to each change log. Each change log includes at least one file change record and a first identifier corresponding to each file change record;

[0174] The index update module 602 is configured to:

[0175] Query the change log corresponding to the second historical identifier from the log information, where the second historical identifier is the latest second identifier saved before the preset service switches to the offline state;

[0176] Query the first historical identifier from the change log corresponding to the second historical identifier.

[0177] In some embodiments, the file search module 603 is configured to:

[0178] In response to a file search request, obtain search parameters corresponding to the file search request, where the search parameters are obtained by parsing the search information carried in the file search request;

[0179] Based on the file index information, determine the file identifier corresponding to the search parameters;

[0180] Determine the file corresponding to the file identifier as the searched file.

[0181] In some embodiments, the file search module 603 is configured to:

[0182] In response to a file search request, send the file search request to the cloud, where the cloud is used to parse the search information to obtain search parameters;

[0183] Receive the search parameters returned by the cloud.

[0184] In some embodiments, the apparatus further includes:

[0185] An index establishment module, configured to establish file index information, where the file index information includes a first list and a second list. The first list is used to store the attribute information of the file and the file identifier of the file, and the second list is used to store the word segmentation index of the file and the file identifier of the file.

[0186] In some embodiments, the index establishment module is configured to:

[0187] Read the attribute information, file name, and file identifier of the file;

[0188] Correspondingly save the attribute information and the file identifier to the first list;

[0189] Call a target word segmenter to perform word segmentation processing on the file name to obtain a word segmentation index;

[0190] Correspondingly save the word segmentation index and the file identifier to the second list;

[0191] Based on the first list and the second list, determine the file index information.

[0192] In some embodiments, the index establishment module is further configured to:

[0193] Based on the indication information stored in the second list, obtain the target word segmenter indicated by the indication information;

[0194] Wherein, the target word segmenter supports word segmentation processing on text containing multiple languages, and the target word segmenter is further used to convert Chinese text into pinyin text.

[0195] In some embodiments, the apparatus further includes a file monitoring module, and the file monitoring module is configured to:

[0196] Receive a file change instruction within the cumulative duration, where the file change instruction is used to indicate the file change situation;

[0197] When the duration of receiving the file change instruction reaches the cumulative duration, update the file index information;

[0198] After the execution of the file change instruction received within the cumulative duration ends, adjust the cumulative duration;

[0199] Continue to receive the file change instruction based on the adjusted cumulative duration and update the file index information.

[0200] In some embodiments, the file monitoring module is configured to:

[0201] When the number of file change instructions received within the cumulative duration is greater than a preset threshold, decrease the cumulative duration; or,

[0202] When the number of file change instructions received within the cumulative duration is less than the preset threshold, increase the cumulative duration.

[0203] In some embodiments, the file monitoring module is configured to:

[0204] When the duration of receiving the file change instruction reaches the cumulative duration and no file change instruction is received, continue to receive the file change instruction until a file change instruction is received, and update the file index information.

[0205] Regarding the device in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be elaborated here.

[0206] Embodiments of the present disclosure further provide an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein, the processor is configured to execute the file search method in the above embodiments.

[0207] Figure 7 It is a block diagram of an electronic device 700 shown according to an exemplary embodiment.

[0208] Refer to Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.

[0209] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-described methods. Additionally, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.

[0210] The memory 704 is configured to store various types of data to support the operation of the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, and the like. The memory 704 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.

[0211] The power component 706 provides power to the various components of the electronic device 700. The power component 706 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 700.

[0212] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each of the front camera and the rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0213] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 704 or transmitted via the communication component 716. In some embodiments, the audio component 710 further includes a speaker for outputting audio signals.

[0214] The I / O interface 712 provides an interface between the processing component 702 and a peripheral interface module, and the peripheral interface module may be a keyboard, a click wheel, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a power button, and a lock button.

[0215] The sensor component 714 includes one or more sensors for providing an assessment of various aspects of the state of the electronic device 700. For example, the sensor component 714 can detect the on / off state of the electronic device 700, the relative positioning of components, such as the display and keypad of the electronic device 700. The sensor component 714 can also detect a change in the position of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor component 714 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 714 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 714 can further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0216] The communication component 716 is configured to facilitate communication between the electronic device 700 and other devices in a wired or wireless manner. The electronic device 700 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0217] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.

[0218] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the above instructions can be executed by a processor 720 of the electronic device 700 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0219] An embodiment of the present disclosure also provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the file search method in the above embodiment.

[0220] Those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention, which follow the general principles of the present invention and include common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and embodiments are only to be considered as exemplary, and the true scope and spirit of the present invention are pointed out by the following claims.

[0221] It should be understood that the present invention is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.

Claims

1. A file search method, characterized in that, The method includes: Obtaining log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record; When a preset service switches from an offline state to an online state, updating file index information based on the file change records corresponding to the first identifiers recorded after a first historical identifier in the log information, where the first historical identifier is the latest first identifier saved before the preset service switches to the offline state; Performing a file search based on the file index information.

2. The method according to claim 1, characterized in that, The first identifier in the log information increases as the number of file change records increases. The updating of the file index information based on the file change records corresponding to the first identifiers recorded after the first historical identifier in the log information includes: Querying the first historical identifier from the log information; Updating the file index information based on the file change records corresponding to the first identifiers greater than the first historical identifier in the log information.

3. The method according to claim 2, characterized in that The log information includes multiple change logs and a second identifier corresponding to each change log. Each change log includes at least one file change record and a first identifier corresponding to each file change record; The querying of the first historical identifier from the log information includes: Querying the change log corresponding to a second historical identifier from the log information, where the second historical identifier is the latest second identifier saved before the preset service switches to the offline state; Querying the first historical identifier from the change log corresponding to the second historical identifier.

4. The method according to claim 1, characterized in that The performing of the file search based on the file index information includes: In response to a file search request, obtaining search parameters corresponding to the file search request, where the search parameters are obtained by parsing the search information carried in the file search request; Based on the file index information, determining file identifiers corresponding to the search parameters; Determining the file corresponding to the file identifier as the searched file.

5. The method according to claim 4, characterized in that, The obtaining of the search parameters corresponding to the file search request in response to the file search request includes: In response to the file search request, sending the file search request to the cloud, where the cloud is used to parse the search information to obtain search parameters; Receiving the search parameters returned by the cloud.

6. The method according to claim 1, wherein The method further includes: Establishing the file index information, where the file index information includes a first list and a second list. The first list is used to save the attribute information of the file and the file identifier of the file, and the second list is used to save the word segmentation index of the file and the file identifier of the file.

7. The method according to claim 6, wherein The establishing of the file index information includes: Reading the attribute information, file name, and file identifier of the file; Correspondingly saving the attribute information and the file identifier to the first list; Invoking a target word segmenter to perform word segmentation processing on the file name to obtain the word segmentation index; Correspondingly saving the word segmentation index and the file identifier to the second list; Determining the file index information based on the first list and the second list.

8. The method according to claim 7, wherein Before calling the target tokenizer to tokenize the file name to obtain the tokenization index, the method further includes: Based on the indication information saved in the second list, obtain the target tokenizer indicated by the indication information; Wherein, the target tokenizer supports tokenizing text containing multiple languages, and the target tokenizer is further used to convert Chinese text into pinyin text.

9. The method according to claim 1, characterized in that, The method further includes: Receiving a file change instruction within an accumulated duration, where the file change instruction is used to indicate the file change situation; When the duration of receiving the file change instruction reaches the accumulated duration, update the file index information; After the file change instructions received within the accumulated duration are executed, adjust the accumulated duration; Based on the adjusted accumulated duration, continue to receive file change instructions and update the file index information.

10. The method according to claim 9, characterized in that, The adjusting the accumulated duration includes: When the number of file change instructions received within the accumulated duration is greater than a preset threshold, decrease the accumulated duration; or, When the number of file change instructions received within the accumulated duration is less than a preset threshold, increase the accumulated duration.

11. The method according to claim 9, characterized in that, The updating the file index information when the duration of receiving the file change instruction reaches the accumulated duration includes: When the duration of receiving the file change instruction reaches the accumulated duration and no file change instruction is received, continue to receive file change instructions until a file change instruction is received, and update the file index information.

12. A file search device, characterized in that, The device includes: A log acquisition module configured to acquire log information, where the log information includes multiple file change records and a first identifier corresponding to each file change record; An index update module configured to, when a preset service switches from an offline state to an online state, update the file index information based on the file change records corresponding to the first identifiers recorded after the first historical identifier in the log information, where the first historical identifier is the latest first identifier saved before the preset service switches to the offline state; A file search module configured to perform file search based on the file index information.

13. An electronic device, characterized in that, Includes: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the method according to any one of claims 1-11.

14. A non-transitory computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is enabled to execute the method according to any one of claims 1-11.