---
title: "POST /v1/{+indexEndpoint}:findNeighbors"
method: POST
path: "/v1/{+indexEndpoint}:findNeighbors"
tags: ["projects"]
---

# POST /v1/{+indexEndpoint}:findNeighbors

`POST /v1/{+indexEndpoint}:findNeighbors`

Finds the nearest neighbors of each vector within the request.

## Path parameters

- `indexEndpoint` string, required

## Request body

- GoogleCloudAiplatformV1FindNeighborsRequest — The request message for MatchService.FindNeighbors.
  - `returnFullDatapoint` boolean — If set to true, the full datapoints (including all vector values and restricts) of the nearest neighbors are returned. Note that returning full datapoint will significantly increase the latency and cost of the query.
  - `deployedIndexId` string — The ID of the DeployedIndex that will serve the request. This request is sent to a specific IndexEndpoint, as per the IndexEndpoint.network. That IndexEndpoint also has IndexEndpoint.deployed_indexes, and each such index has a DeployedIndex.id field. The value of the field below must equal one of the DeployedIndex.id fields of the IndexEndpoint that is being called for this request.
  - `queries` GoogleCloudAiplatformV1FindNeighborsRequestQuery[] — The list of queries.
    - `rrf` GoogleCloudAiplatformV1FindNeighborsRequestQueryRRF — Parameters for RRF algorithm that combines search results.
      - `alpha` number, float — Required. Users can provide an alpha value to give more weight to dense vs sparse results. For example, if the alpha is 0, we only return sparse and if the alpha is 1, we only return dense.
    - `fractionLeafNodesToSearchOverride` number, double — 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. If not set or set to 0.0, query uses the default value specified in NearestNeighborSearchConfig.TreeAHConfig.fraction_leaf_nodes_to_search.
    - `approximateNeighborCount` integer — The number of neighbors to find via approximate search before exact reordering is performed. If not set, the default value from scam config is used; if set, this value must be > 0.
    - `datapoint` GoogleCloudAiplatformV1IndexDatapoint — A datapoint of Index.
      - `featureVector` number[] — Required. Feature embedding vector for dense index. An array of numbers with the length of [NearestNeighborSearchConfig.dimensions].
      - `numericRestricts` GoogleCloudAiplatformV1IndexDatapointNumericRestriction[] — Optional. List of Restrict of the datapoint, used to perform "restricted searches" where boolean rule are used to filter the subset of the database eligible for matching. This uses numeric comparisons.
        - `valueFloat` number, float — Represents 32 bit float.
        - `op` 'OPERATOR_UNSPECIFIED' | 'LESS' | 'LESS_EQUAL' | 'EQUAL' | 'GREATER_EQUAL' | 'GREATER' | 'NOT_EQUAL' — This MUST be specified for queries and must NOT be specified for datapoints.
        - `namespace` string — The namespace of this restriction. e.g.: cost.
        - `valueInt` string, int64 — Represents 64 bit integer.
        - `valueDouble` number, double — Represents 64 bit float.
      - `crowdingTag` GoogleCloudAiplatformV1IndexDatapointCrowdingTag — Crowding tag is a constraint on a neighbor list produced by nearest neighbor search requiring that no more than some value k' of the k neighbors returned have the same value of crowding_attribute.
        - `crowdingAttribute` string — The attribute value used for crowding. The maximum number of neighbors to return per crowding attribute value (per_crowding_attribute_num_neighbors) is configured per-query. This field is ignored if per_crowding_attribute_num_neighbors is larger than the total number of neighbors to return for a given query.
      - `restricts` GoogleCloudAiplatformV1IndexDatapointRestriction[] — Optional. List of Restrict of the datapoint, used to perform "restricted searches" where boolean rule are used to filter the subset of the database eligible for matching. This uses categorical tokens. See: https://cloud.google.com/vertex-ai/docs/matching-engine/filtering
        - `denyList` string[] — The attributes to deny in this namespace. e.g.: 'blue'
        - `namespace` string — The namespace of this restriction. e.g.: color.
        - `allowList` string[] — The attributes to allow in this namespace. e.g.: 'red'
      - `embeddingMetadata` object — Optional. The key-value map of additional metadata for the datapoint.
      - `datapointId` string — Required. Unique identifier of the datapoint.
      - `sparseEmbedding` GoogleCloudAiplatformV1IndexDatapointSparseEmbedding — Feature embedding vector for sparse index. An array of numbers whose values are located in the specified dimensions.
        - `values` number[] — Required. The list of embedding values of the sparse vector.
        - `dimensions` string[] — Required. The list of indexes for the embedding values of the sparse vector.
    - `perCrowdingAttributeNeighborCount` integer — Crowding is a constraint on a neighbor list produced by nearest neighbor search requiring that no more than some value k' of the k neighbors returned have the same value of crowding_attribute. It's used for improving result diversity. This field is the maximum number of matches with the same crowding tag.
    - `neighborCount` integer — The number of nearest neighbors to be retrieved from database for each query. If not set, will use the default from the service configuration (https://cloud.google.com/vertex-ai/docs/matching-engine/configuring-indexes#nearest-neighbor-search-config).

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/aiplatform.md) · [All operations](https://skmtc.net/google/apis/aiplatform/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/aiplatform/versions/b608d71b91f0/schema)
