diff --git a/openapi.yml b/openapi.yml index a6a03be..bab3702 100644 --- a/openapi.yml +++ b/openapi.yml @@ -72,11 +72,11 @@ tags: externalDocs: description: Find out more url: https://typesense.org/docs/28.0/api/conversational-search-rag.html - - name: synonyms - description: Manage synonyms + - name: synonym_sets + description: Manage synonym sets externalDocs: description: Find out more - url: https://typesense.org/docs/28.0/api/synonyms.html + url: https://typesense.org/docs/28.0/api/synonym-sets.html - name: stemming description: Manage stemming dictionaries externalDocs: @@ -583,135 +583,6 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponse" - /collections/{collectionName}/synonyms: - get: - tags: - - synonyms - summary: List all collection synonyms - operationId: getSearchSynonyms - parameters: - - name: collectionName - in: path - description: The name of the collection - required: true - schema: - type: string - responses: - '200': - description: List of all search synonyms - content: - application/json: - schema: - $ref: "#/components/schemas/SearchSynonymsResponse" - '404': - description: Search synonyms was not found - content: - application/json: - schema: - $ref: "#/components/schemas/ApiResponse" - /collections/{collectionName}/synonyms/{synonymId}: - get: - tags: - - synonyms - summary: Retrieve a single search synonym - description: Retrieve the details of a search synonym, given its id. - operationId: getSearchSynonym - parameters: - - name: collectionName - in: path - description: The name of the collection - required: true - schema: - type: string - - name: synonymId - in: path - description: The id of the search synonym - required: true - schema: - type: string - responses: - '200': - description: Search synonym fetched - content: - application/json: - schema: - $ref: "#/components/schemas/SearchSynonym" - '404': - description: Search synonym was not found - content: - application/json: - schema: - $ref: "#/components/schemas/ApiResponse" - put: - tags: - - synonyms - summary: Create or update a synonym - description: Create or update a synonym to define search terms that should be considered equivalent. - operationId: upsertSearchSynonym - parameters: - - name: collectionName - in: path - description: The name of the collection - required: true - schema: - type: string - - name: synonymId - in: path - description: The ID of the search synonym to create/update - required: true - schema: - type: string - requestBody: - description: The search synonym object to be created/updated - content: - application/json: - schema: - $ref: "#/components/schemas/SearchSynonymSchema" - required: true - responses: - '200': - description: Created/updated search synonym - content: - application/json: - schema: - $ref: "#/components/schemas/SearchSynonym" - '404': - description: Search synonym was not found - content: - application/json: - schema: - $ref: "#/components/schemas/ApiResponse" - delete: - tags: - - synonyms - summary: Delete a synonym associated with a collection - operationId: deleteSearchSynonym - parameters: - - name: collectionName - in: path - description: The name of the collection - required: true - schema: - type: string - - name: synonymId - in: path - description: The ID of the search synonym to delete - required: true - schema: - type: string - responses: - '200': - description: The ID of the deleted search synonym - content: - application/json: - schema: - $ref: "#/components/schemas/SearchSynonymDeleteResponse" - '404': - description: Search synonym not found - content: - application/json: - schema: - $ref: "#/components/schemas/ApiResponse" /collections/{collectionName}/documents/export: get: @@ -1406,17 +1277,17 @@ paths: tags: - analytics summary: Create an analytics event - description: Sending events for analytics e.g rank search results based on popularity. + description: Submit a single analytics event. The event must correspond to an existing analytics rule by name. operationId: createAnalyticsEvent requestBody: - description: The Analytics event to be created + description: The analytics event to be created content: application/json: schema: - $ref: '#/components/schemas/AnalyticsEventCreateSchema' + $ref: '#/components/schemas/AnalyticsEvent' required: true responses: - '201': + '200': description: Analytics event successfully created content: application/json: @@ -1428,28 +1299,105 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponse' + get: + tags: + - analytics + summary: Retrieve analytics events + description: Retrieve the most recent events for a user and rule. + operationId: getAnalyticsEvents + parameters: + - name: user_id + in: query + required: true + schema: + type: string + - name: name + in: query + description: Analytics rule name + required: true + schema: + type: string + - name: n + in: query + description: Number of events to return (max 1000) + required: true + schema: + type: integer + responses: + '200': + description: Events fetched + content: + application/json: + schema: + $ref: '#/components/schemas/AnalyticsEventsResponse' + '400': + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + /analytics/flush: + post: + tags: + - analytics + summary: Flush in-memory analytics to disk + description: Triggers a flush of analytics data to persistent storage. + operationId: flushAnalytics + responses: + '200': + description: Flush triggered + content: + application/json: + schema: + $ref: '#/components/schemas/AnalyticsEventCreateResponse' + /analytics/status: + get: + tags: + - analytics + summary: Get analytics subsystem status + description: Returns sizes of internal analytics buffers and queues. + operationId: getAnalyticsStatus + responses: + '200': + description: Status fetched + content: + application/json: + schema: + $ref: '#/components/schemas/AnalyticsStatus' /analytics/rules: post: tags: - analytics - summary: Creates an analytics rule - description: - When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. + summary: Create analytics rule(s) + description: Create one or more analytics rules. You can send a single rule object or an array of rule objects. operationId: createAnalyticsRule requestBody: - description: The Analytics rule to be created + description: The analytics rule(s) to be created content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleSchema" + oneOf: + - $ref: "#/components/schemas/AnalyticsRuleCreate" + - type: array + items: + $ref: "#/components/schemas/AnalyticsRuleCreate" required: true responses: - '201': - description: Analytics rule successfully created + '200': + description: Analytics rule(s) successfully created content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleSchema" + oneOf: + - $ref: "#/components/schemas/AnalyticsRule" + - type: array + items: + anyOf: + - $ref: "#/components/schemas/AnalyticsRule" + - type: object + properties: + error: + type: string '400': description: Bad request, see error message for details content: @@ -1459,17 +1407,25 @@ paths: get: tags: - analytics - summary: Retrieves all analytics rules - description: - Retrieve the details of all analytics rules + summary: Retrieve analytics rules + description: Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. operationId: retrieveAnalyticsRules + parameters: + - in: query + name: rule_tag + schema: + type: string + required: false + description: Filter rules by rule_tag responses: '200': description: Analytics rules fetched content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRulesRetrieveSchema" + type: array + items: + $ref: "#/components/schemas/AnalyticsRule" /analytics/rules/{ruleName}: put: tags: @@ -1490,7 +1446,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleUpsertSchema" + $ref: "#/components/schemas/AnalyticsRuleUpdate" required: true responses: '200': @@ -1498,7 +1454,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleSchema" + $ref: "#/components/schemas/AnalyticsRule" '400': description: Bad request, see error message for details content: @@ -1525,7 +1481,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleSchema" + $ref: "#/components/schemas/AnalyticsRule" '404': description: Analytics rule not found content: @@ -1552,7 +1508,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/AnalyticsRuleDeleteResponse" + $ref: "#/components/schemas/AnalyticsRule" '404': description: Analytics rule not found content: @@ -2032,6 +1988,104 @@ paths: schema: $ref: '#/components/schemas/ApiResponse' + /synonym_sets: + get: + tags: + - synonym_sets + summary: List all synonym sets + description: Retrieve the list of all synonym sets. + operationId: getSynonymSets + responses: + '200': + description: List of synonym sets + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetsListResponse' + + /synonym_sets/{name}: + get: + tags: + - synonym_sets + summary: Get a synonym set + description: Retrieve a specific synonym set by name. + operationId: getSynonymSet + parameters: + - in: path + name: name + required: true + schema: + type: string + responses: + '200': + description: Synonym set fetched + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSet' + '404': + description: Synonym set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + put: + tags: + - synonym_sets + summary: Create or replace a synonym set + description: Create or replace a synonym set with the given name. + operationId: upsertSynonymSet + parameters: + - in: path + name: name + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetUpsert' + responses: + '200': + description: Created/updated synonym set + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSet' + '400': + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + delete: + tags: + - synonym_sets + summary: Delete a synonym set + description: Delete the specified synonym set. + operationId: deleteSynonymSet + parameters: + - in: path + name: name + required: true + schema: + type: string + responses: + '200': + description: Synonym set deleted + content: + application/json: + schema: + $ref: '#/components/schemas/SynonymSetDeleteResponse' + '404': + description: Synonym set not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + components: schemas: CollectionSchema: @@ -2673,6 +2727,61 @@ components: id: type: string readOnly: true + SynonymObject: + type: object + required: + - id + - root + - synonyms + properties: + id: { type: string } + root: { type: string } + synonyms: + type: array + items: { type: string } + locale: { type: string } + symbols_to_index: + type: array + items: { type: string } + SynonymSetUpsert: + type: object + required: + - synonyms + properties: + synonyms: + type: array + items: + $ref: '#/components/schemas/SynonymObject' + SynonymSet: + type: object + required: + - synonyms + properties: + synonyms: + type: array + items: + $ref: '#/components/schemas/SynonymObject' + SynonymSetsListEntry: + type: object + required: + - name + - synonyms + properties: + name: { type: string } + synonyms: + type: array + items: + $ref: '#/components/schemas/SynonymObject' + SynonymSetsListResponse: + type: array + items: + $ref: '#/components/schemas/SynonymSetsListEntry' + SynonymSetDeleteResponse: + type: object + required: + - name + properties: + name: { type: string } SearchSynonymDeleteResponse: type: object required: @@ -3640,105 +3749,133 @@ components: properties: ok: type: boolean - AnalyticsEventCreateSchema: + AnalyticsEvent: type: object required: - - type - name + - event_type - data properties: - type: - type: string name: type: string + description: Name of the analytics rule this event corresponds to + event_type: + type: string + description: Type of event (e.g., click, conversion, query, visit) data: type: object - AnalyticsRuleUpsertSchema: - type: object - required: - - type - - params - properties: - type: - type: string - enum: - - popular_queries - - nohits_queries - - counter - params: - $ref: "#/components/schemas/AnalyticsRuleParameters" - AnalyticsRuleParameters: - type: object - required: - - source - - destination - properties: - source: - $ref: '#/components/schemas/AnalyticsRuleParametersSource' - destination: - $ref: '#/components/schemas/AnalyticsRuleParametersDestination' - limit: - type: integer - expand_query: - type: boolean - AnalyticsRuleParametersSource: + description: Event payload + properties: + user_id: + type: string + doc_id: + type: string + doc_ids: + type: array + items: + type: string + q: + type: string + analytics_tag: + type: string + AnalyticsEventsResponse: type: object required: - - collections + - events properties: - collections: - type: array - items: - type: string events: type: array items: type: object - required: - - type - - weight - - name properties: - type: - type: string - weight: - type: number - format: float - name: - type: string - AnalyticsRuleParametersDestination: + name: { type: string } + event_type: { type: string } + collection: { type: string } + timestamp: { type: integer, format: int64 } + user_id: { type: string } + doc_id: { type: string } + doc_ids: + type: array + items: { type: string } + query: { type: string } + AnalyticsRuleCreate: type: object required: + - name + - type - collection + - event_type properties: + name: + type: string + type: + type: string + enum: [popular_queries, nohits_queries, counter, log] collection: type: string - counter_field: + event_type: + type: string + rule_tag: type: string - AnalyticsRuleDeleteResponse: + params: + type: object + properties: + destination_collection: + type: string + limit: + type: integer + capture_search_requests: + type: boolean + meta_fields: + type: array + items: { type: string } + expand_query: + type: boolean + counter_field: + type: string + weight: + type: integer + AnalyticsRuleUpdate: type: object - required: - - name + description: Fields allowed to update on an analytics rule properties: name: type: string - AnalyticsRuleSchema: - allOf: - - $ref: '#/components/schemas/AnalyticsRuleUpsertSchema' - - type: object - required: - - name + rule_tag: + type: string + params: + type: object properties: - name: + destination_collection: type: string - AnalyticsRulesRetrieveSchema: + limit: + type: integer + capture_search_requests: + type: boolean + meta_fields: + type: array + items: { type: string } + expand_query: + type: boolean + counter_field: + type: string + weight: + type: integer + AnalyticsRule: + allOf: + - $ref: '#/components/schemas/AnalyticsRuleCreate' + - type: object + AnalyticsStatus: type: object properties: - rules: - type: array - items: - $ref: "#/components/schemas/AnalyticsRuleSchema" - x-go-type: '[]*AnalyticsRuleSchema' + popular_prefix_queries: { type: integer } + nohits_prefix_queries: { type: integer } + log_prefix_queries: { type: integer } + query_log_events: { type: integer } + query_counter_events: { type: integer } + doc_log_events: { type: integer } + doc_counter_events: { type: integer } + APIStatsResponse: type: object properties: