Stay organized with collections
Save and categorize content based on your preferences.
Full name: projects.locations.featureOnlineStores.featureViews.searchNearestEntities
Search the nearest entities under a FeatureView. Search only works for indexable feature view; if a feature view isn't indexable, returns Invalid argument response.
Endpoint
post
https://{service-endpoint}/v1/{featureView}:searchNearestEntities
Optional. If set to true, the full entities (including all vector values and metadata) of the nearest neighbors are returned; otherwise only entity id of the nearest neighbors will be returned. Note that returning full entities will significantly increase the latency and cost of the query.
Optional. Crowding is a constraint on a neighbor list produced by nearest neighbor search requiring that no more than sper_crowding_attribute_neighbor_count of the k neighbors returned have the same value of crowdingAttribute. It's used for improving result diversity.
String filter is used to search a subset of the entities by using boolean rules on string columns. For example: if a query specifies string filter with 'name = color, allowTokens = {red, blue}, denyTokens = {purple}',' then that query will match entities that are red or blue, but if those points are also purple, then they will be excluded even if they are red/blue. Only string filter is supported for now, numeric filter will be supported in the near future.
Fields
name
string
Required. column names in BigQuery that used as filters.
Numeric filter is used to search a subset of the entities by using boolean rules on numeric columns. For example: Database Point 0: {name: "a" valueInt: 42} {name: "b" valueFloat: 1.0} Database Point 1: {name: "a" valueInt: 10} {name: "b" valueFloat: 2.0} Database Point 2: {name: "a" valueInt: -1} {name: "b" valueFloat: 3.0} Query: {name: "a" valueInt: 12 operator: LESS} // Matches Point 1, 2 {name: "b" valueFloat: 2.0 operator: EQUAL} // Matches Point 1
Fields
name
string
Required. column name in BigQuery that used as filters.
Value
Union type
The type of Value must be consistent for all datapoints with a given name. This is verified at runtime. Value can be only one of the following:
Optional. This MUST be specified for queries and must NOT be specified for database points.
JSON representation
{"name": string,// Value"valueInt": string,"valueFloat": number,"valueDouble": number// Union type"op": enum (Operator)}
Operator
Datapoints for which Operator is true relative to the query's value field will be allowlisted.
Enums
OPERATOR_UNSPECIFIED
Unspecified operator.
LESS
Entities are eligible if their value is < the query's.
LESS_EQUAL
Entities are eligible if their value is <= the query's.
EQUAL
Entities are eligible if their value is == the query's.
GREATER_EQUAL
Entities are eligible if their value is >= the query's.
GREATER
Entities are eligible if their value is > the query's.
NOT_EQUAL
Entities are eligible if their value is != the query's.
Parameters
Parameters that can be overrided in each query to tune query latency and recall.
Fields
approximateNeighborCandidates
integer
Optional. The number of neighbors to find via approximate search before exact reordering is performed; if set, this value must be > neighborCount.
leafNodesSearchFraction
number
Optional. The fraction of the number of leaves to search, set at query time allows user to tune search performance. This value increase result in both search accuracy and latency increase. The value should be between 0.0 and 1.0.
The attributes of the neighbor, e.g. filters, crowding and metadata Note that full entities are returned only when "returnFullEntity" is set to true. Otherwise, only the "entityId" and "distance" fields are populated.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-27 UTC."],[],[],null,["# Method: featureViews.searchNearestEntities\n\n**Full name**: projects.locations.featureOnlineStores.featureViews.searchNearestEntities\n\nSearch the nearest entities under a FeatureView. Search only works for indexable feature view; if a feature view isn't indexable, returns Invalid argument response. \n\n### Endpoint\n\npost `https:``/``/{service-endpoint}``/v1``/{featureView}:searchNearestEntities` \nWhere `{service-endpoint}` is one of the [supported service endpoints](/vertex-ai/docs/reference/rest#rest_endpoints).\n\n### Path parameters\n\n`featureView` `string` \nRequired. FeatureView resource format `projects/{project}/locations/{location}/featureOnlineStores/{featureOnlineStore}/featureViews/{featureView}`\n\n### Request body\n\nThe request body contains data with the following structure:\nFields `query` `object (`[NearestNeighborQuery](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#NearestNeighborQuery)`)` \nRequired. The query.\n`returnFullEntity` `boolean` \nOptional. If set to true, the full entities (including all vector values and metadata) of the nearest neighbors are returned; otherwise only entity id of the nearest neighbors will be returned. Note that returning full entities will significantly increase the latency and cost of the query. \n\n### Response body\n\nResponse message for [FeatureOnlineStoreService.SearchNearestEntities](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#google.cloud.aiplatform.v1.FeatureOnlineStoreService.SearchNearestEntities)\n\nIf successful, the response body contains data with the following structure:\nFields `nearestNeighbors` `object (`[NearestNeighbors](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#NearestNeighbors)`)` \nThe nearest neighbors of the query entity. \n\nNearestNeighborQuery\n--------------------\n\nA query to find a number of similar entities.\nFields `neighborCount` `integer` \nOptional. The number of similar entities to be retrieved from feature view for each query.\n`stringFilters[]` `object (`[StringFilter](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#StringFilter)`)` \nOptional. The list of string filters.\n`numericFilters[]` `object (`[NumericFilter](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#NumericFilter)`)` \nOptional. The list of numeric filters.\n`perCrowdingAttributeNeighborCount` `integer` \nOptional. Crowding is a constraint on a neighbor list produced by nearest neighbor search requiring that no more than sper_crowding_attribute_neighbor_count of the k neighbors returned have the same value of crowdingAttribute. It's used for improving result diversity.\n`parameters` `object (`[Parameters](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#Parameters)`)` \nOptional. Parameters that can be set to tune query on the fly. \n`instance` `Union type` \n`instance` can be only one of the following:\n`entityId` `string` \nOptional. The entity id whose similar entities should be searched for. If embedding is set, search will use embedding instead of entityId.\n`embedding` `object (`[Embedding](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#Embedding)`)` \nOptional. The embedding vector that be used for similar search. \n\nEmbedding\n---------\n\nThe embedding vector.\nFields `value[]` `number` \nOptional. Individual value in the embedding. \n\nStringFilter\n------------\n\nString filter is used to search a subset of the entities by using boolean rules on string columns. For example: if a query specifies string filter with 'name = color, allowTokens = {red, blue}, denyTokens = {purple}',' then that query will match entities that are red or blue, but if those points are also purple, then they will be excluded even if they are red/blue. Only string filter is supported for now, numeric filter will be supported in the near future.\nFields `name` `string` \nRequired. column names in BigQuery that used as filters.\n`allowTokens[]` `string` \nOptional. The allowed tokens.\n`denyTokens[]` `string` \nOptional. The denied tokens. \n\nNumericFilter\n-------------\n\nNumeric filter is used to search a subset of the entities by using boolean rules on numeric columns. For example: Database Point 0: {name: \"a\" valueInt: 42} {name: \"b\" valueFloat: 1.0} Database Point 1: {name: \"a\" valueInt: 10} {name: \"b\" valueFloat: 2.0} Database Point 2: {name: \"a\" valueInt: -1} {name: \"b\" valueFloat: 3.0} Query: {name: \"a\" valueInt: 12 operator: LESS} // Matches Point 1, 2 {name: \"b\" valueFloat: 2.0 operator: EQUAL} // Matches Point 1\nFields `name` `string` \nRequired. column name in BigQuery that used as filters. \n`Value` `Union type` \nThe type of Value must be consistent for all datapoints with a given name. This is verified at runtime. `Value` can be only one of the following:\n`valueInt` `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` \nint value type.\n`valueFloat` `number` \nfloat value type.\n`valueDouble` `number` \ndouble value type.\n`op` `enum (`[Operator](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#Operator)`)` \nOptional. This MUST be specified for queries and must NOT be specified for database points. \n\nOperator\n--------\n\nDatapoints for which Operator is true relative to the query's value field will be allowlisted.\n\nParameters\n----------\n\nParameters that can be overrided in each query to tune query latency and recall.\nFields `approximateNeighborCandidates` `integer` \nOptional. The number of neighbors to find via approximate search before exact reordering is performed; if set, this value must be \\\u003e neighborCount.\n`leafNodesSearchFraction` `number` \nOptional. The fraction of the number of leaves to search, set at query time allows user to tune search performance. This value increase result in both search accuracy and latency increase. The value should be between 0.0 and 1.0. \n\nNearestNeighbors\n----------------\n\nNearest neighbors for one query.\nFields `neighbors[]` `object (`[Neighbor](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/searchNearestEntities#Neighbor)`)` \nAll its neighbors. \n\nNeighbor\n--------\n\nA neighbor of the query vector.\nFields `entityId` `string` \nThe id of the similar entity.\n`distance` `number` \nThe distance between the neighbor and the query vector.\n`entityKeyValues` `object (`[FetchFeatureValuesResponse](/vertex-ai/docs/reference/rest/v1/FetchFeatureValuesResponse)`)` \nThe attributes of the neighbor, e.g. filters, crowding and metadata Note that full entities are returned only when \"returnFullEntity\" is set to true. Otherwise, only the \"entityId\" and \"distance\" fields are populated."]]