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: 15 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 // The document log is using legacy format. 51 LEGACY_DOCUMENT_LOG_FORMAT = 5; 52 53 // The current code version is different from existing data version. 54 VERSION_CHANGED = 6; 55 56 // Any dependencies have changed. 57 DEPENDENCIES_CHANGED = 7; 58 59 // Change detected in Icing's feature flags since last initialization that 60 // requires recovery. 61 FEATURE_FLAG_CHANGED = 8; 62 } 63 64 // Possible recovery causes for document store: 65 // - DATA_LOSS 66 // - SCHEMA_CHANGES_OUT_OF_SYNC 67 // - IO_ERROR 68 optional RecoveryCause document_store_recovery_cause = 2; 69 70 // Possible recovery causes for index: 71 // - INCONSISTENT_WITH_GROUND_TRUTH 72 // - SCHEMA_CHANGES_OUT_OF_SYNC 73 // - IO_ERROR 74 optional RecoveryCause index_restoration_cause = 3; 75 76 // Possible recovery causes for index: 77 // - IO_ERROR 78 optional RecoveryCause schema_store_recovery_cause = 4; 79 80 // Time used to recover the document store. 81 optional int32 document_store_recovery_latency_ms = 5; 82 83 // Time used to restore the index. 84 optional int32 index_restoration_latency_ms = 6; 85 86 // Time used to restore the schema store. 87 optional int32 schema_store_recovery_latency_ms = 7; 88 89 // Status regarding how much data is lost during the initialization. 90 enum DocumentStoreDataStatus { 91 // Document store is successfully initialized or fully recovered. 92 NO_DATA_LOSS = 0; 93 94 // Ground truth data is partially lost. 95 PARTIAL_LOSS = 1; 96 97 // Ground truth data is completely lost. 98 COMPLETE_LOSS = 2; 99 } 100 optional DocumentStoreDataStatus document_store_data_status = 8; 101 102 // Number of documents currently in document store. Those may 103 // include alive, deleted, and expired documents. 104 optional int32 num_documents = 9; 105 106 // Number of schema types currently in schema store. 107 optional int32 num_schema_types = 10; 108 109 // Number of consecutive initialization failures that immediately preceded 110 // this initialization. 111 optional int32 num_previous_init_failures = 11; 112 113 // Possible recovery causes for integer index: 114 // - INCONSISTENT_WITH_GROUND_TRUTH 115 // - SCHEMA_CHANGES_OUT_OF_SYNC 116 // - IO_ERROR 117 optional RecoveryCause integer_index_restoration_cause = 12; 118 119 // Possible recovery causes for qualified id join index: 120 // - INCONSISTENT_WITH_GROUND_TRUTH 121 // - SCHEMA_CHANGES_OUT_OF_SYNC 122 // - IO_ERROR 123 optional RecoveryCause qualified_id_join_index_restoration_cause = 13; 124 125 // Possible recovery causes for embedding index: 126 // - INCONSISTENT_WITH_GROUND_TRUTH 127 // - SCHEMA_CHANGES_OUT_OF_SYNC 128 // - IO_ERROR 129 optional RecoveryCause embedding_index_restoration_cause = 14; 130} 131 132// Stats of the top-level function IcingSearchEngine::Put(). 133// Next tag: 13 134message PutDocumentStatsProto { 135 // Overall time used for the function call. 136 optional int32 latency_ms = 1; 137 138 // Time used to store the document. 139 optional int32 document_store_latency_ms = 2; 140 141 // Time used to index the document. 142 optional int32 index_latency_ms = 3; 143 144 // Time used to merge the indices. 145 optional int32 index_merge_latency_ms = 4; 146 147 // Document size in bytes. 148 optional int32 document_size = 5; 149 150 message TokenizationStats { 151 // Number of tokens added to the index. 152 optional int32 num_tokens_indexed = 1; 153 154 // Number of metadata tokens added to the index, which can only be added by 155 // PropertyExistenceIndexingHandler currently. 156 optional int32 num_metadata_tokens_indexed = 3; 157 158 reserved 2; 159 } 160 optional TokenizationStats tokenization_stats = 6; 161 162 // Time used to index all indexable string terms and property existence 163 // metadata terms in the document. It does not include the time to merge 164 // indices or the time to sort the lite index. 165 optional int32 term_index_latency_ms = 7; 166 167 // Time used to index all indexable integers in the document. 168 optional int32 integer_index_latency_ms = 8; 169 170 // Time used to index all qualified id join strings in the document. 171 optional int32 qualified_id_join_index_latency_ms = 9; 172 173 // Time used to sort the LiteIndex's HitBuffer. 174 optional int32 lite_index_sort_latency_ms = 10; 175 176 // Time used to index all metadata terms in the document, which can only be 177 // added by PropertyExistenceIndexingHandler currently. 178 optional int32 metadata_term_index_latency_ms = 11; 179 180 // Time used to index all embeddings in the document. 181 optional int32 embedding_index_latency_ms = 12; 182} 183 184// Stats of the top-level function IcingSearchEngine::Search() and 185// IcingSearchEngine::GetNextPage(). 186// Next tag: 28 187message QueryStatsProto { 188 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 189 // The UTF-8 length of the query string 190 optional int32 query_length = 16; 191 192 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 193 // Number of terms in the query string. 194 optional int32 num_terms = 1; 195 196 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 197 // Number of namespaces filtered. 198 optional int32 num_namespaces_filtered = 2; 199 200 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 201 // Number of schema types filtered. 202 optional int32 num_schema_types_filtered = 3; 203 204 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 205 // Strategy of scoring and ranking. 206 optional ScoringSpecProto.RankingStrategy.Code ranking_strategy = 4; 207 208 // Whether the function call is querying the first page. If it’s 209 // not, Icing will fetch the results from cache so that some steps 210 // may be skipped. 211 optional bool is_first_page = 5; 212 213 // The requested number of results in one page. 214 optional int32 requested_page_size = 6; 215 216 // The actual number of results returned in the current page. 217 optional int32 num_results_returned_current_page = 7; 218 219 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 220 // Number of documents scored. 221 optional int32 num_documents_scored = 8; 222 223 // How many of the results in the page returned were snippeted. 224 optional int32 num_results_with_snippets = 15; 225 226 // Overall time used for the function call. 227 optional int32 latency_ms = 10; 228 229 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 230 // Time used to parse the query, including 2 parts: tokenizing and 231 // transforming tokens into an iterator tree. 232 optional int32 parse_query_latency_ms = 11; 233 234 // TODO(b/305098009): deprecate. Use parent_search_stats instead. 235 // Time used to score the raw results. 236 optional int32 scoring_latency_ms = 12; 237 238 // Time used to rank the scored results. 239 optional int32 ranking_latency_ms = 13; 240 241 // Time used to fetch the document protos. Note that it includes the 242 // time to snippet if ‘has_snippets’ is true. 243 optional int32 document_retrieval_latency_ms = 14; 244 245 // Time passed while waiting to acquire the lock before query execution. 246 optional int32 lock_acquisition_latency_ms = 17; 247 248 // Timestamp taken just before sending proto across the JNI boundary from 249 // native to java side. 250 optional int64 native_to_java_start_timestamp_ms = 18; 251 252 // Time used to send protos across the JNI boundary from java to native side. 253 optional int32 java_to_native_jni_latency_ms = 19; 254 255 // Time used to send protos across the JNI boundary from native to java side. 256 optional int32 native_to_java_jni_latency_ms = 20; 257 258 // The native latency due to the join operation. 259 optional int32 join_latency_ms = 21; 260 261 // Number of documents scored. 262 optional int32 num_joined_results_returned_current_page = 22; 263 264 // Whether it contains join query or not. 265 optional bool is_join_query = 23; 266 267 // Stats of the search. Only valid for first page. 268 // Next tag: 16 269 message SearchStats { 270 // The UTF-8 length of the query string 271 optional int32 query_length = 1; 272 273 // Number of terms in the query string. 274 optional int32 num_terms = 2; 275 276 // Number of namespaces filtered. 277 optional int32 num_namespaces_filtered = 3; 278 279 // Number of schema types filtered. 280 optional int32 num_schema_types_filtered = 4; 281 282 // Strategy of scoring and ranking. 283 optional ScoringSpecProto.RankingStrategy.Code ranking_strategy = 5; 284 285 // Number of documents scored. 286 optional int32 num_documents_scored = 6; 287 288 // Time used to parse the query, including 2 parts: tokenizing and 289 // transforming tokens into an iterator tree. 290 optional int32 parse_query_latency_ms = 7; 291 292 // Time used to score the raw results. 293 optional int32 scoring_latency_ms = 8; 294 295 // Whether it contains numeric query or not. 296 optional bool is_numeric_query = 9; 297 298 // Number of hits fetched by lite index before applying any filters. 299 optional int32 num_fetched_hits_lite_index = 10; 300 301 // Number of hits fetched by main index before applying any filters. 302 optional int32 num_fetched_hits_main_index = 11; 303 304 // Number of hits fetched by integer index before applying any filters. 305 optional int32 num_fetched_hits_integer_index = 12; 306 307 // Time used in Lexer to extract lexer tokens from the query. 308 optional int32 query_processor_lexer_extract_token_latency_ms = 13; 309 310 // Time used in Parser to consume lexer tokens extracted from the query. 311 optional int32 query_processor_parser_consume_query_latency_ms = 14; 312 313 // Time used in QueryVisitor to visit and build (nested) DocHitInfoIterator. 314 optional int32 query_processor_query_visitor_latency_ms = 15; 315 } 316 317 // Search stats for parent. Only valid for first page. 318 optional SearchStats parent_search_stats = 24; 319 320 // Search stats for child. 321 optional SearchStats child_search_stats = 25; 322 323 // Byte size of the lite index hit buffer. 324 optional int64 lite_index_hit_buffer_byte_size = 26; 325 326 // Byte size of the unsorted tail of the lite index hit buffer. 327 optional int64 lite_index_hit_buffer_unsorted_byte_size = 27; 328 329 reserved 9; 330} 331 332// Stats of the top-level functions IcingSearchEngine::Delete, 333// IcingSearchEngine::DeleteByNamespace, IcingSearchEngine::DeleteBySchemaType. 334// Next tag: 4 335message DeleteStatsProto { 336 // Overall time used for the function call. 337 optional int32 latency_ms = 1; 338 339 message DeleteType { 340 enum Code { 341 // Default. Should never be used. 342 UNKNOWN = 0; 343 344 // Delete one document. 345 SINGLE = 1; 346 347 // Delete by query. This value is deprecated. 348 // IcingSearchEngine::DeleteByQuery will return a DeleteByQueryStatsProto 349 // rather than a DeleteStatsProto. 350 DEPRECATED_QUERY = 2 [deprecated = true]; 351 352 // Delete by namespace. 353 NAMESPACE = 3; 354 355 // Delete by schema type. 356 SCHEMA_TYPE = 4; 357 } 358 } 359 optional DeleteType.Code delete_type = 2; 360 361 // Number of documents deleted by this call. 362 optional int32 num_documents_deleted = 3; 363} 364 365// Stats of the top-level functions IcingSearchEngine::DeleteByQuery. 366// Next tag: 9 367message DeleteByQueryStatsProto { 368 // Overall time used for the function call. 369 optional int32 latency_ms = 1; 370 371 // Number of documents deleted by this call. 372 optional int32 num_documents_deleted = 2; 373 374 // The UTF-8 length of the query string 375 optional int32 query_length = 3; 376 377 // Number of terms in the query string. 378 optional int32 num_terms = 4; 379 380 // Number of namespaces filtered. 381 optional int32 num_namespaces_filtered = 5; 382 383 // Number of schema types filtered. 384 optional int32 num_schema_types_filtered = 6; 385 386 // Time used to parse the query, including 2 parts: tokenizing and 387 // transforming tokens into an iterator tree. 388 optional int32 parse_query_latency_ms = 7; 389 390 // Time used to delete each document. 391 optional int32 document_removal_latency_ms = 8; 392} 393