Skip to content

Instantly share code, notes, and snippets.

@kishorenc
Last active May 28, 2021 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kishorenc/fe9fd5587f5e8e758da8b3d81091f447 to your computer and use it in GitHub Desktop.
Save kishorenc/fe9fd5587f5e8e758da8b3d81091f447 to your computer and use it in GitHub Desktop.
curl -k "http://localhost:8108/collections" -X POST -H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
"name": "titles", "num_memory_shards": 4,
"fields": [
{"name": "title", "type": "string", "locale": "th" },
{"name": "points", "type": "int32" }
],
"default_sorting_field": "points"
}'
curl 'http://localhost:8108/collections/titles/documents?dirty_values=coerce_or_reject&action=upsert' -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{"points":100,"title":"ติดกับดักรายได้ปานกลาง", "id": "0"}'
curl 'http://localhost:8108/collections/titles/documents?dirty_values=coerce_or_reject&action=upsert' -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{"points":100,"title":"ข้อมูลรายคนหรือรายบริษัทในการเชื่อมโยงส่วนได้ส่วนเสีย", "id": "1"}'
# Search
curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" http://localhost:8108/collections/titles/documents/search/\?q\=%E0%B8%A3%E0%B8%B2%E0%B8%A2%E0%B9%84%E0%B8%94%E0%B9%89\&query_by\=title\&num_typos\=0\&sort_by\=_text_match:desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment