diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 127b1ec..184b3e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: ] services: typesense: - image: typesense/typesense:30.0.rc10 + image: typesense/typesense:30.0.rc26 ports: - 8108:8108/tcp volumes: diff --git a/compose.yml b/compose.yml index ad85db6..61065fc 100644 --- a/compose.yml +++ b/compose.yml @@ -1,6 +1,6 @@ services: typesense: - image: typesense/typesense:30.0.rc10 + image: typesense/typesense:30.0.rc26 restart: on-failure ports: - '8108:8108' diff --git a/openapi.yml b/openapi.yml index 2eb7936..e1a279d 100644 --- a/openapi.yml +++ b/openapi.yml @@ -35,11 +35,6 @@ tags: externalDocs: description: Find out more url: https://typesense.org/api/#index-document - - name: curation - description: Hand-curate search results based on conditional business rules - externalDocs: - description: Find out more - url: https://typesense.org/docs/0.23.0/api/#curation - name: analytics description: Typesense can aggregate search queries for both analytics purposes and for query suggestions. externalDocs: @@ -77,6 +72,8 @@ tags: externalDocs: description: Find out more url: https://typesense.org/docs/28.0/api/synonyms.html + - name: curation_sets + description: Manage curation sets - name: stemming description: Manage stemming dictionaries externalDocs: @@ -460,201 +457,447 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponse" - /collections/{collectionName}/overrides: + + /synonym_sets: get: tags: - - documents - - curation - summary: List all collection overrides - operationId: getSearchOverrides + - synonyms + summary: List all synonym sets + description: Retrieve all synonym sets + operationId: retrieveSynonymSets + responses: + "200": + description: List of all synonym sets + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/SynonymSetSchema" + + /synonym_sets/{synonymSetName}: + get: + tags: + - synonyms + summary: Retrieve a synonym set + description: Retrieve a specific synonym set by its name + operationId: retrieveSynonymSet parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set to retrieve required: true schema: type: string responses: - '200': - description: List of all search overrides + "200": + description: Synonym set fetched + content: + application/json: + schema: + $ref: "#/components/schemas/SynonymSetRetrieveSchema" + "404": + description: Synonym set not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + put: + tags: + - synonyms + summary: Create or update a synonym set + description: Create or update a synonym set with the given name + operationId: upsertSynonymSet + parameters: + - name: synonymSetName + in: path + description: The name of the synonym set to create/update + required: true + schema: + type: string + requestBody: + description: The synonym set to be created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/SynonymSetCreateSchema" + required: true + responses: + "200": + description: Synonym set successfully created/updated content: application/json: schema: - $ref: "#/components/schemas/SearchOverridesResponse" - /collections/{collectionName}/overrides/{overrideId}: + $ref: "#/components/schemas/SynonymSetSchema" + "400": + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - synonyms + summary: Delete a synonym set + description: Delete a specific synonym set by its name + operationId: deleteSynonymSet + parameters: + - name: synonymSetName + in: path + description: The name of the synonym set to delete + required: true + schema: + type: string + responses: + "200": + description: Synonym set successfully deleted + content: + application/json: + schema: + $ref: "#/components/schemas/SynonymSetDeleteSchema" + "404": + description: Synonym set not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + /synonym_sets/{synonymSetName}/items: get: tags: - - documents - - override - summary: Retrieve a single search override - description: Retrieve the details of a search override, given its id. - operationId: getSearchOverride + - synonyms + summary: List items in a synonym set + description: Retrieve all synonym items in a set + operationId: retrieveSynonymSetItems parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set to retrieve items for required: true schema: type: string - - name: overrideId + responses: + "200": + description: List of synonym items + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/SynonymItemSchema" + "404": + description: Synonym set not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + /synonym_sets/{synonymSetName}/items/{itemId}: + get: + tags: + - synonyms + summary: Retrieve a synonym set item + description: Retrieve a specific synonym item by its id + operationId: retrieveSynonymSetItem + parameters: + - name: synonymSetName in: path - description: The id of the search override + description: The name of the synonym set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the synonym item to retrieve required: true schema: type: string responses: - '200': - description: Search override fetched + "200": + description: Synonym item fetched + content: + application/json: + schema: + $ref: "#/components/schemas/SynonymItemSchema" + "404": + description: Synonym item not found content: application/json: schema: - $ref: "#/components/schemas/SearchOverride" + $ref: "#/components/schemas/ApiResponse" put: tags: - - documents - - curation - summary: Create or update an override to promote certain documents over others - description: - Create or update an override to promote certain documents over others. - Using overrides, you can include or exclude specific documents for a given query. - operationId: upsertSearchOverride + - synonyms + summary: Create or update a synonym set item + description: Create or update a synonym set item with the given id + operationId: upsertSynonymSetItem parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set required: true schema: type: string - - name: overrideId + - name: itemId in: path - description: The ID of the search override to create/update + description: The id of the synonym item to upsert required: true schema: type: string requestBody: - description: The search override object to be created/updated + description: The synonym item to be created/updated content: application/json: schema: - $ref: "#/components/schemas/SearchOverrideSchema" + $ref: "#/components/schemas/SynonymItemSchema" required: true responses: - '200': - description: Created/updated search override + "200": + description: Synonym item successfully created/updated content: application/json: schema: - $ref: "#/components/schemas/SearchOverride" - '404': - description: Search override not found + $ref: "#/components/schemas/SynonymItemSchema" + "400": + description: Bad request, see error message for details content: application/json: schema: $ref: "#/components/schemas/ApiResponse" delete: tags: - - documents - - curation - summary: Delete an override associated with a collection - operationId: deleteSearchOverride + - synonyms + summary: Delete a synonym set item + description: Delete a specific synonym item by its id + operationId: deleteSynonymSetItem parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set required: true schema: type: string - - name: overrideId + - name: itemId in: path - description: The ID of the search override to delete + description: The id of the synonym item to delete required: true schema: type: string responses: - '200': - description: The ID of the deleted search override + "200": + description: Synonym item successfully deleted content: application/json: schema: - $ref: "#/components/schemas/SearchOverrideDeleteResponse" - '404': - description: Search override not found + $ref: "#/components/schemas/SynonymItemDeleteSchema" + "404": + description: Synonym item not found content: application/json: schema: $ref: "#/components/schemas/ApiResponse" - /synonym_sets: + /curation_sets: get: tags: - - synonyms - summary: List all synonym sets - description: Retrieve all synonym sets - operationId: retrieveSynonymSets + - curation_sets + summary: List all curation sets + description: Retrieve all curation sets + operationId: retrieveCurationSets responses: "200": - description: List of all synonym sets + description: List of all curation sets content: application/json: schema: type: array items: - $ref: "#/components/schemas/SynonymSetSchema" + $ref: "#/components/schemas/CurationSetSchema" - /synonym_sets/{synonymSetName}: + /curation_sets/{curationSetName}: get: tags: - - synonyms - summary: Retrieve a synonym set - description: Retrieve a specific synonym set by its name - operationId: retrieveSynonymSet + - curation_sets + summary: Retrieve a curation set + description: Retrieve a specific curation set by its name + operationId: retrieveCurationSet parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to retrieve + description: The name of the curation set to retrieve required: true schema: type: string responses: "200": - description: Synonym set fetched + description: Curation set fetched content: application/json: schema: - $ref: "#/components/schemas/SynonymSetRetrieveSchema" + $ref: "#/components/schemas/CurationSetRetrieveSchema" "404": - description: Synonym set not found + description: Curation set not found content: application/json: schema: $ref: "#/components/schemas/ApiResponse" put: tags: - - synonyms - summary: Create or update a synonym set - description: Create or update a synonym set with the given name - operationId: upsertSynonymSet + - curation_sets + summary: Create or update a curation set + description: Create or update a curation set with the given name + operationId: upsertCurationSet parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to create/update + description: The name of the curation set to create/update + required: true + schema: + type: string + requestBody: + description: The curation set to be created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/CurationSetCreateSchema" + required: true + responses: + "200": + description: Curation set successfully created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/CurationSetSchema" + "400": + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - curation_sets + summary: Delete a curation set + description: Delete a specific curation set by its name + operationId: deleteCurationSet + parameters: + - name: curationSetName + in: path + description: The name of the curation set to delete + required: true + schema: + type: string + responses: + "200": + description: Curation set successfully deleted + content: + application/json: + schema: + $ref: "#/components/schemas/CurationSetDeleteSchema" + "404": + description: Curation set not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + /curation_sets/{curationSetName}/items: + get: + tags: + - curation_sets + summary: List items in a curation set + description: Retrieve all curation items in a set + operationId: retrieveCurationSetItems + parameters: + - name: curationSetName + in: path + description: The name of the curation set to retrieve items for + required: true + schema: + type: string + responses: + "200": + description: List of curation items + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/CurationItemSchema" + "404": + description: Curation set not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + /curation_sets/{curationSetName}/items/{itemId}: + get: + tags: + - curation_sets + summary: Retrieve a curation set item + description: Retrieve a specific curation item by its id + operationId: retrieveCurationSetItem + parameters: + - name: curationSetName + in: path + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to retrieve + required: true + schema: + type: string + responses: + "200": + description: Curation item fetched + content: + application/json: + schema: + $ref: "#/components/schemas/CurationItemSchema" + "404": + description: Curation item not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + put: + tags: + - curation_sets + summary: Create or update a curation set item + description: Create or update a curation set item with the given id + operationId: upsertCurationSetItem + parameters: + - name: curationSetName + in: path + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to upsert required: true schema: type: string requestBody: - description: The synonym set to be created/updated + description: The curation item to be created/updated content: application/json: schema: - $ref: "#/components/schemas/SynonymSetCreateSchema" + $ref: "#/components/schemas/CurationItemCreateSchema" required: true responses: "200": - description: Synonym set successfully created/updated + description: Curation item successfully created/updated content: application/json: schema: - $ref: "#/components/schemas/SynonymSetSchema" + $ref: "#/components/schemas/CurationItemSchema" "400": description: Bad request, see error message for details content: @@ -663,26 +906,32 @@ paths: $ref: "#/components/schemas/ApiResponse" delete: tags: - - synonyms - summary: Delete a synonym set - description: Delete a specific synonym set by its name - operationId: deleteSynonymSet + - curation_sets + summary: Delete a curation set item + description: Delete a specific curation item by its id + operationId: deleteCurationSetItem parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to delete + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to delete required: true schema: type: string responses: "200": - description: Synonym set successfully deleted + description: Curation item successfully deleted content: application/json: schema: - $ref: "#/components/schemas/SynonymSetDeleteSchema" + $ref: "#/components/schemas/CurationItemDeleteSchema" "404": - description: Synonym set not found + description: Curation item not found content: application/json: schema: @@ -2479,6 +2728,10 @@ components: description: Returned only for union query response. items: $ref: "#/components/schemas/SearchRequestParams" + metadata: + type: object + description: Custom JSON object that can be returned in the search response + additionalProperties: true SearchRequestParams: type: object required: @@ -2644,136 +2897,6 @@ components: items: type: object x-go-type: "interface{}" - SearchOverrideSchema: - type: object - required: - - rule - properties: - rule: - $ref: "#/components/schemas/SearchOverrideRule" - includes: - type: array - description: - List of document `id`s that should be included in the search results with their - corresponding `position`s. - items: - $ref: "#/components/schemas/SearchOverrideInclude" - excludes: - type: array - description: List of document `id`s that should be excluded from the search results. - items: - $ref: "#/components/schemas/SearchOverrideExclude" - filter_by: - type: string - description: > - A filter by clause that is applied to any search query that matches the override rule. - remove_matched_tokens: - type: boolean - description: > - Indicates whether search query tokens that exist in the override's rule should be removed from the search query. - metadata: - type: object - description: > - Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - sort_by: - type: string - description: > - A sort by clause that is applied to any search query that matches the override rule. - replace_query: - type: string - description: > - Replaces the current search query with this value, when the search query matches the override rule. - filter_curated_hits: - type: boolean - description: > - When set to true, the filter conditions of the query is applied to the curated records as well. - Default: false. - effective_from_ts: - type: integer - description: > - A Unix timestamp that indicates the date/time from which the override will be active. You can use this to create override rules that start applying from a future point in time. - effective_to_ts: - type: integer - description: > - A Unix timestamp that indicates the date/time until which the override will be active. You can use this to create override rules that stop applying after a period of time. - stop_processing: - type: boolean - description: > - When set to true, override processing will stop at the first matching rule. When set to false override processing will continue and multiple override actions will be triggered in sequence. - Overrides are processed in the lexical sort order of their id field. - Default: true. - SearchOverride: - allOf: - - $ref: "#/components/schemas/SearchOverrideSchema" - - type: object - required: - - id - properties: - id: - type: string - readOnly: true - SearchOverrideDeleteResponse: - type: object - required: - - id - properties: - id: - type: string - description: The id of the override that was deleted - SearchOverrideRule: - type: object - properties: - tags: - type: array - description: List of tag values to associate with this override rule. - items: - type: string - query: - type: string - description: Indicates what search queries should be overridden - match: - type: string - description: > - Indicates whether the match on the query term should be `exact` or `contains`. - If we want to match all queries that contained - the word `apple`, we will use the `contains` match instead. - enum: - - exact - - contains - filter_by: - type: string - description: > - Indicates that the override should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). - SearchOverrideInclude: - type: object - required: - - id - - position - properties: - id: - type: string - description: document id that should be included - position: - type: integer - description: position number where document should be included in the search results - SearchOverrideExclude: - type: object - required: - - id - properties: - id: - type: string - description: document id that should be excluded from the search results. - SearchOverridesResponse: - type: object - required: - - overrides - properties: - overrides: - type: array - x-go-type: "[]*SearchOverride" - items: - $ref: "#/components/schemas/SearchOverride" SearchSynonymSchema: type: object required: @@ -3918,7 +4041,7 @@ components: query_counter_events: { type: integer } doc_log_events: { type: integer } doc_counter_events: { type: integer } - + APIStatsResponse: type: object properties: @@ -4312,8 +4435,179 @@ components: type: string description: Name of the deleted synonym set + SynonymItemDeleteSchema: + type: object + required: + - id + properties: + id: + type: string + description: ID of the deleted synonym item + + CurationItemCreateSchema: + type: object + required: + - rule + properties: + rule: + $ref: '#/components/schemas/CurationRule' + includes: + type: array + description: + List of document `id`s that should be included in the search results with their + corresponding `position`s. + items: + $ref: '#/components/schemas/CurationInclude' + excludes: + type: array + description: List of document `id`s that should be excluded from the search results. + items: + $ref: '#/components/schemas/CurationExclude' + filter_by: + type: string + description: > + A filter by clause that is applied to any search query that matches the curation rule. + remove_matched_tokens: + type: boolean + description: > + Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. + metadata: + type: object + description: > + Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. + sort_by: + type: string + description: > + A sort by clause that is applied to any search query that matches the curation rule. + replace_query: + type: string + description: > + Replaces the current search query with this value, when the search query matches the curation rule. + filter_curated_hits: + type: boolean + description: > + When set to true, the filter conditions of the query is applied to the curated records as well. + Default: false. + effective_from_ts: + type: integer + description: > + A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. + effective_to_ts: + type: integer + description: > + A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. + stop_processing: + type: boolean + description: > + When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. + Curations are processed in the lexical sort order of their id field. + id: + type: string + description: ID of the curation item + + + CurationItemSchema: + allOf: + - $ref: '#/components/schemas/CurationItemCreateSchema' + - type: object + required: + - id + properties: + id: + type: string + + CurationSetCreateSchema: + type: object + required: + - items + properties: + items: + type: array + description: Array of curation items + items: + $ref: '#/components/schemas/CurationItemCreateSchema' + description: + type: string + description: Optional description for the curation set + + CurationSetSchema: + allOf: + - $ref: '#/components/schemas/CurationSetCreateSchema' + - type: object + required: + - name + properties: + name: + type: string + + CurationRule: + type: object + properties: + tags: + type: array + description: List of tag values to associate with this curation rule. + items: + type: string + query: + type: string + description: Indicates what search queries should be curated + match: + type: string + description: > + Indicates whether the match on the query term should be `exact` or `contains`. + If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. + enum: + - exact + - contains + filter_by: + type: string + description: > + Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). + + CurationInclude: + type: object + required: + - id + - position + properties: + id: + type: string + description: document id that should be included + position: + type: integer + description: position number where document should be included in the search results + + CurationExclude: + type: object + required: + - id + properties: + id: + type: string + description: document id that should be excluded from the search results. + + CurationSetRetrieveSchema: + $ref: '#/components/schemas/CurationSetCreateSchema' + + CurationSetDeleteSchema: + type: object + required: + - name + properties: + name: + type: string + description: Name of the deleted curation set + CurationItemDeleteSchema: + type: object + required: + - id + properties: + id: + type: string + description: ID of the deleted curation item + securitySchemes: api_key_header: type: apiKey name: X-TYPESENSE-API-KEY - in: header \ No newline at end of file + in: header diff --git a/preprocessed_openapi.yml b/preprocessed_openapi.yml index ad50ea7..eeabdc0 100644 --- a/preprocessed_openapi.yml +++ b/preprocessed_openapi.yml @@ -35,11 +35,6 @@ tags: externalDocs: description: Find out more url: https://typesense.org/api/#index-document -- name: curation - description: Hand-curate search results based on conditional business rules - externalDocs: - description: Find out more - url: https://typesense.org/docs/0.23.0/api/#curation - name: analytics description: Typesense can aggregate search queries for both analytics purposes and for query suggestions. externalDocs: @@ -77,6 +72,8 @@ tags: externalDocs: description: Find out more url: https://typesense.org/docs/28.0/api/synonyms.html +- name: curation_sets + description: Manage curation sets - name: stemming description: Manage stemming dictionaries externalDocs: @@ -848,197 +845,311 @@ paths: $ref: '#/components/schemas/ApiResponse' x-rust-generic-parameter: ' serde::Deserialize<''de> + Serialize>' x-rust-return-type: models::SearchResult - /collections/{collectionName}/overrides: + /synonym_sets: get: tags: - - documents - - curation - summary: List all collection overrides - operationId: getSearchOverrides + - synonyms + summary: List all synonym sets + description: Retrieve all synonym sets + operationId: retrieveSynonymSets + responses: + '200': + description: List of all synonym sets + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SynonymSetSchema' + /synonym_sets/{synonymSetName}: + get: + tags: + - synonyms + summary: Retrieve a synonym set + description: Retrieve a specific synonym set by its name + operationId: retrieveSynonymSet parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set to retrieve + required: true + schema: + type: string + responses: + '200': + description: Synonym set fetched + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetRetrieveSchema' + '404': + description: Synonym set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + put: + tags: + - synonyms + summary: Create or update a synonym set + description: Create or update a synonym set with the given name + operationId: upsertSynonymSet + parameters: + - name: synonymSetName + in: path + description: The name of the synonym set to create/update + required: true + schema: + type: string + requestBody: + description: The synonym set to be created/updated + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetCreateSchema' + required: true + responses: + '200': + description: Synonym set successfully created/updated + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetSchema' + '400': + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + delete: + tags: + - synonyms + summary: Delete a synonym set + description: Delete a specific synonym set by its name + operationId: deleteSynonymSet + parameters: + - name: synonymSetName + in: path + description: The name of the synonym set to delete required: true schema: type: string responses: '200': - description: List of all search overrides + description: Synonym set successfully deleted content: application/json: schema: - $ref: '#/components/schemas/SearchOverridesResponse' - /collections/{collectionName}/overrides/{overrideId}: + $ref: '#/components/schemas/SynonymSetDeleteSchema' + '404': + description: Synonym set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + /synonym_sets/{synonymSetName}/items: get: tags: - - documents - - override - summary: Retrieve a single search override - description: Retrieve the details of a search override, given its id. - operationId: getSearchOverride + - synonyms + summary: List items in a synonym set + description: Retrieve all synonym items in a set + operationId: retrieveSynonymSetItems parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set to retrieve items for + required: true + schema: + type: string + responses: + '200': + description: List of synonym items + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SynonymItemSchema' + '404': + description: Synonym set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + /synonym_sets/{synonymSetName}/items/{itemId}: + get: + tags: + - synonyms + summary: Retrieve a synonym set item + description: Retrieve a specific synonym item by its id + operationId: retrieveSynonymSetItem + parameters: + - name: synonymSetName + in: path + description: The name of the synonym set required: true schema: type: string - - name: overrideId + - name: itemId in: path - description: The id of the search override + description: The id of the synonym item to retrieve required: true schema: type: string responses: '200': - description: Search override fetched + description: Synonym item fetched content: application/json: schema: - $ref: '#/components/schemas/SearchOverride' + $ref: '#/components/schemas/SynonymItemSchema' + '404': + description: Synonym item not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' put: tags: - - documents - - curation - summary: Create or update an override to promote certain documents over others - description: Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query. - operationId: upsertSearchOverride + - synonyms + summary: Create or update a synonym set item + description: Create or update a synonym set item with the given id + operationId: upsertSynonymSetItem parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set required: true schema: type: string - - name: overrideId + - name: itemId in: path - description: The ID of the search override to create/update + description: The id of the synonym item to upsert required: true schema: type: string requestBody: - description: The search override object to be created/updated + description: The synonym item to be created/updated content: application/json: schema: - $ref: '#/components/schemas/SearchOverrideSchema' + $ref: '#/components/schemas/SynonymItemSchema' required: true responses: '200': - description: Created/updated search override + description: Synonym item successfully created/updated content: application/json: schema: - $ref: '#/components/schemas/SearchOverride' - '404': - description: Search override not found + $ref: '#/components/schemas/SynonymItemSchema' + '400': + description: Bad request, see error message for details content: application/json: schema: $ref: '#/components/schemas/ApiResponse' delete: tags: - - documents - - curation - summary: Delete an override associated with a collection - operationId: deleteSearchOverride + - synonyms + summary: Delete a synonym set item + description: Delete a specific synonym item by its id + operationId: deleteSynonymSetItem parameters: - - name: collectionName + - name: synonymSetName in: path - description: The name of the collection + description: The name of the synonym set required: true schema: type: string - - name: overrideId + - name: itemId in: path - description: The ID of the search override to delete + description: The id of the synonym item to delete required: true schema: type: string responses: '200': - description: The ID of the deleted search override + description: Synonym item successfully deleted content: application/json: schema: - $ref: '#/components/schemas/SearchOverrideDeleteResponse' + $ref: '#/components/schemas/SynonymItemDeleteSchema' '404': - description: Search override not found + description: Synonym item not found content: application/json: schema: $ref: '#/components/schemas/ApiResponse' - /synonym_sets: + /curation_sets: get: tags: - - synonyms - summary: List all synonym sets - description: Retrieve all synonym sets - operationId: retrieveSynonymSets + - curation_sets + summary: List all curation sets + description: Retrieve all curation sets + operationId: retrieveCurationSets responses: '200': - description: List of all synonym sets + description: List of all curation sets content: application/json: schema: type: array items: - $ref: '#/components/schemas/SynonymSetSchema' - /synonym_sets/{synonymSetName}: + $ref: '#/components/schemas/CurationSetSchema' + /curation_sets/{curationSetName}: get: tags: - - synonyms - summary: Retrieve a synonym set - description: Retrieve a specific synonym set by its name - operationId: retrieveSynonymSet + - curation_sets + summary: Retrieve a curation set + description: Retrieve a specific curation set by its name + operationId: retrieveCurationSet parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to retrieve + description: The name of the curation set to retrieve required: true schema: type: string responses: '200': - description: Synonym set fetched + description: Curation set fetched content: application/json: schema: - $ref: '#/components/schemas/SynonymSetRetrieveSchema' + $ref: '#/components/schemas/CurationSetRetrieveSchema' '404': - description: Synonym set not found + description: Curation set not found content: application/json: schema: $ref: '#/components/schemas/ApiResponse' put: tags: - - synonyms - summary: Create or update a synonym set - description: Create or update a synonym set with the given name - operationId: upsertSynonymSet + - curation_sets + summary: Create or update a curation set + description: Create or update a curation set with the given name + operationId: upsertCurationSet parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to create/update + description: The name of the curation set to create/update required: true schema: type: string requestBody: - description: The synonym set to be created/updated + description: The curation set to be created/updated content: application/json: schema: - $ref: '#/components/schemas/SynonymSetCreateSchema' + $ref: '#/components/schemas/CurationSetCreateSchema' required: true responses: '200': - description: Synonym set successfully created/updated + description: Curation set successfully created/updated content: application/json: schema: - $ref: '#/components/schemas/SynonymSetSchema' + $ref: '#/components/schemas/CurationSetSchema' '400': description: Bad request, see error message for details content: @@ -1047,26 +1158,159 @@ paths: $ref: '#/components/schemas/ApiResponse' delete: tags: - - synonyms - summary: Delete a synonym set - description: Delete a specific synonym set by its name - operationId: deleteSynonymSet + - curation_sets + summary: Delete a curation set + description: Delete a specific curation set by its name + operationId: deleteCurationSet parameters: - - name: synonymSetName + - name: curationSetName in: path - description: The name of the synonym set to delete + description: The name of the curation set to delete required: true schema: type: string responses: '200': - description: Synonym set successfully deleted + description: Curation set successfully deleted content: application/json: schema: - $ref: '#/components/schemas/SynonymSetDeleteSchema' + $ref: '#/components/schemas/CurationSetDeleteSchema' '404': - description: Synonym set not found + description: Curation set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + /curation_sets/{curationSetName}/items: + get: + tags: + - curation_sets + summary: List items in a curation set + description: Retrieve all curation items in a set + operationId: retrieveCurationSetItems + parameters: + - name: curationSetName + in: path + description: The name of the curation set to retrieve items for + required: true + schema: + type: string + responses: + '200': + description: List of curation items + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/CurationItemSchema' + '404': + description: Curation set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + /curation_sets/{curationSetName}/items/{itemId}: + get: + tags: + - curation_sets + summary: Retrieve a curation set item + description: Retrieve a specific curation item by its id + operationId: retrieveCurationSetItem + parameters: + - name: curationSetName + in: path + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to retrieve + required: true + schema: + type: string + responses: + '200': + description: Curation item fetched + content: + application/json: + schema: + $ref: '#/components/schemas/CurationItemSchema' + '404': + description: Curation item not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + put: + tags: + - curation_sets + summary: Create or update a curation set item + description: Create or update a curation set item with the given id + operationId: upsertCurationSetItem + parameters: + - name: curationSetName + in: path + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to upsert + required: true + schema: + type: string + requestBody: + description: The curation item to be created/updated + content: + application/json: + schema: + $ref: '#/components/schemas/CurationItemCreateSchema' + required: true + responses: + '200': + description: Curation item successfully created/updated + content: + application/json: + schema: + $ref: '#/components/schemas/CurationItemSchema' + '400': + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + delete: + tags: + - curation_sets + summary: Delete a curation set item + description: Delete a specific curation item by its id + operationId: deleteCurationSetItem + parameters: + - name: curationSetName + in: path + description: The name of the curation set + required: true + schema: + type: string + - name: itemId + in: path + description: The id of the curation item to delete + required: true + schema: + type: string + responses: + '200': + description: Curation item successfully deleted + content: + application/json: + schema: + $ref: '#/components/schemas/CurationItemDeleteSchema' + '404': + description: Curation item not found content: application/json: schema: @@ -1670,6 +1914,7 @@ paths: type: array items: $ref: '#/components/schemas/SchemaChangeStatus' + x-rust-return-type: Option> /operations/snapshot: post: tags: @@ -3178,6 +3423,10 @@ components: description: Returned only for union query response. items: $ref: '#/components/schemas/SearchRequestParams' + metadata: + type: object + description: Custom JSON object that can be returned in the search response + additionalProperties: true x-rust-generic-parameter: SearchRequestParams: type: object @@ -3346,129 +3595,6 @@ components: items: type: object x-go-type: interface{} - SearchOverrideSchema: - type: object - required: - - rule - properties: - rule: - $ref: '#/components/schemas/SearchOverrideRule' - includes: - type: array - description: List of document `id`s that should be included in the search results with their corresponding `position`s. - items: - $ref: '#/components/schemas/SearchOverrideInclude' - excludes: - type: array - description: List of document `id`s that should be excluded from the search results. - items: - $ref: '#/components/schemas/SearchOverrideExclude' - filter_by: - type: string - description: | - A filter by clause that is applied to any search query that matches the override rule. - remove_matched_tokens: - type: boolean - description: | - Indicates whether search query tokens that exist in the override's rule should be removed from the search query. - metadata: - type: object - description: | - Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. - sort_by: - type: string - description: | - A sort by clause that is applied to any search query that matches the override rule. - replace_query: - type: string - description: | - Replaces the current search query with this value, when the search query matches the override rule. - filter_curated_hits: - type: boolean - description: | - When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. - effective_from_ts: - type: integer - description: | - A Unix timestamp that indicates the date/time from which the override will be active. You can use this to create override rules that start applying from a future point in time. - effective_to_ts: - type: integer - description: | - A Unix timestamp that indicates the date/time until which the override will be active. You can use this to create override rules that stop applying after a period of time. - stop_processing: - type: boolean - description: | - When set to true, override processing will stop at the first matching rule. When set to false override processing will continue and multiple override actions will be triggered in sequence. Overrides are processed in the lexical sort order of their id field. Default: true. - SearchOverride: - allOf: - - $ref: '#/components/schemas/SearchOverrideSchema' - - type: object - required: - - id - properties: - id: - type: string - readOnly: true - SearchOverrideDeleteResponse: - type: object - required: - - id - properties: - id: - type: string - description: The id of the override that was deleted - SearchOverrideRule: - type: object - properties: - tags: - type: array - description: List of tag values to associate with this override rule. - items: - type: string - query: - type: string - description: Indicates what search queries should be overridden - match: - type: string - description: | - Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. - enum: - - exact - - contains - filter_by: - type: string - description: | - Indicates that the override should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). - SearchOverrideInclude: - type: object - required: - - id - - position - properties: - id: - type: string - description: document id that should be included - position: - type: integer - description: position number where document should be included in the search results - SearchOverrideExclude: - type: object - required: - - id - properties: - id: - type: string - description: document id that should be excluded from the search results. - SearchOverridesResponse: - type: object - required: - - overrides - properties: - overrides: - type: array - x-go-type: '[]*SearchOverride' - items: - $ref: '#/components/schemas/SearchOverride' SearchSynonymSchema: type: object required: @@ -4765,6 +4891,161 @@ components: name: type: string description: Name of the deleted synonym set + SynonymItemDeleteSchema: + type: object + required: + - id + properties: + id: + type: string + description: ID of the deleted synonym item + CurationItemCreateSchema: + type: object + required: + - rule + properties: + rule: + $ref: '#/components/schemas/CurationRule' + includes: + type: array + description: List of document `id`s that should be included in the search results with their corresponding `position`s. + items: + $ref: '#/components/schemas/CurationInclude' + excludes: + type: array + description: List of document `id`s that should be excluded from the search results. + items: + $ref: '#/components/schemas/CurationExclude' + filter_by: + type: string + description: | + A filter by clause that is applied to any search query that matches the curation rule. + remove_matched_tokens: + type: boolean + description: | + Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. + metadata: + type: object + description: | + Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. + sort_by: + type: string + description: | + A sort by clause that is applied to any search query that matches the curation rule. + replace_query: + type: string + description: | + Replaces the current search query with this value, when the search query matches the curation rule. + filter_curated_hits: + type: boolean + description: | + When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. + effective_from_ts: + type: integer + description: | + A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. + effective_to_ts: + type: integer + description: | + A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. + stop_processing: + type: boolean + description: | + When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. + id: + type: string + description: ID of the curation item + CurationItemSchema: + allOf: + - $ref: '#/components/schemas/CurationItemCreateSchema' + - type: object + required: + - id + properties: + id: + type: string + CurationSetCreateSchema: + type: object + required: + - items + properties: + items: + type: array + description: Array of curation items + items: + $ref: '#/components/schemas/CurationItemCreateSchema' + description: + type: string + description: Optional description for the curation set + CurationSetSchema: + allOf: + - $ref: '#/components/schemas/CurationSetCreateSchema' + - type: object + required: + - name + properties: + name: + type: string + CurationRule: + type: object + properties: + tags: + type: array + description: List of tag values to associate with this curation rule. + items: + type: string + query: + type: string + description: Indicates what search queries should be curated + match: + type: string + description: | + Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. + enum: + - exact + - contains + filter_by: + type: string + description: | + Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). + CurationInclude: + type: object + required: + - id + - position + properties: + id: + type: string + description: document id that should be included + position: + type: integer + description: position number where document should be included in the search results + CurationExclude: + type: object + required: + - id + properties: + id: + type: string + description: document id that should be excluded from the search results. + CurationSetRetrieveSchema: + $ref: '#/components/schemas/CurationSetCreateSchema' + CurationSetDeleteSchema: + type: object + required: + - name + properties: + name: + type: string + description: Name of the deleted curation set + CurationItemDeleteSchema: + type: object + required: + - id + properties: + id: + type: string + description: ID of the deleted curation item ImportDocumentsParameters: type: object properties: diff --git a/typesense/src/client/alias.rs b/typesense/src/client/alias.rs new file mode 100644 index 0000000..65c9a68 --- /dev/null +++ b/typesense/src/client/alias.rs @@ -0,0 +1,43 @@ +//! Provides access to the collection alias-related API endpoints. +//! +//! An `Alias` instance is created via the main `client.alias("alias_name")` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::collections_api, models}; + +/// Provides methods for interacting with a specific Typesense collection alias. +/// +/// This struct is created by calling `client.alias("alias_name")`. +pub struct Alias<'a> { + pub(super) client: &'a Client, + pub(super) alias_name: &'a str, +} + +impl<'a> Alias<'a> { + /// Creates a new `Alias` instance. + #[inline] + pub(super) fn new(client: &'a Client, alias_name: &'a str) -> Self { + Self { client, alias_name } + } + + /// Retrieves the details of a collection alias, including the collection it points to. + pub async fn retrieve( + &self, + ) -> Result> { + let params = collections_api::GetAliasParams { + alias_name: self.alias_name.to_owned(), + }; + + execute_wrapper!(self, collections_api::get_alias, params) + } + + /// Deletes a collection alias. + pub async fn delete( + &self, + ) -> Result> { + let params = collections_api::DeleteAliasParams { + alias_name: self.alias_name.to_owned(), + }; + execute_wrapper!(self, collections_api::delete_alias, params) + } +} diff --git a/typesense/src/client/aliases.rs b/typesense/src/client/aliases.rs new file mode 100644 index 0000000..43d3270 --- /dev/null +++ b/typesense/src/client/aliases.rs @@ -0,0 +1,49 @@ +//! Provides access to the collection aliases-related API endpoints. +//! +//! An `Aliases` instance is created via the main `client.aliases()` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::collections_api, models}; + +/// Provides methods for interacting with Typesense collection aliases. +/// +/// This struct is created by calling `client.aliases()`. +pub struct Aliases<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Aliases<'a> { + /// Creates a new `Aliases` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Creates or updates a collection alias. + /// + /// An alias is a virtual collection name that points to a real collection. + /// Aliases are useful when you want to re-index your data in the background + /// on a new collection and then switch your application to it without any + /// changes to your code. + /// + /// # Arguments + /// * `schema` - A `CollectionAliasSchema` pointing to the target collection. + pub async fn upsert( + &self, + alias_name: impl Into, + schema: models::CollectionAliasSchema, + ) -> Result> { + let params = collections_api::UpsertAliasParams { + alias_name: alias_name.into(), + collection_alias_schema: Some(schema), + }; + execute_wrapper!(self, collections_api::upsert_alias, params) + } + + /// Lists all aliases and the corresponding collections that they map to. + pub async fn retrieve( + &self, + ) -> Result> { + execute_wrapper!(self, collections_api::get_aliases) + } +} diff --git a/typesense/src/client/mod.rs b/typesense/src/client/mod.rs index 5ccdead..fd1146b 100644 --- a/typesense/src/client/mod.rs +++ b/typesense/src/client/mod.rs @@ -106,17 +106,31 @@ //! } //! } //! ``` +mod alias; +mod aliases; mod collection; mod collections; mod key; mod keys; mod multi_search; +mod operations; +mod preset; +mod presets; +mod stopword; +mod stopwords; use crate::{Error, traits::Document}; +use alias::Alias; +use aliases::Aliases; use collection::Collection; use collections::Collections; use key::Key; use keys::Keys; +use operations::Operations; +use preset::Preset; +use presets::Presets; +use stopword::Stopword; +use stopwords::Stopwords; #[cfg(not(target_arch = "wasm32"))] use reqwest_middleware::ClientBuilder as ReqwestMiddlewareClientBuilder; @@ -348,6 +362,55 @@ impl Client { }) } + /// Provides access to the collection aliases-related API endpoints. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let all_aliases = client.aliases().retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn aliases(&self) -> Aliases<'_> { + Aliases::new(self) + } + + /// Provides access to a specific collection alias's-related API endpoints. + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let specific_alias = client.alias("books_alias").retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn alias<'a>(&'a self, alias_name: &'a str) -> Alias<'a> { + Alias::new(self, alias_name) + } + /// Provides access to API endpoints for managing collections like `create()` and `retrieve()`. /// # Example /// ```no_run @@ -594,6 +657,136 @@ impl Client { pub fn multi_search(&self) -> multi_search::MultiSearch<'_> { multi_search::MultiSearch::new(self) } + + /// Provides access to top-level, non-namespaced API endpoints like `health` and `debug`. + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let health = client.operations().health().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn operations(&self) -> Operations<'_> { + Operations::new(self) + } + + /// Provides access to endpoints for managing all of your presets. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let list_of_presets = client.presets().retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn presets(&self) -> Presets<'_> { + Presets::new(self) + } + + /// Provides access to endpoints for managing a single preset. + /// + /// # Arguments + /// * `preset_id` - The ID of the preset to manage. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let preset = client.preset("my-preset").retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn preset<'a>(&'a self, preset_id: &'a str) -> Preset<'a> { + Preset::new(self, preset_id) + } + + /// Provides access to endpoints for managing the collection of stopwords sets. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let all_stopwords = client.stopwords().retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn stopwords(&self) -> Stopwords<'_> { + Stopwords::new(self) + } + + /// Provides access to endpoints for managing a single stopwords set. + /// + /// # Arguments + /// * `set_id` - The ID of the stopwords set to manage. + /// + /// # Example + /// ```no_run + /// # #[cfg(not(target_family = "wasm"))] + /// # { + /// # use typesense::Client; + /// # + /// # #[tokio::main] + /// # async fn main() -> Result<(), Box> { + /// # let client = Client::builder() + /// # .nodes(vec!["http://localhost:8108"]) + /// # .api_key("xyz") + /// # .build() + /// # .unwrap(); + /// let my_stopword_set = client.stopword("common_words").retrieve().await.unwrap(); + /// # Ok(()) + /// # } + /// # } + /// ``` + #[inline] + pub fn stopword<'a>(&'a self, set_id: &'a str) -> Stopword<'a> { + Stopword::new(self, set_id) + } } /// A helper function to determine if an error is worth retrying on another node. diff --git a/typesense/src/client/operations.rs b/typesense/src/client/operations.rs new file mode 100644 index 0000000..d1c6060 --- /dev/null +++ b/typesense/src/client/operations.rs @@ -0,0 +1,165 @@ +//! Provides access to top-level, non-namespaced API endpoints. +//! +//! An `Operations` instance is created via the main `client.operations()` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{ + apis::{debug_api, health_api, operations_api}, + models, +}; + +/// Provides methods for top-level, non-namespaced Typesense operations. +/// +/// This struct is created by calling `client.operations()`. +pub struct Operations<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Operations<'a> { + /// Creates a new `Operations` instance + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + /// Retrieves debugging information from a Typesense node. + /// + /// This method will try nodes in sequence according to the health policy + /// until it gets a successful response. The returned information pertains + /// to the specific node that responded successfully. + /// + /// Docs: + pub async fn debug(&self) -> Result> { + execute_wrapper!(self, debug_api::debug) + } + + /// Get health information about a Typesense node. + /// When a node is running out of memory / disk, the API response will have an additional resource_error field that's set to either `OUT_OF_DISK`` or `OUT_OF_MEMORY``. + /// + /// Docs: + pub async fn health(&self) -> Result> { + execute_wrapper!(self, health_api::health) + } + + /// Get current RAM, CPU, Disk & Network usage metrics. + /// ### Example JSON response: + /// ```json + /// { + /// "system_cpu1_active_percentage": "0.00", + /// "system_cpu2_active_percentage": "0.00", + /// "system_cpu3_active_percentage": "0.00", + /// "system_cpu4_active_percentage": "0.00", + /// "system_cpu_active_percentage": "0.00", + /// "system_disk_total_bytes": "1043447808", + /// "system_disk_used_bytes": "561152", + /// "system_memory_total_bytes": "2086899712", + /// "system_memory_used_bytes": "1004507136", + /// "system_memory_total_swap_bytes": "1004507136", + /// "system_memory_used_swap_bytes": "0.00", + /// "system_network_received_bytes": "1466", + /// "system_network_sent_bytes": "182", + /// "typesense_memory_active_bytes": "29630464", + /// "typesense_memory_allocated_bytes": "27886840", + /// "typesense_memory_fragmentation_ratio": "0.06", + /// "typesense_memory_mapped_bytes": "69701632", + /// "typesense_memory_metadata_bytes": "4588768", + /// "typesense_memory_resident_bytes": "29630464", + /// "typesense_memory_retained_bytes": "25718784" + /// } + /// ``` + /// + /// Docs: + pub async fn retrieve_metrics( + &self, + ) -> Result> { + execute_wrapper!(self, operations_api::retrieve_metrics) + } + + /// Get stats about API endpoints. + /// This endpoint returns average requests per second and latencies for all requests in the last 10 seconds. + /// Example JSON response: + /// ```json + /// { + /// "latency_ms": { + /// "GET /collections/products": 0.0, + /// "POST /collections": 4.0, + /// "POST /collections/products/documents/import": 1166.0 + /// }, + /// "requests_per_second": { + /// "GET /collections/products": 0.1, + /// "POST /collections": 0.1, + /// "POST /collections/products/documents/import": 0.1 + /// } + /// } + /// ``` + /// + /// Docs: + pub async fn retrieve_api_stats( + &self, + ) -> Result> { + execute_wrapper!(self, operations_api::retrieve_api_stats) + } + + /// Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. + /// You can then backup the snapshot directory that gets created and later restore it as a data directory, as needed. + /// + /// Docs: + pub async fn take_snapshot( + &self, + params: operations_api::TakeSnapshotParams, + ) -> Result> { + execute_wrapper!(self, operations_api::take_snapshot, params) + } + + /// Triggers a follower node to initiate the raft voting process, which triggers leader re-election. + /// The follower node that you run this operation against will become the new leader, once this command succeeds. + /// + /// Docs: + pub async fn vote(&self) -> Result> { + execute_wrapper!(self, operations_api::vote) + } + + /// You can check the status of in-progress schema change operations by using the schema changes endpoint. + /// + /// Docs: + pub async fn get_schema_changes( + &self, + ) -> Result>, Error> + { + execute_wrapper!(self, operations_api::get_schema_changes) + } + + /// Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. + /// While the database will not block during this operation, we recommend running it during off-peak hours. + /// + /// Docs: + pub async fn compact_db( + &self, + ) -> Result> { + execute_wrapper!(self, operations_api::compact_db) + } + + /// Responses of search requests that are sent with `use_cache` parameter are cached in a LRU cache. This operation will clear the cache completely. + /// + /// Docs: + pub async fn clear_cache( + &self, + ) -> Result> { + execute_wrapper!(self, operations_api::clear_cache) + } + + /// Enable logging of requests that take over a defined threshold of time. + /// Default: `-1` which disables slow request logging. + /// + /// Docs: + pub async fn toggle_slow_request_log( + &self, + slow_requests_threshold_ms: i32, + ) -> Result> { + let params = operations_api::ToggleSlowRequestLogParams { + toggle_slow_request_log_request: Some(models::ToggleSlowRequestLogRequest { + log_slow_requests_time_ms: slow_requests_threshold_ms, + }), + }; + execute_wrapper!(self, operations_api::toggle_slow_request_log, params) + } +} diff --git a/typesense/src/client/preset.rs b/typesense/src/client/preset.rs new file mode 100644 index 0000000..fa6d3cb --- /dev/null +++ b/typesense/src/client/preset.rs @@ -0,0 +1,42 @@ +//! Provides access to the API endpoints for managing a single preset. +//! +//! A `Preset` instance is created via the main `client.preset("preset_id")` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::presets_api, models}; + +/// Provides methods for managing a single Typesense preset. +/// +/// This struct is created by calling `client.preset("preset_id")`. +pub struct Preset<'a> { + pub(super) client: &'a Client, + pub(super) preset_id: &'a str, +} + +impl<'a> Preset<'a> { + /// Creates a new `Preset` instance. + #[inline] + pub(super) fn new(client: &'a Client, preset_id: &'a str) -> Self { + Self { client, preset_id } + } + + /// Retrieves the details of a preset, given its Id. + pub async fn retrieve( + &self, + ) -> Result> { + let params = presets_api::RetrievePresetParams { + preset_id: self.preset_id.to_owned(), + }; + execute_wrapper!(self, presets_api::retrieve_preset, params) + } + + /// Permanently deletes a preset, given its Id. + pub async fn delete( + &self, + ) -> Result> { + let params = presets_api::DeletePresetParams { + preset_id: self.preset_id.to_owned(), + }; + execute_wrapper!(self, presets_api::delete_preset, params) + } +} diff --git a/typesense/src/client/presets.rs b/typesense/src/client/presets.rs new file mode 100644 index 0000000..0cce7b0 --- /dev/null +++ b/typesense/src/client/presets.rs @@ -0,0 +1,47 @@ +//! Provides access to the API endpoints for managing presets. +//! +//! Presets are a set of search parameters that can be applied to a search query by using the `preset` search parameter. +//! +//! A `Presets` instance is created via the main `client.presets()` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::presets_api, models}; + +/// Provides methods for managing all of your Typesense presets. +/// +/// This struct is created by calling `client.presets()`. +pub struct Presets<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Presets<'a> { + /// Creates a new `Presets` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Retrieves the details of all presets. + pub async fn retrieve( + &self, + ) -> Result> { + execute_wrapper!(self, presets_api::retrieve_all_presets) + } + + /// Creates or updates an existing preset. + /// + /// # Arguments + /// * `preset_id` - The ID of the preset to create or update. + /// * `schema` - A `PresetUpsertSchema` object with the preset's value. + pub async fn upsert( + &self, + preset_id: impl Into, + schema: models::PresetUpsertSchema, + ) -> Result> { + let params = presets_api::UpsertPresetParams { + preset_id: preset_id.into(), + preset_upsert_schema: schema, + }; + execute_wrapper!(self, presets_api::upsert_preset, params) + } +} diff --git a/typesense/src/client/stopword.rs b/typesense/src/client/stopword.rs new file mode 100644 index 0000000..f1fce68 --- /dev/null +++ b/typesense/src/client/stopword.rs @@ -0,0 +1,44 @@ +//! Provides access to the API endpoints for managing a single stopwords set. +//! +//! An instance of `Stopword` is created via the `client.stopword("set_id")` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::stopwords_api, models}; + +/// Provides methods for interacting with a specific stopwords set. +/// +/// This struct is created by calling `client.stopword("set_id")`. +pub struct Stopword<'a> { + pub(super) client: &'a Client, + pub(super) set_id: &'a str, +} + +impl<'a> Stopword<'a> { + /// Creates a new `Stopword` instance for a specific set ID. + #[inline] + pub(super) fn new(client: &'a Client, set_id: &'a str) -> Self { + Self { client, set_id } + } + + /// Retrieves the details of this specific stopwords set. + pub async fn retrieve( + &self, + ) -> Result> + { + let params = stopwords_api::RetrieveStopwordsSetParams { + set_id: self.set_id.to_owned(), + }; + execute_wrapper!(self, stopwords_api::retrieve_stopwords_set, params) + } + + /// Permanently deletes this specific stopwords set. + pub async fn delete( + &self, + ) -> Result> + { + let params = stopwords_api::DeleteStopwordsSetParams { + set_id: self.set_id.to_owned(), + }; + execute_wrapper!(self, stopwords_api::delete_stopwords_set, params) + } +} diff --git a/typesense/src/client/stopwords.rs b/typesense/src/client/stopwords.rs new file mode 100644 index 0000000..a19bf29 --- /dev/null +++ b/typesense/src/client/stopwords.rs @@ -0,0 +1,48 @@ +//! Provides access to the API endpoints for managing stopwords sets. +//! +//! A `Stopwords` instance is created via the main `client.stopwords()` method. + +use crate::{Client, Error, execute_wrapper}; +use typesense_codegen::{apis::stopwords_api, models}; + +/// Provides methods for managing Typesense stopwords sets. +/// +/// This struct is created by calling `client.stopwords()`. +pub struct Stopwords<'a> { + pub(super) client: &'a Client, +} + +impl<'a> Stopwords<'a> { + /// Creates a new `Stopwords` instance. + #[inline] + pub(super) fn new(client: &'a Client) -> Self { + Self { client } + } + + /// Creates or updates an existing stopwords set. + /// + /// # Arguments + /// * `set_id` - The ID of the stopwords set to create or update. + /// * `schema` - A `StopwordsSetUpsertSchema` object with the stopwords to upsert. + pub async fn upsert( + &self, + set_id: impl Into, + schema: models::StopwordsSetUpsertSchema, + ) -> Result> { + let params = stopwords_api::UpsertStopwordsSetParams { + set_id: set_id.into(), + stopwords_set_upsert_schema: schema, + }; + execute_wrapper!(self, stopwords_api::upsert_stopwords_set, params) + } + + /// Retrieves the details of all stopwords sets. + pub async fn retrieve( + &self, + ) -> Result< + models::StopwordsSetsRetrieveAllSchema, + Error, + > { + execute_wrapper!(self, stopwords_api::retrieve_stopwords_sets) + } +} diff --git a/typesense/src/models/mod.rs b/typesense/src/models/mod.rs index b41caf3..689ca79 100644 --- a/typesense/src/models/mod.rs +++ b/typesense/src/models/mod.rs @@ -5,6 +5,7 @@ mod scoped_key_parameters; pub use document_index_parameters::*; pub use scoped_key_parameters::*; +pub use typesense_codegen::apis::operations_api::TakeSnapshotParams; pub use typesense_codegen::models::*; pub use multi_search::MultiSearchBody; diff --git a/typesense/src/traits/multi_search_ext.rs b/typesense/src/traits/multi_search_ext.rs index 7f47cf7..dba598f 100644 --- a/typesense/src/traits/multi_search_ext.rs +++ b/typesense/src/traits/multi_search_ext.rs @@ -98,6 +98,7 @@ fn multi_search_item_to_search_result( request_params: item.request_params.clone(), conversation: item.conversation.clone(), union_request_params: item.union_request_params.clone(), + metadata: item.metadata.clone(), }) } diff --git a/typesense/tests/client/aliases_test.rs b/typesense/tests/client/aliases_test.rs new file mode 100644 index 0000000..7faf018 --- /dev/null +++ b/typesense/tests/client/aliases_test.rs @@ -0,0 +1,108 @@ +use typesense::models::{CollectionAliasSchema, CollectionSchema, Field}; + +use super::{get_client, new_id}; + +async fn logic_test_aliases_and_alias_lifecycle() { + let client = get_client(); + let collection_name = new_id("products"); + let alias_name = new_id("products_alias"); + + // --- 1. Create a collection to alias to --- + let collection_schema = CollectionSchema { + name: collection_name.clone(), + fields: vec![Field { + name: "name".to_owned(), + r#type: "string".to_owned(), + ..Default::default() + }], + ..Default::default() + }; + + let create_collection_result = client.collections().create(collection_schema).await; + assert!( + create_collection_result.is_ok(), + "Failed to create collection for alias test" + ); + + // --- 2. Create (Upsert) an alias --- + let alias_schema = CollectionAliasSchema { + collection_name: collection_name.clone(), + }; + + let upsert_result = client.aliases().upsert(&alias_name, alias_schema).await; + assert!(upsert_result.is_ok(), "Failed to create alias"); + let created_alias = upsert_result.unwrap(); + assert_eq!(created_alias.name, alias_name); + assert_eq!(created_alias.collection_name, collection_name); + + // --- 3. Retrieve the specific alias by name --- + let retrieve_one_result = client.alias(&alias_name).retrieve().await; + assert!( + retrieve_one_result.is_ok(), + "Failed to retrieve the specific alias." + ); + let retrieved_alias = retrieve_one_result.unwrap(); + assert_eq!(retrieved_alias.name, alias_name); + assert_eq!(retrieved_alias.collection_name, collection_name); + + // --- 4. Retrieve all aliases --- + let retrieve_all_result = client.aliases().retrieve().await; + assert!( + retrieve_all_result.is_ok(), + "Failed to retrieve the list of aliases." + ); + let all_aliases_response = retrieve_all_result.unwrap(); + + // --- 5. Find our specific alias within the list --- + let our_alias = all_aliases_response + .aliases + .iter() + .find(|a| a.name == alias_name); + + assert!( + our_alias.is_some(), + "The newly created alias was not found in the list." + ); + + if let Some(alias) = our_alias { + assert_eq!(alias.name, alias_name); + assert_eq!(alias.collection_name, collection_name); + } + + // --- 6. Delete the alias --- + let delete_result = client.alias(&alias_name).delete().await; + assert!(delete_result.is_ok(), "Failed to delete alias"); + let deleted_alias = delete_result.unwrap(); + assert_eq!(deleted_alias.name, alias_name); + + // --- 7. Verify Deletion --- + let get_after_delete_result = client.alias(&alias_name).retrieve().await; + assert!( + get_after_delete_result.is_err(), + "Alias should not exist after deletion" + ); +} + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tokio_test { + use super::*; + + #[tokio::test] + async fn test_aliases_and_alias_lifecycle() { + logic_test_aliases_and_alias_lifecycle().await; + } +} + +#[cfg(all(test, target_arch = "wasm32"))] +mod wasm_test { + use super::*; + use wasm_bindgen_test::wasm_bindgen_test; + + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + + #[wasm_bindgen_test] + async fn test_aliases_and_alias_lifecycle() { + console_error_panic_hook::set_once(); + logic_test_aliases_and_alias_lifecycle().await; + } +} diff --git a/typesense/tests/client/mod.rs b/typesense/tests/client/mod.rs index b466f03..668d897 100644 --- a/typesense/tests/client/mod.rs +++ b/typesense/tests/client/mod.rs @@ -1,9 +1,12 @@ +mod aliases_test; mod client_test; mod collections_test; - mod documents_test; mod keys_test; mod multi_search_test; +mod operations_test; +mod presets_test; +mod stopwords_test; use reqwest_retry::policies::ExponentialBackoff; use std::time::Duration; @@ -16,7 +19,7 @@ pub fn get_client() -> Client { .nodes(vec!["http://localhost:8108"]) .api_key("xyz") .healthcheck_interval(Duration::from_secs(5)) - .retry_policy(ExponentialBackoff::builder().build_with_max_retries(0)) + .retry_policy(ExponentialBackoff::builder().build_with_max_retries(3)) .connection_timeout(Duration::from_secs(3)) .build() .expect("Failed to create Typesense client") diff --git a/typesense/tests/client/operations_test.rs b/typesense/tests/client/operations_test.rs new file mode 100644 index 0000000..9a0f1a6 --- /dev/null +++ b/typesense/tests/client/operations_test.rs @@ -0,0 +1,254 @@ +use super::get_client; + +async fn run_test_health_check() { + let client = get_client(); + + let health_result = client.operations().health().await; + assert!(health_result.is_ok(), "Failed to get health status"); + let health_status = health_result.unwrap(); + assert!( + matches!(health_status.ok, true | false), + "The 'ok' field should be a boolean." + ); +} + +async fn run_test_debug_info() { + let client = get_client(); + + let debug_result = client.operations().debug().await; + assert!(debug_result.is_ok(), "Failed to get debug information"); + let debug_info = debug_result.unwrap(); + + assert!( + debug_info.version.is_some(), + "Debug info should contain a version" + ); +} + +async fn run_test_retrieve_metrics() { + let client = get_client(); + let metrics_result = client.operations().retrieve_metrics().await; + + assert!(metrics_result.is_ok(), "Failed to retrieve metrics"); + let metrics = metrics_result.unwrap(); + + assert!(metrics.is_object(), "Metrics should be a JSON object"); + assert!( + metrics.get("system_memory_used_bytes").is_some(), + "Expected system_memory_used_bytes in metrics" + ); + assert!( + metrics.get("typesense_memory_active_bytes").is_some(), + "Expected typesense_memory_active_bytes in metrics" + ); +} + +async fn run_test_retrieve_api_stats() { + let client = get_client(); + let stats_result = client.operations().retrieve_api_stats().await; + + assert!(stats_result.is_ok(), "Failed to retrieve API stats"); + let stats = stats_result.unwrap(); + // The maps might be empty if there are no recent requests, + // so we just check that the call succeeds and returns the correct structure. + assert!( + stats.latency_ms.is_some(), + "Expected latency_ms field in API stats" + ); + assert!( + stats.requests_per_second.is_some(), + "Expected requests_per_second field in API stats" + ); +} + +async fn run_test_take_snapshot() { + let client = get_client(); + // Note: This requires a directory that Typesense can write to. + // In a typical Docker setup, `/tmp` is a safe choice. + let params = typesense::models::TakeSnapshotParams { + snapshot_path: "/tmp/typesense-snapshots-rust-test".to_string(), + }; + let snapshot_result = client.operations().take_snapshot(params).await; + + assert!(snapshot_result.is_ok(), "Failed to take snapshot"); + assert!( + snapshot_result.unwrap().success, + "Snapshot operation should be successful" + ); +} + +async fn run_test_vote() { + let client = get_client(); + let vote_result = client.operations().vote().await; + + assert!( + matches!(vote_result.unwrap().success, true | false), + "The 'success' field should be a boolean." + ); +} + +async fn run_test_get_schema_changes() { + let client = get_client(); + let schema_changes_result = client.operations().get_schema_changes().await; + + assert!( + schema_changes_result.is_ok(), + "Failed to get schema changes" + ); + // The result is a Vec, which is sufficient to confirm the endpoint call was successful. + // The vec can be empty if no schema changes are in progress. + let _schema_changes = schema_changes_result.unwrap(); +} + +async fn run_test_compact_db() { + let client = get_client(); + let vote_result = client.operations().compact_db().await; + + assert!( + matches!(vote_result.unwrap().success, true | false), + "The 'success' field should be a boolean." + ); +} + +async fn run_test_clear_cache() { + let client = get_client(); + let vote_result = client.operations().clear_cache().await; + + assert!( + matches!(vote_result.unwrap().success, true | false), + "The 'success' field should be a boolean." + ); +} + +async fn run_test_toggle_slow_request_log() { + let client = get_client(); + let vote_result = client.operations().toggle_slow_request_log(1000).await; + + assert!( + matches!(vote_result.unwrap().success, true | false), + "The 'success' field should be a boolean." + ); +} + +#[cfg(not(target_arch = "wasm32"))] +mod tokio_test { + use super::*; + + #[tokio::test] + async fn test_health_check() { + run_test_health_check().await; + } + + #[tokio::test] + async fn test_debug_info() { + run_test_debug_info().await; + } + + #[tokio::test] + async fn test_retrieve_metrics() { + run_test_retrieve_metrics().await; + } + + #[tokio::test] + async fn test_retrieve_api_stats() { + run_test_retrieve_api_stats().await; + } + + #[tokio::test] + async fn test_take_snapshot() { + run_test_take_snapshot().await; + } + + #[tokio::test] + async fn test_vote() { + run_test_vote().await; + } + + #[tokio::test] + async fn test_get_schema_changes() { + run_test_get_schema_changes().await; + } + + #[tokio::test] + async fn test_compact_db() { + run_test_compact_db().await; + } + + #[tokio::test] + async fn test_clear_cache() { + run_test_clear_cache().await; + } + + #[tokio::test] + async fn test_toggle_slow_request_log() { + run_test_toggle_slow_request_log().await; + } +} + +#[cfg(target_arch = "wasm32")] +mod wasm_test { + use super::*; + use wasm_bindgen_test::wasm_bindgen_test; + + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + + #[wasm_bindgen_test] + async fn test_health_check() { + console_error_panic_hook::set_once(); + run_test_health_check().await; + } + + #[wasm_bindgen_test] + async fn test_debug_info() { + console_error_panic_hook::set_once(); + run_test_debug_info().await; + } + + #[wasm_bindgen_test] + async fn test_retrieve_metrics() { + console_error_panic_hook::set_once(); + run_test_retrieve_metrics().await; + } + + #[wasm_bindgen_test] + async fn test_retrieve_api_stats() { + console_error_panic_hook::set_once(); + run_test_retrieve_api_stats().await; + } + + #[wasm_bindgen_test] + async fn test_take_snapshot() { + console_error_panic_hook::set_once(); + run_test_take_snapshot().await; + } + + #[wasm_bindgen_test] + async fn test_vote() { + console_error_panic_hook::set_once(); + run_test_vote().await; + } + + #[wasm_bindgen_test] + async fn test_get_schema_changes() { + console_error_panic_hook::set_once(); + run_test_get_schema_changes().await; + } + + #[wasm_bindgen_test] + async fn test_compact_db() { + console_error_panic_hook::set_once(); + run_test_compact_db().await; + } + + #[wasm_bindgen_test] + async fn test_clear_cache() { + console_error_panic_hook::set_once(); + run_test_clear_cache().await; + } + + #[wasm_bindgen_test] + async fn test_toggle_slow_request_log() { + console_error_panic_hook::set_once(); + run_test_toggle_slow_request_log().await; + } +} diff --git a/typesense/tests/client/presets_test.rs b/typesense/tests/client/presets_test.rs new file mode 100644 index 0000000..4cd2c62 --- /dev/null +++ b/typesense/tests/client/presets_test.rs @@ -0,0 +1,107 @@ +use typesense::models::{PresetUpsertSchema, PresetUpsertSchemaValue, SearchParameters}; + +use super::{get_client, new_id}; + +async fn run_test_presets_lifecycle() { + let client = get_client(); + let preset_id = new_id("search-preset"); + + // --- 1. Define the Preset's value using the strong types --- + // This will be the expected value in the response as well. + let search_params = SearchParameters { + query_by: Some("title,authors".to_owned()), + sort_by: Some("_text_match:desc,publication_year:desc".to_owned()), + ..Default::default() + }; + let expected_preset_value = PresetUpsertSchemaValue::SearchParameters(Box::new(search_params)); + + // This is the schema to be sent in the request body. + let upsert_schema = PresetUpsertSchema { + value: Box::new(expected_preset_value.clone()), + }; + + // --- 2. Create (Upsert) a Preset (via `presets`) --- + let upsert_result = client.presets().upsert(&preset_id, upsert_schema).await; + assert!( + upsert_result.is_ok(), + "Failed to create preset: {:?}", + upsert_result.err() + ); + + // The API returns a full PresetSchema object. + let created_preset = upsert_result.unwrap(); + assert_eq!(created_preset.name, preset_id); + // Compare the strongly-typed value field directly. + assert_eq!(*created_preset.value, expected_preset_value); + + // --- 3. Retrieve the specific preset (via `preset`) --- + let retrieve_one_result = client.preset(&preset_id).retrieve().await; + assert!( + retrieve_one_result.is_ok(), + "Failed to retrieve the specific preset." + ); + let retrieved_preset = retrieve_one_result.unwrap(); + assert_eq!(retrieved_preset.name, preset_id); + assert_eq!(*retrieved_preset.value, expected_preset_value); + + // --- 4. Retrieve all presets (via `presets`) --- + let retrieve_all_result = client.presets().retrieve().await; + assert!( + retrieve_all_result.is_ok(), + "Failed to retrieve all presets." + ); + let all_presets_response = retrieve_all_result.unwrap(); + + // --- 5. Find our preset in the list --- + let our_preset = all_presets_response + .presets + .iter() + .find(|p| p.name == preset_id); + + assert!( + our_preset.is_some(), + "The created preset was not found in the list." + ); + + if let Some(preset) = our_preset { + assert_eq!(preset.name, preset_id); + assert_eq!(*preset.value, expected_preset_value); + } + + // --- 6. Delete the preset (via `preset`) --- + let delete_result = client.preset(&preset_id).delete().await; + assert!(delete_result.is_ok(), "Failed to delete preset."); + let deleted_preset = delete_result.unwrap(); + assert_eq!(deleted_preset.name, preset_id); + + // --- 7. Verify Deletion --- + let get_after_delete_result = client.preset(&preset_id).retrieve().await; + assert!( + get_after_delete_result.is_err(), + "Preset should not exist after deletion." + ); +} + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tokio_test { + use super::*; + + #[tokio::test] + async fn test_presets_lifecycle() { + run_test_presets_lifecycle().await; + } +} + +#[cfg(all(test, target_arch = "wasm32"))] +mod wasm_test { + use super::*; + use wasm_bindgen_test::wasm_bindgen_test; + + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + + #[wasm_bindgen_test] + async fn test_presets_lifecycle() { + console_error_panic_hook::set_once(); + run_test_presets_lifecycle().await; + } +} diff --git a/typesense/tests/client/stopwords_test.rs b/typesense/tests/client/stopwords_test.rs new file mode 100644 index 0000000..9f89abe --- /dev/null +++ b/typesense/tests/client/stopwords_test.rs @@ -0,0 +1,82 @@ +use typesense::models::StopwordsSetUpsertSchema; + +use super::{get_client, new_id}; + +async fn run_test_stopwords_and_stopword_lifecycle() { + let client = get_client(); + let set_id = new_id("custom_stopwords"); + + // --- 1. Upsert a Stopwords Set (via `stopwords`) --- + let schema = StopwordsSetUpsertSchema { + stopwords: vec!["a".to_owned(), "the".to_owned(), "an".to_owned()], + ..Default::default() + }; + + let upsert_result = client.stopwords().upsert(&set_id, schema).await; + assert!(upsert_result.is_ok(), "Failed to upsert stopwords set"); + let upserted_set = upsert_result.unwrap(); + assert_eq!(upserted_set.id, set_id); + assert_eq!(upserted_set.stopwords, vec!["a", "the", "an"]); + + // --- 2. Retrieve the specific Stopword set (via `stopword`) --- + let retrieve_one_result = client.stopword(&set_id).retrieve().await; + assert!( + retrieve_one_result.is_ok(), + "Failed to retrieve the newly created stopwords set." + ); + let retrieved_set = retrieve_one_result.unwrap(); + assert_eq!(retrieved_set.stopwords.id, set_id); + assert_eq!(retrieved_set.stopwords.stopwords, vec!["a", "the", "an"]); + + // --- 3. Retrieve all stopwords sets (via `stopwords`) --- + let retrieve_all_result = client.stopwords().retrieve().await; + assert!( + retrieve_all_result.is_ok(), + "Failed to retrieve the list of stopwords sets." + ); + let all_sets = retrieve_all_result.unwrap(); + + // --- 4. Find our specific set within the list --- + let our_set = all_sets.stopwords.iter().find(|s| s.id == set_id); + assert!( + our_set.is_some(), + "The newly created stopwords set was not found in the list." + ); + + // --- 5. Delete the Stopword set (via `stopword`) --- + let delete_result = client.stopword(&set_id).delete().await; + assert!(delete_result.is_ok(), "Failed to delete stopwords set"); + let deleted_response = delete_result.unwrap(); + assert_eq!(deleted_response.id, set_id); + + // --- 6. Verify Deletion --- + let get_after_delete_result = client.stopword(&set_id).retrieve().await; + assert!( + get_after_delete_result.is_err(), + "Stopwords set should not exist after deletion" + ); +} + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tokio_test { + use super::*; + + #[tokio::test] + async fn test_stopwords_and_stopword_lifecycle() { + run_test_stopwords_and_stopword_lifecycle().await; + } +} + +#[cfg(all(test, target_arch = "wasm32"))] +mod wasm_test { + use super::*; + use wasm_bindgen_test::wasm_bindgen_test; + + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + + #[wasm_bindgen_test] + async fn test_stopwords_and_stopword_lifecycle() { + console_error_panic_hook::set_once(); + run_test_stopwords_and_stopword_lifecycle().await; + } +} diff --git a/typesense_codegen/.openapi-generator/FILES b/typesense_codegen/.openapi-generator/FILES index 2a46e2a..108b0e2 100644 --- a/typesense_codegen/.openapi-generator/FILES +++ b/typesense_codegen/.openapi-generator/FILES @@ -31,7 +31,16 @@ docs/CreateAnalyticsRule200Response.md docs/CreateAnalyticsRule200ResponseOneOfInner.md docs/CreateAnalyticsRule200ResponseOneOfInnerAnyOf.md docs/CreateAnalyticsRuleRequest.md -docs/CurationApi.md +docs/CurationExclude.md +docs/CurationInclude.md +docs/CurationItemCreateSchema.md +docs/CurationItemDeleteSchema.md +docs/CurationItemSchema.md +docs/CurationRule.md +docs/CurationSetCreateSchema.md +docs/CurationSetDeleteSchema.md +docs/CurationSetSchema.md +docs/CurationSetsApi.md docs/Debug200Response.md docs/DebugApi.md docs/DeleteDocuments200Response.md @@ -65,7 +74,6 @@ docs/NlSearchModelDeleteSchema.md docs/NlSearchModelSchema.md docs/NlSearchModelsApi.md docs/OperationsApi.md -docs/OverrideApi.md docs/PresetDeleteSchema.md docs/PresetSchema.md docs/PresetUpsertSchema.md @@ -75,13 +83,6 @@ docs/PresetsRetrieveSchema.md docs/SchemaChangeStatus.md docs/SearchGroupedHit.md docs/SearchHighlight.md -docs/SearchOverride.md -docs/SearchOverrideDeleteResponse.md -docs/SearchOverrideExclude.md -docs/SearchOverrideInclude.md -docs/SearchOverrideRule.md -docs/SearchOverrideSchema.md -docs/SearchOverridesResponse.md docs/SearchParameters.md docs/SearchRequestParams.md docs/SearchRequestParamsVoiceQuery.md @@ -103,6 +104,7 @@ docs/StopwordsSetSchema.md docs/StopwordsSetUpsertSchema.md docs/StopwordsSetsRetrieveAllSchema.md docs/SuccessStatus.md +docs/SynonymItemDeleteSchema.md docs/SynonymItemSchema.md docs/SynonymSetCreateSchema.md docs/SynonymSetDeleteSchema.md @@ -116,7 +118,7 @@ docs/VoiceQueryModelCollectionConfig.md src/apis/analytics_api.rs src/apis/collections_api.rs src/apis/conversations_api.rs -src/apis/curation_api.rs +src/apis/curation_sets_api.rs src/apis/debug_api.rs src/apis/documents_api.rs src/apis/health_api.rs @@ -124,7 +126,6 @@ src/apis/keys_api.rs src/apis/mod.rs src/apis/nl_search_models_api.rs src/apis/operations_api.rs -src/apis/override_api.rs src/apis/presets_api.rs src/apis/stemming_api.rs src/apis/stopwords_api.rs @@ -159,6 +160,15 @@ src/models/create_analytics_rule_200_response.rs src/models/create_analytics_rule_200_response_one_of_inner.rs src/models/create_analytics_rule_200_response_one_of_inner_any_of.rs src/models/create_analytics_rule_request.rs +src/models/curation_exclude.rs +src/models/curation_include.rs +src/models/curation_item_create_schema.rs +src/models/curation_item_delete_schema.rs +src/models/curation_item_schema.rs +src/models/curation_rule.rs +src/models/curation_set_create_schema.rs +src/models/curation_set_delete_schema.rs +src/models/curation_set_schema.rs src/models/debug_200_response.rs src/models/delete_documents_200_response.rs src/models/delete_documents_parameters.rs @@ -195,13 +205,6 @@ src/models/presets_retrieve_schema.rs src/models/schema_change_status.rs src/models/search_grouped_hit.rs src/models/search_highlight.rs -src/models/search_override.rs -src/models/search_override_delete_response.rs -src/models/search_override_exclude.rs -src/models/search_override_include.rs -src/models/search_override_rule.rs -src/models/search_override_schema.rs -src/models/search_overrides_response.rs src/models/search_parameters.rs src/models/search_request_params.rs src/models/search_request_params_voice_query.rs @@ -221,6 +224,7 @@ src/models/stopwords_set_schema.rs src/models/stopwords_set_upsert_schema.rs src/models/stopwords_sets_retrieve_all_schema.rs src/models/success_status.rs +src/models/synonym_item_delete_schema.rs src/models/synonym_item_schema.rs src/models/synonym_set_create_schema.rs src/models/synonym_set_delete_schema.rs diff --git a/typesense_codegen/.openapi-generator/VERSION b/typesense_codegen/.openapi-generator/VERSION index 5e52829..e465da4 100644 --- a/typesense_codegen/.openapi-generator/VERSION +++ b/typesense_codegen/.openapi-generator/VERSION @@ -1 +1 @@ -7.16.0-SNAPSHOT +7.14.0 diff --git a/typesense_codegen/README.md b/typesense_codegen/README.md index 768dcfa..d324f6f 100644 --- a/typesense_codegen/README.md +++ b/typesense_codegen/README.md @@ -9,7 +9,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat - API version: 30.0 - Package version: 30.0 -- Generator version: 7.16.0-SNAPSHOT +- Generator version: 7.14.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` ## Installation @@ -49,24 +49,25 @@ Class | Method | HTTP request | Description *ConversationsApi* | [**retrieve_all_conversation_models**](docs/ConversationsApi.md#retrieve_all_conversation_models) | **GET** /conversations/models | List all conversation models *ConversationsApi* | [**retrieve_conversation_model**](docs/ConversationsApi.md#retrieve_conversation_model) | **GET** /conversations/models/{modelId} | Retrieve a conversation model *ConversationsApi* | [**update_conversation_model**](docs/ConversationsApi.md#update_conversation_model) | **PUT** /conversations/models/{modelId} | Update a conversation model -*CurationApi* | [**delete_search_override**](docs/CurationApi.md#delete_search_override) | **DELETE** /collections/{collectionName}/overrides/{overrideId} | Delete an override associated with a collection -*CurationApi* | [**get_search_overrides**](docs/CurationApi.md#get_search_overrides) | **GET** /collections/{collectionName}/overrides | List all collection overrides -*CurationApi* | [**upsert_search_override**](docs/CurationApi.md#upsert_search_override) | **PUT** /collections/{collectionName}/overrides/{overrideId} | Create or update an override to promote certain documents over others +*CurationSetsApi* | [**delete_curation_set**](docs/CurationSetsApi.md#delete_curation_set) | **DELETE** /curation_sets/{curationSetName} | Delete a curation set +*CurationSetsApi* | [**delete_curation_set_item**](docs/CurationSetsApi.md#delete_curation_set_item) | **DELETE** /curation_sets/{curationSetName}/items/{itemId} | Delete a curation set item +*CurationSetsApi* | [**retrieve_curation_set**](docs/CurationSetsApi.md#retrieve_curation_set) | **GET** /curation_sets/{curationSetName} | Retrieve a curation set +*CurationSetsApi* | [**retrieve_curation_set_item**](docs/CurationSetsApi.md#retrieve_curation_set_item) | **GET** /curation_sets/{curationSetName}/items/{itemId} | Retrieve a curation set item +*CurationSetsApi* | [**retrieve_curation_set_items**](docs/CurationSetsApi.md#retrieve_curation_set_items) | **GET** /curation_sets/{curationSetName}/items | List items in a curation set +*CurationSetsApi* | [**retrieve_curation_sets**](docs/CurationSetsApi.md#retrieve_curation_sets) | **GET** /curation_sets | List all curation sets +*CurationSetsApi* | [**upsert_curation_set**](docs/CurationSetsApi.md#upsert_curation_set) | **PUT** /curation_sets/{curationSetName} | Create or update a curation set +*CurationSetsApi* | [**upsert_curation_set_item**](docs/CurationSetsApi.md#upsert_curation_set_item) | **PUT** /curation_sets/{curationSetName}/items/{itemId} | Create or update a curation set item *DebugApi* | [**debug**](docs/DebugApi.md#debug) | **GET** /debug | Print debugging information *DocumentsApi* | [**delete_document**](docs/DocumentsApi.md#delete_document) | **DELETE** /collections/{collectionName}/documents/{documentId} | Delete a document *DocumentsApi* | [**delete_documents**](docs/DocumentsApi.md#delete_documents) | **DELETE** /collections/{collectionName}/documents | Delete a bunch of documents -*DocumentsApi* | [**delete_search_override**](docs/DocumentsApi.md#delete_search_override) | **DELETE** /collections/{collectionName}/overrides/{overrideId} | Delete an override associated with a collection *DocumentsApi* | [**export_documents**](docs/DocumentsApi.md#export_documents) | **GET** /collections/{collectionName}/documents/export | Export all documents in a collection *DocumentsApi* | [**get_document**](docs/DocumentsApi.md#get_document) | **GET** /collections/{collectionName}/documents/{documentId} | Retrieve a document -*DocumentsApi* | [**get_search_override**](docs/DocumentsApi.md#get_search_override) | **GET** /collections/{collectionName}/overrides/{overrideId} | Retrieve a single search override -*DocumentsApi* | [**get_search_overrides**](docs/DocumentsApi.md#get_search_overrides) | **GET** /collections/{collectionName}/overrides | List all collection overrides *DocumentsApi* | [**import_documents**](docs/DocumentsApi.md#import_documents) | **POST** /collections/{collectionName}/documents/import | Import documents into a collection *DocumentsApi* | [**index_document**](docs/DocumentsApi.md#index_document) | **POST** /collections/{collectionName}/documents | Index a document *DocumentsApi* | [**multi_search**](docs/DocumentsApi.md#multi_search) | **POST** /multi_search | send multiple search requests in a single HTTP request *DocumentsApi* | [**search_collection**](docs/DocumentsApi.md#search_collection) | **GET** /collections/{collectionName}/documents/search | Search for documents in a collection *DocumentsApi* | [**update_document**](docs/DocumentsApi.md#update_document) | **PATCH** /collections/{collectionName}/documents/{documentId} | Update a document *DocumentsApi* | [**update_documents**](docs/DocumentsApi.md#update_documents) | **PATCH** /collections/{collectionName}/documents | Update documents with conditional query -*DocumentsApi* | [**upsert_search_override**](docs/DocumentsApi.md#upsert_search_override) | **PUT** /collections/{collectionName}/overrides/{overrideId} | Create or update an override to promote certain documents over others *HealthApi* | [**health**](docs/HealthApi.md#health) | **GET** /health | Checks if Typesense server is ready to accept requests. *KeysApi* | [**create_key**](docs/KeysApi.md#create_key) | **POST** /keys | Create an API Key *KeysApi* | [**delete_key**](docs/KeysApi.md#delete_key) | **DELETE** /keys/{keyId} | Delete an API key given its ID. @@ -85,7 +86,6 @@ Class | Method | HTTP request | Description *OperationsApi* | [**take_snapshot**](docs/OperationsApi.md#take_snapshot) | **POST** /operations/snapshot | Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. *OperationsApi* | [**toggle_slow_request_log**](docs/OperationsApi.md#toggle_slow_request_log) | **POST** /config | Toggle Slow Request Log *OperationsApi* | [**vote**](docs/OperationsApi.md#vote) | **POST** /operations/vote | Triggers a follower node to initiate the raft voting process, which triggers leader re-election. -*OverrideApi* | [**get_search_override**](docs/OverrideApi.md#get_search_override) | **GET** /collections/{collectionName}/overrides/{overrideId} | Retrieve a single search override *PresetsApi* | [**delete_preset**](docs/PresetsApi.md#delete_preset) | **DELETE** /presets/{presetId} | Delete a preset. *PresetsApi* | [**retrieve_all_presets**](docs/PresetsApi.md#retrieve_all_presets) | **GET** /presets | Retrieves all presets. *PresetsApi* | [**retrieve_preset**](docs/PresetsApi.md#retrieve_preset) | **GET** /presets/{presetId} | Retrieves a preset. @@ -98,9 +98,13 @@ Class | Method | HTTP request | Description *StopwordsApi* | [**retrieve_stopwords_sets**](docs/StopwordsApi.md#retrieve_stopwords_sets) | **GET** /stopwords | Retrieves all stopwords sets. *StopwordsApi* | [**upsert_stopwords_set**](docs/StopwordsApi.md#upsert_stopwords_set) | **PUT** /stopwords/{setId} | Upserts a stopwords set. *SynonymsApi* | [**delete_synonym_set**](docs/SynonymsApi.md#delete_synonym_set) | **DELETE** /synonym_sets/{synonymSetName} | Delete a synonym set +*SynonymsApi* | [**delete_synonym_set_item**](docs/SynonymsApi.md#delete_synonym_set_item) | **DELETE** /synonym_sets/{synonymSetName}/items/{itemId} | Delete a synonym set item *SynonymsApi* | [**retrieve_synonym_set**](docs/SynonymsApi.md#retrieve_synonym_set) | **GET** /synonym_sets/{synonymSetName} | Retrieve a synonym set +*SynonymsApi* | [**retrieve_synonym_set_item**](docs/SynonymsApi.md#retrieve_synonym_set_item) | **GET** /synonym_sets/{synonymSetName}/items/{itemId} | Retrieve a synonym set item +*SynonymsApi* | [**retrieve_synonym_set_items**](docs/SynonymsApi.md#retrieve_synonym_set_items) | **GET** /synonym_sets/{synonymSetName}/items | List items in a synonym set *SynonymsApi* | [**retrieve_synonym_sets**](docs/SynonymsApi.md#retrieve_synonym_sets) | **GET** /synonym_sets | List all synonym sets *SynonymsApi* | [**upsert_synonym_set**](docs/SynonymsApi.md#upsert_synonym_set) | **PUT** /synonym_sets/{synonymSetName} | Create or update a synonym set +*SynonymsApi* | [**upsert_synonym_set_item**](docs/SynonymsApi.md#upsert_synonym_set_item) | **PUT** /synonym_sets/{synonymSetName}/items/{itemId} | Create or update a synonym set item ## Documentation For Models @@ -134,6 +138,15 @@ Class | Method | HTTP request | Description - [CreateAnalyticsRule200ResponseOneOfInner](docs/CreateAnalyticsRule200ResponseOneOfInner.md) - [CreateAnalyticsRule200ResponseOneOfInnerAnyOf](docs/CreateAnalyticsRule200ResponseOneOfInnerAnyOf.md) - [CreateAnalyticsRuleRequest](docs/CreateAnalyticsRuleRequest.md) + - [CurationExclude](docs/CurationExclude.md) + - [CurationInclude](docs/CurationInclude.md) + - [CurationItemCreateSchema](docs/CurationItemCreateSchema.md) + - [CurationItemDeleteSchema](docs/CurationItemDeleteSchema.md) + - [CurationItemSchema](docs/CurationItemSchema.md) + - [CurationRule](docs/CurationRule.md) + - [CurationSetCreateSchema](docs/CurationSetCreateSchema.md) + - [CurationSetDeleteSchema](docs/CurationSetDeleteSchema.md) + - [CurationSetSchema](docs/CurationSetSchema.md) - [Debug200Response](docs/Debug200Response.md) - [DeleteDocuments200Response](docs/DeleteDocuments200Response.md) - [DeleteDocumentsParameters](docs/DeleteDocumentsParameters.md) @@ -169,13 +182,6 @@ Class | Method | HTTP request | Description - [SchemaChangeStatus](docs/SchemaChangeStatus.md) - [SearchGroupedHit](docs/SearchGroupedHit.md) - [SearchHighlight](docs/SearchHighlight.md) - - [SearchOverride](docs/SearchOverride.md) - - [SearchOverrideDeleteResponse](docs/SearchOverrideDeleteResponse.md) - - [SearchOverrideExclude](docs/SearchOverrideExclude.md) - - [SearchOverrideInclude](docs/SearchOverrideInclude.md) - - [SearchOverrideRule](docs/SearchOverrideRule.md) - - [SearchOverrideSchema](docs/SearchOverrideSchema.md) - - [SearchOverridesResponse](docs/SearchOverridesResponse.md) - [SearchParameters](docs/SearchParameters.md) - [SearchRequestParams](docs/SearchRequestParams.md) - [SearchRequestParamsVoiceQuery](docs/SearchRequestParamsVoiceQuery.md) @@ -195,6 +201,7 @@ Class | Method | HTTP request | Description - [StopwordsSetUpsertSchema](docs/StopwordsSetUpsertSchema.md) - [StopwordsSetsRetrieveAllSchema](docs/StopwordsSetsRetrieveAllSchema.md) - [SuccessStatus](docs/SuccessStatus.md) + - [SynonymItemDeleteSchema](docs/SynonymItemDeleteSchema.md) - [SynonymItemSchema](docs/SynonymItemSchema.md) - [SynonymSetCreateSchema](docs/SynonymSetCreateSchema.md) - [SynonymSetDeleteSchema](docs/SynonymSetDeleteSchema.md) diff --git a/typesense_codegen/docs/CurationExclude.md b/typesense_codegen/docs/CurationExclude.md new file mode 100644 index 0000000..a88e3b1 --- /dev/null +++ b/typesense_codegen/docs/CurationExclude.md @@ -0,0 +1,11 @@ +# CurationExclude + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | document id that should be excluded from the search results. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationInclude.md b/typesense_codegen/docs/CurationInclude.md new file mode 100644 index 0000000..893685e --- /dev/null +++ b/typesense_codegen/docs/CurationInclude.md @@ -0,0 +1,12 @@ +# CurationInclude + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | document id that should be included | +**position** | **i32** | position number where document should be included in the search results | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationItemCreateSchema.md b/typesense_codegen/docs/CurationItemCreateSchema.md new file mode 100644 index 0000000..638eb16 --- /dev/null +++ b/typesense_codegen/docs/CurationItemCreateSchema.md @@ -0,0 +1,23 @@ +# CurationItemCreateSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**rule** | [**models::CurationRule**](CurationRule.md) | | +**includes** | Option<[**Vec**](CurationInclude.md)> | List of document `id`s that should be included in the search results with their corresponding `position`s. | [optional] +**excludes** | Option<[**Vec**](CurationExclude.md)> | List of document `id`s that should be excluded from the search results. | [optional] +**filter_by** | Option<**String**> | A filter by clause that is applied to any search query that matches the curation rule. | [optional] +**remove_matched_tokens** | Option<**bool**> | Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. | [optional] +**metadata** | Option<[**serde_json::Value**](.md)> | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. | [optional] +**sort_by** | Option<**String**> | A sort by clause that is applied to any search query that matches the curation rule. | [optional] +**replace_query** | Option<**String**> | Replaces the current search query with this value, when the search query matches the curation rule. | [optional] +**filter_curated_hits** | Option<**bool**> | When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. | [optional] +**effective_from_ts** | Option<**i32**> | A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. | [optional] +**effective_to_ts** | Option<**i32**> | A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. | [optional] +**stop_processing** | Option<**bool**> | When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. | [optional] +**id** | Option<**String**> | ID of the curation item | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationItemDeleteSchema.md b/typesense_codegen/docs/CurationItemDeleteSchema.md new file mode 100644 index 0000000..013ae5f --- /dev/null +++ b/typesense_codegen/docs/CurationItemDeleteSchema.md @@ -0,0 +1,11 @@ +# CurationItemDeleteSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID of the deleted curation item | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationItemSchema.md b/typesense_codegen/docs/CurationItemSchema.md new file mode 100644 index 0000000..8302472 --- /dev/null +++ b/typesense_codegen/docs/CurationItemSchema.md @@ -0,0 +1,23 @@ +# CurationItemSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**rule** | [**models::CurationRule**](CurationRule.md) | | +**includes** | Option<[**Vec**](CurationInclude.md)> | List of document `id`s that should be included in the search results with their corresponding `position`s. | [optional] +**excludes** | Option<[**Vec**](CurationExclude.md)> | List of document `id`s that should be excluded from the search results. | [optional] +**filter_by** | Option<**String**> | A filter by clause that is applied to any search query that matches the curation rule. | [optional] +**remove_matched_tokens** | Option<**bool**> | Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. | [optional] +**metadata** | Option<[**serde_json::Value**](.md)> | Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. | [optional] +**sort_by** | Option<**String**> | A sort by clause that is applied to any search query that matches the curation rule. | [optional] +**replace_query** | Option<**String**> | Replaces the current search query with this value, when the search query matches the curation rule. | [optional] +**filter_curated_hits** | Option<**bool**> | When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. | [optional] +**effective_from_ts** | Option<**i32**> | A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. | [optional] +**effective_to_ts** | Option<**i32**> | A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. | [optional] +**stop_processing** | Option<**bool**> | When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. | [optional] +**id** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationRule.md b/typesense_codegen/docs/CurationRule.md new file mode 100644 index 0000000..19e7098 --- /dev/null +++ b/typesense_codegen/docs/CurationRule.md @@ -0,0 +1,14 @@ +# CurationRule + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | List of tag values to associate with this curation rule. | [optional] +**query** | Option<**String**> | Indicates what search queries should be curated | [optional] +**r#match** | Option<**String**> | Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. | [optional] +**filter_by** | Option<**String**> | Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationSetCreateSchema.md b/typesense_codegen/docs/CurationSetCreateSchema.md new file mode 100644 index 0000000..9f97eaf --- /dev/null +++ b/typesense_codegen/docs/CurationSetCreateSchema.md @@ -0,0 +1,12 @@ +# CurationSetCreateSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**Vec**](CurationItemCreateSchema.md) | Array of curation items | +**description** | Option<**String**> | Optional description for the curation set | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationSetDeleteSchema.md b/typesense_codegen/docs/CurationSetDeleteSchema.md new file mode 100644 index 0000000..946fc75 --- /dev/null +++ b/typesense_codegen/docs/CurationSetDeleteSchema.md @@ -0,0 +1,11 @@ +# CurationSetDeleteSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | Name of the deleted curation set | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationSetSchema.md b/typesense_codegen/docs/CurationSetSchema.md new file mode 100644 index 0000000..feb0567 --- /dev/null +++ b/typesense_codegen/docs/CurationSetSchema.md @@ -0,0 +1,13 @@ +# CurationSetSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**items** | [**Vec**](CurationItemCreateSchema.md) | Array of curation items | +**description** | Option<**String**> | Optional description for the curation set | [optional] +**name** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/CurationSetsApi.md b/typesense_codegen/docs/CurationSetsApi.md new file mode 100644 index 0000000..0f9e018 --- /dev/null +++ b/typesense_codegen/docs/CurationSetsApi.md @@ -0,0 +1,258 @@ +# \CurationSetsApi + +All URIs are relative to *http://localhost:8108* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_curation_set**](CurationSetsApi.md#delete_curation_set) | **DELETE** /curation_sets/{curationSetName} | Delete a curation set +[**delete_curation_set_item**](CurationSetsApi.md#delete_curation_set_item) | **DELETE** /curation_sets/{curationSetName}/items/{itemId} | Delete a curation set item +[**retrieve_curation_set**](CurationSetsApi.md#retrieve_curation_set) | **GET** /curation_sets/{curationSetName} | Retrieve a curation set +[**retrieve_curation_set_item**](CurationSetsApi.md#retrieve_curation_set_item) | **GET** /curation_sets/{curationSetName}/items/{itemId} | Retrieve a curation set item +[**retrieve_curation_set_items**](CurationSetsApi.md#retrieve_curation_set_items) | **GET** /curation_sets/{curationSetName}/items | List items in a curation set +[**retrieve_curation_sets**](CurationSetsApi.md#retrieve_curation_sets) | **GET** /curation_sets | List all curation sets +[**upsert_curation_set**](CurationSetsApi.md#upsert_curation_set) | **PUT** /curation_sets/{curationSetName} | Create or update a curation set +[**upsert_curation_set_item**](CurationSetsApi.md#upsert_curation_set_item) | **PUT** /curation_sets/{curationSetName}/items/{itemId} | Create or update a curation set item + + + +## delete_curation_set + +> models::CurationSetDeleteSchema delete_curation_set(curation_set_name) +Delete a curation set + +Delete a specific curation set by its name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set to delete | [required] | + +### Return type + +[**models::CurationSetDeleteSchema**](CurationSetDeleteSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_curation_set_item + +> models::CurationItemDeleteSchema delete_curation_set_item(curation_set_name, item_id) +Delete a curation set item + +Delete a specific curation item by its id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set | [required] | +**item_id** | **String** | The id of the curation item to delete | [required] | + +### Return type + +[**models::CurationItemDeleteSchema**](CurationItemDeleteSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## retrieve_curation_set + +> models::CurationSetCreateSchema retrieve_curation_set(curation_set_name) +Retrieve a curation set + +Retrieve a specific curation set by its name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set to retrieve | [required] | + +### Return type + +[**models::CurationSetCreateSchema**](CurationSetCreateSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## retrieve_curation_set_item + +> models::CurationItemSchema retrieve_curation_set_item(curation_set_name, item_id) +Retrieve a curation set item + +Retrieve a specific curation item by its id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set | [required] | +**item_id** | **String** | The id of the curation item to retrieve | [required] | + +### Return type + +[**models::CurationItemSchema**](CurationItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## retrieve_curation_set_items + +> Vec retrieve_curation_set_items(curation_set_name) +List items in a curation set + +Retrieve all curation items in a set + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set to retrieve items for | [required] | + +### Return type + +[**Vec**](CurationItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## retrieve_curation_sets + +> Vec retrieve_curation_sets() +List all curation sets + +Retrieve all curation sets + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](CurationSetSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## upsert_curation_set + +> models::CurationSetSchema upsert_curation_set(curation_set_name, curation_set_create_schema) +Create or update a curation set + +Create or update a curation set with the given name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set to create/update | [required] | +**curation_set_create_schema** | [**CurationSetCreateSchema**](CurationSetCreateSchema.md) | The curation set to be created/updated | [required] | + +### Return type + +[**models::CurationSetSchema**](CurationSetSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## upsert_curation_set_item + +> models::CurationItemSchema upsert_curation_set_item(curation_set_name, item_id, curation_item_create_schema) +Create or update a curation set item + +Create or update a curation set item with the given id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**curation_set_name** | **String** | The name of the curation set | [required] | +**item_id** | **String** | The id of the curation item to upsert | [required] | +**curation_item_create_schema** | [**CurationItemCreateSchema**](CurationItemCreateSchema.md) | The curation item to be created/updated | [required] | + +### Return type + +[**models::CurationItemSchema**](CurationItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/typesense_codegen/docs/DocumentsApi.md b/typesense_codegen/docs/DocumentsApi.md index 9b5858f..ea1b5b8 100644 --- a/typesense_codegen/docs/DocumentsApi.md +++ b/typesense_codegen/docs/DocumentsApi.md @@ -6,18 +6,14 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**delete_document**](DocumentsApi.md#delete_document) | **DELETE** /collections/{collectionName}/documents/{documentId} | Delete a document [**delete_documents**](DocumentsApi.md#delete_documents) | **DELETE** /collections/{collectionName}/documents | Delete a bunch of documents -[**delete_search_override**](DocumentsApi.md#delete_search_override) | **DELETE** /collections/{collectionName}/overrides/{overrideId} | Delete an override associated with a collection [**export_documents**](DocumentsApi.md#export_documents) | **GET** /collections/{collectionName}/documents/export | Export all documents in a collection [**get_document**](DocumentsApi.md#get_document) | **GET** /collections/{collectionName}/documents/{documentId} | Retrieve a document -[**get_search_override**](DocumentsApi.md#get_search_override) | **GET** /collections/{collectionName}/overrides/{overrideId} | Retrieve a single search override -[**get_search_overrides**](DocumentsApi.md#get_search_overrides) | **GET** /collections/{collectionName}/overrides | List all collection overrides [**import_documents**](DocumentsApi.md#import_documents) | **POST** /collections/{collectionName}/documents/import | Import documents into a collection [**index_document**](DocumentsApi.md#index_document) | **POST** /collections/{collectionName}/documents | Index a document [**multi_search**](DocumentsApi.md#multi_search) | **POST** /multi_search | send multiple search requests in a single HTTP request [**search_collection**](DocumentsApi.md#search_collection) | **GET** /collections/{collectionName}/documents/search | Search for documents in a collection [**update_document**](DocumentsApi.md#update_document) | **PATCH** /collections/{collectionName}/documents/{documentId} | Update a document [**update_documents**](DocumentsApi.md#update_documents) | **PATCH** /collections/{collectionName}/documents | Update documents with conditional query -[**upsert_search_override**](DocumentsApi.md#upsert_search_override) | **PUT** /collections/{collectionName}/overrides/{overrideId} | Create or update an override to promote certain documents over others @@ -86,35 +82,6 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -## delete_search_override - -> models::SearchOverrideDeleteResponse delete_search_override(collection_name, override_id) -Delete an override associated with a collection - -### Parameters - - -Name | Type | Description | Required | Notes -------------- | ------------- | ------------- | ------------- | ------------- -**collection_name** | **String** | The name of the collection | [required] | -**override_id** | **String** | The ID of the search override to delete | [required] | - -### Return type - -[**models::SearchOverrideDeleteResponse**](SearchOverrideDeleteResponse.md) - -### Authorization - -[api_key_header](../README.md#api_key_header) - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - - ## export_documents > String export_documents(collection_name, filter_by, include_fields, exclude_fields) @@ -179,65 +146,6 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -## get_search_override - -> models::SearchOverride get_search_override(collection_name, override_id) -Retrieve a single search override - -Retrieve the details of a search override, given its id. - -### Parameters - - -Name | Type | Description | Required | Notes -------------- | ------------- | ------------- | ------------- | ------------- -**collection_name** | **String** | The name of the collection | [required] | -**override_id** | **String** | The id of the search override | [required] | - -### Return type - -[**models::SearchOverride**](SearchOverride.md) - -### Authorization - -[api_key_header](../README.md#api_key_header) - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - - -## get_search_overrides - -> models::SearchOverridesResponse get_search_overrides(collection_name) -List all collection overrides - -### Parameters - - -Name | Type | Description | Required | Notes -------------- | ------------- | ------------- | ------------- | ------------- -**collection_name** | **String** | The name of the collection | [required] | - -### Return type - -[**models::SearchOverridesResponse**](SearchOverridesResponse.md) - -### Authorization - -[api_key_header](../README.md#api_key_header) - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - - ## import_documents > String import_documents(collection_name, body, batch_size, return_id, remote_embedding_batch_size, return_doc, action, dirty_values) @@ -567,35 +475,3 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -## upsert_search_override - -> models::SearchOverride upsert_search_override(collection_name, override_id, search_override_schema) -Create or update an override to promote certain documents over others - -Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query. - -### Parameters - - -Name | Type | Description | Required | Notes -------------- | ------------- | ------------- | ------------- | ------------- -**collection_name** | **String** | The name of the collection | [required] | -**override_id** | **String** | The ID of the search override to create/update | [required] | -**search_override_schema** | [**SearchOverrideSchema**](SearchOverrideSchema.md) | The search override object to be created/updated | [required] | - -### Return type - -[**models::SearchOverride**](SearchOverride.md) - -### Authorization - -[api_key_header](../README.md#api_key_header) - -### HTTP request headers - -- **Content-Type**: application/json -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/typesense_codegen/docs/MultiSearchResultItem.md b/typesense_codegen/docs/MultiSearchResultItem.md index 0f306be..6e21b24 100644 --- a/typesense_codegen/docs/MultiSearchResultItem.md +++ b/typesense_codegen/docs/MultiSearchResultItem.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **request_params** | Option<[**models::SearchRequestParams**](SearchRequestParams.md)> | | [optional] **conversation** | Option<[**models::SearchResultConversation**](SearchResultConversation.md)> | | [optional] **union_request_params** | Option<[**Vec**](SearchRequestParams.md)> | Returned only for union query response. | [optional] +**metadata** | Option<[**std::collections::HashMap**](serde_json::Value.md)> | Custom JSON object that can be returned in the search response | [optional] **code** | Option<**i64**> | HTTP error code | [optional] **error** | Option<**String**> | Error description | [optional] diff --git a/typesense_codegen/docs/SearchResult.md b/typesense_codegen/docs/SearchResult.md index 0f3bb0f..678d5f8 100644 --- a/typesense_codegen/docs/SearchResult.md +++ b/typesense_codegen/docs/SearchResult.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **request_params** | Option<[**models::SearchRequestParams**](SearchRequestParams.md)> | | [optional] **conversation** | Option<[**models::SearchResultConversation**](SearchResultConversation.md)> | | [optional] **union_request_params** | Option<[**Vec**](SearchRequestParams.md)> | Returned only for union query response. | [optional] +**metadata** | Option<[**std::collections::HashMap**](serde_json::Value.md)> | Custom JSON object that can be returned in the search response | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/typesense_codegen/docs/SynonymItemDeleteSchema.md b/typesense_codegen/docs/SynonymItemDeleteSchema.md new file mode 100644 index 0000000..461d2f3 --- /dev/null +++ b/typesense_codegen/docs/SynonymItemDeleteSchema.md @@ -0,0 +1,11 @@ +# SynonymItemDeleteSchema + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID of the deleted synonym item | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/typesense_codegen/docs/SynonymsApi.md b/typesense_codegen/docs/SynonymsApi.md index d00c016..f1e1fb2 100644 --- a/typesense_codegen/docs/SynonymsApi.md +++ b/typesense_codegen/docs/SynonymsApi.md @@ -5,9 +5,13 @@ All URIs are relative to *http://localhost:8108* Method | HTTP request | Description ------------- | ------------- | ------------- [**delete_synonym_set**](SynonymsApi.md#delete_synonym_set) | **DELETE** /synonym_sets/{synonymSetName} | Delete a synonym set +[**delete_synonym_set_item**](SynonymsApi.md#delete_synonym_set_item) | **DELETE** /synonym_sets/{synonymSetName}/items/{itemId} | Delete a synonym set item [**retrieve_synonym_set**](SynonymsApi.md#retrieve_synonym_set) | **GET** /synonym_sets/{synonymSetName} | Retrieve a synonym set +[**retrieve_synonym_set_item**](SynonymsApi.md#retrieve_synonym_set_item) | **GET** /synonym_sets/{synonymSetName}/items/{itemId} | Retrieve a synonym set item +[**retrieve_synonym_set_items**](SynonymsApi.md#retrieve_synonym_set_items) | **GET** /synonym_sets/{synonymSetName}/items | List items in a synonym set [**retrieve_synonym_sets**](SynonymsApi.md#retrieve_synonym_sets) | **GET** /synonym_sets | List all synonym sets [**upsert_synonym_set**](SynonymsApi.md#upsert_synonym_set) | **PUT** /synonym_sets/{synonymSetName} | Create or update a synonym set +[**upsert_synonym_set_item**](SynonymsApi.md#upsert_synonym_set_item) | **PUT** /synonym_sets/{synonymSetName}/items/{itemId} | Create or update a synonym set item @@ -41,6 +45,37 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +## delete_synonym_set_item + +> models::SynonymItemDeleteSchema delete_synonym_set_item(synonym_set_name, item_id) +Delete a synonym set item + +Delete a specific synonym item by its id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**synonym_set_name** | **String** | The name of the synonym set | [required] | +**item_id** | **String** | The id of the synonym item to delete | [required] | + +### Return type + +[**models::SynonymItemDeleteSchema**](SynonymItemDeleteSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## retrieve_synonym_set > models::SynonymSetCreateSchema retrieve_synonym_set(synonym_set_name) @@ -71,6 +106,67 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +## retrieve_synonym_set_item + +> models::SynonymItemSchema retrieve_synonym_set_item(synonym_set_name, item_id) +Retrieve a synonym set item + +Retrieve a specific synonym item by its id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**synonym_set_name** | **String** | The name of the synonym set | [required] | +**item_id** | **String** | The id of the synonym item to retrieve | [required] | + +### Return type + +[**models::SynonymItemSchema**](SynonymItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## retrieve_synonym_set_items + +> Vec retrieve_synonym_set_items(synonym_set_name) +List items in a synonym set + +Retrieve all synonym items in a set + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**synonym_set_name** | **String** | The name of the synonym set to retrieve items for | [required] | + +### Return type + +[**Vec**](SynonymItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## retrieve_synonym_sets > Vec retrieve_synonym_sets() @@ -128,3 +224,35 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## upsert_synonym_set_item + +> models::SynonymItemSchema upsert_synonym_set_item(synonym_set_name, item_id, synonym_item_schema) +Create or update a synonym set item + +Create or update a synonym set item with the given id + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**synonym_set_name** | **String** | The name of the synonym set | [required] | +**item_id** | **String** | The id of the synonym item to upsert | [required] | +**synonym_item_schema** | [**SynonymItemSchema**](SynonymItemSchema.md) | The synonym item to be created/updated | [required] | + +### Return type + +[**models::SynonymItemSchema**](SynonymItemSchema.md) + +### Authorization + +[api_key_header](../README.md#api_key_header) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/typesense_codegen/src/apis/curation_sets_api.rs b/typesense_codegen/src/apis/curation_sets_api.rs new file mode 100644 index 0000000..87a253f --- /dev/null +++ b/typesense_codegen/src/apis/curation_sets_api.rs @@ -0,0 +1,628 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{ContentType, Error, configuration}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; + +/// struct for passing parameters to the method [`delete_curation_set`] +#[derive(Clone, Debug)] +pub struct DeleteCurationSetParams { + /// The name of the curation set to delete + pub curation_set_name: String, +} + +/// struct for passing parameters to the method [`delete_curation_set_item`] +#[derive(Clone, Debug)] +pub struct DeleteCurationSetItemParams { + /// The name of the curation set + pub curation_set_name: String, + /// The id of the curation item to delete + pub item_id: String, +} + +/// struct for passing parameters to the method [`retrieve_curation_set`] +#[derive(Clone, Debug)] +pub struct RetrieveCurationSetParams { + /// The name of the curation set to retrieve + pub curation_set_name: String, +} + +/// struct for passing parameters to the method [`retrieve_curation_set_item`] +#[derive(Clone, Debug)] +pub struct RetrieveCurationSetItemParams { + /// The name of the curation set + pub curation_set_name: String, + /// The id of the curation item to retrieve + pub item_id: String, +} + +/// struct for passing parameters to the method [`retrieve_curation_set_items`] +#[derive(Clone, Debug)] +pub struct RetrieveCurationSetItemsParams { + /// The name of the curation set to retrieve items for + pub curation_set_name: String, +} + +/// struct for passing parameters to the method [`upsert_curation_set`] +#[derive(Clone, Debug)] +pub struct UpsertCurationSetParams { + /// The name of the curation set to create/update + pub curation_set_name: String, + /// The curation set to be created/updated + pub curation_set_create_schema: models::CurationSetCreateSchema, +} + +/// struct for passing parameters to the method [`upsert_curation_set_item`] +#[derive(Clone, Debug)] +pub struct UpsertCurationSetItemParams { + /// The name of the curation set + pub curation_set_name: String, + /// The id of the curation item to upsert + pub item_id: String, + /// The curation item to be created/updated + pub curation_item_create_schema: models::CurationItemCreateSchema, +} + +/// struct for typed errors of method [`delete_curation_set`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteCurationSetError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_curation_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteCurationSetItemError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_curation_set`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveCurationSetError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_curation_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveCurationSetItemError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_curation_set_items`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveCurationSetItemsError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_curation_sets`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveCurationSetsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upsert_curation_set`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpsertCurationSetError { + Status400(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upsert_curation_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpsertCurationSetItemError { + Status400(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// Delete a specific curation set by its name +pub async fn delete_curation_set( + configuration: &configuration::Configuration, + params: &DeleteCurationSetParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationSetDeleteSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationSetDeleteSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Delete a specific curation item by its id +pub async fn delete_curation_set_item( + configuration: &configuration::Configuration, + params: &DeleteCurationSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}/items/{itemId}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationItemDeleteSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationItemDeleteSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve a specific curation set by its name +pub async fn retrieve_curation_set( + configuration: &configuration::Configuration, + params: &RetrieveCurationSetParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationSetCreateSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationSetCreateSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve a specific curation item by its id +pub async fn retrieve_curation_set_item( + configuration: &configuration::Configuration, + params: &RetrieveCurationSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}/items/{itemId}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationItemSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationItemSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve all curation items in a set +pub async fn retrieve_curation_set_items( + configuration: &configuration::Configuration, + params: &RetrieveCurationSetItemsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}/items", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `Vec`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `Vec`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve all curation sets +pub async fn retrieve_curation_sets( + configuration: &configuration::Configuration, +) -> Result, Error> { + let uri_str = format!("{}/curation_sets", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `Vec`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `Vec`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create or update a curation set with the given name +pub async fn upsert_curation_set( + configuration: &configuration::Configuration, + params: &UpsertCurationSetParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name) + ); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + req_builder = req_builder.json(¶ms.curation_set_create_schema); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationSetSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationSetSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create or update a curation set item with the given id +pub async fn upsert_curation_set_item( + configuration: &configuration::Configuration, + params: &UpsertCurationSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/curation_sets/{curationSetName}/items/{itemId}", + configuration.base_path, + curationSetName = crate::apis::urlencode(¶ms.curation_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + req_builder = req_builder.json(¶ms.curation_item_create_schema); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::CurationItemSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::CurationItemSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/typesense_codegen/src/apis/documents_api.rs b/typesense_codegen/src/apis/documents_api.rs index 1ab77a3..eb146e3 100644 --- a/typesense_codegen/src/apis/documents_api.rs +++ b/typesense_codegen/src/apis/documents_api.rs @@ -33,15 +33,6 @@ pub struct DeleteDocumentsParams { pub truncate: Option, } -/// struct for passing parameters to the method [`delete_search_override`] -#[derive(Clone, Debug)] -pub struct DeleteSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The ID of the search override to delete - pub override_id: String, -} - /// struct for passing parameters to the method [`export_documents`] #[derive(Clone, Debug)] pub struct ExportDocumentsParams { @@ -61,22 +52,6 @@ pub struct GetDocumentParams { pub document_id: String, } -/// struct for passing parameters to the method [`get_search_override`] -#[derive(Clone, Debug)] -pub struct GetSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The id of the search override - pub override_id: String, -} - -/// struct for passing parameters to the method [`get_search_overrides`] -#[derive(Clone, Debug)] -pub struct GetSearchOverridesParams { - /// The name of the collection - pub collection_name: String, -} - /// struct for passing parameters to the method [`import_documents`] #[derive(Clone, Debug)] pub struct ImportDocumentsParams { @@ -276,17 +251,6 @@ pub struct UpdateDocumentsParams { pub filter_by: Option, } -/// struct for passing parameters to the method [`upsert_search_override`] -#[derive(Clone, Debug)] -pub struct UpsertSearchOverrideParams { - /// The name of the collection - pub collection_name: String, - /// The ID of the search override to create/update - pub override_id: String, - /// The search override object to be created/updated - pub search_override_schema: models::SearchOverrideSchema, -} - /// struct for typed errors of method [`delete_document`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -303,14 +267,6 @@ pub enum DeleteDocumentsError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`delete_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DeleteSearchOverrideError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`export_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -327,20 +283,6 @@ pub enum GetDocumentError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`get_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetSearchOverrideError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_search_overrides`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetSearchOverridesError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`import_documents`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -392,14 +334,6 @@ pub enum UpdateDocumentsError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`upsert_search_override`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpsertSearchOverrideError { - Status404(models::ApiResponse), - UnknownValue(serde_json::Value), -} - /// Delete an individual document from a collection by using its ID. pub async fn delete_document( configuration: &configuration::Configuration, @@ -539,69 +473,6 @@ pub async fn delete_documents( } } -pub async fn delete_search_override( - configuration: &configuration::Configuration, - params: &DeleteSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration - .client - .request(reqwest::Method::DELETE, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverrideDeleteResponse`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverrideDeleteResponse`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - /// Export all documents in a collection in JSON lines format. pub async fn export_documents( configuration: &configuration::Configuration, @@ -729,128 +600,6 @@ pub async fn get_document( } } -/// Retrieve the details of a search override, given its id. -pub async fn get_search_override( - configuration: &configuration::Configuration, - params: &GetSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverride`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverride`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - -pub async fn get_search_overrides( - configuration: &configuration::Configuration, - params: &GetSearchOverridesParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name) - ); - let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverridesResponse`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverridesResponse`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} - /// The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import. pub async fn import_documents( configuration: &configuration::Configuration, @@ -1681,66 +1430,3 @@ pub async fn update_documents( })) } } - -/// Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query. -pub async fn upsert_search_override( - configuration: &configuration::Configuration, - params: &UpsertSearchOverrideParams, -) -> Result> { - let uri_str = format!( - "{}/collections/{collectionName}/overrides/{overrideId}", - configuration.base_path, - collectionName = crate::apis::urlencode(¶ms.collection_name), - overrideId = crate::apis::urlencode(¶ms.override_id) - ); - let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - - if let Some(ref user_agent) = configuration.user_agent { - req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); - } - if let Some(ref apikey) = configuration.api_key { - let key = &apikey.key; - let value = match apikey.prefix { - Some(ref prefix) => &format!("{prefix} {key}"), - None => key, - }; - req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); - }; - req_builder = req_builder.json(¶ms.search_override_schema); - - let req = req_builder.build()?; - let resp = configuration.client.execute(req).await?; - - let status = resp.status(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("application/octet-stream"); - let content_type = super::ContentType::from(content_type); - - if !status.is_client_error() && !status.is_server_error() { - let content = resp.text().await?; - match content_type { - ContentType::Json => serde_json::from_str(&content).map_err(Error::from), - ContentType::Text => { - return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `models::SearchOverride`", - ))); - } - ContentType::Unsupported(unknown_type) => { - return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `models::SearchOverride`" - )))); - } - } - } else { - let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { - status, - content, - entity, - })) - } -} diff --git a/typesense_codegen/src/apis/mod.rs b/typesense_codegen/src/apis/mod.rs index 12bf0c1..b66b0b3 100644 --- a/typesense_codegen/src/apis/mod.rs +++ b/typesense_codegen/src/apis/mod.rs @@ -127,14 +127,13 @@ impl From<&str> for ContentType { pub mod analytics_api; pub mod collections_api; pub mod conversations_api; -pub mod curation_api; +pub mod curation_sets_api; pub mod debug_api; pub mod documents_api; pub mod health_api; pub mod keys_api; pub mod nl_search_models_api; pub mod operations_api; -pub mod override_api; pub mod presets_api; pub mod stemming_api; pub mod stopwords_api; diff --git a/typesense_codegen/src/apis/operations_api.rs b/typesense_codegen/src/apis/operations_api.rs index 8a1b91d..defe8cb 100644 --- a/typesense_codegen/src/apis/operations_api.rs +++ b/typesense_codegen/src/apis/operations_api.rs @@ -201,7 +201,7 @@ pub async fn compact_db( /// Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. pub async fn get_schema_changes( configuration: &configuration::Configuration, -) -> Result, Error> { +) -> Result>, Error> { let uri_str = format!("{}/operations/schema_changes", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -234,12 +234,12 @@ pub async fn get_schema_changes( ContentType::Json => serde_json::from_str(&content).map_err(Error::from), ContentType::Text => { return Err(Error::from(serde_json::Error::custom( - "Received `text/plain` content type response that cannot be converted to `Vec`", + "Received `text/plain` content type response that cannot be converted to `Option>`", ))); } ContentType::Unsupported(unknown_type) => { return Err(Error::from(serde_json::Error::custom(format!( - "Received `{unknown_type}` content type response that cannot be converted to `Vec`" + "Received `{unknown_type}` content type response that cannot be converted to `Option>`" )))); } } diff --git a/typesense_codegen/src/apis/synonyms_api.rs b/typesense_codegen/src/apis/synonyms_api.rs index 90777fa..53d5cbb 100644 --- a/typesense_codegen/src/apis/synonyms_api.rs +++ b/typesense_codegen/src/apis/synonyms_api.rs @@ -20,6 +20,15 @@ pub struct DeleteSynonymSetParams { pub synonym_set_name: String, } +/// struct for passing parameters to the method [`delete_synonym_set_item`] +#[derive(Clone, Debug)] +pub struct DeleteSynonymSetItemParams { + /// The name of the synonym set + pub synonym_set_name: String, + /// The id of the synonym item to delete + pub item_id: String, +} + /// struct for passing parameters to the method [`retrieve_synonym_set`] #[derive(Clone, Debug)] pub struct RetrieveSynonymSetParams { @@ -27,6 +36,22 @@ pub struct RetrieveSynonymSetParams { pub synonym_set_name: String, } +/// struct for passing parameters to the method [`retrieve_synonym_set_item`] +#[derive(Clone, Debug)] +pub struct RetrieveSynonymSetItemParams { + /// The name of the synonym set + pub synonym_set_name: String, + /// The id of the synonym item to retrieve + pub item_id: String, +} + +/// struct for passing parameters to the method [`retrieve_synonym_set_items`] +#[derive(Clone, Debug)] +pub struct RetrieveSynonymSetItemsParams { + /// The name of the synonym set to retrieve items for + pub synonym_set_name: String, +} + /// struct for passing parameters to the method [`upsert_synonym_set`] #[derive(Clone, Debug)] pub struct UpsertSynonymSetParams { @@ -36,6 +61,17 @@ pub struct UpsertSynonymSetParams { pub synonym_set_create_schema: models::SynonymSetCreateSchema, } +/// struct for passing parameters to the method [`upsert_synonym_set_item`] +#[derive(Clone, Debug)] +pub struct UpsertSynonymSetItemParams { + /// The name of the synonym set + pub synonym_set_name: String, + /// The id of the synonym item to upsert + pub item_id: String, + /// The synonym item to be created/updated + pub synonym_item_schema: models::SynonymItemSchema, +} + /// struct for typed errors of method [`delete_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -44,6 +80,14 @@ pub enum DeleteSynonymSetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`delete_synonym_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteSynonymSetItemError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`retrieve_synonym_set`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -52,6 +96,22 @@ pub enum RetrieveSynonymSetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`retrieve_synonym_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveSynonymSetItemError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_synonym_set_items`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveSynonymSetItemsError { + Status404(models::ApiResponse), + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`retrieve_synonym_sets`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -67,6 +127,14 @@ pub enum UpsertSynonymSetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`upsert_synonym_set_item`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpsertSynonymSetItemError { + Status400(models::ApiResponse), + UnknownValue(serde_json::Value), +} + /// Delete a specific synonym set by its name pub async fn delete_synonym_set( configuration: &configuration::Configuration, @@ -130,6 +198,70 @@ pub async fn delete_synonym_set( } } +/// Delete a specific synonym item by its id +pub async fn delete_synonym_set_item( + configuration: &configuration::Configuration, + params: &DeleteSynonymSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/synonym_sets/{synonymSetName}/items/{itemId}", + configuration.base_path, + synonymSetName = crate::apis::urlencode(¶ms.synonym_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::SynonymItemDeleteSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::SynonymItemDeleteSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + /// Retrieve a specific synonym set by its name pub async fn retrieve_synonym_set( configuration: &configuration::Configuration, @@ -191,6 +323,129 @@ pub async fn retrieve_synonym_set( } } +/// Retrieve a specific synonym item by its id +pub async fn retrieve_synonym_set_item( + configuration: &configuration::Configuration, + params: &RetrieveSynonymSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/synonym_sets/{synonymSetName}/items/{itemId}", + configuration.base_path, + synonymSetName = crate::apis::urlencode(¶ms.synonym_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::SynonymItemSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::SynonymItemSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve all synonym items in a set +pub async fn retrieve_synonym_set_items( + configuration: &configuration::Configuration, + params: &RetrieveSynonymSetItemsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/synonym_sets/{synonymSetName}/items", + configuration.base_path, + synonymSetName = crate::apis::urlencode(¶ms.synonym_set_name) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `Vec`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `Vec`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + /// Retrieve all synonym sets pub async fn retrieve_synonym_sets( configuration: &configuration::Configuration, @@ -308,3 +563,66 @@ pub async fn upsert_synonym_set( })) } } + +/// Create or update a synonym set item with the given id +pub async fn upsert_synonym_set_item( + configuration: &configuration::Configuration, + params: &UpsertSynonymSetItemParams, +) -> Result> { + let uri_str = format!( + "{}/synonym_sets/{synonymSetName}/items/{itemId}", + configuration.base_path, + synonymSetName = crate::apis::urlencode(¶ms.synonym_set_name), + itemId = crate::apis::urlencode(¶ms.item_id) + ); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = &apikey.key; + let value = match apikey.prefix { + Some(ref prefix) => &format!("{prefix} {key}"), + None => key, + }; + req_builder = req_builder.header("X-TYPESENSE-API-KEY", value); + }; + req_builder = req_builder.json(¶ms.synonym_item_schema); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::SynonymItemSchema`", + ))); + } + ContentType::Unsupported(unknown_type) => { + return Err(Error::from(serde_json::Error::custom(format!( + "Received `{unknown_type}` content type response that cannot be converted to `models::SynonymItemSchema`" + )))); + } + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/typesense_codegen/src/models/curation_exclude.rs b/typesense_codegen/src/models/curation_exclude.rs new file mode 100644 index 0000000..af70fa3 --- /dev/null +++ b/typesense_codegen/src/models/curation_exclude.rs @@ -0,0 +1,25 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationExclude { + /// document id that should be excluded from the search results. + #[serde(rename = "id")] + pub id: String, +} + +impl CurationExclude { + pub fn new(id: String) -> CurationExclude { + CurationExclude { id } + } +} diff --git a/typesense_codegen/src/models/curation_include.rs b/typesense_codegen/src/models/curation_include.rs new file mode 100644 index 0000000..5f9c2e5 --- /dev/null +++ b/typesense_codegen/src/models/curation_include.rs @@ -0,0 +1,28 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationInclude { + /// document id that should be included + #[serde(rename = "id")] + pub id: String, + /// position number where document should be included in the search results + #[serde(rename = "position")] + pub position: i32, +} + +impl CurationInclude { + pub fn new(id: String, position: i32) -> CurationInclude { + CurationInclude { id, position } + } +} diff --git a/typesense_codegen/src/models/curation_item_create_schema.rs b/typesense_codegen/src/models/curation_item_create_schema.rs new file mode 100644 index 0000000..7f4f975 --- /dev/null +++ b/typesense_codegen/src/models/curation_item_create_schema.rs @@ -0,0 +1,80 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationItemCreateSchema { + #[serde(rename = "rule")] + pub rule: Box, + /// List of document `id`s that should be included in the search results with their corresponding `position`s. + #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] + pub includes: Option>, + /// List of document `id`s that should be excluded from the search results. + #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] + pub excludes: Option>, + /// A filter by clause that is applied to any search query that matches the curation rule. + #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] + pub filter_by: Option, + /// Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. + #[serde( + rename = "remove_matched_tokens", + skip_serializing_if = "Option::is_none" + )] + pub remove_matched_tokens: Option, + /// Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option, + /// A sort by clause that is applied to any search query that matches the curation rule. + #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] + pub sort_by: Option, + /// Replaces the current search query with this value, when the search query matches the curation rule. + #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] + pub replace_query: Option, + /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. + #[serde( + rename = "filter_curated_hits", + skip_serializing_if = "Option::is_none" + )] + pub filter_curated_hits: Option, + /// A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. + #[serde(rename = "effective_from_ts", skip_serializing_if = "Option::is_none")] + pub effective_from_ts: Option, + /// A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. + #[serde(rename = "effective_to_ts", skip_serializing_if = "Option::is_none")] + pub effective_to_ts: Option, + /// When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. + #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] + pub stop_processing: Option, + /// ID of the curation item + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, +} + +impl CurationItemCreateSchema { + pub fn new(rule: models::CurationRule) -> CurationItemCreateSchema { + CurationItemCreateSchema { + rule: Box::new(rule), + includes: None, + excludes: None, + filter_by: None, + remove_matched_tokens: None, + metadata: None, + sort_by: None, + replace_query: None, + filter_curated_hits: None, + effective_from_ts: None, + effective_to_ts: None, + stop_processing: None, + id: None, + } + } +} diff --git a/typesense_codegen/src/models/curation_item_delete_schema.rs b/typesense_codegen/src/models/curation_item_delete_schema.rs new file mode 100644 index 0000000..9bdf0c5 --- /dev/null +++ b/typesense_codegen/src/models/curation_item_delete_schema.rs @@ -0,0 +1,25 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationItemDeleteSchema { + /// ID of the deleted curation item + #[serde(rename = "id")] + pub id: String, +} + +impl CurationItemDeleteSchema { + pub fn new(id: String) -> CurationItemDeleteSchema { + CurationItemDeleteSchema { id } + } +} diff --git a/typesense_codegen/src/models/curation_item_schema.rs b/typesense_codegen/src/models/curation_item_schema.rs new file mode 100644 index 0000000..74c3d4e --- /dev/null +++ b/typesense_codegen/src/models/curation_item_schema.rs @@ -0,0 +1,79 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationItemSchema { + #[serde(rename = "rule")] + pub rule: Box, + /// List of document `id`s that should be included in the search results with their corresponding `position`s. + #[serde(rename = "includes", skip_serializing_if = "Option::is_none")] + pub includes: Option>, + /// List of document `id`s that should be excluded from the search results. + #[serde(rename = "excludes", skip_serializing_if = "Option::is_none")] + pub excludes: Option>, + /// A filter by clause that is applied to any search query that matches the curation rule. + #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] + pub filter_by: Option, + /// Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. + #[serde( + rename = "remove_matched_tokens", + skip_serializing_if = "Option::is_none" + )] + pub remove_matched_tokens: Option, + /// Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered. + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option, + /// A sort by clause that is applied to any search query that matches the curation rule. + #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")] + pub sort_by: Option, + /// Replaces the current search query with this value, when the search query matches the curation rule. + #[serde(rename = "replace_query", skip_serializing_if = "Option::is_none")] + pub replace_query: Option, + /// When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. + #[serde( + rename = "filter_curated_hits", + skip_serializing_if = "Option::is_none" + )] + pub filter_curated_hits: Option, + /// A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time. + #[serde(rename = "effective_from_ts", skip_serializing_if = "Option::is_none")] + pub effective_from_ts: Option, + /// A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time. + #[serde(rename = "effective_to_ts", skip_serializing_if = "Option::is_none")] + pub effective_to_ts: Option, + /// When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field. + #[serde(rename = "stop_processing", skip_serializing_if = "Option::is_none")] + pub stop_processing: Option, + #[serde(rename = "id")] + pub id: String, +} + +impl CurationItemSchema { + pub fn new(rule: models::CurationRule, id: String) -> CurationItemSchema { + CurationItemSchema { + rule: Box::new(rule), + includes: None, + excludes: None, + filter_by: None, + remove_matched_tokens: None, + metadata: None, + sort_by: None, + replace_query: None, + filter_curated_hits: None, + effective_from_ts: None, + effective_to_ts: None, + stop_processing: None, + id, + } + } +} diff --git a/typesense_codegen/src/models/curation_rule.rs b/typesense_codegen/src/models/curation_rule.rs new file mode 100644 index 0000000..45db3a0 --- /dev/null +++ b/typesense_codegen/src/models/curation_rule.rs @@ -0,0 +1,53 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationRule { + /// List of tag values to associate with this curation rule. + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + /// Indicates what search queries should be curated + #[serde(rename = "query", skip_serializing_if = "Option::is_none")] + pub query: Option, + /// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. + #[serde(rename = "match", skip_serializing_if = "Option::is_none")] + pub r#match: Option, + /// Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc). + #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")] + pub filter_by: Option, +} + +impl CurationRule { + pub fn new() -> CurationRule { + CurationRule { + tags: None, + query: None, + r#match: None, + filter_by: None, + } + } +} +/// Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Match { + #[serde(rename = "exact")] + Exact, + #[serde(rename = "contains")] + Contains, +} + +impl Default for Match { + fn default() -> Match { + Self::Exact + } +} diff --git a/typesense_codegen/src/models/curation_set_create_schema.rs b/typesense_codegen/src/models/curation_set_create_schema.rs new file mode 100644 index 0000000..8676aaa --- /dev/null +++ b/typesense_codegen/src/models/curation_set_create_schema.rs @@ -0,0 +1,31 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationSetCreateSchema { + /// Array of curation items + #[serde(rename = "items")] + pub items: Vec, + /// Optional description for the curation set + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, +} + +impl CurationSetCreateSchema { + pub fn new(items: Vec) -> CurationSetCreateSchema { + CurationSetCreateSchema { + items, + description: None, + } + } +} diff --git a/typesense_codegen/src/models/curation_set_delete_schema.rs b/typesense_codegen/src/models/curation_set_delete_schema.rs new file mode 100644 index 0000000..d57d683 --- /dev/null +++ b/typesense_codegen/src/models/curation_set_delete_schema.rs @@ -0,0 +1,25 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationSetDeleteSchema { + /// Name of the deleted curation set + #[serde(rename = "name")] + pub name: String, +} + +impl CurationSetDeleteSchema { + pub fn new(name: String) -> CurationSetDeleteSchema { + CurationSetDeleteSchema { name } + } +} diff --git a/typesense_codegen/src/models/curation_set_schema.rs b/typesense_codegen/src/models/curation_set_schema.rs new file mode 100644 index 0000000..70f5e54 --- /dev/null +++ b/typesense_codegen/src/models/curation_set_schema.rs @@ -0,0 +1,34 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CurationSetSchema { + /// Array of curation items + #[serde(rename = "items")] + pub items: Vec, + /// Optional description for the curation set + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(rename = "name")] + pub name: String, +} + +impl CurationSetSchema { + pub fn new(items: Vec, name: String) -> CurationSetSchema { + CurationSetSchema { + items, + description: None, + name, + } + } +} diff --git a/typesense_codegen/src/models/mod.rs b/typesense_codegen/src/models/mod.rs index 40ce6f2..47ac5d6 100644 --- a/typesense_codegen/src/models/mod.rs +++ b/typesense_codegen/src/models/mod.rs @@ -56,6 +56,24 @@ pub mod create_analytics_rule_200_response_one_of_inner_any_of; pub use self::create_analytics_rule_200_response_one_of_inner_any_of::CreateAnalyticsRule200ResponseOneOfInnerAnyOf; pub mod create_analytics_rule_request; pub use self::create_analytics_rule_request::CreateAnalyticsRuleRequest; +pub mod curation_exclude; +pub use self::curation_exclude::CurationExclude; +pub mod curation_include; +pub use self::curation_include::CurationInclude; +pub mod curation_item_create_schema; +pub use self::curation_item_create_schema::CurationItemCreateSchema; +pub mod curation_item_delete_schema; +pub use self::curation_item_delete_schema::CurationItemDeleteSchema; +pub mod curation_item_schema; +pub use self::curation_item_schema::CurationItemSchema; +pub mod curation_rule; +pub use self::curation_rule::CurationRule; +pub mod curation_set_create_schema; +pub use self::curation_set_create_schema::CurationSetCreateSchema; +pub mod curation_set_delete_schema; +pub use self::curation_set_delete_schema::CurationSetDeleteSchema; +pub mod curation_set_schema; +pub use self::curation_set_schema::CurationSetSchema; pub mod debug_200_response; pub use self::debug_200_response::Debug200Response; pub mod delete_documents_200_response; @@ -126,20 +144,6 @@ pub mod search_grouped_hit; pub use self::search_grouped_hit::SearchGroupedHit; pub mod search_highlight; pub use self::search_highlight::SearchHighlight; -pub mod search_override; -pub use self::search_override::SearchOverride; -pub mod search_override_delete_response; -pub use self::search_override_delete_response::SearchOverrideDeleteResponse; -pub mod search_override_exclude; -pub use self::search_override_exclude::SearchOverrideExclude; -pub mod search_override_include; -pub use self::search_override_include::SearchOverrideInclude; -pub mod search_override_rule; -pub use self::search_override_rule::SearchOverrideRule; -pub mod search_override_schema; -pub use self::search_override_schema::SearchOverrideSchema; -pub mod search_overrides_response; -pub use self::search_overrides_response::SearchOverridesResponse; pub mod search_parameters; pub use self::search_parameters::SearchParameters; pub mod search_request_params; @@ -178,6 +182,8 @@ pub mod stopwords_sets_retrieve_all_schema; pub use self::stopwords_sets_retrieve_all_schema::StopwordsSetsRetrieveAllSchema; pub mod success_status; pub use self::success_status::SuccessStatus; +pub mod synonym_item_delete_schema; +pub use self::synonym_item_delete_schema::SynonymItemDeleteSchema; pub mod synonym_item_schema; pub use self::synonym_item_schema::SynonymItemSchema; pub mod synonym_set_create_schema; diff --git a/typesense_codegen/src/models/multi_search_result_item.rs b/typesense_codegen/src/models/multi_search_result_item.rs index 64794c8..daa3024 100644 --- a/typesense_codegen/src/models/multi_search_result_item.rs +++ b/typesense_codegen/src/models/multi_search_result_item.rs @@ -47,6 +47,9 @@ pub struct MultiSearchResultItem { skip_serializing_if = "Option::is_none" )] pub union_request_params: Option>, + /// Custom JSON object that can be returned in the search response + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, /// HTTP error code #[serde(rename = "code", skip_serializing_if = "Option::is_none")] pub code: Option, @@ -70,6 +73,7 @@ impl MultiSearchResultItem { request_params: None, conversation: None, union_request_params: None, + metadata: None, code: None, error: None, } diff --git a/typesense_codegen/src/models/search_result.rs b/typesense_codegen/src/models/search_result.rs index f5ea5b5..1805210 100644 --- a/typesense_codegen/src/models/search_result.rs +++ b/typesense_codegen/src/models/search_result.rs @@ -47,6 +47,9 @@ pub struct SearchResult { skip_serializing_if = "Option::is_none" )] pub union_request_params: Option>, + /// Custom JSON object that can be returned in the search response + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, } impl SearchResult { @@ -64,6 +67,7 @@ impl SearchResult { request_params: None, conversation: None, union_request_params: None, + metadata: None, } } } diff --git a/typesense_codegen/src/models/synonym_item_delete_schema.rs b/typesense_codegen/src/models/synonym_item_delete_schema.rs new file mode 100644 index 0000000..91c3e1d --- /dev/null +++ b/typesense_codegen/src/models/synonym_item_delete_schema.rs @@ -0,0 +1,25 @@ +/* + * Typesense API + * + * An open source search engine for building delightful search experiences. + * + * The version of the OpenAPI document: 30.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SynonymItemDeleteSchema { + /// ID of the deleted synonym item + #[serde(rename = "id")] + pub id: String, +} + +impl SynonymItemDeleteSchema { + pub fn new(id: String) -> SynonymItemDeleteSchema { + SynonymItemDeleteSchema { id } + } +} diff --git a/xtask/src/add_vendor_attributes.rs b/xtask/src/add_vendor_attributes.rs index d8fd0aa..ac3013f 100644 --- a/xtask/src/add_vendor_attributes.rs +++ b/xtask/src/add_vendor_attributes.rs @@ -51,6 +51,12 @@ pub fn add_vendor_attributes(doc_root: &mut Mapping) -> Result<(), String> { .return_type("serde_json::Value") .done()?; + // The endpoint return `null` if no schema changes are in progress + attrs + .operation("/operations/schema_changes", "get") + .return_type("Option>") + .done()?; + attrs .operation("/collections/{collectionName}/documents/import", "post") .body_is_raw_text()