# 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", "fields": [ {"name": "title", "type": "string", "optional": true}, {"name": "region", "type": "string[]", "optional": true}, {"name": "bestseller", "type": "int32", "optional": true, "sort": true}, {"name": "bestseller:region", "type": "object", "optional": true}, {"name": "bestseller:region.QLD", "type": "int32", "optional": true, "sort": true}, {"name": "bestseller:region.NSW", "type": "int32", "optional": true, "sort": true} ], "enable_nested_fields": true }' # 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 dynamic filter 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": { "filter_by": "region:={region}" }, "remove_matched_tokens": true, "sort_by": "bestseller:region.{region}:desc" }' # Override doesn't apply - documents aren't sorted by bestseller:region.QLD curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_BASE_URL}/collections/regions:test/documents/search?q=*&filter_by=region:=QLD"