```source .env typeSenseApiKey=${TYPE_SENSE_API_MA...
# community-help
b
Copy code
source .env
typeSenseApiKey=${TYPE_SENSE_API_MASTER_KEY}
typeSenseHost=${TYPE_SENSE_HOSTURL}


curl "${typeSenseHost}/collections" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${typeSenseApiKey}" \
       -d '{
         "name": "companies",
         "fields": [
           {"name": "company_name", "type": "string" },
           {"name": "num_employees", "type": "int32" },
           {"name": "country", "type": "string", "facet": true }
         ],
         "default_sorting_field": "num_employees"
       }'

curl "${typeSenseHost}/collections/companies/documents/import?action=create" \
        -H "X-TYPESENSE-API-KEY: ${typeSenseApiKey}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "124","company_name": "Stark Industries","num_employees": 5215,"country": "USA"}
            {"id": "125","company_name": "Acme Corp","num_employees": 2133,"country": "CA"}'

curl "${TYPE_SENSE_HOSTURL}/aliases/companies_alias" -X PUT \
            -H "X-TYPESENSE-API-KEY: ${TYPE_SENSE_API_MASTER_KEY}" \
            -H "Content-Type: application/json" \
            -d "{\"collection_name\":\"companies\"}"


curl "${typeSenseHost}/multi_search?query_by=name" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: ${typeSenseApiKey}" \
        -d '{
          "searches": [
            {
              "collection": "companies_alias",
              "q": "stark"
            }
          ]
        }'