Typesense Cheatsheet

# Run container:
docker run -p 8108:8108 -v/tmp:/data typesense/typesense:0.21.0 --data-dir /data --api-key=xyz

# Create collection:
curl --insecure --request POST 'http://localhost:8108/collections' --header 'content-type: application/json' --header "X-TYPESENSE-API-KEY: xyz" --data-binary '{
    "name": "log",
    "fields": [
        { "name": "id", "type": "string" },
        { "name": "uuid", "type": "string" },
        { "name": "title", "type": "string" },
        { "name": "date", "type": "string" },
        { "name": "tags", "type": "string[]" },
        { "name": "url", "type": "string" },
        { "name": "content", "type": "string" }
    ]
}' | jq '.'

# List collection:
curl --header "X-TYPESENSE-API-KEY: xyz" "http://localhost:8108/collections" | jq '.'

# Get Index:
wget --no-check-certificate https://log.ark.lan/index.json --output-document=log.json

# Convert to JSONL:
cat log.json | jq --compact-output '.[]' > log.jsonl

# Import document:
curl --insecure --header "X-TYPESENSE-API-KEY: xyz" --header 'content-type: application/json' --request POST "http://localhost:8108/collections/log/documents/import?action=create" --data-binary @log.jsonl | jq '.'

# Drop collection:
curl --header "X-TYPESENSE-API-KEY: xyz" --request DELETE "http://localhost:8108/collections/log" | jq '.'

# Search:
curl --header "X-TYPESENSE-API-KEY: xyz" "http://localhost:8108/collections/log/documents/search?q=<query>&query_by=title" | jq '.'

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.