• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/logging.proto";
20import "icing/proto/status.proto";
21
22option java_package = "com.google.android.icing.proto";
23option java_multiple_files = true;
24option objc_class_prefix = "ICNG";
25
26// Defines a unit of data understood by the IcingSearchEngine.
27// Next tag: 10
28message DocumentProto {
29  // REQUIRED: Namespace that this Document resides in.
30  // Namespaces can affect read/write permissions.
31  optional string namespace = 1;
32
33  // REQUIRED: Identifier of the Document; must be unique within the
34  // Document's `namespace`. Otherwise, the new Document will override any
35  // other Documents with the same `namespace`+`uri` that Icing knows about.
36  optional string uri = 2;
37
38  // REQUIRED: Type of the Document. This should match the 'schema_type' of
39  // one of the types given to Icing as part of the overall schema.
40  // See icing.lib.SchemaTypeConfigProto.schema_type for details.
41  optional string schema = 3;
42
43  // OPTIONAL: Seconds since epoch at which the Document was created.
44  // Negative values will lead to validation errors. If not specified, it will
45  // default to when the Icing receives the Document.
46  optional int64 creation_timestamp_ms = 4;
47
48  // REQUIRED: Properties that will be validated against the provided schema.
49  // The names of these properties should map to one of the properties
50  // already defined in the schema for this Document's schema_type.
51  repeated PropertyProto properties = 5;
52
53  // OPTIONAL: Score of the document which could be used during search result
54  // ranking. Negative values will lead to validation errors. The default is the
55  // lowest score 0.
56  optional int32 score = 7 [default = 0];
57
58  // The time-to-live that should be enforced on this Document. Documents get
59  // garbage-collected once the current time exceeds the ttl_ms after the
60  // creation_timestamp_ms. Negative values will lead to validation errors.
61  //
62  // Default value of 0 keeps the Documents till they're explicitly deleted.
63  //
64  // TODO(cassiewang): Benchmark if fixed64 or some other proto type is better
65  // in terms of space/time efficiency. Both for ttl_ms and timestamp fields
66  optional int64 ttl_ms = 8 [default = 0];
67
68  // Defines document level data that's generated internally by Icing.
69  message InternalFields {
70    // The length of the document as a count of tokens (or terms) in all indexed
71    // text properties. This field is used in the computation of BM25F relevance
72    // score.
73    optional int32 length_in_tokens = 1;
74  }
75  optional InternalFields internal_fields = 9;
76
77  reserved 6;
78}
79
80// Holds a property field of the Document.
81// Next tag: 9
82message PropertyProto {
83  // Name of the property.
84  // See icing.lib.PropertyConfigProto.property_name for details.
85  optional string name = 1;
86
87  // Only the field corresponding to the DataType specified in
88  // icing.lib.PropertyConfigProto.data_type should be set.
89  repeated string string_values = 2;
90  repeated int64 int64_values = 3;
91  repeated double double_values = 4;
92  repeated bool boolean_values = 5;
93  repeated bytes bytes_values = 6;
94  repeated DocumentProto document_values = 7;
95
96  message VectorProto {
97    // The values of the vector.
98    repeated float values = 1 [packed = true];
99    // The model signature of the vector, which can be any string used to
100    // identify the model, so that embedding searches can be restricted only to
101    // the vectors with the matching target signature.
102    // Eg: "universal-sentence-encoder_v0"
103    optional string model_signature = 2;
104  }
105  repeated VectorProto vector_values = 8;
106}
107
108// Result of a call to IcingSearchEngine.Put
109// Next tag: 3
110message PutResultProto {
111  // Status code can be one of:
112  //   OK
113  //   FAILED_PRECONDITION
114  //   NOT_FOUND
115  //   INTERNAL
116  //   OUT_OF_SPACE
117  //
118  // See status.proto for more details.
119  //
120  // TODO(b/147699081): Fix error codes: +ABORTED
121  // go/icing-library-apis.
122  optional StatusProto status = 1;
123
124  // Stats of the function call. Inside PutDocumentStatsProto, the function
125  // call latency 'latency_ms' will always be populated. The other fields will
126  // be accurate only when the status above is OK. See logging.proto for
127  // details.
128  optional PutDocumentStatsProto put_document_stats = 2;
129}
130
131// Result of a call to IcingSearchEngine.Get
132// Next tag: 3
133message GetResultProto {
134  // Status code can be one of:
135  //   OK
136  //   FAILED_PRECONDITION
137  //   NOT_FOUND
138  //   INTERNAL
139  //
140  // See status.proto for more details.
141  //
142  // TODO(b/147699081): Fix error codes: +ABORTED, -INTERNAL.
143  // go/icing-library-apis.
144  optional StatusProto status = 1;
145
146  // Copy of the Document proto with the specified name_space, uri. Modifying
147  // this does not affect the Document in IcingSearchEngine.
148  optional DocumentProto document = 2;
149}
150
151// Result of a call to IcingSearchEngine.GetAllNamespaces
152// Next tag: 3
153message GetAllNamespacesResultProto {
154  // Status code can be one of:
155  //   OK
156  //
157  // See status.proto for more details.
158  optional StatusProto status = 1;
159
160  // List of namespaces which have at least one existing document in it (not
161  // deleted and not expired). Order of namespaces is undefined.
162  repeated string namespaces = 2;
163}
164
165// Result of a call to IcingSearchEngine.Delete
166// Next tag: 3
167message DeleteResultProto {
168  // Status code can be one of:
169  //   OK
170  //   FAILED_PRECONDITION
171  //   NOT_FOUND
172  //   INTERNAL
173  //
174  // See status.proto for more details.
175  //
176  // TODO(b/147699081): Fix error codes: +ABORTED.
177  // go/icing-library-apis.
178  optional StatusProto status = 1;
179
180  // Stats for delete execution performance.
181  optional DeleteStatsProto delete_stats = 2;
182}
183
184// Result of a call to IcingSearchEngine.DeleteByNamespace
185// Next tag: 3
186message DeleteByNamespaceResultProto {
187  // Status code can be one of:
188  //   OK
189  //   FAILED_PRECONDITION
190  //   NOT_FOUND
191  //   INTERNAL
192  //
193  // See status.proto for more details.
194  //
195  // TODO(b/147699081): Fix error codes: +ABORTED.
196  // go/icing-library-apis.
197  optional StatusProto status = 1;
198
199  // Stats for delete execution performance.
200  optional DeleteStatsProto delete_stats = 2;
201}
202
203// Result of a call to IcingSearchEngine.DeleteBySchemaType
204// Next tag: 3
205message DeleteBySchemaTypeResultProto {
206  // Status code can be one of:
207  //   OK
208  //   FAILED_PRECONDITION
209  //   NOT_FOUND
210  //   INTERNAL
211  //
212  // See status.proto for more details.
213  //
214  // TODO(b/147699081): Fix error codes: +ABORTED.
215  // go/icing-library-apis.
216  optional StatusProto status = 1;
217
218  // Stats for delete execution performance.
219  optional DeleteStatsProto delete_stats = 2;
220}
221
222// Result of a call to IcingSearchEngine.DeleteByQuery
223// Next tag: 5
224message DeleteByQueryResultProto {
225  // Status code can be one of:
226  //   OK
227  //   FAILED_PRECONDITION
228  //   NOT_FOUND
229  //   INTERNAL
230  //
231  // See status.proto for more details.
232  //
233  // TODO(b/147699081): Fix error codes: +ABORTED.
234  // go/icing-library-apis.
235  optional StatusProto status = 1;
236
237  // Stats for delete execution performance.
238  optional DeleteByQueryStatsProto delete_by_query_stats = 3;
239
240  // Used by DeleteByQueryResultProto to return information about deleted
241  // documents.
242  message DocumentGroupInfo {
243    optional string namespace = 1;
244    optional string schema = 2;
245    repeated string uris = 3;
246  }
247
248  // Additional return message that shows the uris of the deleted documents, if
249  // users set return_deleted_document_info to true.
250  // The result is grouped by the corresponding namespace and type.
251  repeated DocumentGroupInfo deleted_documents = 4;
252
253  reserved 2;
254}
255