Created
January 22, 2026 15:52
-
-
Save clone1018/79735b24223525bcd4545e169d8fdac2 to your computer and use it in GitHub Desktop.
sort_by pivot typesense bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 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": "companies", | |
| "fields": [ | |
| {"name": "company_name", "type": "string" }, | |
| {"name": "num_employees", "type": "int32" }, | |
| {"name": "country", "type": "string", "facet": true }, | |
| {"name": "created", "type": "int64" } | |
| ], | |
| "default_sorting_field": "created" | |
| }' | jq | |
| curl -s "$TYPESENSE_HOST/collections/companies/documents/import?action=create" \ | |
| -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ | |
| -H "Content-Type: text/plain" \ | |
| -X POST \ | |
| -d '{"id": "124","company_name": "Stark Industries","num_employees": 5215,"country": "USA", "created": 1768453200} | |
| {"id": "125","company_name": "Acme Corp","num_employees": 2133,"country": "CA", "created": 1768885200}' | jq | |
| # OK SORT | |
| curl -s "$TYPESENSE_HOST/multi_search" \ | |
| -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ | |
| -d ' | |
| { | |
| "searches": [ | |
| { | |
| "collection": "companies", | |
| "q": "", | |
| "query_by": "company_name", | |
| "sort_by": "created:asc" | |
| } | |
| ] | |
| }' | jq | |
| # NOT OK SORT | |
| curl -s "$TYPESENSE_HOST/multi_search" \ | |
| -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ | |
| -d ' | |
| { | |
| "searches": [ | |
| { | |
| "collection": "companies", | |
| "q": "", | |
| "query_by": "company_name", | |
| "sort_by": "created(pivot:1768453200):asc" | |
| } | |
| ] | |
| }' | 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment