Adrian Kager
05/30/2023, 3:46 PMexport TYPESENSE_API_KEY=xyz
curl "<http://localhost:8108/collections>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{
"name": "companies",
"fields": [
{"name": "company_name", "type": "string" },
{"name": "num_employees", "type": "int32" },
{"name": "additional_data_1", "type": "string", "optional": true }
],
"default_sorting_field": "num_employees"
}'
curl "<http://localhost:8108/collections/companies/documents/import?action=create>" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: text/plain" \
-X POST \
-d '{"id": "124","company_name": "Stark Industries","num_employees": 5215}
{"id": "125","company_name": "Acme Corp","num_employees": 2133}
{"id": "126","company_name": "Stark Industries","num_employees": 5215,"additional_data_1": "data"}'
curl "<http://localhost:8108/multi_search>" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{
"searches": [
{
"collection": "companies",
"q": "stark",
"query_by": "company_name, additional_data_.*"
}
]
}'