Text search processing method and related device
A text search processing method and a related device are disclosed, to search a plurality of pieces of running path information for a keyword based on a keyword rule in a keyword rule set. The method includes: obtaining a first text, where the first text includes one or more pieces of running path information; obtaining a search rule set, where each search rule indicates a logical relationship between at least one keyword; searching for one or more second keywords based on a first keyword and a first search rule, where the first keyword is obtained based on first running path information, and the first running path information is any one of the one or more pieces of running path information; and determining a first search result based on the first keyword and the one or more second keywords.
1 . A text search method, comprising:
obtaining a first text including one or more pieces of running path information, each of the one or more pieces of the running path information being a contiguous segment of log text that is generated during a running process of software code;
obtaining a search rule set, wherein the search rule set comprises one or more search rules, each of the one or more pieces of running path information corresponds to one or more search rules, and each of the one or more search rules indicates a logical relationship between at least one keyword;
searching for one or more second keywords based on a first keyword and a first search rule, wherein the first keyword is obtained based on first running path information, the first running path information is any one of the one or more pieces of running path information, and the first search rule is any search rule that is in the one or more search rules and corresponds to the first running path information; and
obtaining a first search result based on the first keyword and the one or more second keywords.
2 . The method according to claim 1 , wherein the searching for the one or more second keywords based on the first keyword and the first search rule comprises:
obtaining a first row number for identifying a number of a row in which the first keyword is located; and
searching an offset range for the one or more second keywords based on the first row number and the first search rule, wherein the offset range indicates a row offset value between the one or more second keywords and the first keyword.
3 . The method according to claim 2 , wherein the searching the offset range for the one or more second keywords based on the first row number and the first search rule comprises:
searching a first offset range for a third keyword based on the first row number and the first search rule, wherein the third keyword is any one of the one or more second keywords, and the first offset range corresponds to the third keyword.
4 . The method according to claim 2 , wherein the logical relationship comprises: a first identifier, a second identifier, and/or a third identifier, wherein the first identifier indicates that one or more keywords exist in the offset range, the second identifier indicates that one of the one or more keywords exists in the offset range, and the third identifier indicates that one or more keywords do not exist in the offset range.
5 . The method according to claim 3 , wherein
the one or more second keywords further comprise a fourth keyword and a fifth keyword; and
the method further comprises searching for the fourth keyword based on a second offset range, wherein the second offset range is obtained by using a row offset value between the fourth keyword and the first keyword, and the fourth keyword is one of the one or more second keywords; or
the second offset range is obtained by using a row offset value between the fifth keyword and the fourth keyword and a row offset value between the fourth keyword and the first keyword, and the fifth keyword is a keyword that is in the one or more second keywords and that is different from the fourth keyword.
6 . The method according to claim 2 , wherein the obtaining of the first row number comprises:
obtaining a second text by processing the first text by using a hash algorithm; and
obtaining the first row number based on the second text.
7 . The method according to claim 1 , wherein a keyword type comprises at least one of a string type or a key-value pair type.
8 . A text search apparatus, comprising:
receiver, configured to obtain a first text, wherein the first text comprises one or more pieces of running path information, each of the one or more pieces of the running path information being a contiguous segment of log text that is generated during a running process of software code, and
the receiver is configured to obtain a search rule set, wherein the search rule set comprises one or more search rules, and each search rule indicates a logical relationship between at least one keyword; and
at least one processor, configured to search for one or more second keywords based on a first keyword and a first search rule, wherein the first keyword is obtained based on first running path information, the first running path information is any one of the one or more pieces of running path information, and the first search rule is any search rule that is in the one or more search rules and corresponds to the first running path information; and
the at least one processor is configured to obtain a first search result based on the first keyword and the one or more second keywords.
9 . The text search apparatus according to claim 8 , wherein
the receiver is configured to obtain a first row number for identifying a number of a row in which the first keyword is located; and
the at least one processor is configured to search an offset range for the one or more second keywords based on the first row number and the first search rule, wherein the offset range indicates a row offset value between the one or more second keywords and the first keyword.
10 . The text search apparatus according to claim 9 , wherein
the at least one processor is further configured to search a first offset range for a third keyword based on the first row number and the first search rule, wherein the third keyword is any one of the one or more second keywords, and the first offset range corresponds to the third keyword.
11 . The text search apparatus according to claim 9 , wherein the logical relationship comprises a first identifier, a second identifier, and/or a third identifier, wherein the first identifier indicates that one or more keywords exist in the offset range, the second identifier indicates that one of the one or more keywords exists in the offset range, and the third identifier indicates that one or more keywords do not exist in the offset range.
12 . The text search apparatus according to claim 10 , wherein the one or more second keywords further comprise a fourth keyword and a fifth keyword; and
the at least one processor is configured to search for the fourth keyword based on a second offset range, wherein the second offset range is obtained by using a row offset value between the fourth keyword and the first keyword, and the fourth keyword is one of the one or more of the second keywords; or the second offset range is obtained by using a row offset value between the fifth keyword and the fourth keyword and a row offset value between the fourth keyword and the first keyword, and the fifth keyword is in the one or more second keywords and is different from the fourth keyword.
13 . The text search apparatus according to claim 9 , wherein the receiver is configured to:
obtain a second text by processing the first text by using a hash algorithm; and
obtain the first row number based on the second text.
14 . The text search apparatus according to claim 8 , wherein a keyword type comprises at least one of a string type or a key-value pair type.
15 . A non-transitory, computer-readable storage medium storing instructions that, when run on a computer, enable the computer to perform operations comprising:
obtaining a first text including one or more pieces of running path information, each of the one or more pieces of the running path information being a contiguous segment of log text that is generated during a running process of software code;
obtaining a search rule set, wherein the search rule set comprises one or more search rules, each of the one or more pieces of running path information corresponds to one or more search rules, and each of the one or more search rules indicates a logical relationship between at least one keyword;
searching for one or more second keywords based on a first keyword and a first search rule, wherein the first keyword is obtained based on first running path information, the first running path information is any one of the one or more pieces of running path information, and the first search rule is any search rule that is in the one or more search rules and corresponds to the first running path information; and
obtaining a first search result based on the first keyword and the one or more second keywords.
16 . The non-transitory, computer-readable storage medium according to claim 15 , wherein the searching for the one or more second keywords based on the first keyword and the first search rule comprises:
obtaining a first row number for identifying a number of a row in which the first keyword is located; and
searching an offset range for the one or more second keywords based on the first row number and the first search rule, wherein the offset range indicates a row offset value between the one or more second keywords and the first keyword.
17 . The non-transitory, computer-readable storage medium according to claim 16 , wherein the searching the offset range for the one or more second keywords based on the first row number and the first search rule comprises:
searching a first offset range for a third keyword based on the first row number and the first search rule, wherein the third keyword is any one of the one or more second keywords, and the first offset range corresponds to the third keyword.
18 . The non-transitory, computer-readable storage medium according to claim 16 , wherein the logical relationship comprises: a first identifier, a second identifier, and/or a third identifier, wherein the first identifier indicates that one or more keywords exist in the offset range, the second identifier indicates that one of the one or more keywords exists in the offset range, and the third identifier indicates that one or more keywords do not exist in the offset range.