Search a vector store

Search a vector store for relevant chunks based on a query and file attributes filter.

Request

POST

https://ai.api.cloud.yandex.net/v1/vector_stores/{vector_store_id}/search

Path parameters

Name

Description

vector_store_id

Type: string

The ID of the vector store to search.

Example: ``

Body

application/json
{
  "query": "example",
  "rewrite_query": false,
  "max_num_results": 10,
  "filters": {
    "type": "eq",
    "key": "example",
    "value": "example"
  },
  "ranking_options": {
    "ranker": "auto",
    "score_threshold": 0
  }
}

Name

Description

query

One of 2 types
  • Type: string

    Example: example

  • Type: string[]

    Example
    [
      "example"
    ]
    

A query string for a search

Example: example

filters

One of 2 types
  • Comparison Filter

    Type: ComparisonFilter

    A filter used to compare a specified attribute key to a given value using a defined comparison operation.

    Example
    {
      "type": "eq",
      "key": "example",
      "value": "example"
    }
    
  • Compound Filter

    Type: CompoundFilter

    Combine multiple filters using and or or.

    Example
    {
      "type": "and",
      "filters": [
        {
          "type": "eq",
          "key": "example",
          "value": "example"
        }
      ]
    }
    

A filter to apply based on file attributes.

Example
{
  "type": "eq",
  "key": "example",
  "value": "example"
}

max_num_results

Type: integer

The maximum number of results to return. This number should be between 1 and 50 inclusive.

Default: 10

Min value: 1

Max value: 50

ranking_options

Type: object

ranker

Type: string

Enable re-ranking; set to none to disable, which can help reduce latency.

Default: auto

Enum: none, auto, default-2024-11-15

score_threshold

Type: number

Default: 0

Min value: 0

Max value: 1

Ranking options for search.

Example
{
  "ranker": "auto",
  "score_threshold": 0
}

rewrite_query

Type: boolean

Whether to rewrite the natural language query for vector search.

Default: false

ComparisonFilter

A filter used to compare a specified attribute key to a given value using a defined comparison operation.

Name

Description

key

Type: string

The key to compare against the value.

Example: example

type

Type: string

Specifies the comparison operator:

  • eq: equals - ne: not equal - gt: greater than - gte: greater than or equal - lt: less than - lte: less than or equal - in: in - nin: not in

Default: eq

Enum: eq, ne, gt, gte, lt, lte, in, nin

value

One of 4 types
  • Type: string

    Example: example

  • Type: number

  • Type: boolean

  • Type: array
    One of 2 types
    • Type: string

      Example: example

    • Type: number

    Example
    [
      "example"
    ]
    

The value to compare against the attribute key; supports string, number, or boolean types.

Example: example

Example
{
  "type": "eq",
  "key": "example",
  "value": "example"
}

CompoundFilter

Combine multiple filters using and or or.

Name

Description

filters

Type: array
One of 2 types
  • Comparison Filter

    Type: ComparisonFilter

    A filter used to compare a specified attribute key to a given value using a defined comparison operation.

    Example
    {
      "type": "eq",
      "key": "example",
      "value": "example"
    }
    
  • Type: unknown

    Example: null

Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.

Example
[
  {
    "type": "eq",
    "key": "example",
    "value": "example"
  }
]

type

Type: string

Type of operation: and or or.

Enum: and, or

Example
{
  "type": "and",
  "filters": [
    {
      "type": "eq",
      "key": "example",
      "value": "example"
    }
  ]
}

Responses

200 OK

OK

Body

application/json
{
  "object": "vector_store.search_results.page",
  "search_query": [
    "example"
  ],
  "data": [
    {
      "file_id": "example",
      "filename": "example",
      "score": 0,
      "attributes": null,
      "content": [
        {
          "type": "text",
          "text": "example"
        }
      ]
    }
  ],
  "has_more": true,
  "next_page": "example"
}

Name

Description

data

Type: VectorStoreSearchResultItem[]

The list of search result items.

Example
[
  {
    "file_id": "example",
    "filename": "example",
    "score": 0,
    "attributes": null,
    "content": [
      {
        "type": "text",
        "text": "example"
      }
    ]
  }
]

has_more

Type: boolean

Indicates if there are more results to fetch.

next_page

Any of 2 types
  • Type: string

    The token for the next page, if any.

    Example: example

  • Type: null

    Example: null

Example: example

object

Type: string

The object type, which is always vector_store.search_results.page

Const: vector_store.search_results.page

Example: example

search_query

Type: string[]

Example
[
  "example"
]

VectorStoreFileAttributes

Any of 2 types
  • Type: object

    [additional]

    One of 3 types
    • Type: string

      Max length: 512

      Example: example

    • Type: number

    • Type: boolean

    Example: example

    Set of key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

    Max properties: 16

    Example
    {}
    
  • Type: unknown

    Example: null

Default: null

VectorStoreSearchResultContentObject

Name

Description

text

Type: string

The text content returned from search.

Example: example

type

Type: string

The type of content.

Const: text

Example: example

Example
{
  "type": "text",
  "text": "example"
}

VectorStoreSearchResultItem

Name

Description

attributes

Type: VectorStoreFileAttributes

Default: null

Example
{}

content

Type: VectorStoreSearchResultContentObject[]

Content chunks from the file.

Example
[
  {
    "type": "text",
    "text": "example"
  }
]

file_id

Type: string

The ID of the vector store file.

Example: example

filename

Type: string

The name of the vector store file.

Example: example

score

Type: number

The similarity score for the result.

Min value: 0

Max value: 1

Example
{
  "file_id": "example",
  "filename": "example",
  "score": 0,
  "attributes": null,
  "content": [
    {
      "type": "text",
      "text": "example"
    }
  ]
}