Skip to main content

Vector Search

POST 

/v1/query/topk

Get sorted results of the top k most semantically similar data points to your query.

The below example demonstrates how to call the endpoint using curl. It includes a vector search query for "footwear", a filter for data with "comfortable" in the title, and will return the fields title, average_rating, and price along with _similarity (which is returned by default).

The results will be 3 data points that contain the text "comfortable" and are most semantically related to "footwear". If fields is not provided, all user-uploaded fields will be returned.

See this guide for a more detailed walkthrough.

curl -X POST 'https://api-atlas.nomic.ai/v1/query/topk' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $NOMIC_API_KEY' \
-d '{
"projection_id": "f1e499cd-b5c1-4d31-b38a-fff61e1f8b59",
"k": 3,
"fields": ["title", "average_rating", "price"],
"query": "footwear",
"selection": {
"method": "composition",
"conjunctor": "ALL",
"filters": [
{
"method": "search",
"query": "comfortable",
"field": "title"
}
]
}
}'

Request

Body

required

    k integerrequired

    Possible values: >= 1

    query

    object

    required

    oneOf

    string

    fields string[]
    task_type string

    Possible values: [search_document, search_query, null]

    Default value: search_query

    projection_id uuidrequired

    selection

    object

    method stringrequired

    Possible values: [composition]

    polarity boolean

    Default value: true

    conjunctor stringrequired

    Possible values: [ANY, ALL]

    cherries

    object

    polarity boolean

    Default value: true

    method stringrequired

    Possible values: [cherrypick]

    added array[]

    Possible values: >= 2, <= 2

    Default value: ``

    removed array[]

    Possible values: >= 2, <= 2

    Default value: ``

    field stringnullable

    filters

    object[]

  • Array [

  • oneOf

    polarity boolean

    Default value: true

    method stringrequired

    Possible values: [search]

    query stringrequired
    field stringrequired
    ignoreCase boolean

    Default value: true

    regex boolean
    wordBoundary boolean
  • ]

  • includeSimilarity boolean

    Default value: true

Responses

Returns the data included in your optional selection most semantically similar to your query. Each object contains the fields specified in the fields request parameter.

Schema

    data object[]required
Loading...