Vector Search
posthttps://api-atlas.nomic.ai/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) application/json
kinteger*requiredquerystring | array<number>*requiredfieldsarray<string>task_typestringPossible values: search_document, search_query, null
Default: "search_query"
projection_idstring ($uuid)*requiredselectionobjectmethodstring*requiredPossible values: composition
polaritybooleanDefault: true
conjunctorstring*requiredPossible values: ANY, ALL
cherriesobjectpolaritybooleanDefault: true
methodstring*requiredPossible values: cherrypick
addedarray<array<any>>Default: []
removedarray<array<any>>Default: []
fieldstringfiltersarray<object>includeSimilaritybooleanDefault: true
Responses
fields request parameter.dataarray<object>*requiredExamples
curl -X 'POST' \
'https://api-atlas.nomic.ai/v1/query/topk' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"k": 1,
"query": "string",
"fields": [
"string"
],
"task_type": "search_document",
"projection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"selection": {
"method": "composition",
"polarity": true,
"conjunctor": "ANY",
"cherries": {
"polarity": true,
"method": "cherrypick",
"added": [],
"removed": [],
"field": "string"
},
"filters": [
{
"polarity": null,
"method": "search",
"query": "string",
"field": "string",
"ignoreCase": true,
"regex": false,
"wordBoundary": false
},
{
"polarity": null,
"method": "range",
"field": "string",
"range": [
null
]
},
{
"polarity": null,
"method": "category",
"field": "string",
"values": null
},
{
"method": "composition",
"polarity": true,
"conjunctor": "ANY",
"cherries": {},
"filters": [
null,
null,
null,
null
]
}
]
},
"includeSimilarity": true
}'