Skip to content

Instantly share code, notes, and snippets.

@kishorenc
Created June 28, 2023 08:24
Show Gist options
  • Save kishorenc/865511899735ab23d82b29d8592751c5 to your computer and use it in GitHub Desktop.
Save kishorenc/865511899735ab23d82b29d8592751c5 to your computer and use it in GitHub Desktop.
curl -k "http://localhost:8108/collections" -X POST -H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
"name": "titles",
"fields": [
{"name": "embedding", "type": "float[]", "num_dim": 3},
{"name": "title", "type": "string"}
]
}'
curl "http://localhost:8108/collections/titles/documents" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{"title": "Title 1", "embedding": [0.1, 0.2, 0.3]}'
curl "http://localhost:8108/collections/titles/documents" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{"title": "Title 2", "embedding": [0.4, 0.5, 0.6]}'
# Returns the vector field
curl 'http://localhost:8108/multi_search' -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" --data-raw '{
"per_page": 1,
"searches":[
{
"q":"*",
"include_fields": "embedding",
"collection": "titles"
}
]
}'
{"results":[{"facet_counts":[],"found":2,"hits":[{"document":{"embedding":[0.4,0.5,0.6]},"highlight":{},"highlights":[]},{"document":{"embedding":[0.1,0.2,0.3]},"highlight":{},"highlights":[]}],"out_of":2,"page":1,"request_params":{"collection_name":"titles","per_page":10,"q":"*"},"search_cutoff":false,"search_time_ms":0}]}%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment