export TYPESENSE_API_KEY=xyz curl -sv "http://localhost:8108/debug" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" curl -sv "http://localhost:8108/collections/following" -X DELETE -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" curl -sv "http://localhost:8108/collections/users" -X DELETE -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" curl -sv "http://localhost:8108/collections" \ -X POST \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -d '{ "name": "users", "fields": [ {"name": "id", "type": "string" }, {"name": "name", "type": "string" } ] }' curl -sv "http://localhost:8108/collections" \ -X POST \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -d '{ "name": "following", "fields": [ {"name": "follower_id", "type": "string", "reference": "users.id" }, {"name": "followed_id", "type": "string", "reference": "users.id" } ] }' echo "\n\nNOTE that I can create a collection with two references to users," \ "\nbut it only takes into account one of them ¿the first one?," \ "\nso maybe it would be better to fail reporting than only one reference is allowed.\n\n" curl -sv "http://localhost:8108/collections/users/documents/import?action=create" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -H "Content-Type: text/plain" \ -X POST \ -d '{"id": "1", "name": "silvia"} {"id": "2", "name": "david"} {"id": "3", "name": "blanca"} {"id": "4", "name": "mario"}' curl -sv "http://localhost:8108/collections/following/documents/import?action=create" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -H "Content-Type: text/plain" \ -X POST \ -d '{"follower_id": "2", "followed_id": "1"} {"follower_id": "3", "followed_id": "1"} {"follower_id": "4", "followed_id": "1"} {"follower_id": "3", "followed_id": "2"} {"follower_id": "4", "followed_id": "2"} {"follower_id": "4", "followed_id": "3"}' curl -sv "http://localhost:8108/multi_search" \ -X POST \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ -d '{ "searches": [ { "collection": "following", "q": "*", "filter_by": "follower_id:=3", "include_fields": "$users(*)" }, { "collection": "following", "q": "*", "filter_by": "followed_id:=3", "include_fields": "$users(*)" } ] }' echo "\n\nNOTE that the '\$users' in 'include_fields' always returns" \ "\nthe user joined via the 'follower_id' reference, but there is" \ "\n no way retrieve the users via the 'followed_id' reference.\n\n"