Henrik Sjödahl
09/29/2025, 12:04 PMAlan Martini
09/29/2025, 1:56 PMHenrik Sjödahl
09/29/2025, 2:27 PMproducts
& product_data
When searching products with a pinned_hit, joining product_data, the pinned hit do not get product_data
joined
### 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 \
--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": "name", "type": "string" }
]
}' | 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": "124","name": "First Product"}
{"id": "125","name": "Second Product"}' | jq
curl -s "$TYPESENSE_HOST/collections" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '
{
"name": "product_data",
"fields": [
{"name": "product_id", "type": "string", "reference": "products.id" },
{"name": "extra_data", "type": "string" }
]
}' | jq
curl -s "$TYPESENSE_HOST/collections/product_data/documents/import?action=create" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: text/plain" \
-X POST \
-d '{"id": "124","product_id": "124","extra_data": "foo"}
{"id": "125","product_id": "125","extra_data": "bar"}' | jq
curl -s "$TYPESENSE_HOST/collections/products/documents/search" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-X GET \
-G \
--data-urlencode "q=*" \
--data-urlencode 'filter_by=$product_data(id:*)' \
--data-urlencode "pinned_hits=124:1" \
--data-urlencode "filter_curated_hits=true" | 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 endpoints
Alan Martini
09/29/2025, 3:57 PMHenrik Sjödahl
09/30/2025, 5:15 AMAlan Martini
09/30/2025, 3:03 PM