Athul
09/17/2025, 8:48 AMFanis Tharropoulos
09/17/2025, 8:48 AMAthul
09/17/2025, 9:07 AMFanis Tharropoulos
09/17/2025, 9:07 AMAthul
09/17/2025, 9:35 AM### Run Typesense via Docker ########################################
set -x
export TYPESENSE_API_KEY=xyz
export TYPESENSE_HOST=<http://localhost:8108>
docker stop typesense-repro 2>/dev/null
docker rm typesense-repro 2>/dev/null
rm -rf "$(pwd)"/typesense-data-dir-repro
mkdir "$(pwd)"/typesense-data-dir-repro
# Wait for Typesense to be ready
docker run -d -p 8108:8108 --name typesense-repro \
-v"$(pwd)"/typesense-data-dir-repro:/data \
typesense/typesense:29.0.rc31 \
--data-dir /data \
--api-key=$TYPESENSE_API_KEY \
--enable-cors
# Wait till typesense is ready.
until curl -s -o /dev/null -w "%{http_code}" "$TYPESENSE_HOST/health" -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" | grep -q "200"; do
sleep 2
done
curl -s "$TYPESENSE_HOST/debug" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" | jq
curl -s "$TYPESENSE_HOST/collections" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '
{
"name": "products",
"fields": [
{"name": "title", "type": "string" },
{"name": "tags", "type": "string[]" },
{"name": "product_types", "type": "string[]" },
{"name" : "embedding","type" : "float[]","embed": {"from": ["title","tags","product_types"],"model_config": {"model_name": "ts/all-MiniLM-L12-v2"}}}
]
}' | jq
curl -s "$TYPESENSE_HOST/collections/products/documents/import?action=create" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: text/plain" \
-X POST \
-d $'{"id": "1","title": "Bow Print Nightie","tags": ["bow print","nightie","short sleeve","t-shirt dress","casual dress","navy dress","womens nightwear","sleepwear","night dress","knee length dress"],"product_types":["nightie","dress","sleepwear"]}
{"id": "2","title": "Star Print Nightie","tags": ["star print","nightgown","night dress","sleepwear","short sleeve","casual nightie","star pattern","women\'s nightwear","lightweight nightgown"],"product_types": ["nightgown","sleepwear","nightdress"]}
{"id":"3","title":"Star Nightie","tags":["star nightie","star dress","night dress","nightgown","sleepwear","womens nightie","casual dress","t-shirt dress","star print dress","white dress","brown star","short sleeve nightie"],"product_types": ["nightie","dress","sleepwear"]}
{"id":"4","title":"Bobble LED Lamp","tags":["LED lamp","bobble lamp","white lamp","modern lamp","decorative lamp","table lamp","night light","bedroom lamp","living room lamp","accent lighting","textured lamp","unique lamp","bulb lamp","small lamp"],"product_types":["Table Lamp","LED Lamp","Accent Lamp","Night Light"]}' | jq
curl -s "$TYPESENSE_HOST/multi_search" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '
{
"searches": [
{
"collection": "products",
"q": "modern night dress",
"query_by": "title,tags,product_types,embedding",
"include_fields":"title",
"vector_query":"embedding:([], distance_threshold: 0.22)"
}
]
}' | jq
docker stop typesense-repro
docker rm typesense-repro
### Documentation ######################################################################################
# Visit the API reference section: <https://typesense.org/docs/28.0/api/collections.html>
# Click on the "Shell" tab under each API resource's docs, to get shell commands for other API endpointsAthul
09/17/2025, 9:36 AMFanis Tharropoulos
09/17/2025, 10:35 AMdrop_tokens_mode.Athul
09/17/2025, 11:43 AM