Typesense-readme-3.py
· 493 B · Python
Исходник
import typesense
client = typesense.Client({
'api_key': 'Hu52dwsas2AdxdE',
'nodes': [{
'host': 'localhost',
'port': '8108',
'protocol': 'http'
}],
'connection_timeout_seconds': 2
})
create_response = client.collections.create({
"name": "companies",
"fields": [
{"name": "company_name", "type": "string" },
{"name": "num_employees", "type": "int32" },
{"name": "country", "type": "string", "facet": True }
],
"default_sorting_field": "num_employees"
})
1 | import typesense |
2 | |
3 | client = typesense.Client({ |
4 | 'api_key': 'Hu52dwsas2AdxdE', |
5 | 'nodes': [{ |
6 | 'host': 'localhost', |
7 | 'port': '8108', |
8 | 'protocol': 'http' |
9 | }], |
10 | 'connection_timeout_seconds': 2 |
11 | }) |
12 | |
13 | create_response = client.collections.create({ |
14 | "name": "companies", |
15 | "fields": [ |
16 | {"name": "company_name", "type": "string" }, |
17 | {"name": "num_employees", "type": "int32" }, |
18 | {"name": "country", "type": "string", "facet": True } |
19 | ], |
20 | "default_sorting_field": "num_employees" |
21 | }) |