Slackbot
06/04/2025, 1:58 PMJason Bosco
06/04/2025, 6:46 PMTed Mader
06/05/2025, 1:27 PMJason Bosco
06/05/2025, 1:28 PMTed Mader
06/05/2025, 1:28 PMTed Mader
06/05/2025, 1:30 PMTed Mader
06/05/2025, 1:31 PMTed Mader
06/05/2025, 1:32 PMJason Bosco
06/05/2025, 1:51 PMTed Mader
06/11/2025, 4:41 PMAlan Martini
06/11/2025, 5:11 PM#!/bin/bash
### Run Typesense via Docker ########################################
export TYPESENSE_API_KEY=xyz
export TYPESENSE_HOST=http://localhost:8108
export TYPESENSE_PORT=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 $TYPESENSE_PORT:8108 --name typesense-repro \
-v"$(pwd)"/typesense-data-dir-repro:/data \
typesense/typesense:28.0 \
--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
# Create collection
curl -X POST "$TYPESENSE_HOST/collections" \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"name": "YOUR_COLLECTION_NAME",
"fields": [
{"name": "shortId", "type": "string"},
{"name": "keywords", "type": "string[]"},
{"name": "topics", "type": "string[]"},
{"name": "popularity","type": "int32"}
],
"default_sorting_field": "popularity"
}'
curl -X POST "$TYPESENSE_HOST/collections/YOUR_COLLECTION_NAME/documents" \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"keywords": [
"Nicks - Robert",
"Nicks Handmade Boots",
"Nicks - 55",
"Horween Brown Chromexcel",
"Vibram 700 Tygum V-Bar Full Sole Black"
],
"popularity": 8,
"shortId": "QiLfeyT",
"topics": [
"6803c819a132f6c950755d9c",
"68028873903fc39d877489dd",
"6805143d7922e4b1753037f7",
"6803cd4ee5c82c92a297bfc8",
"6803d1232b25930a6c35e417"
]
}'
curl -X POST "$TYPESENSE_HOST/collections/YOUR_COLLECTION_NAME/documents" \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"keywords": [
"John Lofgren Bootmaker",
"John Lofgren - Combat Boots",
"Horween Black Chromexcel",
"Vibram 7335 Cork Heel",
"John Lofgren - 120",
"Vibram 700 Tygum V-Bar Full Sole Brown Cork"
],
"popularity": 5,
"shortId": "HHEM8Bx",
"topics": [
"68028873903fc39d87748973",
"6803c805a132f6c9507541d4",
"6803cd4ee5c82c92a297bf8f",
"6805143c7922e4b175303752",
"6803d1232b25930a6c35e39f"
]
}'
RESULT=$(curl -X POST "$TYPESENSE_HOST/multi_search" \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"searches": [
{
"query_by": "keywords",
"sort_by": "popularity:desc",
"per_page": 6,
"highlight_full_fields": "keywords",
"collection": "YOUR_COLLECTION_NAME",
"q": "Brown Chromexcel",
"page": 1
}
]
}' | jq .)
echo $RESULT | jq .
docker stop typesense-repro
docker rm typesense-reproTed Mader
06/11/2025, 7:49 PMTed Mader
07/17/2025, 5:39 PMAlan Martini
07/17/2025, 6:07 PMTed Mader
07/18/2025, 3:33 PM