Skip to content

Commit 40eb4d1

Browse files
authored
Add v2/search (#297)
* Add v2/search * Add v2/search updated license text
1 parent 28bf581 commit 40eb4d1

File tree

8 files changed

+7071
-0
lines changed

8 files changed

+7071
-0
lines changed

v2/internal/search/search.pb.go

Lines changed: 3463 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v2/internal/search/search.proto

Lines changed: 398 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,398 @@
1+
// Copyright 2023 Google Inc. All rights reserved.
2+
// Use of this source code is governed by the Apache 2.0
3+
// license that can be found in the LICENSE file.
4+
5+
syntax = "proto2";
6+
option go_package = "search";
7+
8+
package search;
9+
10+
message Scope {
11+
enum Type {
12+
USER_BY_CANONICAL_ID = 1;
13+
USER_BY_EMAIL = 2;
14+
GROUP_BY_CANONICAL_ID = 3;
15+
GROUP_BY_EMAIL = 4;
16+
GROUP_BY_DOMAIN = 5;
17+
ALL_USERS = 6;
18+
ALL_AUTHENTICATED_USERS = 7;
19+
}
20+
21+
optional Type type = 1;
22+
optional string value = 2;
23+
}
24+
25+
message Entry {
26+
enum Permission {
27+
READ = 1;
28+
WRITE = 2;
29+
FULL_CONTROL = 3;
30+
}
31+
32+
optional Scope scope = 1;
33+
optional Permission permission = 2;
34+
optional string display_name = 3;
35+
}
36+
37+
message AccessControlList {
38+
optional string owner = 1;
39+
repeated Entry entries = 2;
40+
}
41+
42+
message FieldValue {
43+
enum ContentType {
44+
TEXT = 0;
45+
HTML = 1;
46+
ATOM = 2;
47+
DATE = 3;
48+
NUMBER = 4;
49+
GEO = 5;
50+
}
51+
52+
optional ContentType type = 1 [default = TEXT];
53+
54+
optional string language = 2 [default = "en"];
55+
56+
optional string string_value = 3;
57+
58+
optional group Geo = 4 {
59+
required double lat = 5;
60+
required double lng = 6;
61+
}
62+
}
63+
64+
message Field {
65+
required string name = 1;
66+
required FieldValue value = 2;
67+
}
68+
69+
message FieldTypes {
70+
required string name = 1;
71+
repeated FieldValue.ContentType type = 2;
72+
}
73+
74+
message IndexShardSettings {
75+
repeated int32 prev_num_shards = 1;
76+
required int32 num_shards = 2 [default=1];
77+
repeated int32 prev_num_shards_search_false = 3;
78+
optional string local_replica = 4 [default = ""];
79+
}
80+
81+
message FacetValue {
82+
enum ContentType {
83+
ATOM = 2;
84+
NUMBER = 4;
85+
}
86+
87+
optional ContentType type = 1 [default = ATOM];
88+
optional string string_value = 3;
89+
}
90+
91+
message Facet {
92+
required string name = 1;
93+
required FacetValue value = 2;
94+
}
95+
96+
message DocumentMetadata {
97+
optional int64 version = 1;
98+
optional int64 committed_st_version = 2;
99+
}
100+
101+
message Document {
102+
optional string id = 1;
103+
optional string language = 2 [default = "en"];
104+
repeated Field field = 3;
105+
optional int32 order_id = 4;
106+
optional OrderIdSource order_id_source = 6 [default = SUPPLIED];
107+
108+
enum OrderIdSource {
109+
DEFAULTED = 0;
110+
SUPPLIED = 1;
111+
}
112+
113+
enum Storage {
114+
DISK = 0;
115+
}
116+
117+
optional Storage storage = 5 [default = DISK];
118+
repeated Facet facet = 8;
119+
}
120+
121+
message SearchServiceError {
122+
enum ErrorCode {
123+
OK = 0;
124+
INVALID_REQUEST = 1;
125+
TRANSIENT_ERROR = 2;
126+
INTERNAL_ERROR = 3;
127+
PERMISSION_DENIED = 4;
128+
TIMEOUT = 5;
129+
CONCURRENT_TRANSACTION = 6;
130+
}
131+
}
132+
133+
message RequestStatus {
134+
required SearchServiceError.ErrorCode code = 1;
135+
optional string error_detail = 2;
136+
optional int32 canonical_code = 3;
137+
}
138+
139+
message IndexSpec {
140+
required string name = 1;
141+
142+
enum Consistency {
143+
GLOBAL = 0;
144+
PER_DOCUMENT = 1;
145+
}
146+
optional Consistency consistency = 2 [default = PER_DOCUMENT];
147+
148+
optional string namespace = 3;
149+
optional int32 version = 4;
150+
151+
enum Source {
152+
SEARCH = 0;
153+
DATASTORE = 1;
154+
CLOUD_STORAGE = 2;
155+
}
156+
optional Source source = 5 [default = SEARCH];
157+
158+
enum Mode {
159+
PRIORITY = 0;
160+
BACKGROUND = 1;
161+
}
162+
optional Mode mode = 6 [default = PRIORITY];
163+
}
164+
165+
message IndexMetadata {
166+
required IndexSpec index_spec = 1;
167+
168+
repeated FieldTypes field = 2;
169+
170+
message Storage {
171+
optional int64 amount_used = 1;
172+
optional int64 limit = 2;
173+
}
174+
optional Storage storage = 3;
175+
}
176+
177+
message IndexDocumentParams {
178+
repeated Document document = 1;
179+
180+
enum Freshness {
181+
SYNCHRONOUSLY = 0;
182+
WHEN_CONVENIENT = 1;
183+
}
184+
optional Freshness freshness = 2 [default = SYNCHRONOUSLY, deprecated=true];
185+
186+
required IndexSpec index_spec = 3;
187+
}
188+
189+
message IndexDocumentRequest {
190+
required IndexDocumentParams params = 1;
191+
192+
optional bytes app_id = 3;
193+
}
194+
195+
message IndexDocumentResponse {
196+
repeated RequestStatus status = 1;
197+
198+
repeated string doc_id = 2;
199+
}
200+
201+
message DeleteDocumentParams {
202+
repeated string doc_id = 1;
203+
204+
required IndexSpec index_spec = 2;
205+
}
206+
207+
message DeleteDocumentRequest {
208+
required DeleteDocumentParams params = 1;
209+
210+
optional bytes app_id = 3;
211+
}
212+
213+
message DeleteDocumentResponse {
214+
repeated RequestStatus status = 1;
215+
}
216+
217+
message ListDocumentsParams {
218+
required IndexSpec index_spec = 1;
219+
optional string start_doc_id = 2;
220+
optional bool include_start_doc = 3 [default = true];
221+
optional int32 limit = 4 [default = 100];
222+
optional bool keys_only = 5;
223+
}
224+
225+
message ListDocumentsRequest {
226+
required ListDocumentsParams params = 1;
227+
228+
optional bytes app_id = 2;
229+
}
230+
231+
message ListDocumentsResponse {
232+
required RequestStatus status = 1;
233+
234+
repeated Document document = 2;
235+
}
236+
237+
message ListIndexesParams {
238+
optional bool fetch_schema = 1;
239+
optional int32 limit = 2 [default = 20];
240+
optional string namespace = 3;
241+
optional string start_index_name = 4;
242+
optional bool include_start_index = 5 [default = true];
243+
optional string index_name_prefix = 6;
244+
optional int32 offset = 7;
245+
optional IndexSpec.Source source = 8 [default = SEARCH];
246+
}
247+
248+
message ListIndexesRequest {
249+
required ListIndexesParams params = 1;
250+
251+
optional bytes app_id = 3;
252+
}
253+
254+
message ListIndexesResponse {
255+
required RequestStatus status = 1;
256+
repeated IndexMetadata index_metadata = 2;
257+
}
258+
259+
message DeleteSchemaParams {
260+
optional IndexSpec.Source source = 1 [default = SEARCH];
261+
repeated IndexSpec index_spec = 2;
262+
}
263+
264+
message DeleteSchemaRequest {
265+
required DeleteSchemaParams params = 1;
266+
267+
optional bytes app_id = 3;
268+
}
269+
270+
message DeleteSchemaResponse {
271+
repeated RequestStatus status = 1;
272+
}
273+
274+
message SortSpec {
275+
required string sort_expression = 1;
276+
optional bool sort_descending = 2 [default = true];
277+
optional string default_value_text = 4;
278+
optional double default_value_numeric = 5;
279+
}
280+
281+
message ScorerSpec {
282+
enum Scorer {
283+
RESCORING_MATCH_SCORER = 0;
284+
MATCH_SCORER = 2;
285+
}
286+
optional Scorer scorer = 1 [default = MATCH_SCORER];
287+
288+
optional int32 limit = 2 [default = 1000];
289+
optional string match_scorer_parameters = 9;
290+
}
291+
292+
message FieldSpec {
293+
repeated string name = 1;
294+
295+
repeated group Expression = 2 {
296+
required string name = 3;
297+
required string expression = 4;
298+
}
299+
}
300+
301+
message FacetRange {
302+
optional string name = 1;
303+
optional string start = 2;
304+
optional string end = 3;
305+
}
306+
307+
message FacetRequestParam {
308+
optional int32 value_limit = 1;
309+
repeated FacetRange range = 2;
310+
repeated string value_constraint = 3;
311+
}
312+
313+
message FacetAutoDetectParam {
314+
optional int32 value_limit = 1 [default = 10];
315+
}
316+
317+
message FacetRequest {
318+
required string name = 1;
319+
optional FacetRequestParam params = 2;
320+
}
321+
322+
message FacetRefinement {
323+
required string name = 1;
324+
optional string value = 2;
325+
326+
message Range {
327+
optional string start = 1;
328+
optional string end = 2;
329+
}
330+
optional Range range = 3;
331+
}
332+
333+
message SearchParams {
334+
required IndexSpec index_spec = 1;
335+
required string query = 2;
336+
optional string cursor = 4;
337+
optional int32 offset = 11;
338+
339+
enum CursorType {
340+
NONE = 0;
341+
SINGLE = 1;
342+
PER_RESULT = 2;
343+
}
344+
optional CursorType cursor_type = 5 [default = NONE];
345+
346+
optional int32 limit = 6 [default = 20];
347+
optional int32 matched_count_accuracy = 7;
348+
repeated SortSpec sort_spec = 8;
349+
optional ScorerSpec scorer_spec = 9;
350+
optional FieldSpec field_spec = 10;
351+
optional bool keys_only = 12;
352+
353+
enum ParsingMode {
354+
STRICT = 0;
355+
RELAXED = 1;
356+
}
357+
optional ParsingMode parsing_mode = 13 [default = STRICT];
358+
359+
optional int32 auto_discover_facet_count = 15 [default = 0];
360+
repeated FacetRequest include_facet = 16;
361+
repeated FacetRefinement facet_refinement = 17;
362+
optional FacetAutoDetectParam facet_auto_detect_param = 18;
363+
optional int32 facet_depth = 19 [default=1000];
364+
}
365+
366+
message SearchRequest {
367+
required SearchParams params = 1;
368+
369+
optional bytes app_id = 3;
370+
}
371+
372+
message FacetResultValue {
373+
required string name = 1;
374+
required int32 count = 2;
375+
required FacetRefinement refinement = 3;
376+
}
377+
378+
message FacetResult {
379+
required string name = 1;
380+
repeated FacetResultValue value = 2;
381+
}
382+
383+
message SearchResult {
384+
required Document document = 1;
385+
repeated Field expression = 4;
386+
repeated double score = 2;
387+
optional string cursor = 3;
388+
}
389+
390+
message SearchResponse {
391+
repeated SearchResult result = 1;
392+
required int64 matched_count = 2;
393+
required RequestStatus status = 3;
394+
optional string cursor = 4;
395+
repeated FacetResult facet_result = 5;
396+
397+
extensions 1000 to 9999;
398+
}

0 commit comments

Comments
 (0)