1// Copyright 2019 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto2";
16
17package icing.lib;
18
19import "icing/proto/scoring.proto";
20
21option java_package = "com.google.android.icing.proto";
22option java_multiple_files = true;
23option objc_class_prefix = "ICNG";
24
25// Stats of the top-level function IcingSearchEngine::Initialize().
26// Next tag: 11
27message InitializeStatsProto {
28  // Overall time used for the function call.
29  optional int32 latency_ms = 1;
30
31  // The cause of IcingSearchEngine recovering from a previous bad state during
32  // initialization.
33  enum RecoveryCause {
34    // No recovery happened.
35    NONE = 0;
36
37    // Data loss in ground truth.
38    DATA_LOSS = 1;
39
40    // Data in index is inconsistent with ground truth.
41    INCONSISTENT_WITH_GROUND_TRUTH = 2;
42
43    // Changes were made to the schema, but possibly not fully applied to the
44    // document store and the index - requiring a recovery.
45    SCHEMA_CHANGES_OUT_OF_SYNC = 3;
46
47    // Random I/O errors.
48    IO_ERROR = 4;
49  }
50
51  // Possible recovery causes for document store:
52  // - DATA_LOSS
53  // - SCHEMA_CHANGES_OUT_OF_SYNC
54  // - IO_ERROR
55  optional RecoveryCause document_store_recovery_cause = 2;
56
57  // Possible recovery causes for index:
58  // - INCONSISTENT_WITH_GROUND_TRUTH
59  // - SCHEMA_CHANGES_OUT_OF_SYNC
60  // - IO_ERROR
61  optional RecoveryCause index_restoration_cause = 3;
62
63  // Possible recovery causes for index:
64  // - IO_ERROR
65  optional RecoveryCause schema_store_recovery_cause = 4;
66
67  // Time used to recover the document store.
68  optional int32 document_store_recovery_latency_ms = 5;
69
70  // Time used to restore the index.
71  optional int32 index_restoration_latency_ms = 6;
72
73  // Time used to restore the index.
74  optional int32 schema_store_recovery_latency_ms = 7;
75
76  // Status regarding how much data is lost during the initialization.
77  enum DocumentStoreDataStatus {
78    // Document store is successfully initialized or fully recovered.
79    NO_DATA_LOSS = 0;
80
81    // Ground truth data is partially lost.
82    PARTIAL_LOSS = 1;
83
84    // Ground truth data is completely lost.
85    COMPLETE_LOSS = 2;
86  }
87  optional DocumentStoreDataStatus document_store_data_status = 8;
88
89  // Number of documents currently in document store. Those may
90  // include alive, deleted, and expired documents.
91  optional int32 num_documents = 9;
92
93  // Number of schema types currently in schema store.
94  optional int32 num_schema_types = 10;
95}
96
97// Stats of the top-level function IcingSearchEngine::Put().
98// Next tag: 7
99message PutDocumentStatsProto {
100  // Overall time used for the function call.
101  optional int32 latency_ms = 1;
102
103  // Time used to store the document.
104  optional int32 document_store_latency_ms = 2;
105
106  // Time used to index the document. It does not include the time to merge
107  // indices.
108  optional int32 index_latency_ms = 3;
109
110  // Time used to merge the indices.
111  optional int32 index_merge_latency_ms = 4;
112
113  // Document size in bytes.
114  optional int32 document_size = 5;
115
116  message TokenizationStats {
117    // Whether the number of tokens to be indexed exceeded the max number of
118    // tokens per document.
119    optional bool exceeded_max_token_num = 2;
120
121    // Number of tokens added to the index.
122    optional int32 num_tokens_indexed = 1;
123  }
124  optional TokenizationStats tokenization_stats = 6;
125}
126
127// Stats of the top-level function IcingSearchEngine::Search() and
128// IcingSearchEngine::GetNextPage().
129// Next tag: 17
130message QueryStatsProto {
131  // The UTF-8 length of the query string
132  optional int32 query_length = 16;
133
134  // Number of terms in the query string.
135  optional int32 num_terms = 1;
136
137  // Number of namespaces filtered.
138  optional int32 num_namespaces_filtered = 2;
139
140  // Number of schema types filtered.
141  optional int32 num_schema_types_filtered = 3;
142
143  // Strategy of scoring and ranking.
144  optional ScoringSpecProto.RankingStrategy.Code ranking_strategy = 4;
145
146  // Whether the function call is querying the first page. If it’s
147  // not, Icing will fetch the results from cache so that some steps
148  // may be skipped.
149  optional bool is_first_page = 5;
150
151  // The requested number of results in one page.
152  optional int32 requested_page_size = 6;
153
154  // The actual number of results returned in the current page.
155  optional int32 num_results_returned_current_page = 7;
156
157  // Number of documents scored.
158  optional int32 num_documents_scored = 8;
159
160  // How many of the results in the page returned were snippeted.
161  optional int32 num_results_with_snippets = 15;
162
163  // Overall time used for the function call.
164  optional int32 latency_ms = 10;
165
166  // Time used to parse the query, including 2 parts: tokenizing and
167  // transforming tokens into an iterator tree.
168  optional int32 parse_query_latency_ms = 11;
169
170  // Time used to score the raw results.
171  optional int32 scoring_latency_ms = 12;
172
173  // Time used to rank the scored results.
174  optional int32 ranking_latency_ms = 13;
175
176  // Time used to fetch the document protos. Note that it includes the
177  // time to snippet if ‘has_snippets’ is true.
178  optional int32 document_retrieval_latency_ms = 14;
179
180  reserved 9;
181}
182
183// Stats of the top-level functions IcingSearchEngine::Delete,
184// IcingSearchEngine::DeleteByNamespace, IcingSearchEngine::DeleteBySchemaType,
185// IcingSearchEngine::DeleteByQuery.
186// Next tag: 4
187message DeleteStatsProto {
188  // Overall time used for the function call.
189  optional int32 latency_ms = 1;
190
191  message DeleteType {
192    enum Code {
193      // Default. Should never be used.
194      UNKNOWN = 0;
195
196      // Delete one document.
197      SINGLE = 1;
198
199      // Delete by query.
200      QUERY = 2;
201
202      // Delete by namespace.
203      NAMESPACE = 3;
204
205      // Delete by schema type.
206      SCHEMA_TYPE = 4;
207    }
208  }
209  optional DeleteType.Code delete_type = 2;
210
211  // Number of documents deleted by this call.
212  optional int32 num_documents_deleted = 3;
213}
214