From e8ef8aa13cd906a1c57a26658f4e48b452c72eb1 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Tue, 17 Sep 2024 11:56:25 +0300 Subject: [PATCH 1/5] docs(preset): update preset configuration documentation for search API - Modify example to show single-search preset structure - Add tip section explaining multi-search preset option - Recommend using single-search presets for flexibility - Update code examples in JavaScript, Dart, and Shell --- docs-site/content/27.0/api/search.md | 34 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/docs-site/content/27.0/api/search.md b/docs-site/content/27.0/api/search.md index ce248f27..1736e13d 100644 --- a/docs-site/content/27.0/api/search.md +++ b/docs-site/content/27.0/api/search.md @@ -716,7 +716,7 @@ Let's create a preset with name `listing_view`. ```js await client.presets().upsert("listing_view", { value: { - searches: [{ collection: "products", q: "*", sort_by: "popularity" }], + collection: "products", q: "*", sort_by: "popularity", }, }); ``` @@ -727,9 +727,7 @@ Let's create a preset with name `listing_view`. ```dart await client.presets.upsert('listing_view', { 'value': { - 'searches': [ - {'collection': 'products', 'q': '*','sort_by': 'popularity'} - ] + 'collection': 'products', 'q': '*','sort_by': 'popularity' } }); ``` @@ -741,11 +739,10 @@ Let's create a preset with name `listing_view`. curl "http://localhost:8108/presets/listing_view" -X PUT \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ --d '{"value": {"searches":[{"collection":"products","q":"*", "sort_by": "popularity"}]}}' +-d '{"value": {"collection":"products","q":"*", "sort_by": "popularity"}}' ``` - You can refer to this preset configuration during a search operation. @@ -776,6 +773,31 @@ curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -X POST \ +:::tip +The `value` key in the preset configuration can also match the search parameters for Federated / Multi Search. For example: + +```js + await client.presets().upsert("listing_view", { + value: { + searches: [ + { + collection: "products", + q: "*", + sort_by: "popularity", + }, + { + collection: "blog_posts", + q: "*", + sort_by: "published_at:desc", + } + ], + }, + }) +``` + +It's generally recommended to use single-search presets for flexibility. You can then combine them in a multi-search request using the `preset` parameter. +::: + You can use the preset configuration for a `GET .../search` end-point as well. The only requirement is that for From 9ae2277f631808cadf19c712cec3718ea954ac89 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 19 Sep 2024 17:13:35 +0300 Subject: [PATCH 2/5] docs(preset): remove redudant information about mutli search presets --- docs-site/content/27.0/api/search.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs-site/content/27.0/api/search.md b/docs-site/content/27.0/api/search.md index 1736e13d..9afca6d5 100644 --- a/docs-site/content/27.0/api/search.md +++ b/docs-site/content/27.0/api/search.md @@ -794,8 +794,6 @@ The `value` key in the preset configuration can also match the search parameters }, }) ``` - -It's generally recommended to use single-search presets for flexibility. You can then combine them in a multi-search request using the `preset` parameter. ::: You can use the preset configuration for a `GET .../search` end-point as well. From 235aaad774b6db46aef09a8718b5f48ec075b2f1 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 3 Oct 2024 11:14:59 +0300 Subject: [PATCH 3/5] docs(presets): reintroduce recommendation and remove following paragraph Remove the paragraph following the new documentation updates, as it was reiterating the same ideas. --- docs-site/content/27.0/api/search.md | 32 +--------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/docs-site/content/27.0/api/search.md b/docs-site/content/27.0/api/search.md index 9afca6d5..c85801c8 100644 --- a/docs-site/content/27.0/api/search.md +++ b/docs-site/content/27.0/api/search.md @@ -796,37 +796,7 @@ The `value` key in the preset configuration can also match the search parameters ``` ::: -You can use the preset configuration for a `GET .../search` end-point as well. - -The only requirement is that for -`GET .../search`, the stored preset value should be a simple dictionary of search configurations, like this. - - - - - +It's generally recommended to use single-search presets for flexibility. You can then combine them in a multi-search request using the `preset` parameter. :::tip Explicit query parameters passed to the search end-point will override parameters stored in preset value. From ad05db2fc9d40adf1141b0535f10e2df2918d79e Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 3 Oct 2024 11:21:30 +0300 Subject: [PATCH 4/5] docs(presets): update 27.1 version of docs with changes for presets --- docs-site/content/27.1/api/search.md | 51 ++++++++++++---------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/docs-site/content/27.1/api/search.md b/docs-site/content/27.1/api/search.md index 09a411c4..e5c22e76 100644 --- a/docs-site/content/27.1/api/search.md +++ b/docs-site/content/27.1/api/search.md @@ -776,38 +776,31 @@ curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -X POST \ -You can use the preset configuration for a `GET .../search` end-point as well. - -The only requirement is that for -`GET .../search`, the stored preset value should be a simple dictionary of search configurations, like this. - - - - - +It's generally recommended to use single-search presets for flexibility. You can then combine them in a multi-search request using the `preset` parameter. :::tip Explicit query parameters passed to the search end-point will override parameters stored in preset value. -::: +::: \ No newline at end of file From 5df7dbe0e1fe883a0594d53fa9802fe2ffa0c989 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Fri, 11 Oct 2024 10:41:10 +0300 Subject: [PATCH 5/5] fix(presets): update preset upsert example for 27.1 to match that one of 27.0 --- docs-site/content/27.1/api/search.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs-site/content/27.1/api/search.md b/docs-site/content/27.1/api/search.md index e5c22e76..26ac6baf 100644 --- a/docs-site/content/27.1/api/search.md +++ b/docs-site/content/27.1/api/search.md @@ -716,7 +716,7 @@ Let's create a preset with name `listing_view`. ```js await client.presets().upsert("listing_view", { value: { - searches: [{ collection: "products", q: "*", sort_by: "popularity" }], + collection: "products", q: "*", sort_by: "popularity", }, }); ``` @@ -727,9 +727,7 @@ Let's create a preset with name `listing_view`. ```dart await client.presets.upsert('listing_view', { 'value': { - 'searches': [ - {'collection': 'products', 'q': '*','sort_by': 'popularity'} - ] + 'collection': 'products', 'q': '*','sort_by': 'popularity' } }); ``` @@ -741,7 +739,7 @@ Let's create a preset with name `listing_view`. curl "http://localhost:8108/presets/listing_view" -X PUT \ -H "Content-Type: application/json" \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ --d '{"value": {"searches":[{"collection":"products","q":"*", "sort_by": "popularity"}]}}' +-d '{"value": {"collection":"products","q":"*", "sort_by": "popularity"}}' ```