-
-
Save kishorenc/6ccb571aec63cc64ee4822c8ec6b6dc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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":113,"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":114,"title":"จารีย์", "id": "1"}' | |
# Try searching: we expect record with id "1" to appear first | |
curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" http://localhost:8108/collections/titles/documents/search/\?q\=จารีย์\&query_by\=title | |
# id "1" appearing first correctly | |
{"facet_counts":[],"found":2,"hits":[{"document":{"id":"1","points":114,"title":"จารีย์"},"highlights":[{"field":"title","matched_tokens":["จา","รีย์"],"snippet":"<mark>จา</mark><mark>รีย์</mark>"}],"text_match":50291458},{"document":{"id":"0","points":113,"title":"การกระจายรายได้"},"highlights":[{"field":"title","matched_tokens":["จา"],"snippet":"การกระ<mark>จา</mark>ยรายได้"}],"text_match":33514496}],"out_of":2,"page":1,"request_params":{"collection_name":"titles","per_page":10,"q":"จารีย์"},"search_time_ms":1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment