Skip to content

Commit c6addce

Browse files
feat: enable safe search feature for site search (#11174)
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 78957ed commit c6addce

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1beta/types/search_service.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class SearchRequest(proto.Message):
9898
9999
If this field is unrecognizable, an ``INVALID_ARGUMENT`` is
100100
returned.
101+
user_info (google.cloud.discoveryengine_v1beta.types.UserInfo):
102+
Information about the end user. Highly recommended for
103+
analytics. The user_agent string in UserInfo will be used to
104+
deduce device_type for analytics.
101105
facet_specs (MutableSequence[google.cloud.discoveryengine_v1beta.types.SearchRequest.FacetSpec]):
102106
Facet specifications for faceted search. If empty, no facets
103107
are returned.
@@ -120,7 +124,7 @@ class SearchRequest(proto.Message):
120124
- ``search_type``: double. Default empty. Enables
121125
non-webpage searching depending on the value. The only
122126
valid non-default value is 1, which enables image
123-
searching. This field is ignored for other verticals.
127+
searching.
124128
query_expansion_spec (google.cloud.discoveryengine_v1beta.types.SearchRequest.QueryExpansionSpec):
125129
The query expansion specification that
126130
specifies the conditions under which query
@@ -150,6 +154,31 @@ class SearchRequest(proto.Message):
150154
content_search_spec (google.cloud.discoveryengine_v1beta.types.SearchRequest.ContentSearchSpec):
151155
The content search spec that configs the
152156
desired behavior of content search.
157+
safe_search (bool):
158+
Whether to turn on safe search. This is only supported for
159+
[ContentConfig.PUBLIC_WEBSITE][].
160+
user_label (MutableMapping[str, str]):
161+
The user labels applied to a resource must meet the
162+
following requirements:
163+
164+
- Each resource can have multiple labels, up to a maximum
165+
of 64.
166+
- Each label must be a key-value pair.
167+
- Keys have a minimum length of 1 character and a maximum
168+
length of 63 characters and cannot be empty. Values can
169+
be empty and have a maximum length of 63 characters.
170+
- Keys and values can contain only lowercase letters,
171+
numeric characters, underscores, and dashes. All
172+
characters must use UTF-8 encoding, and international
173+
characters are allowed.
174+
- The key portion of a label must be unique. However, you
175+
can use the same key with multiple resources.
176+
- Keys must start with a lowercase letter or international
177+
character.
178+
179+
See `Google Cloud
180+
Document <https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements>`__
181+
for more details.
153182
"""
154183

155184
class FacetSpec(proto.Message):
@@ -589,6 +618,11 @@ class SummarySpec(proto.Message):
589618
proto.STRING,
590619
number=8,
591620
)
621+
user_info: common.UserInfo = proto.Field(
622+
proto.MESSAGE,
623+
number=21,
624+
message=common.UserInfo,
625+
)
592626
facet_specs: MutableSequence[FacetSpec] = proto.RepeatedField(
593627
proto.MESSAGE,
594628
number=9,
@@ -624,6 +658,15 @@ class SummarySpec(proto.Message):
624658
number=24,
625659
message=ContentSearchSpec,
626660
)
661+
safe_search: bool = proto.Field(
662+
proto.BOOL,
663+
number=20,
664+
)
665+
user_label: MutableMapping[str, str] = proto.MapField(
666+
proto.STRING,
667+
proto.STRING,
668+
number=22,
669+
)
627670

628671

629672
class SearchResponse(proto.Message):

packages/google-cloud-discoveryengine/samples/generated_samples/snippet_metadata_google.cloud.discoveryengine.v1beta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-discoveryengine",
11-
"version": "0.6.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-discoveryengine/scripts/fixup_discoveryengine_v1beta_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class discoveryengineCallTransformer(cst.CSTTransformer):
5353
'list_schemas': ('parent', 'page_size', 'page_token', ),
5454
'purge_documents': ('parent', 'filter', 'force', ),
5555
'recommend': ('serving_config', 'user_event', 'page_size', 'filter', 'validate_only', 'params', 'user_labels', ),
56-
'search': ('serving_config', 'branch', 'query', 'page_size', 'page_token', 'offset', 'filter', 'order_by', 'facet_specs', 'boost_spec', 'params', 'query_expansion_spec', 'spell_correction_spec', 'user_pseudo_id', 'content_search_spec', ),
56+
'search': ('serving_config', 'branch', 'query', 'page_size', 'page_token', 'offset', 'filter', 'order_by', 'user_info', 'facet_specs', 'boost_spec', 'params', 'query_expansion_spec', 'spell_correction_spec', 'user_pseudo_id', 'content_search_spec', 'safe_search', 'user_label', ),
5757
'update_document': ('document', 'allow_missing', ),
5858
'update_schema': ('schema', 'allow_missing', ),
5959
'write_user_event': ('parent', 'user_event', ),

0 commit comments

Comments
 (0)