Skip to content

Commit

Permalink
now targets typesense 0.24.0 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
runeanielsen authored Feb 12, 2023
1 parent 34f9054 commit 637a632
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ executors:
auth:
username: $DOCKER_LOGIN
password: $DOCKER_ACCESSTOKEN
- image: typesense/typesense:0.23.1 # For integration testing
- image: typesense/typesense:0.24.0 # For integration testing
auth:
username: $DOCKER_LOGIN
password: $DOCKER_ACCESSTOKEN
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Clojars Project](https://img.shields.io/clojars/v/io.github.runeanielsen/typesense-clj.svg)](https://clojars.org/io.github.runeanielsen/typesense-clj)

Clojure client for [Typesense 0.23.1](https://github.com/typesense/typesense)
Clojure client for [Typesense 0.24.0](https://github.com/typesense/typesense)

All of the examples uses the `typesense.client` namespace. The examples shows the simplest way to get started using the client, but all parameters described on Typesense API documentation should work, if that is not the case, please make a pull-request or open an issue.

Expand Down Expand Up @@ -723,7 +723,7 @@ bin/kaocha unit
To run the integration tests you can run a local docker instance with the following command. This will start a instance of Typesense on `localhost:8108`. The Typesense instance will be cleaned before starting the integration tests.

```sh
docker run -p 8108:8108 -v/tmp/data:/data typesense/typesense:0.23.1 --data-dir /data --api-key=key
docker run -p 8108:8108 -v/tmp/data:/data typesense/typesense:0.24.0 --data-dir /data --api-key=key
```

The following command runs only the integration tests.
Expand Down
164 changes: 100 additions & 64 deletions test/typesense/client_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
(deftest client-primary-workflow-tests
(testing "Create collection"
(let [expected {:default_sorting_field "num_employees"
:enable_nested_fields false
:fields [{:facet false
:index true
:name "company_name"
Expand Down Expand Up @@ -88,6 +89,7 @@

(testing "List collections"
(let [expected [{:default_sorting_field "num_employees"
:enable_nested_fields false
:fields [{:facet false
:index true
:name "company_name"
Expand Down Expand Up @@ -124,6 +126,7 @@

(testing "Retrieve collection"
(let [expected {:default_sorting_field "num_employees"
:enable_nested_fields false
:fields [{:facet false
:index true
:infix false
Expand Down Expand Up @@ -159,6 +162,7 @@

(testing "Delete collection"
(let [expected {:default_sorting_field "num_employees"
:enable_nested_fields false
:fields [{:facet false
:index true
:name "company_name"
Expand Down Expand Up @@ -323,26 +327,36 @@
(is (= exp res))))

(testing "Search"
(let [exp {:facet_counts []
:found 1
(let [exp {:facet_counts [],
:found 1,
:hits
[{:document
{:company_name "Innovationsoft A/S"
:country "Finland"
:id "1"
:num_employees 10}
{:company_name "Innovationsoft A/S",
:country "Finland",
:id "1",
:num_employees 10},
:highlight
{:company_name
{:matched_tokens ["Innovation"],
:snippet "<mark>Innovation</mark>soft A/S"}},
:highlights
[{:field "company_name"
:matched_tokens ["Innovation"]
:snippet "<mark>Innovation</mark>soft A/S"}]
:text_match 72341261125681153}]
:out_of 1
:page 1
[{:field "company_name",
:matched_tokens ["Innovation"],
:snippet "<mark>Innovation</mark>soft A/S"}],
:text_match 578730089005449337,
:text_match_info
{:best_field_score "1108074561536",
:best_field_weight 15,
:fields_matched 1,
:score "578730089005449337",
:tokens_matched 1}}],
:out_of 1,
:page 1,
:request_params
{:collection_name "companies_documents_test"
:per_page 10
:q "Innovation"}
:search_cutoff false
{:collection_name "companies_documents_test",
:per_page 10,
:q "Innovation"},
:search_cutoff false,
:search_time_ms 0}
res (sut/search settings
"companies_documents_test"
Expand Down Expand Up @@ -371,35 +385,55 @@

(testing "Multi search"
(let [exp {:results
[{:facet_counts []
:found 1
[{:facet_counts [],
:found 1,
:hits
[{:document {:id "1" :name "shoe" :price 75}
[{:document {:id "1", :name "shoe", :price 75},
:highlight
{:name {:matched_tokens ["shoe"], :snippet "<mark>shoe</mark>"}},
:highlights
[{:field "name"
:matched_tokens ["shoe"]
:snippet "<mark>shoe</mark>"}]
:text_match 72341265420713985}]
:out_of 1
:page 1
[{:field "name",
:matched_tokens ["shoe"],
:snippet "<mark>shoe</mark>"}],
:text_match 578730123365711993,
:text_match_info
{:best_field_score "1108091339008",
:best_field_weight 15,
:fields_matched 1,
:score "578730123365711993",
:tokens_matched 1}}],
:out_of 1,
:page 1,
:request_params
{:collection_name "products_multi_search_test" :per_page 10 :q "shoe"}
:search_cutoff false
{:collection_name "products_multi_search_test",
:per_page 10,
:q "shoe"},
:search_cutoff false,
:search_time_ms 0}
{:facet_counts []
:found 1
{:facet_counts [],
:found 1,
:hits
[{:document {:id "1" :name "Nike"}
[{:document {:id "1", :name "Nike"},
:highlight
{:name {:matched_tokens ["Nike"], :snippet "<mark>Nike</mark>"}},
:highlights
[{:field "name"
:matched_tokens ["Nike"]
:snippet "<mark>Nike</mark>"}]
:text_match 72341265420713985}]
:out_of 1
:page 1
[{:field "name",
:matched_tokens ["Nike"],
:snippet "<mark>Nike</mark>"}],
:text_match 578730123365711993,
:text_match_info
{:best_field_score "1108091339008",
:best_field_weight 15,
:fields_matched 1,
:score "578730123365711993",
:tokens_matched 1}}],
:out_of 1,
:page 1,
:request_params
{:collection_name "brands_multi_search_test" :per_page 10 :q "Nike"}
:search_cutoff false
{:collection_name "brands_multi_search_test",
:per_page 10,
:q "Nike"},
:search_cutoff false,
:search_time_ms 0}]}
res (sut/multi-search settings
{:searches [{:collection "products_multi_search_test"
Expand All @@ -423,22 +457,21 @@
(sut/create-document! settings "places" document))

(testing "Geosearch"
(let [exp {:facet_counts []
:found 1
(let [exp {:facet_counts [],
:found 1,
:hits
[{:document
{:id "0"
:location [48.86093481609114 2.33698396872901]
:points 1
:title "Louvre Museuem"}
:geo_distance_meters {:location 1020}
:highlights []
:text_match 100}]
:out_of 1
:page 1
:request_params {:collection_name "places" :per_page 10 :q "*"}
:search_cutoff false
:search_time_ms 0}
{:id "0",
:location [48.86093481609114 2.33698396872901],
:points 1,
:title "Louvre Museuem"},
:geo_distance_meters {:location 1020},
:highlight {},
:highlights []}],
:out_of 1,
:page 1,
:request_params {:collection_name "places", :per_page 10, :q "*"},
:search_cutoff false}
res (sut/search settings
"places"
{:q "*"
Expand Down Expand Up @@ -478,22 +511,25 @@
(is (= exp res))))

(testing "List all overrides"
(let [exp {:overrides [{:excludes [{:id "287"}]
:id "customize_apple"
:includes [{:id "422" :position 1} {:id "54" :position 2}]
:rule {:match "exact" :query "apple"}
:filter_curated_hits false
:remove_matched_tokens false}]}
(let [exp {:overrides
[{:excludes [{:id "287"}],
:filter_curated_hits false,
:id "customize_apple",
:includes [{:id "422", :position 1} {:id "54", :position 2}],
:remove_matched_tokens false,
:rule {:match "exact", :query "apple"},
:stop_processing true}]}
res (sut/list-overrides settings "companies_curation_test")]
(is (= exp res))))

(testing "Retrieve override"
(let [exp {:excludes [{:id "287"}]
:id "customize_apple"
:includes [{:id "422" :position 1} {:id "54" :position 2}]
:rule {:match "exact" :query "apple"}
:filter_curated_hits false
:remove_matched_tokens false}
(let [exp {:excludes [{:id "287"}],
:filter_curated_hits false,
:id "customize_apple",
:includes [{:id "422", :position 1} {:id "54", :position 2}],
:remove_matched_tokens false,
:rule {:match "exact", :query "apple"},
:stop_processing true}
res (sut/retrieve-override settings
"companies_curation_test"
"customize_apple")]
Expand Down

0 comments on commit 637a632

Please sign in to comment.