# Create collection curl "${TYPESENSE_BASE_URL}/collections" \ -X POST \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -d '{ "name": "regions:test", "enable_nested_fields": true, "fields": [ {"name": ".*", "type": "auto" } ] }' # Add documents curl "${TYPESENSE_BASE_URL}/collections/regions:test/documents/import?action=create" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -H "Content-Type: text/plain" \ -X POST \ -d '{"id": "1","title": "Product 1","region": ["NSW","QLD"], "bestseller": 300,"bestseller:region": {"NSW": 100,"QLD":200}} {"id": "2","title": "Product 2","region": ["NSW","QLD"], "bestseller": 600,"bestseller:region": {"NSW": 500,"QLD":100}}' # Create override curl "${TYPESENSE_BASE_URL}/collections/regions:test/overrides/dynamic-query" -X PUT \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{ "rule": { "query": "{region}", "match": "exact" }, "remove_matched_tokens": true, "sort_by": "bestseller:region.{region}:desc" }' # "Could not find a field named `bestseller:region.{region}` in the schema for sorting." curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_BASE_URL}/collections/regions:test/documents/search?q=*" curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_BASE_URL}/collections/regions:test/documents/search?q=product&fields=title" curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_BASE_URL}/collections/regions:test/documents/search?q=product%20NSW&query_by=title,region" # Success curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_BASE_URL}/collections/regions:test/documents/search?q=product%20NSW&query_by=title,region&enable_overrides=false"