Seb
11/13/2024, 11:34 AM### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
mkdir "$(pwd)"/typesense-data
docker run -p 8108:8108 \
-v"$(pwd)"/typesense-data:/data typesense/typesense:27.1 \
--data-dir /data \
--api-key=$TYPESENSE_API_KEY \
--enable-cors
### Reproduction Steps ###############################################
export TYPESENSE_API_KEY=xyz
curl "<http://localhost:8108/debug>" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
curl "<http://localhost:8108/collections>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{
"name": "entities",
"fields": [
{"name": "type", "type": "string", "facet": true, "sort": true },
{"name": "id", "type": "string", "sort": true },
{"name": "name", "type": "string", "sort": true },
{"name": "host", "type": "string", "sort": true },
{"name": "is_dev", "type": "bool", "facet": true },
{"name": "created_at", "type": "int64", "sort": true },
],
"default_sorting_field": "created_at"
}'
curl "<http://localhost:8108/collections/entities/documents/import?action=create>" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: text/plain" \
-X POST \
-d '{"type": "tenant", "id": "tenant-1","name": "Scott Ltd 1","host": "scott-ltd-1.dev","is_dev": false, "created_at": 1730136502}'
curl "<http://localhost:8108/multi_search>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{
"searches": [
{
"collection": "entities",
"q": "scott",
"query_by": "name,host",
"highlight_fields": "name,host",
"facet_by": "type",
"page": 1,
"per_page": 10
}
]
}'
### Documentation ######################################################################################
# Visit the API reference section: <https://typesense.org/docs/27.1/api/collections.html>
# Click on the "Shell" tab under each API resource's docs, to get shell commands for other API endpoints