Reference documentation and code samples for the Google Cloud Vector Search V1 Client class SemanticSearch.
Defines a semantic search operation.
Generated from protobuf message google.cloud.vectorsearch.v1.SemanticSearch
Namespace
Google \ Cloud \ VectorSearch \ V1Methods
__construct
Constructor.
| Parameters | |
|---|---|
| Name | Description |
data |
array
Optional. Data for populating the Message object. |
↳ search_text |
string
Optional. The query text, which is used to generate an embedding according to the embedding model specified in the collection config. Required when using the text search mode. |
↳ search_field |
string
Required. The vector field to search. |
↳ task_type |
int
Optional. The task type of the query embedding. Must be specified for text-only embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/task-types Not needed for multi modal embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/get-multimodal-embeddings#specify-task-instructions |
↳ output_fields |
OutputFields
Optional. The fields to return in the search results. |
↳ filter |
Google\Protobuf\Struct
Optional. A JSON filter expression, e.g. |
↳ top_k |
int
Optional. The number of data objects to return. |
↳ search_hint |
SearchHint
Optional. Sets the search hint. If no strategy is specified, the service will use an index if one is available, and fall back to KNN search otherwise. |
getSearchText
Optional. The query text, which is used to generate an embedding according to the embedding model specified in the collection config.
Required when using the text search mode.
| Returns | |
|---|---|
| Type | Description |
string |
|
setSearchText
Optional. The query text, which is used to generate an embedding according to the embedding model specified in the collection config.
Required when using the text search mode.
| Parameter | |
|---|---|
| Name | Description |
var |
string
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getSearchField
Required. The vector field to search.
| Returns | |
|---|---|
| Type | Description |
string |
|
setSearchField
Required. The vector field to search.
| Parameter | |
|---|---|
| Name | Description |
var |
string
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getTaskType
Optional. The task type of the query embedding. Must be specified for text-only embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/task-types Not needed for multi modal embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/get-multimodal-embeddings#specify-task-instructions
| Returns | |
|---|---|
| Type | Description |
int |
Enum of type EmbeddingTaskType. |
setTaskType
Optional. The task type of the query embedding. Must be specified for text-only embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/task-types Not needed for multi modal embedding models, see https://docs.cloud.google.analiseja.site/gemini-enterprise-agent-platform/models/embeddings/get-multimodal-embeddings#specify-task-instructions
| Parameter | |
|---|---|
| Name | Description |
var |
int
Enum of type EmbeddingTaskType. |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getOutputFields
Optional. The fields to return in the search results.
| Returns | |
|---|---|
| Type | Description |
OutputFields|null |
|
hasOutputFields
clearOutputFields
setOutputFields
Optional. The fields to return in the search results.
| Parameter | |
|---|---|
| Name | Description |
var |
OutputFields
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getFilter
Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
represented as a google.protobuf.Struct.
An empty filter (}) matches all data objects. Otherwise, each JSON
object in the filter must have exactly one key: either a field name mapped
to one operator ({"price": {"$lt": 100}}), or a logical operator: $and
or $or with a list of filters, or $not with one filter. Field
operators and their values: $eq and $ne take a string, number or bool;
$lt, $lte, $gt and $gte take a number; $in, $nin and $all
take a list of strings; $exists takes a bool. Several keys in one object
(implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected;
use $and and $eq instead.
Logical operators can be nested at most 2 levels deep, e.g.
{"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper
filters are rejected with INVALID_ARGUMENT.
Which filters are accepted depends on how the search is served. If it is
served by an approximate nearest neighbor (ANN) index (by default when a
ready index exists on search_field, or when one is selected via
search_hint.index_hint), every filtered field must be listed in
Index.filter_fields at index creation, $or and $all are accepted
only at the top level of the filter, and $not and $exists are not
supported. Not every unsupported filter is rejected: most produce
INVALID_ARGUMENT, but some are silently ignored, so do not rely on the
error. If no ready index exists on search_field, or if
search_hint.knn_hint is set, the search is served by K-Nearest Neighbor
(KNN) search, which has none of these filter restrictions.
| Returns | |
|---|---|
| Type | Description |
Google\Protobuf\Struct|null |
|
hasFilter
clearFilter
setFilter
Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
represented as a google.protobuf.Struct.
An empty filter (}) matches all data objects. Otherwise, each JSON
object in the filter must have exactly one key: either a field name mapped
to one operator ({"price": {"$lt": 100}}), or a logical operator: $and
or $or with a list of filters, or $not with one filter. Field
operators and their values: $eq and $ne take a string, number or bool;
$lt, $lte, $gt and $gte take a number; $in, $nin and $all
take a list of strings; $exists takes a bool. Several keys in one object
(implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected;
use $and and $eq instead.
Logical operators can be nested at most 2 levels deep, e.g.
{"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper
filters are rejected with INVALID_ARGUMENT.
Which filters are accepted depends on how the search is served. If it is
served by an approximate nearest neighbor (ANN) index (by default when a
ready index exists on search_field, or when one is selected via
search_hint.index_hint), every filtered field must be listed in
Index.filter_fields at index creation, $or and $all are accepted
only at the top level of the filter, and $not and $exists are not
supported. Not every unsupported filter is rejected: most produce
INVALID_ARGUMENT, but some are silently ignored, so do not rely on the
error. If no ready index exists on search_field, or if
search_hint.knn_hint is set, the search is served by K-Nearest Neighbor
(KNN) search, which has none of these filter restrictions.
| Parameter | |
|---|---|
| Name | Description |
var |
Google\Protobuf\Struct
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getTopK
Optional. The number of data objects to return.
| Returns | |
|---|---|
| Type | Description |
int |
|
hasTopK
clearTopK
setTopK
Optional. The number of data objects to return.
| Parameter | |
|---|---|
| Name | Description |
var |
int
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getSearchHint
Optional. Sets the search hint. If no strategy is specified, the service will use an index if one is available, and fall back to KNN search otherwise.
| Returns | |
|---|---|
| Type | Description |
SearchHint|null |
|
hasSearchHint
clearSearchHint
setSearchHint
Optional. Sets the search hint. If no strategy is specified, the service will use an index if one is available, and fall back to KNN search otherwise.
| Parameter | |
|---|---|
| Name | Description |
var |
SearchHint
|
| Returns | |
|---|---|
| Type | Description |
$this |
|