From 3f46a045092dba8424406f1acd1817e6b1f37833 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Mon, 12 Aug 2024 10:30:58 +0800 Subject: [PATCH 1/7] open api generator --- .gitignore | 3 + README.md | 12 + config/config.exs | 8 + docker-compose.yml | 4 + mix.exs | 3 +- mix.lock | 6 +- openapi/openapi.yml | 3024 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 3058 insertions(+), 2 deletions(-) create mode 100644 openapi/openapi.yml diff --git a/.gitignore b/.gitignore index 2c10b54..defc07b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ ex_typesense-*.tar # Misc. .elixir_ls **.DS_Store + +# openapi generator files +/openapi/generator/ diff --git a/README.md b/README.md index c44fa82..b2c10f9 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,18 @@ ExTypesense.search(Person, params) Check [Cheatsheet](https://hexdocs.pm/ex_typesense/cheatsheet.html) for more usage examples. +## Miscellaneous + +### OpenAPI generator + +```bash +# default in ./openapi/generator/ExTypesense +mix api.gen + +# another profile +mix api.gen default path/to/rest-api-description/spec.yaml +``` + ## License Copyright (c) 2021 Jaeyson Anthony Y. diff --git a/config/config.exs b/config/config.exs index 1f438af..3ab6b7b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -6,4 +6,12 @@ if Mix.env() in [:dev, :test] do host: "localhost", port: 8108, scheme: "http" + + config :oapi_generator, + default: [ + output: [ + base_module: ExTypesense, + location: "openapi/generator/ExTypesense" + ] + ] end diff --git a/docker-compose.yml b/docker-compose.yml index 4a49863..a1d8c4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: - 8108:8108 # typesense server volumes: - ./typesense-data:/data +<<<<<<< Updated upstream command: '--data-dir /data --api-key=xyz --enable-cors' typesense_dashboard: image: ghcr.io/bfritscher/typesense-dashboard:latest @@ -19,3 +20,6 @@ services: - ./config/config.json:/srv/config.json depends_on: - typesense +======= + command: "--data-dir /data --api-key=xyz --enable-cors" +>>>>>>> Stashed changes diff --git a/mix.exs b/mix.exs index 87de5bd..cb0f1ab 100644 --- a/mix.exs +++ b/mix.exs @@ -41,7 +41,8 @@ defmodule ExTypesense.MixProject do {:req, "~> 0.5"}, {:ecto, "~> 3.11"}, {:excoveralls, "~> 0.10", only: :test}, - {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false} + {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}, + {:oapi_generator, "~> 0.2.0", only: :dev, runtime: false} ] end diff --git a/mix.lock b/mix.lock index 9c6b3dd..5a6b963 100644 --- a/mix.lock +++ b/mix.lock @@ -13,13 +13,17 @@ "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, - "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"}, "mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"}, "mix_audit": {:hex, :mix_audit, "2.1.4", "0a23d5b07350cdd69001c13882a4f5fb9f90fbd4cbf2ebc190a2ee0d187ea3e9", [:make, :mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.11", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "fd807653cc8c1cada2911129c7eb9e985e3cc76ebf26f4dd628bb25bbcaa7099"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, +<<<<<<< Updated upstream +======= + "oapi_generator": {:hex, :oapi_generator, "0.2.0", "b2e84892329e24f5b98ab27bfdd66069e015b90061c4d540a0c5a5e0ae260631", [:mix], [{:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "1171ba8610d947e1b13581eba1807fbd5fccc4f12402cd04e71df8efa51ef62b"}, +>>>>>>> Stashed changes "req": {:hex, :req, "0.5.6", "8fe1eead4a085510fe3d51ad854ca8f20a622aae46e97b302f499dfb84f726ac", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cfaa8e720945d46654853de39d368f40362c2641c4b2153c886418914b372185"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"}, diff --git a/openapi/openapi.yml b/openapi/openapi.yml new file mode 100644 index 0000000..61d074a --- /dev/null +++ b/openapi/openapi.yml @@ -0,0 +1,3024 @@ +openapi: 3.1.0 +info: + title: Typesense API + description: "An open source search engine for building delightful search experiences." + version: "26.0" +externalDocs: + description: Find out more about Typsesense + url: https://typesense.org +security: + - api_key_header: [] +tags: + - name: collections + description: A collection is defined by a schema + externalDocs: + description: Find out more + url: https://typesense.org/api/#create-collection + - name: documents + description: A document is an individual record to be indexed and belongs to a collection + externalDocs: + description: Find out more + url: https://typesense.org/api/#index-document + - name: promote + description: Promote certain documents over others + 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: + description: Find out more + url: https://typesense.org/docs/0.25.0/api/analytics-query-suggestions.html + - name: keys + description: Manage API Keys with fine-grain access control + externalDocs: + description: Find out more + url: https://typesense.org/docs/0.23.0/api/#api-keys + - name: debug + description: Debugging information + - name: operations + description: Manage Typesense cluster + externalDocs: + description: Find out more + url: https://typesense.org/docs/26.0/api/cluster-operations.html + - name: stopwords + description: Manage stopwords sets + externalDocs: + description: Find out more + url: https://typesense.org/docs/26.0/api/stopwords.html + - name: presets + description: Store and reference search parameters + externalDocs: + description: Find out more + url: https://typesense.org/docs/26.0/api/search.html#presets +paths: + /collections: + get: + tags: + - collections + summary: List all collections + description: + Returns a summary of all your collections. The collections are + returned sorted by creation date, with the most recent collections appearing + first. + operationId: getCollections + responses: + 200: + description: List of all collections + content: + application/json: + schema: + type: array + x-go-type: "[]*CollectionResponse" + items: + $ref: "#/components/schemas/CollectionResponse" + post: + tags: + - collections + summary: Create a new collection + description: + When a collection is created, we give it a name and describe the + fields that will be indexed from the documents added to the collection. + operationId: createCollection + requestBody: + description: The collection object to be created + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionSchema" + required: true + responses: + 201: + description: Collection successfully created + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionResponse" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 409: + description: Collection already exists + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}: + get: + tags: + - collections + summary: Retrieve a single collection + description: Retrieve the details of a collection, given its name. + operationId: getCollection + parameters: + - name: collectionName + in: path + description: The name of the collection to retrieve + required: true + schema: + type: string + responses: + 200: + description: Collection fetched + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionResponse" + 404: + description: Collection not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + patch: + tags: + - collections + summary: Update a collection + description: Update a collection's schema to modify the fields and their types. + operationId: updateCollection + parameters: + - name: collectionName + in: path + description: The name of the collection to update + required: true + schema: + type: string + requestBody: + description: The document object with fields to be updated + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionUpdateSchema" + required: true + responses: + 200: + description: The updated partial collection schema + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionUpdateSchema" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 404: + description: The collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - collections + summary: Delete a collection + description: + Permanently drops a collection. This action cannot be undone. For + large collections, this might have an impact on read latencies. + operationId: deleteCollection + parameters: + - name: collectionName + in: path + description: The name of the collection to delete + required: true + schema: + type: string + responses: + 200: + description: Collection deleted + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionResponse" + 404: + description: Collection not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/documents: + post: + tags: + - documents + summary: Index a document + description: + A document to be indexed in a given collection must conform to + the schema of the collection. + operationId: indexDocument + parameters: + - name: collectionName + in: path + description: The name of the collection to add the document to + required: true + schema: + type: string + - name: action + in: query + description: Additional action to perform + schema: + type: string + example: upsert + enum: + - upsert + requestBody: + description: The document object to be indexed + content: + application/json: + schema: + type: object + description: Can be any key-value pair + x-go-type: "interface{}" + required: true + responses: + 201: + description: Document successfully created/indexed + content: + application/json: + schema: + type: object + description: Can be any key-value pair + 404: + description: Collection not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + patch: + tags: + - documents + summary: Update documents with conditional query + description: + The filter_by query parameter is used to filter to specify a condition against which the documents are matched. + The request body contains the fields that should be updated for any documents that match the filter condition. + This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later. + operationId: updateDocuments + parameters: + - name: collectionName + in: path + description: The name of the collection to update documents in + required: true + schema: + type: string + - name: updateDocumentsParameters + in: query + schema: + type: object + properties: + filter_by: + type: string + example: "num_employees:>100 && country: [USA, UK]" + responses: + "200": + description: The response contains a single field, `num_updated`, indicating the number of documents affected. + content: + application/json: + schema: + type: object + required: + - num_updated + properties: + num_updated: + type: integer + description: The number of documents that have been updated + example: 1 + "400": + description: "Bad request, see error message for details" + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + "404": + description: The collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + requestBody: + description: The document fields to be updated + content: + application/json: + schema: + type: object + description: Can be any key-value pair + x-go-type: "interface{}" + required: true + delete: + tags: + - documents + summary: Delete a bunch of documents + description: + Delete a bunch of documents that match a specific filter condition. + Use the `batch_size` parameter to control the number of documents that + should deleted at a time. A larger value will speed up deletions, but will + impact performance of other operations running on the server. + operationId: deleteDocuments + parameters: + - name: collectionName + in: path + description: The name of the collection to delete documents from + required: true + schema: + type: string + - name: deleteDocumentsParameters + in: query + schema: + type: object + properties: + filter_by: + type: string + example: "num_employees:>100 && country: [USA, UK]" + batch_size: + description: + Batch size parameter controls the number of documents that should be deleted + at a time. A larger value will speed up deletions, but will impact performance + of other operations running on the server. + type: integer + responses: + 200: + description: Documents successfully deleted + content: + application/json: + schema: + type: object + required: + - num_deleted + properties: + num_deleted: + type: integer + 404: + description: Collection not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/documents/search: + get: + tags: + - documents + summary: Search for documents in a collection + description: Search for documents in a collection that match the search criteria. + operationId: searchCollection + parameters: + - name: collectionName + in: path + description: The name of the collection to search for the document under + required: true + schema: + type: string + - name: searchParameters + required: true + in: query + schema: + $ref: "#/components/schemas/SearchParameters" + responses: + 200: + description: Search results + content: + application/json: + schema: + $ref: "#/components/schemas/SearchResult" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 404: + description: The collection or field was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/overrides: + get: + tags: + - documents + - promote + summary: List all collection overrides + operationId: getSearchOverrides + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + responses: + 200: + description: List of all search overrides + content: + application/json: + schema: + $ref: "#/components/schemas/SearchOverridesResponse" + /collections/{collectionName}/overrides/{overrideId}: + get: + tags: + - documents + - override + summary: Retrieve a single search override + description: Retrieve the details of a search override, given its id. + operationId: getSearchOverride + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + - name: overrideId + in: path + description: The id of the search override + required: true + schema: + type: string + responses: + 200: + description: Search override fetched + content: + application/json: + schema: + $ref: "#/components/schemas/SearchOverride" + put: + tags: + - documents + - promote + 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 + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + - name: overrideId + in: path + description: The ID of the search override to create/update + required: true + schema: + type: string + requestBody: + description: The search override object to be created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/SearchOverrideSchema" + required: true + responses: + 200: + description: Created/updated search override + content: + application/json: + schema: + $ref: "#/components/schemas/SearchOverride" + 404: + description: Search override not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - documents + - promote + summary: Delete an override associated with a collection + operationId: deleteSearchOverride + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + - name: overrideId + in: path + description: The ID of the search override to delete + required: true + schema: + type: string + responses: + 200: + description: The ID of the deleted search override + content: + application/json: + schema: + $ref: "#/components/schemas/SearchOverride" + 404: + description: Search override not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/synonyms: + get: + tags: + - documents + 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: + - documents + 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: + - documents + 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: + - documents + 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/SearchSynonym" + 404: + description: Search synonym not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + + /collections/{collectionName}/documents/export: + get: + tags: + - documents + summary: Export all documents in a collection + description: Export all documents in a collection in JSON lines format. + operationId: exportDocuments + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + - name: exportDocumentsParameters + in: query + schema: + type: object + required: + - include_fields + - exclude_fields + properties: + filter_by: + description: + Filter conditions for refining your search results. Separate + multiple conditions with &&. + type: string + include_fields: + description: List of fields from the document to include in the search result + type: string + exclude_fields: + description: List of fields from the document to exclude in the search result + type: string + + responses: + 200: + description: Exports all the documents in a given collection. + content: + application/octet-stream: + schema: + type: string + example: | + {"id": "124", "company_name": "Stark Industries", "num_employees": 5215, "country": "US"} + {"id": "125", "company_name": "Future Technology", "num_employees": 1232,"country": "UK"} + {"id": "126", "company_name": "Random Corp.", "num_employees": 531,"country": "AU"} + 404: + description: The collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/documents/import: + post: + tags: + - documents + summary: Import documents into a collection + description: + 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. + operationId: importDocuments + parameters: + - name: collectionName + in: path + description: The name of the collection + required: true + schema: + type: string + - name: importDocumentsParameters + in: query + schema: + type: object + properties: + action: + type: string + batch_size: + type: integer + dirty_values: + type: string + enum: + - coerce_or_reject + - coerce_or_drop + - drop + - reject + remote_embedding_batch_size: + type: integer + requestBody: + description: The json array of documents or the JSONL file to import + content: + application/octet-stream: + schema: + type: string + description: The JSONL file to import + required: true + responses: + 200: + description: + Result of the import operation. Each line of the response indicates the result + of each document present in the request body (in the same order). If the import + of a single document fails, it does not affect the other documents. + If there is a failure, the response line will include a corresponding error + message and as well as the actual document content. + content: + application/octet-stream: + schema: + type: string + example: | + {"success": true} + {"success": false, "error": "Bad JSON.", "document": "[bad doc"} + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 404: + description: The collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /collections/{collectionName}/documents/{documentId}: + get: + tags: + - documents + summary: Retreive a document + description: Fetch an individual document from a collection by using its ID. + operationId: getDocument + parameters: + - name: collectionName + in: path + description: The name of the collection to search for the document under + required: true + schema: + type: string + - name: documentId + in: path + description: The Document ID + required: true + schema: + type: string + responses: + 200: + description: The document referenced by the ID + content: + application/json: + schema: + type: object + description: Can be any key-value pair + 404: + description: The document or collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + patch: + tags: + - documents + summary: Update a document + description: + Update an individual document from a collection by using its ID. + The update can be partial. + operationId: updateDocument + parameters: + - name: collectionName + in: path + description: The name of the collection to search for the document under + required: true + schema: + type: string + - name: documentId + in: path + description: The Document ID + required: true + schema: + type: string + requestBody: + description: The document object with fields to be updated + content: + application/json: + schema: + type: object + description: Can be any key-value pair + x-go-type: "interface{}" + required: true + responses: + 200: + description: The document referenced by the ID was updated + content: + application/json: + schema: + type: object + description: Can be any key-value pair + 404: + description: The document or collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - documents + summary: Delete a document + description: Delete an individual document from a collection by using its ID. + operationId: deleteDocument + parameters: + - name: collectionName + in: path + description: The name of the collection to search for the document under + required: true + schema: + type: string + - name: documentId + in: path + description: The Document ID + required: true + schema: + type: string + responses: + 200: + description: The document referenced by the ID was deleted + content: + application/json: + schema: + type: object + description: Can be any key-value pair + 404: + description: The document or collection was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /keys: + get: + tags: + - keys + summary: Retrieve (metadata about) all keys. + operationId: getKeys + responses: + 200: + description: List of all keys + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeysResponse" + post: + tags: + - keys + summary: Create an API Key + description: + Create an API Key with fine-grain access control. You can restrict access + on both a per-collection and per-action level. + The generated key is returned only during creation. You want to store + this key carefully in a secure place. + operationId: createKey + requestBody: + description: The object that describes API key scope + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeySchema" + responses: + 201: + description: Created API key + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKey" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 409: + description: API key generation conflict + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /keys/{keyId}: + get: + tags: + - keys + summary: Retrieve (metadata about) a key + description: + Retrieve (metadata about) a key. Only the key prefix is returned + when you retrieve a key. Due to security reasons, only the create endpoint + returns the full API key. + operationId: getKey + parameters: + - name: keyId + in: path + description: The ID of the key to retrieve + required: true + schema: + type: integer + format: int64 + responses: + 200: + description: The key referenced by the ID + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKey" + 404: + description: The key was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - keys + summary: Delete an API key given its ID. + operationId: deleteKey + parameters: + - name: keyId + in: path + description: The ID of the key to delete + required: true + schema: + type: integer + format: int64 + responses: + 200: + description: The key referenced by the ID + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKey" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 404: + description: Key not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /aliases: + get: + tags: + - collections + summary: List all aliases + description: List all aliases and the corresponding collections that they map to. + operationId: getAliases + responses: + 200: + description: List of all collection aliases + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionAliasesResponse" + /aliases/{aliasName}: + put: + tags: + - collections + summary: Create or update a collection alias + description: + Create or update a collection alias. An alias is a virtual collection name that points + to a real collection. If you're familiar with symbolic links on Linux, it's very similar + to that. Aliases are useful when you want to reindex your data in the + background on a new collection and switch your application to it without any changes to + your code. + operationId: upsertAlias + parameters: + - name: aliasName + in: path + description: The name of the alias to create/update + required: true + schema: + type: string + requestBody: + description: Collection alias to be created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionAliasSchema" + responses: + 200: + description: The collection alias was created/updated + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionAlias" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + 404: + description: Alias not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + get: + tags: + - collections + summary: Retrieve an alias + description: Find out which collection an alias points to by fetching it + operationId: getAlias + parameters: + - name: aliasName + in: path + description: The name of the alias to retrieve + required: true + schema: + type: string + responses: + 200: + description: Collection alias fetched + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionAlias" + 404: + description: The alias was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - collections + summary: Delete an alias + operationId: deleteAlias + parameters: + - name: aliasName + in: path + description: The name of the alias to delete + required: true + schema: + type: string + responses: + 200: + description: Collection alias was deleted + content: + application/json: + schema: + $ref: "#/components/schemas/CollectionAlias" + 404: + description: Alias not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /debug: + get: + tags: + - debug + summary: Print debugging information + description: Print debugging information + operationId: debug + responses: + 200: + description: Debugging information + content: + application/json: + schema: + type: object + properties: + version: + type: string + /health: + get: + tags: + - health + summary: Checks if Typesense server is ready to accept requests. + description: Checks if Typesense server is ready to accept requests. + operationId: health + responses: + 200: + description: Search service is ready for requests. + content: + application/json: + schema: + $ref: "#/components/schemas/HealthStatus" + /operations/snapshot: + post: + tags: + - operations + summary: Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. + description: + 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. + operationId: takeSnapshot + parameters: + - name: snapshot_path + in: query + description: The directory on the server where the snapshot should be saved. + required: true + schema: + type: string + responses: + 201: + description: Snapshot is created. + content: + application/json: + schema: + $ref: "#/components/schemas/SuccessStatus" + /operations/vote: + post: + tags: + - operations + summary: Triggers a follower node to initiate the raft voting process, which triggers leader re-election. + description: + 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. + operationId: vote + responses: + 200: + description: Re-election is performed. + content: + application/json: + schema: + $ref: "#/components/schemas/SuccessStatus" + /multi_search: + post: + operationId: multiSearch + tags: + - documents + summary: send multiple search requests in a single HTTP request + description: + This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. + You can also use this feature to do a federated search across multiple collections in a single HTTP request. + parameters: + - name: multiSearchParameters + required: true + in: query + schema: + $ref: "#/components/schemas/MultiSearchParameters" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/MultiSearchSearchesParameter" + responses: + 200: + description: Search results + content: + application/json: + schema: + $ref: "#/components/schemas/MultiSearchResult" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /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. + operationId: createAnalyticsRule + requestBody: + description: The Analytics rule to be created + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + required: true + responses: + 201: + description: Analytics rule successfully created + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + get: + tags: + - analytics + summary: Retrieves all analytics rules + description: Retrieve the details of all analytics rules + operationId: retrieveAnalyticsRules + responses: + 200: + description: Analytics rules fetched + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRulesRetrieveSchema" + /analytics/rules/{ruleName}: + put: + tags: + - analytics + summary: Upserts an analytics rule + description: Upserts an analytics rule with the given name. + operationId: upsertAnalyticsRule + parameters: + - in: path + name: ruleName + description: The name of the analytics rule to upsert + schema: + type: string + required: true + requestBody: + description: The Analytics rule to be upserted + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + required: true + responses: + 201: + description: Analytics rule successfully upserted + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + 400: + description: Bad request, see error message for details + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + get: + tags: + - analytics + summary: Retrieves an analytics rule + description: Retrieve the details of an analytics rule, given it's name + operationId: retrieveAnalyticsRule + parameters: + - in: path + name: ruleName + description: The name of the analytics rule to retrieve + schema: + type: string + required: true + responses: + 200: + description: Analytics rule fetched + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + 404: + description: Analytics rule not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - analytics + summary: Delete an analytics rule + description: Permanently deletes an analytics rule, given it's name + operationId: deleteAnalyticsRule + parameters: + - in: path + name: ruleName + description: The name of the analytics rule to delete + schema: + type: string + required: true + responses: + 200: + description: Analytics rule deleted + content: + application/json: + schema: + $ref: "#/components/schemas/AnalyticsRuleSchema" + 404: + description: Analytics rule not found + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /metrics.json: + get: + tags: + - operations + summary: Get current RAM, CPU, Disk & Network usage metrics. + description: Retrieve the metrics. + operationId: retrieveMetrics + responses: + 200: + description: Metrics fetched. + content: + application/json: + schema: + type: object + /stats.json: + get: + tags: + - operations + summary: Get stats about API endpoints. + description: Retrieve the stats about API endpoints. + operationId: retrieveAPIStats + responses: + 200: + description: Stats fetched. + content: + application/json: + schema: + $ref: "#/components/schemas/APIStatsResponse" + /stopwords: + get: + tags: + - stopwords + summary: Retrieves all stopwords sets. + description: Retrieve the details of all stopwords sets + operationId: retrieveStopwordsSets + responses: + 200: + description: Stopwords sets fetched. + content: + application/json: + schema: + $ref: "#/components/schemas/StopwordsSetsRetrieveAllSchema" + /stopwords/{setId}: + put: + tags: + - stopwords + summary: Upserts a stopwords set. + description: When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. + operationId: upsertStopwordsSet + parameters: + - in: path + name: setId + description: The ID of the stopwords set to upsert. + schema: + type: string + required: true + example: countries + requestBody: + description: The stopwords set to upsert. + content: + application/json: + schema: + $ref: "#/components/schemas/StopwordsSetUpsertSchema" + required: true + responses: + 200: + description: Stopwords set successfully upserted. + content: + application/json: + schema: + $ref: "#/components/schemas/StopwordsSetSchema" + 400: + description: Bad request, see error message for details. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + get: + tags: + - stopwords + summary: Retrieves a stopwords set. + description: Retrieve the details of a stopwords set, given it's name. + operationId: retrieveStopwordsSet + parameters: + - in: path + name: setId + description: The ID of the stopwords set to retrieve. + schema: + type: string + required: true + example: countries + responses: + 200: + description: Stopwords set fetched. + content: + application/json: + schema: + $ref: "#/components/schemas/StopwordsSetRetrieveSchema" + 404: + description: Stopwords set not found. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - stopwords + summary: Delete a stopwords set. + description: Permanently deletes a stopwords set, given it's name. + operationId: deleteStopwordsSet + parameters: + - in: path + name: setId + description: The ID of the stopwords set to delete. + schema: + type: string + required: true + example: countries + responses: + 200: + description: Stopwords set rule deleted. + content: + application/json: + schema: + type: object + properties: + id: + type: string + required: + - id + example: | + {"id": "countries"} + 404: + description: Stopwords set not found. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + /presets: + get: + tags: + - presets + summary: Retrieves all presets. + description: Retrieve the details of all presets + operationId: retrieveAllPresets + responses: + 200: + description: Presets fetched. + content: + application/json: + schema: + $ref: "#/components/schemas/PresetsRetrieveSchema" + /presets/{presetId}: + get: + tags: + - presets + summary: Retrieves a preset. + description: Retrieve the details of a preset, given it's name. + operationId: retrievePreset + parameters: + - in: path + name: presetId + description: The ID of the preset to retrieve. + schema: + type: string + required: true + example: listing_view + responses: + 200: + description: Preset fetched. + content: + application/json: + schema: + $ref: "#/components/schemas/PresetSchema" + 404: + description: Preset not found. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + put: + tags: + - presets + summary: Upserts a preset. + description: Create or update an existing preset. + operationId: upsertPreset + parameters: + - in: path + name: presetId + description: The name of the preset set to upsert. + schema: + type: string + required: true + example: listing_view + requestBody: + description: The stopwords set to upsert. + content: + application/json: + schema: + $ref: "#/components/schemas/PresetUpsertSchema" + required: true + responses: + 200: + description: Preset successfully upserted. + content: + application/json: + schema: + $ref: "#/components/schemas/PresetSchema" + 400: + description: Bad request, see error message for details. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" + delete: + tags: + - presets + summary: Delete a preset. + description: Permanently deletes a preset, given it's name. + operationId: deletePreset + parameters: + - in: path + name: presetId + description: The ID of the preset to delete. + schema: + type: string + required: true + example: listing_view + responses: + 200: + description: Preset deleted. + content: + application/json: + schema: + $ref: "#/components/schemas/PresetDeleteSchema" + 404: + description: Preset not found. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponse" +components: + schemas: + CollectionSchema: + required: + - name + - fields + type: object + properties: + name: + type: string + description: Name of the collection + example: companies + fields: + type: array + description: A list of fields for querying, filtering and faceting + example: + - name: num_employees + type: int32 + facet: false + - name: company_name + type: string + facet: false + - name: country + type: string + facet: true + items: + $ref: "#/components/schemas/Field" + default_sorting_field: + type: string + description: + The name of an int32 / float field that determines the order in which + the search results are ranked when a sort_by clause is not provided during + searching. This field must indicate some kind of popularity. + example: num_employees # Go with the first field name listed above to produce sane defaults + default: "" + token_separators: + type: array + description: > + List of symbols or special characters to be used for + splitting the text into individual words in addition to space and new-line characters. + items: + type: string # characters only + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: + # enum: ["@", "!", ".", "/", ","] + minLength: 1 + maxLength: 1 + default: [] + enable_nested_fields: + type: boolean + description: + Enables experimental support at a collection level for nested object or object array fields. + This field is only available if the Typesense server is version `0.24.0.rcn34` or later. + default: false + example: true + symbols_to_index: + type: array + description: > + List of symbols or special characters to be indexed. + items: + type: string # characters only + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: + # enum: ["@", "!", ".", "/", ","] + minLength: 1 + maxLength: 1 + default: [] + CollectionUpdateSchema: + required: + - fields + type: object + properties: + fields: + type: array + description: A list of fields for querying, filtering and faceting + example: + - name: company_name + type: string + facet: false + - name: num_employees + type: int32 + facet: false + - name: country + type: string + facet: true + items: + $ref: "#/components/schemas/Field" + CollectionResponse: + allOf: + - $ref: "#/components/schemas/CollectionSchema" + - type: object + required: + - num_documents + - created_at + properties: + num_documents: + type: integer + description: Number of documents in the collection + format: int64 + readOnly: true + created_at: + type: integer + description: Timestamp of when the collection was created (Unix epoch in seconds) + format: int64 + readOnly: true + Field: + required: + - name + - type + type: object + properties: + name: + type: string + example: company_name + type: + type: string + example: string + optional: + type: boolean + example: true + facet: + type: boolean + example: false + index: + type: boolean + example: true + default: true + locale: + type: string + example: el + sort: + type: boolean + example: true + infix: + type: boolean + example: true + default: false + reference: + type: string + example: string + num_dim: + type: integer + example: 256 + drop: + type: boolean + example: true + # omitting default value since we want it to be null + embed: + type: object + required: + - from + - model_config + properties: + from: + type: array + items: + type: string + model_config: + type: object + required: + - model_name + properties: + model_name: + type: string + api_key: + type: string + access_token: + type: string + client_id: + type: string + client_secret: + type: string + project_id: + type: string + CollectionAliasSchema: + type: object + required: + - collection_name + properties: + collection_name: + type: string + description: Name of the collection you wish to map the alias to + CollectionAlias: + type: object + required: + - collection_name + - name + properties: + name: + type: string + readOnly: true + description: Name of the collection alias + collection_name: + type: string + description: Name of the collection the alias mapped to + CollectionAliasesResponse: + type: object + required: + - aliases + properties: + aliases: + type: array + x-go-type: "[]*CollectionAlias" + items: + $ref: "#/components/schemas/CollectionAlias" + SearchResult: + type: object + properties: + facet_counts: + type: array + items: + $ref: "#/components/schemas/FacetCounts" + found: + type: integer + description: The number of documents found + search_time_ms: + type: integer + description: The number of milliseconds the search took + out_of: + type: integer + description: The total number of documents in the collection + search_cutoff: + type: boolean + description: Whether the search was cut off + page: + type: integer + description: The search result page number + grouped_hits: + type: array + items: + $ref: "#/components/schemas/SearchGroupedHit" + hits: + type: array + description: The documents that matched the search query + items: + $ref: "#/components/schemas/SearchResultHit" + request_params: + type: object + required: + - collection_name + - q + - per_page + properties: + collection_name: + type: string + q: + type: string + per_page: + type: integer + + SearchGroupedHit: + type: object + required: + - group_key + - hits + properties: + found: + type: integer + group_key: + type: array + items: {} + hits: + type: array + description: The documents that matched the search query + items: + $ref: "#/components/schemas/SearchResultHit" + SearchResultHit: + type: object + properties: + highlights: + type: array + description: (Deprecated) Contains highlighted portions of the search fields + items: + $ref: "#/components/schemas/SearchHighlight" + highlight: + type: object + description: Highlighted version of the matching document + additionalProperties: true + document: + type: object + description: Can be any key-value pair + additionalProperties: + type: object + text_match: + type: integer + format: int64 + geo_distance_meters: + type: object + description: Can be any key-value pair + additionalProperties: + type: integer + vector_distance: + type: number + format: float + description: Distance between the query vector and matching document's vector value + example: + highlights: + company_name: + field: company_name + snippet: Stark Industries + document: + id: "124" + company_name: Stark Industries + num_employees: 5215 + country: USA + text_match: 1234556 + SearchHighlight: + type: object + properties: + field: + type: string + example: company_name + snippet: + type: string + description: Present only for (non-array) string fields + example: Stark Industries + snippets: + type: array + description: Present only for (array) string[] fields + example: + - Stark Industries + - Stark Corp + items: + type: string + value: + type: string + description: Full field value with highlighting, present only for (non-array) string fields + example: Stark Industries is a major supplier of space equipment. + values: + type: array + description: Full field value with highlighting, present only for (array) string[] fields + example: + - Stark Industries + - Stark Corp + items: + type: string + indices: + type: array + description: The indices property will be present only for string[] + fields and will contain the corresponding indices of the snippets + in the search field + example: 1 + items: + type: integer + matched_tokens: + type: array + 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. + SearchOverride: + allOf: + - $ref: "#/components/schemas/SearchOverrideSchema" + - type: object + required: + - id + properties: + id: + type: string + readOnly: true + SearchOverrideRule: + type: object + required: + - query + - match + properties: + 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 + tags: + type: array + description: List of tags. + items: + type: string + 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: + - synonyms + properties: + root: + type: string + description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. + synonyms: + type: array + description: Array of words that should be considered as synonyms. + items: + type: string + SearchSynonym: + allOf: + - $ref: "#/components/schemas/SearchSynonymSchema" + - type: object + required: + - id + properties: + id: + type: string + readOnly: true + SearchSynonymsResponse: + type: object + required: + - synonyms + properties: + synonyms: + type: array + x-go-type: "[]*SearchSynonym" + items: + $ref: "#/components/schemas/SearchSynonym" + HealthStatus: + type: object + required: + - ok + properties: + ok: + type: boolean + SuccessStatus: + type: object + required: + - success + properties: + success: + type: boolean + ApiResponse: + type: object + required: + - message + properties: + message: + type: string + ApiKeySchema: + type: object + required: + - actions + - collections + - description + properties: + value: + type: string + description: + type: string + actions: + type: array + items: + type: string + collections: + type: array + items: + type: string + expires_at: + type: integer + format: int64 + ApiKey: + allOf: + - $ref: "#/components/schemas/ApiKeySchema" + - type: object + properties: + id: + type: integer + format: int64 + readOnly: true + value_prefix: + type: string + readOnly: true + ApiKeysResponse: + type: object + required: + - keys + properties: + keys: + type: array + x-go-type: "[]*ApiKey" + items: + $ref: "#/components/schemas/ApiKey" + ScopedKeyParameters: + type: object + properties: + filter_by: + type: string + expires_at: + type: integer + format: int64 + SnapshotParameters: + type: object + properties: + snapshot_path: + type: string + ErrorResponse: + type: object + properties: + message: + type: string + MultiSearchResult: + type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/SearchResult" + SearchParameters: + type: object + required: + - q + - query_by + + properties: + q: + description: The query text to search for in the collection. + Use * as the search string to return all documents. + This is typically useful when used in conjunction with filter_by. + type: string + + query_by: + description: A list of `string` fields that should be queried + against. Multiple fields are separated with a comma. + type: string + + query_by_weights: + description: + The relative weight to give each `query_by` field when ranking results. + This can be used to boost fields in priority, when looking for matches. + Multiple fields are separated with a comma. + type: string + + text_match_type: + description: + In a multi-field matching context, this parameter determines how the representative text match + score of a record is calculated. Possible values are max_score (default) or max_weight. + type: string + + prefix: + description: + Boolean field to indicate that the last word in the query should + be treated as a prefix, and not as a whole word. This is used for building + autocomplete and instant search interfaces. Defaults to true. + type: string + + infix: + description: + If infix index is enabled for this field, infix searching can be done on a per-field + basis by sending a comma separated string parameter called infix to the search query. + This parameter can have 3 values; `off` infix search is disabled, which is default + `always` infix search is performed along with regular search + `fallback` infix search is performed if regular search does not produce results + type: string + + max_extra_prefix: + description: + There are also 2 parameters that allow you to control the extent of infix searching + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before + or after the query that can be present in the token. For example query "K2100" has 2 extra + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + type: integer + + max_extra_suffix: + description: + There are also 2 parameters that allow you to control the extent of infix searching + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before + or after the query that can be present in the token. For example query "K2100" has 2 extra + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + type: integer + + filter_by: + description: + Filter conditions for refining youropen api validator search results. Separate + multiple conditions with &&. + type: string + example: "num_employees:>100 && country: [USA, UK]" + + sort_by: + description: + A list of numerical fields and their corresponding sort orders + that will be used for ordering your results. + Up to 3 sort fields can be specified. + The text similarity score is exposed as a special `_text_match` field that + you can use in the list of sorting fields. + If no `sort_by` parameter is specified, results are sorted by + `_text_match:desc,default_sorting_field:desc` + type: string + example: num_employees:desc + + facet_by: + description: + A list of fields that will be used for faceting your results + on. Separate multiple fields with a comma. + type: string + + max_facet_values: + description: Maximum number of facet values to be returned. + type: integer + + facet_query: + description: + Facet values that are returned can now be filtered via this parameter. + The matching facet text is also highlighted. For example, when faceting + by `category`, you can set `facet_query=category:shoe` to return only + facet values that contain the prefix "shoe". + type: string + + num_typos: + description: > + The number of typographical errors (1 or 2) that would be tolerated. + Default: 2 + type: string + + page: + description: Results from this specific page number would be fetched. + type: integer + + per_page: + description: "Number of results to fetch per page. Default: 10" + type: integer + + limit: + description: > + Number of hits to fetch. Can be used as an alternative to the per_page parameter. + Default: 10. + type: integer + + offset: + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. + type: integer + + group_by: + description: + You can aggregate search results into groups or buckets by specify + one or more `group_by` fields. Separate multiple fields with a comma. + To group on a particular field, it must be a faceted field. + type: string + + group_limit: + description: > + Maximum number of hits to be returned for every group. If the `group_limit` is + set as `K` then only the top K hits in each group are returned in the response. + Default: 3 + type: integer + + include_fields: + description: List of fields from the document to include in the search result + type: string + + exclude_fields: + description: List of fields from the document to exclude in the search result + type: string + + highlight_full_fields: + description: List of fields which should be highlighted fully without snippeting + type: string + + highlight_affix_num_tokens: + description: > + The number of tokens that should surround the highlighted text on each side. + Default: 4 + type: integer + + highlight_start_tag: + description: > + The start tag used for the highlighted snippets. + Default: `` + type: string + highlight_end_tag: + description: > + The end tag used for the highlighted snippets. + Default: `` + type: string + + enable_highlight_v1: + description: > + Flag for enabling/disabling the deprecated, old highlight structure in the response. + Default: true + type: boolean + default: true + + snippet_threshold: + description: > + Field values under this length will be fully highlighted, instead of showing + a snippet of relevant portion. Default: 30 + type: integer + + drop_tokens_threshold: + description: > + If the number of results found for a specific query is less than + this number, Typesense will attempt to drop the tokens in the query until + enough results are found. Tokens that have the least individual hits + are dropped first. Set to 0 to disable. Default: 10 + type: integer + typo_tokens_threshold: + description: > + If the number of results found for a specific query is less than this number, + Typesense will attempt to look for tokens with more typos until + enough results are found. Default: 100 + type: integer + + pinned_hits: + description: > + A list of records to unconditionally include in the search results + at specific positions. An example use case would be to feature or promote + certain items on the top of search results. + A list of `record_id:hit_position`. Eg: to include a record with ID 123 + at Position 1 and another record with ID 456 at Position 5, + you'd specify `123:1,456:5`. + + You could also use the Overrides feature to override search results based + on rules. Overrides are applied first, followed by `pinned_hits` and + finally `hidden_hits`. + type: string + + hidden_hits: + description: > + A list of records to unconditionally hide from search results. + A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, + you'd specify `123,456`. + + You could also use the Overrides feature to override search results based + on rules. Overrides are applied first, followed by `pinned_hits` and + finally `hidden_hits`. + type: string + + override_tags: + description: Comma separated list of tags to trigger the curations rules that match the tags. + type: string + + highlight_fields: + description: > + A list of custom fields that must be highlighted even if you don't query + for them + type: string + + split_join_tokens: + description: > + Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa. + Splitting/joining of tokens will only be attempted if the original query produces no results. + To always trigger this behavior, set value to `always``. + To disable, set value to `off`. Default is `fallback`. + type: string + + pre_segmented_query: + description: > + You can index content from any logographic language into Typesense if you + are able to segment / split the text into space-separated words yourself + before indexing and querying. + + Set this parameter to true to do the same + type: boolean + + preset: + description: > + Search using a bunch of search parameters by setting this parameter to + the name of the existing Preset. + type: string + + enable_overrides: + description: > + If you have some overrides defined but want to disable all of them during + query time, you can do that by setting this parameter to false + type: boolean + default: false + + prioritize_exact_match: + description: > + Set this parameter to true to ensure that an exact match is ranked above + the others + type: boolean + default: true + max_candidates: + description: > + Control the number of words that Typesense considers for typo and prefix searching. + type: integer + prioritize_token_position: + description: > + Make Typesense prioritize documents where the query words appear earlier in the text. + type: boolean + default: false + prioritize_num_matching_fields: + description: > + Make Typesense prioritize documents where the query words appear in more number of fields. + type: boolean + default: true + enable_typos_for_numerical_tokens: + description: > + Make Typesense disable typos for numerical tokens. + type: boolean + default: true + exhaustive_search: + description: > + Setting this to true will make Typesense consider all prefixes and typo + corrections of the words in the query without stopping early when enough results are found + (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). + type: boolean + search_cutoff_ms: + description: > + Typesense will attempt to return results early if the cutoff time has elapsed. + This is not a strict guarantee and facet computation is not bound by this parameter. + type: integer + use_cache: + description: > + Enable server side caching of search query results. By default, caching is disabled. + type: boolean + cache_ttl: + description: > + The duration (in seconds) that determines how long the search query is cached. + This value can be set on a per-query basis. Default: 60. + type: integer + min_len_1typo: + description: > + Minimum word length for 1-typo correction to be applied. + The value of num_typos is still treated as the maximum allowed typos. + type: integer + min_len_2typo: + description: > + Minimum word length for 2-typo correction to be applied. + The value of num_typos is still treated as the maximum allowed typos. + type: integer + vector_query: + description: > + Vector query expression for fetching documents "closest" to a given query/document vector. + type: string + remote_embedding_timeout_ms: + description: > + Timeout (in milliseconds) for fetching remote embeddings. + type: integer + remote_embedding_num_tries: + description: > + Number of times to retry fetching remote embeddings. + type: integer + facet_strategy: + description: > + Choose the underlying faceting strategy used. Comma separated string of allows values: + exhaustive, top_values or automatic (default). + type: string + stopwords: + description: > + Name of the stopwords set to apply for this search, + the keywords present in the set will be removed from the search query. + type: string + facet_return_parent: + description: > + Comma separated string of nested facet fields whose parent object should be returned in facet response. + type: string + + MultiSearchParameters: + description: > + Parameters for the multi search API. + type: object + properties: + q: + description: The query text to search for in the collection. + Use * as the search string to return all documents. + This is typically useful when used in conjunction with filter_by. + type: string + + query_by: + description: A list of `string` fields that should be queried + against. Multiple fields are separated with a comma. + type: string + + query_by_weights: + description: + The relative weight to give each `query_by` field when ranking results. + This can be used to boost fields in priority, when looking for matches. + Multiple fields are separated with a comma. + type: string + + text_match_type: + description: + In a multi-field matching context, this parameter determines how the representative text match + score of a record is calculated. Possible values are max_score (default) or max_weight. + type: string + + prefix: + description: + Boolean field to indicate that the last word in the query should + be treated as a prefix, and not as a whole word. This is used for building + autocomplete and instant search interfaces. Defaults to true. + type: string + + infix: + description: + If infix index is enabled for this field, infix searching can be done on a per-field + basis by sending a comma separated string parameter called infix to the search query. + This parameter can have 3 values; `off` infix search is disabled, which is default + `always` infix search is performed along with regular search + `fallback` infix search is performed if regular search does not produce results + type: string + + max_extra_prefix: + description: + There are also 2 parameters that allow you to control the extent of infix searching + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before + or after the query that can be present in the token. For example query "K2100" has 2 extra + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + type: integer + + max_extra_suffix: + description: + There are also 2 parameters that allow you to control the extent of infix searching + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before + or after the query that can be present in the token. For example query "K2100" has 2 extra + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. + type: integer + + filter_by: + description: + Filter conditions for refining youropen api validator search results. Separate + multiple conditions with &&. + type: string + example: "num_employees:>100 && country: [USA, UK]" + + sort_by: + description: + A list of numerical fields and their corresponding sort orders + that will be used for ordering your results. + Up to 3 sort fields can be specified. + The text similarity score is exposed as a special `_text_match` field that + you can use in the list of sorting fields. + If no `sort_by` parameter is specified, results are sorted by + `_text_match:desc,default_sorting_field:desc` + type: string + + facet_by: + description: + A list of fields that will be used for faceting your results + on. Separate multiple fields with a comma. + type: string + + max_facet_values: + description: Maximum number of facet values to be returned. + type: integer + + facet_query: + description: + Facet values that are returned can now be filtered via this parameter. + The matching facet text is also highlighted. For example, when faceting + by `category`, you can set `facet_query=category:shoe` to return only + facet values that contain the prefix "shoe". + type: string + + num_typos: + description: > + The number of typographical errors (1 or 2) that would be tolerated. + Default: 2 + type: string + + page: + description: Results from this specific page number would be fetched. + type: integer + + per_page: + description: "Number of results to fetch per page. Default: 10" + type: integer + + limit: + description: > + Number of hits to fetch. Can be used as an alternative to the per_page parameter. + Default: 10. + type: integer + + offset: + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. + type: integer + + group_by: + description: + You can aggregate search results into groups or buckets by specify + one or more `group_by` fields. Separate multiple fields with a comma. + To group on a particular field, it must be a faceted field. + type: string + + group_limit: + description: > + Maximum number of hits to be returned for every group. If the `group_limit` is + set as `K` then only the top K hits in each group are returned in the response. + Default: 3 + type: integer + + include_fields: + description: List of fields from the document to include in the search result + type: string + + exclude_fields: + description: List of fields from the document to exclude in the search result + type: string + + highlight_full_fields: + description: List of fields which should be highlighted fully without snippeting + type: string + + highlight_affix_num_tokens: + description: > + The number of tokens that should surround the highlighted text on each side. + Default: 4 + type: integer + + highlight_start_tag: + description: > + The start tag used for the highlighted snippets. + Default: `` + type: string + highlight_end_tag: + description: > + The end tag used for the highlighted snippets. + Default: `` + type: string + + snippet_threshold: + description: > + Field values under this length will be fully highlighted, instead of showing + a snippet of relevant portion. Default: 30 + type: integer + + drop_tokens_threshold: + description: > + If the number of results found for a specific query is less than + this number, Typesense will attempt to drop the tokens in the query until + enough results are found. Tokens that have the least individual hits + are dropped first. Set to 0 to disable. Default: 10 + type: integer + typo_tokens_threshold: + description: > + If the number of results found for a specific query is less than this number, + Typesense will attempt to look for tokens with more typos until + enough results are found. Default: 100 + type: integer + + pinned_hits: + description: > + A list of records to unconditionally include in the search results + at specific positions. An example use case would be to feature or promote + certain items on the top of search results. + A list of `record_id:hit_position`. Eg: to include a record with ID 123 + at Position 1 and another record with ID 456 at Position 5, + you'd specify `123:1,456:5`. + + You could also use the Overrides feature to override search results based + on rules. Overrides are applied first, followed by `pinned_hits` and + finally `hidden_hits`. + type: string + + hidden_hits: + description: > + A list of records to unconditionally hide from search results. + A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, + you'd specify `123,456`. + + You could also use the Overrides feature to override search results based + on rules. Overrides are applied first, followed by `pinned_hits` and + finally `hidden_hits`. + type: string + + override_tags: + description: Comma separated list of tags to trigger the curations rules that match the tags. + type: string + + highlight_fields: + description: > + A list of custom fields that must be highlighted even if you don't query + for them + type: string + + pre_segmented_query: + description: > + You can index content from any logographic language into Typesense if you + are able to segment / split the text into space-separated words yourself + before indexing and querying. + + Set this parameter to true to do the same + type: boolean + default: false + + preset: + description: > + Search using a bunch of search parameters by setting this parameter to + the name of the existing Preset. + type: string + + enable_overrides: + description: > + If you have some overrides defined but want to disable all of them during + query time, you can do that by setting this parameter to false + type: boolean + default: false + + prioritize_exact_match: + description: > + Set this parameter to true to ensure that an exact match is ranked above + the others + type: boolean + default: true + + prioritize_token_position: + description: > + Make Typesense prioritize documents where the query words appear earlier in the text. + type: boolean + default: false + + prioritize_num_matching_fields: + description: > + Make Typesense prioritize documents where the query words appear in more number of fields. + type: boolean + default: true + + enable_typos_for_numerical_tokens: + description: > + Make Typesense disable typos for numerical tokens. + type: boolean + default: true + + exhaustive_search: + description: > + Setting this to true will make Typesense consider all prefixes and typo + corrections of the words in the query without stopping early when enough results are found + (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). + type: boolean + search_cutoff_ms: + description: > + Typesense will attempt to return results early if the cutoff time has elapsed. + This is not a strict guarantee and facet computation is not bound by this parameter. + type: integer + use_cache: + description: > + Enable server side caching of search query results. By default, caching is disabled. + type: boolean + cache_ttl: + description: > + The duration (in seconds) that determines how long the search query is cached. + This value can be set on a per-query basis. Default: 60. + type: integer + min_len_1typo: + description: > + Minimum word length for 1-typo correction to be applied. + The value of num_typos is still treated as the maximum allowed typos. + type: integer + min_len_2typo: + description: > + Minimum word length for 2-typo correction to be applied. + The value of num_typos is still treated as the maximum allowed typos. + type: integer + vector_query: + description: > + Vector query expression for fetching documents "closest" to a given query/document vector. + type: string + remote_embedding_timeout_ms: + description: > + Timeout (in milliseconds) for fetching remote embeddings. + type: integer + remote_embedding_num_tries: + description: > + Number of times to retry fetching remote embeddings. + type: integer + facet_strategy: + description: > + Choose the underlying faceting strategy used. Comma separated string of allows values: + exhaustive, top_values or automatic (default). + type: string + stopwords: + description: > + Name of the stopwords set to apply for this search, + the keywords present in the set will be removed from the search query. + type: string + facet_return_parent: + description: > + Comma separated string of nested facet fields whose parent object should be returned in facet response. + type: string + MultiSearchSearchesParameter: + type: object + required: + - searches + properties: + searches: + type: array + items: + $ref: "#/components/schemas/MultiSearchCollectionParameters" + MultiSearchCollectionParameters: + allOf: + - $ref: "#/components/schemas/MultiSearchParameters" + - type: object + required: + - collection + properties: + collection: + type: string + description: > + The collection to search in. + FacetCounts: + type: object + properties: + counts: + type: array + items: + type: object + properties: + count: + type: integer + highlighted: + type: string + value: + type: string + parent: + type: object + field_name: + type: string + stats: + type: object + properties: + max: + type: number + format: double + min: + type: number + format: double + sum: + type: number + format: double + total_values: + type: integer + avg: + type: number + format: double + AnalyticsRuleSchema: + type: object + required: + - name + - type + - params + properties: + name: + type: string + type: + type: string + params: + $ref: "#/components/schemas/AnalyticsRuleParameters" + AnalyticsRuleParameters: + type: object + required: + - source + - destination + - limit + properties: + source: + type: object + properties: + collections: + type: array + items: + type: string + destination: + type: object + properties: + collection: + type: string + limit: + type: integer + AnalyticsRulesRetrieveSchema: + type: object + properties: + rules: + type: array + items: + $ref: "#/components/schemas/AnalyticsRuleSchema" + APIStatsResponse: + type: object + properties: + delete_latency_ms: + type: number + format: double + delete_requests_per_second: + type: number + format: double + import_latency_ms: + type: number + format: double + import_requests_per_second: + type: number + format: double + latency_ms: + type: object + x-go-type: "map[string]float64" + overloaded_requests_per_second: + type: number + format: double + pending_write_batches: + type: number + format: double + requests_per_second: + type: object + x-go-type: "map[string]float64" + search_latency_ms: + type: number + format: double + search_requests_per_second: + type: number + format: double + total_requests_per_second: + type: number + format: double + write_latency_ms: + type: number + format: double + write_requests_per_second: + type: number + format: double + StopwordsSetUpsertSchema: + type: object + properties: + stopwords: + type: array + items: + type: string + locale: + type: string + required: + - stopwords + example: | + {"stopwords": ["Germany", "France", "Italy"], "locale": "en"} + StopwordsSetSchema: + type: object + properties: + id: + type: string + stopwords: + type: array + items: + type: string + locale: + type: string + required: + - id + - stopwords + example: | + {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"} + StopwordsSetRetrieveSchema: + type: object + properties: + stopwords: + $ref: "#/components/schemas/StopwordsSetSchema" + required: + - stopwords + example: | + {"stopwords": {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}} + StopwordsSetsRetrieveAllSchema: + type: object + properties: + stopwords: + type: array + items: + $ref: "#/components/schemas/StopwordsSetSchema" + required: + - stopwords + example: | + {"stopwords": [{"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}]} + PresetUpsertSchema: + properties: + value: + oneOf: + - $ref: "#/components/schemas/SearchParameters" + - $ref: "#/components/schemas/MultiSearchSearchesParameter" + required: + - value + PresetSchema: + allOf: + - $ref: "#/components/schemas/PresetUpsertSchema" + - type: object + required: + - name + properties: + name: + type: string + PresetsRetrieveSchema: + type: object + required: + - presets + properties: + presets: + type: array + items: + $ref: "#/components/schemas/PresetSchema" + x-go-type: "[]*PresetSchema" + PresetDeleteSchema: + type: object + required: + - name + properties: + name: + type: string + securitySchemes: + api_key_header: + type: apiKey + name: X-TYPESENSE-API-KEY + in: header From db4923ce696219aff9f2e91d9b84113581a66666 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Mon, 12 Aug 2024 10:33:37 +0800 Subject: [PATCH 2/7] fix merge conflict --- mix.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/mix.lock b/mix.lock index 5a6b963..9fe6ef8 100644 --- a/mix.lock +++ b/mix.lock @@ -20,10 +20,7 @@ "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, -<<<<<<< Updated upstream -======= "oapi_generator": {:hex, :oapi_generator, "0.2.0", "b2e84892329e24f5b98ab27bfdd66069e015b90061c4d540a0c5a5e0ae260631", [:mix], [{:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "1171ba8610d947e1b13581eba1807fbd5fccc4f12402cd04e71df8efa51ef62b"}, ->>>>>>> Stashed changes "req": {:hex, :req, "0.5.6", "8fe1eead4a085510fe3d51ad854ca8f20a622aae46e97b302f499dfb84f726ac", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cfaa8e720945d46654853de39d368f40362c2641c4b2153c886418914b372185"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"}, From a3db2e3e9f8d03ce3568c72f596f9101fe5a871d Mon Sep 17 00:00:00 2001 From: jaeyson Date: Mon, 12 Aug 2024 10:36:19 +0800 Subject: [PATCH 3/7] update openapi.yml --- openapi/openapi.yml | 48 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/openapi/openapi.yml b/openapi/openapi.yml index 61d074a..8b3d770 100644 --- a/openapi/openapi.yml +++ b/openapi/openapi.yml @@ -1944,6 +1944,37 @@ components: 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" @@ -1956,10 +1987,12 @@ components: readOnly: true SearchOverrideRule: type: object - required: - - query - - match 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 @@ -1972,11 +2005,10 @@ components: enum: - exact - contains - tags: - type: array - description: List of tags. - items: - type: string + 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: From 01efa3a7bcb85fa0cc16bc6a328139ccacda6009 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Thu, 15 Aug 2024 13:32:28 +0800 Subject: [PATCH 4/7] fix merge conflict --- docker-compose.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a1d8c4f..3681d21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,7 @@ services: - 8108:8108 # typesense server volumes: - ./typesense-data:/data -<<<<<<< Updated upstream - command: '--data-dir /data --api-key=xyz --enable-cors' + command: "--data-dir /data --api-key=xyz --enable-cors" typesense_dashboard: image: ghcr.io/bfritscher/typesense-dashboard:latest container_name: typesense_dashboard @@ -20,6 +19,3 @@ services: - ./config/config.json:/srv/config.json depends_on: - typesense -======= - command: "--data-dir /data --api-key=xyz --enable-cors" ->>>>>>> Stashed changes From 0f88f506e73713e374ee37abcba48a7ce7ba9d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaeyson=20Anthony=20Y=2E=20=E2=9A=97=EF=B8=8F?= Date: Tue, 20 Aug 2024 16:18:08 +0800 Subject: [PATCH 5/7] Update config/config.exs Co-authored-by: Kian-Meng Ang --- config/config.exs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/config/config.exs b/config/config.exs index 3ab6b7b..920be49 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,11 +7,15 @@ if Mix.env() in [:dev, :test] do port: 8108, scheme: "http" - config :oapi_generator, - default: [ - output: [ - base_module: ExTypesense, - location: "openapi/generator/ExTypesense" - ] +import Config + +config :oapi_generator, + default: [ + output: [ + base_module: OpenApiTypesense, + location: "lib/open_api_typesense" + operation_subdirectory: "operations/", + schema_subdirectory: "schemas/" ] + ] end From cd8f3fe0a76d8479060676994befd75c15056046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaeyson=20Anthony=20Y=2E=20=E2=9A=97=EF=B8=8F?= Date: Tue, 20 Aug 2024 16:18:48 +0800 Subject: [PATCH 6/7] Update README.md Co-authored-by: Kian-Meng Ang --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2c10f9..ec68fc3 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ Check [Cheatsheet](https://hexdocs.pm/ex_typesense/cheatsheet.html) for more usa mix api.gen # another profile -mix api.gen default path/to/rest-api-description/spec.yaml +mix api.gen default priv/openapi.yml ``` ## License From 165cfe18847607e5940c51f251dac9039f9eeaeb Mon Sep 17 00:00:00 2001 From: jaeyson Date: Tue, 20 Aug 2024 18:01:53 +0800 Subject: [PATCH 7/7] add generated code from openapi --- .gitignore | 3 - README.md | 4 - config/config.exs | 2 +- .../open_api_typesense}/openapi.yml | 0 .../operations/analytics.ex | 127 +++++ .../operations/collections.ex | 217 ++++++++ lib/open_api_typesense/operations/debug.ex | 34 ++ .../operations/documents.ex | 484 ++++++++++++++++++ lib/open_api_typesense/operations/health.ex | 26 + lib/open_api_typesense/operations/keys.ex | 92 ++++ .../operations/operations.ex | 90 ++++ lib/open_api_typesense/operations/override.ex | 27 + lib/open_api_typesense/operations/presets.ex | 99 ++++ lib/open_api_typesense/operations/promote.ex | 76 +++ .../operations/stopwords.ex | 108 ++++ .../schemas/analytics_rule_parameters.ex | 25 + .../analytics_rule_parameters_destination.ex | 17 + .../analytics_rule_parameters_source.ex | 17 + .../schemas/analytics_rule_schema.ex | 25 + .../analytics_rules_retrieve_schema.ex | 17 + lib/open_api_typesense/schemas/api_key.ex | 33 ++ .../schemas/api_key_schema.ex | 29 ++ .../schemas/api_keys_response.ex | 17 + .../schemas/api_response.ex | 17 + .../schemas/api_stats_response.ex | 59 +++ .../schemas/collection_alias.ex | 17 + .../schemas/collection_alias_schema.ex | 17 + .../schemas/collection_aliases_response.ex | 17 + .../schemas/collection_response.ex | 44 ++ .../schemas/collection_schema.ex | 38 ++ .../schemas/collection_update_schema.ex | 17 + .../schemas/facet_counts.ex | 25 + .../schemas/facet_counts_counts.ex | 22 + .../schemas/facet_counts_stats.ex | 23 + lib/open_api_typesense/schemas/field.ex | 56 ++ lib/open_api_typesense/schemas/field_embed.ex | 20 + .../schemas/field_embed_model_config.ex | 31 ++ .../schemas/health_status.ex | 17 + .../multi_search_collection_parameters.ex | 179 +++++++ .../schemas/multi_search_result.ex | 17 + .../multi_search_searches_parameter.ex | 17 + .../schemas/preset_delete_schema.ex | 17 + .../schemas/preset_schema.ex | 31 ++ .../schemas/preset_upsert_schema.ex | 28 + .../schemas/presets_retrieve_schema.ex | 17 + .../schemas/search_grouped_hit.ex | 21 + .../schemas/search_highlight.ex | 33 ++ .../schemas/search_override.ex | 59 +++ .../schemas/search_override_exclude.ex | 17 + .../schemas/search_override_include.ex | 17 + .../schemas/search_override_rule.ex | 27 + .../schemas/search_override_schema.ex | 56 ++ .../schemas/search_overrides_response.ex | 17 + .../schemas/search_parameters.ex | 185 +++++++ .../schemas/search_result.ex | 47 ++ .../schemas/search_result_hit.ex | 38 ++ .../schemas/search_result_hit_document.ex | 17 + .../search_result_hit_geo_distance_meters.ex | 17 + .../schemas/search_result_request_params.ex | 17 + .../schemas/search_synonym.ex | 21 + .../schemas/search_synonym_schema.ex | 17 + .../schemas/search_synonyms_response.ex | 17 + .../schemas/stopwords_set_retrieve_schema.ex | 17 + .../schemas/stopwords_set_schema.ex | 17 + .../schemas/stopwords_set_upsert_schema.ex | 17 + .../stopwords_sets_retrieve_all_schema.ex | 17 + .../schemas/success_status.ex | 17 + 67 files changed, 2995 insertions(+), 8 deletions(-) rename {openapi => lib/open_api_typesense}/openapi.yml (100%) create mode 100644 lib/open_api_typesense/operations/analytics.ex create mode 100644 lib/open_api_typesense/operations/collections.ex create mode 100644 lib/open_api_typesense/operations/debug.ex create mode 100644 lib/open_api_typesense/operations/documents.ex create mode 100644 lib/open_api_typesense/operations/health.ex create mode 100644 lib/open_api_typesense/operations/keys.ex create mode 100644 lib/open_api_typesense/operations/operations.ex create mode 100644 lib/open_api_typesense/operations/override.ex create mode 100644 lib/open_api_typesense/operations/presets.ex create mode 100644 lib/open_api_typesense/operations/promote.ex create mode 100644 lib/open_api_typesense/operations/stopwords.ex create mode 100644 lib/open_api_typesense/schemas/analytics_rule_parameters.ex create mode 100644 lib/open_api_typesense/schemas/analytics_rule_parameters_destination.ex create mode 100644 lib/open_api_typesense/schemas/analytics_rule_parameters_source.ex create mode 100644 lib/open_api_typesense/schemas/analytics_rule_schema.ex create mode 100644 lib/open_api_typesense/schemas/analytics_rules_retrieve_schema.ex create mode 100644 lib/open_api_typesense/schemas/api_key.ex create mode 100644 lib/open_api_typesense/schemas/api_key_schema.ex create mode 100644 lib/open_api_typesense/schemas/api_keys_response.ex create mode 100644 lib/open_api_typesense/schemas/api_response.ex create mode 100644 lib/open_api_typesense/schemas/api_stats_response.ex create mode 100644 lib/open_api_typesense/schemas/collection_alias.ex create mode 100644 lib/open_api_typesense/schemas/collection_alias_schema.ex create mode 100644 lib/open_api_typesense/schemas/collection_aliases_response.ex create mode 100644 lib/open_api_typesense/schemas/collection_response.ex create mode 100644 lib/open_api_typesense/schemas/collection_schema.ex create mode 100644 lib/open_api_typesense/schemas/collection_update_schema.ex create mode 100644 lib/open_api_typesense/schemas/facet_counts.ex create mode 100644 lib/open_api_typesense/schemas/facet_counts_counts.ex create mode 100644 lib/open_api_typesense/schemas/facet_counts_stats.ex create mode 100644 lib/open_api_typesense/schemas/field.ex create mode 100644 lib/open_api_typesense/schemas/field_embed.ex create mode 100644 lib/open_api_typesense/schemas/field_embed_model_config.ex create mode 100644 lib/open_api_typesense/schemas/health_status.ex create mode 100644 lib/open_api_typesense/schemas/multi_search_collection_parameters.ex create mode 100644 lib/open_api_typesense/schemas/multi_search_result.ex create mode 100644 lib/open_api_typesense/schemas/multi_search_searches_parameter.ex create mode 100644 lib/open_api_typesense/schemas/preset_delete_schema.ex create mode 100644 lib/open_api_typesense/schemas/preset_schema.ex create mode 100644 lib/open_api_typesense/schemas/preset_upsert_schema.ex create mode 100644 lib/open_api_typesense/schemas/presets_retrieve_schema.ex create mode 100644 lib/open_api_typesense/schemas/search_grouped_hit.ex create mode 100644 lib/open_api_typesense/schemas/search_highlight.ex create mode 100644 lib/open_api_typesense/schemas/search_override.ex create mode 100644 lib/open_api_typesense/schemas/search_override_exclude.ex create mode 100644 lib/open_api_typesense/schemas/search_override_include.ex create mode 100644 lib/open_api_typesense/schemas/search_override_rule.ex create mode 100644 lib/open_api_typesense/schemas/search_override_schema.ex create mode 100644 lib/open_api_typesense/schemas/search_overrides_response.ex create mode 100644 lib/open_api_typesense/schemas/search_parameters.ex create mode 100644 lib/open_api_typesense/schemas/search_result.ex create mode 100644 lib/open_api_typesense/schemas/search_result_hit.ex create mode 100644 lib/open_api_typesense/schemas/search_result_hit_document.ex create mode 100644 lib/open_api_typesense/schemas/search_result_hit_geo_distance_meters.ex create mode 100644 lib/open_api_typesense/schemas/search_result_request_params.ex create mode 100644 lib/open_api_typesense/schemas/search_synonym.ex create mode 100644 lib/open_api_typesense/schemas/search_synonym_schema.ex create mode 100644 lib/open_api_typesense/schemas/search_synonyms_response.ex create mode 100644 lib/open_api_typesense/schemas/stopwords_set_retrieve_schema.ex create mode 100644 lib/open_api_typesense/schemas/stopwords_set_schema.ex create mode 100644 lib/open_api_typesense/schemas/stopwords_set_upsert_schema.ex create mode 100644 lib/open_api_typesense/schemas/stopwords_sets_retrieve_all_schema.ex create mode 100644 lib/open_api_typesense/schemas/success_status.ex diff --git a/.gitignore b/.gitignore index defc07b..2c10b54 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,3 @@ ex_typesense-*.tar # Misc. .elixir_ls **.DS_Store - -# openapi generator files -/openapi/generator/ diff --git a/README.md b/README.md index ec68fc3..639104c 100644 --- a/README.md +++ b/README.md @@ -248,10 +248,6 @@ Check [Cheatsheet](https://hexdocs.pm/ex_typesense/cheatsheet.html) for more usa ### OpenAPI generator ```bash -# default in ./openapi/generator/ExTypesense -mix api.gen - -# another profile mix api.gen default priv/openapi.yml ``` diff --git a/config/config.exs b/config/config.exs index 920be49..a8f0db7 100644 --- a/config/config.exs +++ b/config/config.exs @@ -13,7 +13,7 @@ config :oapi_generator, default: [ output: [ base_module: OpenApiTypesense, - location: "lib/open_api_typesense" + location: "lib/open_api_typesense", operation_subdirectory: "operations/", schema_subdirectory: "schemas/" ] diff --git a/openapi/openapi.yml b/lib/open_api_typesense/openapi.yml similarity index 100% rename from openapi/openapi.yml rename to lib/open_api_typesense/openapi.yml diff --git a/lib/open_api_typesense/operations/analytics.ex b/lib/open_api_typesense/operations/analytics.ex new file mode 100644 index 0000000..1d646fe --- /dev/null +++ b/lib/open_api_typesense/operations/analytics.ex @@ -0,0 +1,127 @@ +defmodule OpenApiTypesense.Analytics do + @moduledoc """ + Provides API endpoints related to analytics + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Creates an analytics rule + + When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. + """ + @spec create_analytics_rule(OpenApiTypesense.AnalyticsRuleSchema.t(), keyword) :: + {:ok, OpenApiTypesense.AnalyticsRuleSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def create_analytics_rule(body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [body: body], + call: {OpenApiTypesense.Analytics, :create_analytics_rule}, + url: "/analytics/rules", + body: body, + method: :post, + request: [{"application/json", {OpenApiTypesense.AnalyticsRuleSchema, :t}}], + response: [ + {201, {OpenApiTypesense.AnalyticsRuleSchema, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete an analytics rule + + Permanently deletes an analytics rule, given it's name + """ + @spec delete_analytics_rule(String.t(), keyword) :: + {:ok, OpenApiTypesense.AnalyticsRuleSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_analytics_rule(ruleName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [ruleName: ruleName], + call: {OpenApiTypesense.Analytics, :delete_analytics_rule}, + url: "/analytics/rules/#{ruleName}", + method: :delete, + response: [ + {200, {OpenApiTypesense.AnalyticsRuleSchema, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieves an analytics rule + + Retrieve the details of an analytics rule, given it's name + """ + @spec retrieve_analytics_rule(String.t(), keyword) :: + {:ok, OpenApiTypesense.AnalyticsRuleSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def retrieve_analytics_rule(ruleName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [ruleName: ruleName], + call: {OpenApiTypesense.Analytics, :retrieve_analytics_rule}, + url: "/analytics/rules/#{ruleName}", + method: :get, + response: [ + {200, {OpenApiTypesense.AnalyticsRuleSchema, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieves all analytics rules + + Retrieve the details of all analytics rules + """ + @spec retrieve_analytics_rules(keyword) :: + {:ok, OpenApiTypesense.AnalyticsRulesRetrieveSchema.t()} | :error + def retrieve_analytics_rules(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Analytics, :retrieve_analytics_rules}, + url: "/analytics/rules", + method: :get, + response: [{200, {OpenApiTypesense.AnalyticsRulesRetrieveSchema, :t}}], + opts: opts + }) + end + + @doc """ + Upserts an analytics rule + + Upserts an analytics rule with the given name. + """ + @spec upsert_analytics_rule(String.t(), OpenApiTypesense.AnalyticsRuleSchema.t(), keyword) :: + {:ok, OpenApiTypesense.AnalyticsRuleSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_analytics_rule(ruleName, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [ruleName: ruleName, body: body], + call: {OpenApiTypesense.Analytics, :upsert_analytics_rule}, + url: "/analytics/rules/#{ruleName}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.AnalyticsRuleSchema, :t}}], + response: [ + {201, {OpenApiTypesense.AnalyticsRuleSchema, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/collections.ex b/lib/open_api_typesense/operations/collections.ex new file mode 100644 index 0000000..e108dd8 --- /dev/null +++ b/lib/open_api_typesense/operations/collections.ex @@ -0,0 +1,217 @@ +defmodule OpenApiTypesense.Collections do + @moduledoc """ + Provides API endpoints related to collections + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Create a new collection + + When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. + """ + @spec create_collection(OpenApiTypesense.CollectionSchema.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionResponse.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def create_collection(body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [body: body], + call: {OpenApiTypesense.Collections, :create_collection}, + url: "/collections", + body: body, + method: :post, + request: [{"application/json", {OpenApiTypesense.CollectionSchema, :t}}], + response: [ + {201, {OpenApiTypesense.CollectionResponse, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {409, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete an alias + """ + @spec delete_alias(String.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_alias(aliasName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [aliasName: aliasName], + call: {OpenApiTypesense.Collections, :delete_alias}, + url: "/aliases/#{aliasName}", + method: :delete, + response: [ + {200, {OpenApiTypesense.CollectionAlias, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete a collection + + Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies. + """ + @spec delete_collection(String.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionResponse.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_collection(collectionName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Collections, :delete_collection}, + url: "/collections/#{collectionName}", + method: :delete, + response: [ + {200, {OpenApiTypesense.CollectionResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieve an alias + + Find out which collection an alias points to by fetching it + """ + @spec get_alias(String.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def get_alias(aliasName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [aliasName: aliasName], + call: {OpenApiTypesense.Collections, :get_alias}, + url: "/aliases/#{aliasName}", + method: :get, + response: [ + {200, {OpenApiTypesense.CollectionAlias, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + List all aliases + + List all aliases and the corresponding collections that they map to. + """ + @spec get_aliases(keyword) :: {:ok, OpenApiTypesense.CollectionAliasesResponse.t()} | :error + def get_aliases(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Collections, :get_aliases}, + url: "/aliases", + method: :get, + response: [{200, {OpenApiTypesense.CollectionAliasesResponse, :t}}], + opts: opts + }) + end + + @doc """ + Retrieve a single collection + + Retrieve the details of a collection, given its name. + """ + @spec get_collection(String.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionResponse.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def get_collection(collectionName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Collections, :get_collection}, + url: "/collections/#{collectionName}", + method: :get, + response: [ + {200, {OpenApiTypesense.CollectionResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + List all collections + + Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. + """ + @spec get_collections(keyword) :: {:ok, [OpenApiTypesense.CollectionResponse.t()]} | :error + def get_collections(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Collections, :get_collections}, + url: "/collections", + method: :get, + response: [{200, [{OpenApiTypesense.CollectionResponse, :t}]}], + opts: opts + }) + end + + @doc """ + Update a collection + + Update a collection's schema to modify the fields and their types. + """ + @spec update_collection(String.t(), OpenApiTypesense.CollectionUpdateSchema.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionUpdateSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def update_collection(collectionName, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, body: body], + call: {OpenApiTypesense.Collections, :update_collection}, + url: "/collections/#{collectionName}", + body: body, + method: :patch, + request: [{"application/json", {OpenApiTypesense.CollectionUpdateSchema, :t}}], + response: [ + {200, {OpenApiTypesense.CollectionUpdateSchema, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Create or update a collection alias + + Create or update a collection alias. An alias is a virtual collection name that points to a real collection. If you're familiar with symbolic links on Linux, it's very similar to that. Aliases are useful when you want to reindex your data in the background on a new collection and switch your application to it without any changes to your code. + """ + @spec upsert_alias(String.t(), OpenApiTypesense.CollectionAliasSchema.t(), keyword) :: + {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_alias(aliasName, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [aliasName: aliasName, body: body], + call: {OpenApiTypesense.Collections, :upsert_alias}, + url: "/aliases/#{aliasName}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.CollectionAliasSchema, :t}}], + response: [ + {200, {OpenApiTypesense.CollectionAlias, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/debug.ex b/lib/open_api_typesense/operations/debug.ex new file mode 100644 index 0000000..e7f673f --- /dev/null +++ b/lib/open_api_typesense/operations/debug.ex @@ -0,0 +1,34 @@ +defmodule OpenApiTypesense.Debug do + @moduledoc """ + Provides API endpoint related to debug + """ + + @default_client OpenApiTypesense.Client + + @type debug_200_json_resp :: %{version: String.t() | nil} + + @doc """ + Print debugging information + + Print debugging information + """ + @spec debug(keyword) :: {:ok, map} | :error + def debug(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Debug, :debug}, + url: "/debug", + method: :get, + response: [{200, {OpenApiTypesense.Debug, :debug_200_json_resp}}], + opts: opts + }) + end + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(:debug_200_json_resp) do + [version: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/operations/documents.ex b/lib/open_api_typesense/operations/documents.ex new file mode 100644 index 0000000..e86e79d --- /dev/null +++ b/lib/open_api_typesense/operations/documents.ex @@ -0,0 +1,484 @@ +defmodule OpenApiTypesense.Documents do + @moduledoc """ + Provides API endpoints related to documents + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Delete a document + + Delete an individual document from a collection by using its ID. + """ + @spec delete_document(String.t(), String.t(), keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_document(collectionName, documentId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, documentId: documentId], + call: {OpenApiTypesense.Documents, :delete_document}, + url: "/collections/#{collectionName}/documents/#{documentId}", + method: :delete, + response: [{200, :map}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @type delete_documents_200_json_resp :: %{num_deleted: integer} + + @doc """ + Delete a bunch of documents + + Delete a bunch of documents that match a specific filter condition. Use the `batch_size` parameter to control the number of documents that should deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. + + ## Options + + * `deleteDocumentsParameters` + + """ + @spec delete_documents(String.t(), keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_documents(collectionName, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:deleteDocumentsParameters]) + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Documents, :delete_documents}, + url: "/collections/#{collectionName}/documents", + method: :delete, + query: query, + response: [ + {200, {OpenApiTypesense.Documents, :delete_documents_200_json_resp}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete an override associated with a collection + """ + @spec delete_search_override(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_search_override(collectionName, overrideId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId], + call: {OpenApiTypesense.Documents, :delete_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.SearchOverride, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete a synonym associated with a collection + """ + @spec delete_search_synonym(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchSynonym.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_search_synonym(collectionName, synonymId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, synonymId: synonymId], + call: {OpenApiTypesense.Documents, :delete_search_synonym}, + url: "/collections/#{collectionName}/synonyms/#{synonymId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.SearchSynonym, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Export all documents in a collection + + Export all documents in a collection in JSON lines format. + + ## Options + + * `exportDocumentsParameters` + + """ + @spec export_documents(String.t(), keyword) :: + {:ok, String.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def export_documents(collectionName, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:exportDocumentsParameters]) + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Documents, :export_documents}, + url: "/collections/#{collectionName}/documents/export", + method: :get, + query: query, + response: [{200, {:string, :generic}}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @doc """ + Retreive a document + + Fetch an individual document from a collection by using its ID. + """ + @spec get_document(String.t(), String.t(), keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def get_document(collectionName, documentId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, documentId: documentId], + call: {OpenApiTypesense.Documents, :get_document}, + url: "/collections/#{collectionName}/documents/#{documentId}", + method: :get, + response: [{200, :map}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @doc """ + Retrieve a single search override + + Retrieve the details of a search override, given its id. + """ + @spec get_search_override(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | :error + def get_search_override(collectionName, overrideId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId], + call: {OpenApiTypesense.Documents, :get_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + method: :get, + response: [{200, {OpenApiTypesense.SearchOverride, :t}}], + opts: opts + }) + end + + @doc """ + List all collection overrides + """ + @spec get_search_overrides(String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverridesResponse.t()} | :error + def get_search_overrides(collectionName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Documents, :get_search_overrides}, + url: "/collections/#{collectionName}/overrides", + method: :get, + response: [{200, {OpenApiTypesense.SearchOverridesResponse, :t}}], + opts: opts + }) + end + + @doc """ + Retrieve a single search synonym + + Retrieve the details of a search synonym, given its id. + """ + @spec get_search_synonym(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchSynonym.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def get_search_synonym(collectionName, synonymId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, synonymId: synonymId], + call: {OpenApiTypesense.Documents, :get_search_synonym}, + url: "/collections/#{collectionName}/synonyms/#{synonymId}", + method: :get, + response: [ + {200, {OpenApiTypesense.SearchSynonym, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + List all collection synonyms + """ + @spec get_search_synonyms(String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchSynonymsResponse.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def get_search_synonyms(collectionName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Documents, :get_search_synonyms}, + url: "/collections/#{collectionName}/synonyms", + method: :get, + response: [ + {200, {OpenApiTypesense.SearchSynonymsResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Import documents into a collection + + 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. + + ## Options + + * `importDocumentsParameters` + + """ + @spec import_documents(String.t(), String.t(), keyword) :: + {:ok, String.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def import_documents(collectionName, body, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:importDocumentsParameters]) + + client.request(%{ + args: [collectionName: collectionName, body: body], + call: {OpenApiTypesense.Documents, :import_documents}, + url: "/collections/#{collectionName}/documents/import", + body: body, + method: :post, + query: query, + request: [{"application/octet-stream", {:string, :generic}}], + response: [ + {200, {:string, :generic}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Index a document + + A document to be indexed in a given collection must conform to the schema of the collection. + + ## Options + + * `action`: Additional action to perform + + """ + @spec index_document(String.t(), map, keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def index_document(collectionName, body, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:action]) + + client.request(%{ + args: [collectionName: collectionName, body: body], + call: {OpenApiTypesense.Documents, :index_document}, + url: "/collections/#{collectionName}/documents", + body: body, + method: :post, + query: query, + request: [{"application/json", :map}], + response: [{201, :map}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @doc """ + send multiple search requests in a single HTTP request + + This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. You can also use this feature to do a federated search across multiple collections in a single HTTP request. + + ## Options + + * `multiSearchParameters` + + """ + @spec multi_search(OpenApiTypesense.MultiSearchSearchesParameter.t(), keyword) :: + {:ok, OpenApiTypesense.MultiSearchResult.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def multi_search(body, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:multiSearchParameters]) + + client.request(%{ + args: [body: body], + call: {OpenApiTypesense.Documents, :multi_search}, + url: "/multi_search", + body: body, + method: :post, + query: query, + request: [{"application/json", {OpenApiTypesense.MultiSearchSearchesParameter, :t}}], + response: [ + {200, {OpenApiTypesense.MultiSearchResult, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Search for documents in a collection + + Search for documents in a collection that match the search criteria. + + ## Options + + * `searchParameters` + + """ + @spec search_collection(String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchResult.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def search_collection(collectionName, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:searchParameters]) + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Documents, :search_collection}, + url: "/collections/#{collectionName}/documents/search", + method: :get, + query: query, + response: [ + {200, {OpenApiTypesense.SearchResult, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Update a document + + Update an individual document from a collection by using its ID. The update can be partial. + """ + @spec update_document(String.t(), String.t(), map, keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def update_document(collectionName, documentId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, documentId: documentId, body: body], + call: {OpenApiTypesense.Documents, :update_document}, + url: "/collections/#{collectionName}/documents/#{documentId}", + body: body, + method: :patch, + request: [{"application/json", :map}], + response: [{200, :map}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @type update_documents_200_json_resp :: %{num_updated: integer} + + @doc """ + Update documents with conditional query + + The filter_by query parameter is used to filter to specify a condition against which the documents are matched. The request body contains the fields that should be updated for any documents that match the filter condition. This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later. + + ## Options + + * `updateDocumentsParameters` + + """ + @spec update_documents(String.t(), map, keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def update_documents(collectionName, body, opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:updateDocumentsParameters]) + + client.request(%{ + args: [collectionName: collectionName, body: body], + call: {OpenApiTypesense.Documents, :update_documents}, + url: "/collections/#{collectionName}/documents", + body: body, + method: :patch, + query: query, + request: [{"application/json", :map}], + response: [ + {200, {OpenApiTypesense.Documents, :update_documents_200_json_resp}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + 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. + """ + @spec upsert_search_override( + String.t(), + String.t(), + OpenApiTypesense.SearchOverrideSchema.t(), + keyword + ) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_search_override(collectionName, overrideId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId, body: body], + call: {OpenApiTypesense.Documents, :upsert_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.SearchOverrideSchema, :t}}], + response: [ + {200, {OpenApiTypesense.SearchOverride, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Create or update a synonym + + Create or update a synonym to define search terms that should be considered equivalent. + """ + @spec upsert_search_synonym( + String.t(), + String.t(), + OpenApiTypesense.SearchSynonymSchema.t(), + keyword + ) :: + {:ok, OpenApiTypesense.SearchSynonym.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_search_synonym(collectionName, synonymId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, synonymId: synonymId, body: body], + call: {OpenApiTypesense.Documents, :upsert_search_synonym}, + url: "/collections/#{collectionName}/synonyms/#{synonymId}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.SearchSynonymSchema, :t}}], + response: [ + {200, {OpenApiTypesense.SearchSynonym, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(:delete_documents_200_json_resp) do + [num_deleted: :integer] + end + + def __fields__(:update_documents_200_json_resp) do + [num_updated: :integer] + end +end diff --git a/lib/open_api_typesense/operations/health.ex b/lib/open_api_typesense/operations/health.ex new file mode 100644 index 0000000..08d29b4 --- /dev/null +++ b/lib/open_api_typesense/operations/health.ex @@ -0,0 +1,26 @@ +defmodule OpenApiTypesense.Health do + @moduledoc """ + Provides API endpoint related to health + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Checks if Typesense server is ready to accept requests. + + Checks if Typesense server is ready to accept requests. + """ + @spec health(keyword) :: {:ok, OpenApiTypesense.HealthStatus.t()} | :error + def health(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Health, :health}, + url: "/health", + method: :get, + response: [{200, {OpenApiTypesense.HealthStatus, :t}}], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/keys.ex b/lib/open_api_typesense/operations/keys.ex new file mode 100644 index 0000000..176d7c8 --- /dev/null +++ b/lib/open_api_typesense/operations/keys.ex @@ -0,0 +1,92 @@ +defmodule OpenApiTypesense.Keys do + @moduledoc """ + Provides API endpoints related to keys + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Create an API Key + + Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place. + """ + @spec create_key(OpenApiTypesense.ApiKeySchema.t(), keyword) :: + {:ok, OpenApiTypesense.ApiKey.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def create_key(body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [body: body], + call: {OpenApiTypesense.Keys, :create_key}, + url: "/keys", + body: body, + method: :post, + request: [{"application/json", {OpenApiTypesense.ApiKeySchema, :t}}], + response: [ + {201, {OpenApiTypesense.ApiKey, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {409, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Delete an API key given its ID. + """ + @spec delete_key(integer, keyword) :: + {:ok, OpenApiTypesense.ApiKey.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_key(keyId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [keyId: keyId], + call: {OpenApiTypesense.Keys, :delete_key}, + url: "/keys/#{keyId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.ApiKey, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieve (metadata about) a key + + Retrieve (metadata about) a key. Only the key prefix is returned when you retrieve a key. Due to security reasons, only the create endpoint returns the full API key. + """ + @spec get_key(integer, keyword) :: + {:ok, OpenApiTypesense.ApiKey.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def get_key(keyId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [keyId: keyId], + call: {OpenApiTypesense.Keys, :get_key}, + url: "/keys/#{keyId}", + method: :get, + response: [{200, {OpenApiTypesense.ApiKey, :t}}, {404, {OpenApiTypesense.ApiResponse, :t}}], + opts: opts + }) + end + + @doc """ + Retrieve (metadata about) all keys. + """ + @spec get_keys(keyword) :: {:ok, OpenApiTypesense.ApiKeysResponse.t()} | :error + def get_keys(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Keys, :get_keys}, + url: "/keys", + method: :get, + response: [{200, {OpenApiTypesense.ApiKeysResponse, :t}}], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/operations.ex b/lib/open_api_typesense/operations/operations.ex new file mode 100644 index 0000000..3e1f02e --- /dev/null +++ b/lib/open_api_typesense/operations/operations.ex @@ -0,0 +1,90 @@ +defmodule OpenApiTypesense.Operations do + @moduledoc """ + Provides API endpoints related to operations + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Get stats about API endpoints. + + Retrieve the stats about API endpoints. + """ + @spec retrieve_api_stats(keyword) :: {:ok, OpenApiTypesense.APIStatsResponse.t()} | :error + def retrieve_api_stats(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Operations, :retrieve_api_stats}, + url: "/stats.json", + method: :get, + response: [{200, {OpenApiTypesense.APIStatsResponse, :t}}], + opts: opts + }) + end + + @doc """ + Get current RAM, CPU, Disk & Network usage metrics. + + Retrieve the metrics. + """ + @spec retrieve_metrics(keyword) :: {:ok, map} | :error + def retrieve_metrics(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Operations, :retrieve_metrics}, + url: "/metrics.json", + method: :get, + response: [{200, :map}], + opts: opts + }) + end + + @doc """ + Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. + + 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. + + ## Options + + * `snapshot_path`: The directory on the server where the snapshot should be saved. + + """ + @spec take_snapshot(keyword) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error + def take_snapshot(opts \\ []) do + client = opts[:client] || @default_client + query = Keyword.take(opts, [:snapshot_path]) + + client.request(%{ + args: [], + call: {OpenApiTypesense.Operations, :take_snapshot}, + url: "/operations/snapshot", + method: :post, + query: query, + response: [{201, {OpenApiTypesense.SuccessStatus, :t}}], + opts: opts + }) + end + + @doc """ + Triggers a follower node to initiate the raft voting process, which triggers leader re-election. + + 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. + """ + @spec vote(keyword) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error + def vote(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Operations, :vote}, + url: "/operations/vote", + method: :post, + response: [{200, {OpenApiTypesense.SuccessStatus, :t}}], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/override.ex b/lib/open_api_typesense/operations/override.ex new file mode 100644 index 0000000..291a2ac --- /dev/null +++ b/lib/open_api_typesense/operations/override.ex @@ -0,0 +1,27 @@ +defmodule OpenApiTypesense.Override do + @moduledoc """ + Provides API endpoint related to override + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Retrieve a single search override + + Retrieve the details of a search override, given its id. + """ + @spec get_search_override(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | :error + def get_search_override(collectionName, overrideId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId], + call: {OpenApiTypesense.Override, :get_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + method: :get, + response: [{200, {OpenApiTypesense.SearchOverride, :t}}], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/presets.ex b/lib/open_api_typesense/operations/presets.ex new file mode 100644 index 0000000..a4d76f8 --- /dev/null +++ b/lib/open_api_typesense/operations/presets.ex @@ -0,0 +1,99 @@ +defmodule OpenApiTypesense.Presets do + @moduledoc """ + Provides API endpoints related to presets + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Delete a preset. + + Permanently deletes a preset, given it's name. + """ + @spec delete_preset(String.t(), keyword) :: + {:ok, OpenApiTypesense.PresetDeleteSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_preset(presetId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [presetId: presetId], + call: {OpenApiTypesense.Presets, :delete_preset}, + url: "/presets/#{presetId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.PresetDeleteSchema, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieves all presets. + + Retrieve the details of all presets + """ + @spec retrieve_all_presets(keyword) :: + {:ok, OpenApiTypesense.PresetsRetrieveSchema.t()} | :error + def retrieve_all_presets(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Presets, :retrieve_all_presets}, + url: "/presets", + method: :get, + response: [{200, {OpenApiTypesense.PresetsRetrieveSchema, :t}}], + opts: opts + }) + end + + @doc """ + Retrieves a preset. + + Retrieve the details of a preset, given it's name. + """ + @spec retrieve_preset(String.t(), keyword) :: + {:ok, OpenApiTypesense.PresetSchema.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def retrieve_preset(presetId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [presetId: presetId], + call: {OpenApiTypesense.Presets, :retrieve_preset}, + url: "/presets/#{presetId}", + method: :get, + response: [ + {200, {OpenApiTypesense.PresetSchema, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Upserts a preset. + + Create or update an existing preset. + """ + @spec upsert_preset(String.t(), OpenApiTypesense.PresetUpsertSchema.t(), keyword) :: + {:ok, OpenApiTypesense.PresetSchema.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_preset(presetId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [presetId: presetId, body: body], + call: {OpenApiTypesense.Presets, :upsert_preset}, + url: "/presets/#{presetId}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.PresetUpsertSchema, :t}}], + response: [ + {200, {OpenApiTypesense.PresetSchema, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/promote.ex b/lib/open_api_typesense/operations/promote.ex new file mode 100644 index 0000000..8413af1 --- /dev/null +++ b/lib/open_api_typesense/operations/promote.ex @@ -0,0 +1,76 @@ +defmodule OpenApiTypesense.Promote do + @moduledoc """ + Provides API endpoints related to promote + """ + + @default_client OpenApiTypesense.Client + + @doc """ + Delete an override associated with a collection + """ + @spec delete_search_override(String.t(), String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_search_override(collectionName, overrideId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId], + call: {OpenApiTypesense.Promote, :delete_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.SearchOverride, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + List all collection overrides + """ + @spec get_search_overrides(String.t(), keyword) :: + {:ok, OpenApiTypesense.SearchOverridesResponse.t()} | :error + def get_search_overrides(collectionName, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName], + call: {OpenApiTypesense.Promote, :get_search_overrides}, + url: "/collections/#{collectionName}/overrides", + method: :get, + response: [{200, {OpenApiTypesense.SearchOverridesResponse, :t}}], + opts: opts + }) + end + + @doc """ + 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. + """ + @spec upsert_search_override( + String.t(), + String.t(), + OpenApiTypesense.SearchOverrideSchema.t(), + keyword + ) :: + {:ok, OpenApiTypesense.SearchOverride.t()} | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_search_override(collectionName, overrideId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [collectionName: collectionName, overrideId: overrideId, body: body], + call: {OpenApiTypesense.Promote, :upsert_search_override}, + url: "/collections/#{collectionName}/overrides/#{overrideId}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.SearchOverrideSchema, :t}}], + response: [ + {200, {OpenApiTypesense.SearchOverride, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end +end diff --git a/lib/open_api_typesense/operations/stopwords.ex b/lib/open_api_typesense/operations/stopwords.ex new file mode 100644 index 0000000..fcf2ed8 --- /dev/null +++ b/lib/open_api_typesense/operations/stopwords.ex @@ -0,0 +1,108 @@ +defmodule OpenApiTypesense.Stopwords do + @moduledoc """ + Provides API endpoints related to stopwords + """ + + @default_client OpenApiTypesense.Client + + @type delete_stopwords_set_200_json_resp :: %{id: String.t()} + + @doc """ + Delete a stopwords set. + + Permanently deletes a stopwords set, given it's name. + """ + @spec delete_stopwords_set(String.t(), keyword) :: + {:ok, map} | {:error, OpenApiTypesense.ApiResponse.t()} + def delete_stopwords_set(setId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [setId: setId], + call: {OpenApiTypesense.Stopwords, :delete_stopwords_set}, + url: "/stopwords/#{setId}", + method: :delete, + response: [ + {200, {OpenApiTypesense.Stopwords, :delete_stopwords_set_200_json_resp}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieves a stopwords set. + + Retrieve the details of a stopwords set, given it's name. + """ + @spec retrieve_stopwords_set(String.t(), keyword) :: + {:ok, OpenApiTypesense.StopwordsSetRetrieveSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def retrieve_stopwords_set(setId, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [setId: setId], + call: {OpenApiTypesense.Stopwords, :retrieve_stopwords_set}, + url: "/stopwords/#{setId}", + method: :get, + response: [ + {200, {OpenApiTypesense.StopwordsSetRetrieveSchema, :t}}, + {404, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc """ + Retrieves all stopwords sets. + + Retrieve the details of all stopwords sets + """ + @spec retrieve_stopwords_sets(keyword) :: + {:ok, OpenApiTypesense.StopwordsSetsRetrieveAllSchema.t()} | :error + def retrieve_stopwords_sets(opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [], + call: {OpenApiTypesense.Stopwords, :retrieve_stopwords_sets}, + url: "/stopwords", + method: :get, + response: [{200, {OpenApiTypesense.StopwordsSetsRetrieveAllSchema, :t}}], + opts: opts + }) + end + + @doc """ + Upserts a stopwords set. + + When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. + """ + @spec upsert_stopwords_set(String.t(), OpenApiTypesense.StopwordsSetUpsertSchema.t(), keyword) :: + {:ok, OpenApiTypesense.StopwordsSetSchema.t()} + | {:error, OpenApiTypesense.ApiResponse.t()} + def upsert_stopwords_set(setId, body, opts \\ []) do + client = opts[:client] || @default_client + + client.request(%{ + args: [setId: setId, body: body], + call: {OpenApiTypesense.Stopwords, :upsert_stopwords_set}, + url: "/stopwords/#{setId}", + body: body, + method: :put, + request: [{"application/json", {OpenApiTypesense.StopwordsSetUpsertSchema, :t}}], + response: [ + {200, {OpenApiTypesense.StopwordsSetSchema, :t}}, + {400, {OpenApiTypesense.ApiResponse, :t}} + ], + opts: opts + }) + end + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(:delete_stopwords_set_200_json_resp) do + [id: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/analytics_rule_parameters.ex b/lib/open_api_typesense/schemas/analytics_rule_parameters.ex new file mode 100644 index 0000000..3ca0571 --- /dev/null +++ b/lib/open_api_typesense/schemas/analytics_rule_parameters.ex @@ -0,0 +1,25 @@ +defmodule OpenApiTypesense.AnalyticsRuleParameters do + @moduledoc """ + Provides struct and type for a AnalyticsRuleParameters + """ + + @type t :: %__MODULE__{ + destination: OpenApiTypesense.AnalyticsRuleParametersDestination.t(), + limit: integer, + source: OpenApiTypesense.AnalyticsRuleParametersSource.t() + } + + defstruct [:destination, :limit, :source] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + destination: {OpenApiTypesense.AnalyticsRuleParametersDestination, :t}, + limit: :integer, + source: {OpenApiTypesense.AnalyticsRuleParametersSource, :t} + ] + end +end diff --git a/lib/open_api_typesense/schemas/analytics_rule_parameters_destination.ex b/lib/open_api_typesense/schemas/analytics_rule_parameters_destination.ex new file mode 100644 index 0000000..1868f4f --- /dev/null +++ b/lib/open_api_typesense/schemas/analytics_rule_parameters_destination.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.AnalyticsRuleParametersDestination do + @moduledoc """ + Provides struct and type for a AnalyticsRuleParametersDestination + """ + + @type t :: %__MODULE__{collection: String.t() | nil} + + defstruct [:collection] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [collection: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/analytics_rule_parameters_source.ex b/lib/open_api_typesense/schemas/analytics_rule_parameters_source.ex new file mode 100644 index 0000000..c6f6d52 --- /dev/null +++ b/lib/open_api_typesense/schemas/analytics_rule_parameters_source.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.AnalyticsRuleParametersSource do + @moduledoc """ + Provides struct and type for a AnalyticsRuleParametersSource + """ + + @type t :: %__MODULE__{collections: [String.t()] | nil} + + defstruct [:collections] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [collections: [string: :generic]] + end +end diff --git a/lib/open_api_typesense/schemas/analytics_rule_schema.ex b/lib/open_api_typesense/schemas/analytics_rule_schema.ex new file mode 100644 index 0000000..b887b58 --- /dev/null +++ b/lib/open_api_typesense/schemas/analytics_rule_schema.ex @@ -0,0 +1,25 @@ +defmodule OpenApiTypesense.AnalyticsRuleSchema do + @moduledoc """ + Provides struct and type for a AnalyticsRuleSchema + """ + + @type t :: %__MODULE__{ + name: String.t(), + params: OpenApiTypesense.AnalyticsRuleParameters.t(), + type: String.t() + } + + defstruct [:name, :params, :type] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + name: {:string, :generic}, + params: {OpenApiTypesense.AnalyticsRuleParameters, :t}, + type: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/analytics_rules_retrieve_schema.ex b/lib/open_api_typesense/schemas/analytics_rules_retrieve_schema.ex new file mode 100644 index 0000000..5f7494d --- /dev/null +++ b/lib/open_api_typesense/schemas/analytics_rules_retrieve_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.AnalyticsRulesRetrieveSchema do + @moduledoc """ + Provides struct and type for a AnalyticsRulesRetrieveSchema + """ + + @type t :: %__MODULE__{rules: [OpenApiTypesense.AnalyticsRuleSchema.t()] | nil} + + defstruct [:rules] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [rules: [{OpenApiTypesense.AnalyticsRuleSchema, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/api_key.ex b/lib/open_api_typesense/schemas/api_key.ex new file mode 100644 index 0000000..57960f5 --- /dev/null +++ b/lib/open_api_typesense/schemas/api_key.ex @@ -0,0 +1,33 @@ +defmodule OpenApiTypesense.ApiKey do + @moduledoc """ + Provides struct and type for a ApiKey + """ + + @type t :: %__MODULE__{ + actions: [String.t()] | nil, + collections: [String.t()] | nil, + description: String.t() | nil, + expires_at: integer | nil, + id: integer | nil, + value: String.t() | nil, + value_prefix: String.t() | nil + } + + defstruct [:actions, :collections, :description, :expires_at, :id, :value, :value_prefix] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + actions: [string: :generic], + collections: [string: :generic], + description: {:string, :generic}, + expires_at: :integer, + id: :integer, + value: {:string, :generic}, + value_prefix: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/api_key_schema.ex b/lib/open_api_typesense/schemas/api_key_schema.ex new file mode 100644 index 0000000..a9f611a --- /dev/null +++ b/lib/open_api_typesense/schemas/api_key_schema.ex @@ -0,0 +1,29 @@ +defmodule OpenApiTypesense.ApiKeySchema do + @moduledoc """ + Provides struct and type for a ApiKeySchema + """ + + @type t :: %__MODULE__{ + actions: [String.t()], + collections: [String.t()], + description: String.t(), + expires_at: integer | nil, + value: String.t() | nil + } + + defstruct [:actions, :collections, :description, :expires_at, :value] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + actions: [string: :generic], + collections: [string: :generic], + description: {:string, :generic}, + expires_at: :integer, + value: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/api_keys_response.ex b/lib/open_api_typesense/schemas/api_keys_response.ex new file mode 100644 index 0000000..a496cea --- /dev/null +++ b/lib/open_api_typesense/schemas/api_keys_response.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.ApiKeysResponse do + @moduledoc """ + Provides struct and type for a ApiKeysResponse + """ + + @type t :: %__MODULE__{keys: [OpenApiTypesense.ApiKey.t()]} + + defstruct [:keys] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [keys: [{OpenApiTypesense.ApiKey, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/api_response.ex b/lib/open_api_typesense/schemas/api_response.ex new file mode 100644 index 0000000..5bce800 --- /dev/null +++ b/lib/open_api_typesense/schemas/api_response.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.ApiResponse do + @moduledoc """ + Provides struct and type for a ApiResponse + """ + + @type t :: %__MODULE__{message: String.t()} + + defstruct [:message] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [message: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/api_stats_response.ex b/lib/open_api_typesense/schemas/api_stats_response.ex new file mode 100644 index 0000000..9d17fde --- /dev/null +++ b/lib/open_api_typesense/schemas/api_stats_response.ex @@ -0,0 +1,59 @@ +defmodule OpenApiTypesense.APIStatsResponse do + @moduledoc """ + Provides struct and type for a APIStatsResponse + """ + + @type t :: %__MODULE__{ + delete_latency_ms: number | nil, + delete_requests_per_second: number | nil, + import_latency_ms: number | nil, + import_requests_per_second: number | nil, + latency_ms: map | nil, + overloaded_requests_per_second: number | nil, + pending_write_batches: number | nil, + requests_per_second: map | nil, + search_latency_ms: number | nil, + search_requests_per_second: number | nil, + total_requests_per_second: number | nil, + write_latency_ms: number | nil, + write_requests_per_second: number | nil + } + + defstruct [ + :delete_latency_ms, + :delete_requests_per_second, + :import_latency_ms, + :import_requests_per_second, + :latency_ms, + :overloaded_requests_per_second, + :pending_write_batches, + :requests_per_second, + :search_latency_ms, + :search_requests_per_second, + :total_requests_per_second, + :write_latency_ms, + :write_requests_per_second + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + delete_latency_ms: :number, + delete_requests_per_second: :number, + import_latency_ms: :number, + import_requests_per_second: :number, + latency_ms: :map, + overloaded_requests_per_second: :number, + pending_write_batches: :number, + requests_per_second: :map, + search_latency_ms: :number, + search_requests_per_second: :number, + total_requests_per_second: :number, + write_latency_ms: :number, + write_requests_per_second: :number + ] + end +end diff --git a/lib/open_api_typesense/schemas/collection_alias.ex b/lib/open_api_typesense/schemas/collection_alias.ex new file mode 100644 index 0000000..04ae8b6 --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_alias.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.CollectionAlias do + @moduledoc """ + Provides struct and type for a CollectionAlias + """ + + @type t :: %__MODULE__{collection_name: String.t(), name: String.t()} + + defstruct [:collection_name, :name] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [collection_name: {:string, :generic}, name: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/collection_alias_schema.ex b/lib/open_api_typesense/schemas/collection_alias_schema.ex new file mode 100644 index 0000000..41f8467 --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_alias_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.CollectionAliasSchema do + @moduledoc """ + Provides struct and type for a CollectionAliasSchema + """ + + @type t :: %__MODULE__{collection_name: String.t()} + + defstruct [:collection_name] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [collection_name: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/collection_aliases_response.ex b/lib/open_api_typesense/schemas/collection_aliases_response.ex new file mode 100644 index 0000000..5448400 --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_aliases_response.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.CollectionAliasesResponse do + @moduledoc """ + Provides struct and type for a CollectionAliasesResponse + """ + + @type t :: %__MODULE__{aliases: [OpenApiTypesense.CollectionAlias.t()]} + + defstruct [:aliases] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [aliases: [{OpenApiTypesense.CollectionAlias, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/collection_response.ex b/lib/open_api_typesense/schemas/collection_response.ex new file mode 100644 index 0000000..41bee8d --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_response.ex @@ -0,0 +1,44 @@ +defmodule OpenApiTypesense.CollectionResponse do + @moduledoc """ + Provides struct and type for a CollectionResponse + """ + + @type t :: %__MODULE__{ + created_at: integer | nil, + default_sorting_field: String.t() | nil, + enable_nested_fields: boolean | nil, + fields: [OpenApiTypesense.Field.t()] | nil, + name: String.t() | nil, + num_documents: integer | nil, + symbols_to_index: [String.t()] | nil, + token_separators: [String.t()] | nil + } + + defstruct [ + :created_at, + :default_sorting_field, + :enable_nested_fields, + :fields, + :name, + :num_documents, + :symbols_to_index, + :token_separators + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + created_at: :integer, + default_sorting_field: {:string, :generic}, + enable_nested_fields: :boolean, + fields: [{OpenApiTypesense.Field, :t}], + name: {:string, :generic}, + num_documents: :integer, + symbols_to_index: [string: :generic], + token_separators: [string: :generic] + ] + end +end diff --git a/lib/open_api_typesense/schemas/collection_schema.ex b/lib/open_api_typesense/schemas/collection_schema.ex new file mode 100644 index 0000000..e3045ae --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_schema.ex @@ -0,0 +1,38 @@ +defmodule OpenApiTypesense.CollectionSchema do + @moduledoc """ + Provides struct and type for a CollectionSchema + """ + + @type t :: %__MODULE__{ + default_sorting_field: String.t() | nil, + enable_nested_fields: boolean | nil, + fields: [OpenApiTypesense.Field.t()], + name: String.t(), + symbols_to_index: [String.t()] | nil, + token_separators: [String.t()] | nil + } + + defstruct [ + :default_sorting_field, + :enable_nested_fields, + :fields, + :name, + :symbols_to_index, + :token_separators + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + default_sorting_field: {:string, :generic}, + enable_nested_fields: :boolean, + fields: [{OpenApiTypesense.Field, :t}], + name: {:string, :generic}, + symbols_to_index: [string: :generic], + token_separators: [string: :generic] + ] + end +end diff --git a/lib/open_api_typesense/schemas/collection_update_schema.ex b/lib/open_api_typesense/schemas/collection_update_schema.ex new file mode 100644 index 0000000..c8d1173 --- /dev/null +++ b/lib/open_api_typesense/schemas/collection_update_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.CollectionUpdateSchema do + @moduledoc """ + Provides struct and type for a CollectionUpdateSchema + """ + + @type t :: %__MODULE__{fields: [OpenApiTypesense.Field.t()]} + + defstruct [:fields] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [fields: [{OpenApiTypesense.Field, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/facet_counts.ex b/lib/open_api_typesense/schemas/facet_counts.ex new file mode 100644 index 0000000..4afad26 --- /dev/null +++ b/lib/open_api_typesense/schemas/facet_counts.ex @@ -0,0 +1,25 @@ +defmodule OpenApiTypesense.FacetCounts do + @moduledoc """ + Provides struct and type for a FacetCounts + """ + + @type t :: %__MODULE__{ + counts: [OpenApiTypesense.FacetCountsCounts.t()] | nil, + field_name: String.t() | nil, + stats: OpenApiTypesense.FacetCountsStats.t() | nil + } + + defstruct [:counts, :field_name, :stats] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + counts: [{OpenApiTypesense.FacetCountsCounts, :t}], + field_name: {:string, :generic}, + stats: {OpenApiTypesense.FacetCountsStats, :t} + ] + end +end diff --git a/lib/open_api_typesense/schemas/facet_counts_counts.ex b/lib/open_api_typesense/schemas/facet_counts_counts.ex new file mode 100644 index 0000000..163a0e0 --- /dev/null +++ b/lib/open_api_typesense/schemas/facet_counts_counts.ex @@ -0,0 +1,22 @@ +defmodule OpenApiTypesense.FacetCountsCounts do + @moduledoc """ + Provides struct and type for a FacetCountsCounts + """ + + @type t :: %__MODULE__{ + count: integer | nil, + highlighted: String.t() | nil, + parent: map | nil, + value: String.t() | nil + } + + defstruct [:count, :highlighted, :parent, :value] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [count: :integer, highlighted: {:string, :generic}, parent: :map, value: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/facet_counts_stats.ex b/lib/open_api_typesense/schemas/facet_counts_stats.ex new file mode 100644 index 0000000..2df31ee --- /dev/null +++ b/lib/open_api_typesense/schemas/facet_counts_stats.ex @@ -0,0 +1,23 @@ +defmodule OpenApiTypesense.FacetCountsStats do + @moduledoc """ + Provides struct and type for a FacetCountsStats + """ + + @type t :: %__MODULE__{ + avg: number | nil, + max: number | nil, + min: number | nil, + sum: number | nil, + total_values: integer | nil + } + + defstruct [:avg, :max, :min, :sum, :total_values] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [avg: :number, max: :number, min: :number, sum: :number, total_values: :integer] + end +end diff --git a/lib/open_api_typesense/schemas/field.ex b/lib/open_api_typesense/schemas/field.ex new file mode 100644 index 0000000..48bed09 --- /dev/null +++ b/lib/open_api_typesense/schemas/field.ex @@ -0,0 +1,56 @@ +defmodule OpenApiTypesense.Field do + @moduledoc """ + Provides struct and type for a Field + """ + + @type t :: %__MODULE__{ + drop: boolean | nil, + embed: OpenApiTypesense.FieldEmbed.t() | nil, + facet: boolean | nil, + index: boolean | nil, + infix: boolean | nil, + locale: String.t() | nil, + name: String.t(), + num_dim: integer | nil, + optional: boolean | nil, + reference: String.t() | nil, + sort: boolean | nil, + type: String.t() + } + + defstruct [ + :drop, + :embed, + :facet, + :index, + :infix, + :locale, + :name, + :num_dim, + :optional, + :reference, + :sort, + :type + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + drop: :boolean, + embed: {OpenApiTypesense.FieldEmbed, :t}, + facet: :boolean, + index: :boolean, + infix: :boolean, + locale: {:string, :generic}, + name: {:string, :generic}, + num_dim: :integer, + optional: :boolean, + reference: {:string, :generic}, + sort: :boolean, + type: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/field_embed.ex b/lib/open_api_typesense/schemas/field_embed.ex new file mode 100644 index 0000000..de3141b --- /dev/null +++ b/lib/open_api_typesense/schemas/field_embed.ex @@ -0,0 +1,20 @@ +defmodule OpenApiTypesense.FieldEmbed do + @moduledoc """ + Provides struct and type for a FieldEmbed + """ + + @type t :: %__MODULE__{ + from: [String.t()], + model_config: OpenApiTypesense.FieldEmbedModelConfig.t() + } + + defstruct [:from, :model_config] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [from: [string: :generic], model_config: {OpenApiTypesense.FieldEmbedModelConfig, :t}] + end +end diff --git a/lib/open_api_typesense/schemas/field_embed_model_config.ex b/lib/open_api_typesense/schemas/field_embed_model_config.ex new file mode 100644 index 0000000..a8cf24b --- /dev/null +++ b/lib/open_api_typesense/schemas/field_embed_model_config.ex @@ -0,0 +1,31 @@ +defmodule OpenApiTypesense.FieldEmbedModelConfig do + @moduledoc """ + Provides struct and type for a FieldEmbedModelConfig + """ + + @type t :: %__MODULE__{ + access_token: String.t() | nil, + api_key: String.t() | nil, + client_id: String.t() | nil, + client_secret: String.t() | nil, + model_name: String.t(), + project_id: String.t() | nil + } + + defstruct [:access_token, :api_key, :client_id, :client_secret, :model_name, :project_id] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + access_token: {:string, :generic}, + api_key: {:string, :generic}, + client_id: {:string, :generic}, + client_secret: {:string, :generic}, + model_name: {:string, :generic}, + project_id: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/health_status.ex b/lib/open_api_typesense/schemas/health_status.ex new file mode 100644 index 0000000..ff52206 --- /dev/null +++ b/lib/open_api_typesense/schemas/health_status.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.HealthStatus do + @moduledoc """ + Provides struct and type for a HealthStatus + """ + + @type t :: %__MODULE__{ok: boolean} + + defstruct [:ok] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ok: :boolean] + end +end diff --git a/lib/open_api_typesense/schemas/multi_search_collection_parameters.ex b/lib/open_api_typesense/schemas/multi_search_collection_parameters.ex new file mode 100644 index 0000000..22f0853 --- /dev/null +++ b/lib/open_api_typesense/schemas/multi_search_collection_parameters.ex @@ -0,0 +1,179 @@ +defmodule OpenApiTypesense.MultiSearchCollectionParameters do + @moduledoc """ + Provides struct and type for a MultiSearchCollectionParameters + """ + + @type t :: %__MODULE__{ + cache_ttl: integer | nil, + collection: String.t() | nil, + drop_tokens_threshold: integer | nil, + enable_overrides: boolean | nil, + enable_typos_for_numerical_tokens: boolean | nil, + exclude_fields: String.t() | nil, + exhaustive_search: boolean | nil, + facet_by: String.t() | nil, + facet_query: String.t() | nil, + facet_return_parent: String.t() | nil, + facet_strategy: String.t() | nil, + filter_by: String.t() | nil, + group_by: String.t() | nil, + group_limit: integer | nil, + hidden_hits: String.t() | nil, + highlight_affix_num_tokens: integer | nil, + highlight_end_tag: String.t() | nil, + highlight_fields: String.t() | nil, + highlight_full_fields: String.t() | nil, + highlight_start_tag: String.t() | nil, + include_fields: String.t() | nil, + infix: String.t() | nil, + limit: integer | nil, + max_extra_prefix: integer | nil, + max_extra_suffix: integer | nil, + max_facet_values: integer | nil, + min_len_1typo: integer | nil, + min_len_2typo: integer | nil, + num_typos: String.t() | nil, + offset: integer | nil, + override_tags: String.t() | nil, + page: integer | nil, + per_page: integer | nil, + pinned_hits: String.t() | nil, + pre_segmented_query: boolean | nil, + prefix: String.t() | nil, + preset: String.t() | nil, + prioritize_exact_match: boolean | nil, + prioritize_num_matching_fields: boolean | nil, + prioritize_token_position: boolean | nil, + q: String.t() | nil, + query_by: String.t() | nil, + query_by_weights: String.t() | nil, + remote_embedding_num_tries: integer | nil, + remote_embedding_timeout_ms: integer | nil, + search_cutoff_ms: integer | nil, + snippet_threshold: integer | nil, + sort_by: String.t() | nil, + stopwords: String.t() | nil, + text_match_type: String.t() | nil, + typo_tokens_threshold: integer | nil, + use_cache: boolean | nil, + vector_query: String.t() | nil + } + + defstruct [ + :cache_ttl, + :collection, + :drop_tokens_threshold, + :enable_overrides, + :enable_typos_for_numerical_tokens, + :exclude_fields, + :exhaustive_search, + :facet_by, + :facet_query, + :facet_return_parent, + :facet_strategy, + :filter_by, + :group_by, + :group_limit, + :hidden_hits, + :highlight_affix_num_tokens, + :highlight_end_tag, + :highlight_fields, + :highlight_full_fields, + :highlight_start_tag, + :include_fields, + :infix, + :limit, + :max_extra_prefix, + :max_extra_suffix, + :max_facet_values, + :min_len_1typo, + :min_len_2typo, + :num_typos, + :offset, + :override_tags, + :page, + :per_page, + :pinned_hits, + :pre_segmented_query, + :prefix, + :preset, + :prioritize_exact_match, + :prioritize_num_matching_fields, + :prioritize_token_position, + :q, + :query_by, + :query_by_weights, + :remote_embedding_num_tries, + :remote_embedding_timeout_ms, + :search_cutoff_ms, + :snippet_threshold, + :sort_by, + :stopwords, + :text_match_type, + :typo_tokens_threshold, + :use_cache, + :vector_query + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + cache_ttl: :integer, + collection: {:string, :generic}, + drop_tokens_threshold: :integer, + enable_overrides: :boolean, + enable_typos_for_numerical_tokens: :boolean, + exclude_fields: {:string, :generic}, + exhaustive_search: :boolean, + facet_by: {:string, :generic}, + facet_query: {:string, :generic}, + facet_return_parent: {:string, :generic}, + facet_strategy: {:string, :generic}, + filter_by: {:string, :generic}, + group_by: {:string, :generic}, + group_limit: :integer, + hidden_hits: {:string, :generic}, + highlight_affix_num_tokens: :integer, + highlight_end_tag: {:string, :generic}, + highlight_fields: {:string, :generic}, + highlight_full_fields: {:string, :generic}, + highlight_start_tag: {:string, :generic}, + include_fields: {:string, :generic}, + infix: {:string, :generic}, + limit: :integer, + max_extra_prefix: :integer, + max_extra_suffix: :integer, + max_facet_values: :integer, + min_len_1typo: :integer, + min_len_2typo: :integer, + num_typos: {:string, :generic}, + offset: :integer, + override_tags: {:string, :generic}, + page: :integer, + per_page: :integer, + pinned_hits: {:string, :generic}, + pre_segmented_query: :boolean, + prefix: {:string, :generic}, + preset: {:string, :generic}, + prioritize_exact_match: :boolean, + prioritize_num_matching_fields: :boolean, + prioritize_token_position: :boolean, + q: {:string, :generic}, + query_by: {:string, :generic}, + query_by_weights: {:string, :generic}, + remote_embedding_num_tries: :integer, + remote_embedding_timeout_ms: :integer, + search_cutoff_ms: :integer, + snippet_threshold: :integer, + sort_by: {:string, :generic}, + stopwords: {:string, :generic}, + text_match_type: {:string, :generic}, + typo_tokens_threshold: :integer, + use_cache: :boolean, + vector_query: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/multi_search_result.ex b/lib/open_api_typesense/schemas/multi_search_result.ex new file mode 100644 index 0000000..f41a70e --- /dev/null +++ b/lib/open_api_typesense/schemas/multi_search_result.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.MultiSearchResult do + @moduledoc """ + Provides struct and type for a MultiSearchResult + """ + + @type t :: %__MODULE__{results: [OpenApiTypesense.SearchResult.t()]} + + defstruct [:results] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [results: [{OpenApiTypesense.SearchResult, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/multi_search_searches_parameter.ex b/lib/open_api_typesense/schemas/multi_search_searches_parameter.ex new file mode 100644 index 0000000..f9193f8 --- /dev/null +++ b/lib/open_api_typesense/schemas/multi_search_searches_parameter.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.MultiSearchSearchesParameter do + @moduledoc """ + Provides struct and type for a MultiSearchSearchesParameter + """ + + @type t :: %__MODULE__{searches: [OpenApiTypesense.MultiSearchCollectionParameters.t()]} + + defstruct [:searches] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [searches: [{OpenApiTypesense.MultiSearchCollectionParameters, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/preset_delete_schema.ex b/lib/open_api_typesense/schemas/preset_delete_schema.ex new file mode 100644 index 0000000..ab77fb2 --- /dev/null +++ b/lib/open_api_typesense/schemas/preset_delete_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.PresetDeleteSchema do + @moduledoc """ + Provides struct and type for a PresetDeleteSchema + """ + + @type t :: %__MODULE__{name: String.t()} + + defstruct [:name] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [name: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/preset_schema.ex b/lib/open_api_typesense/schemas/preset_schema.ex new file mode 100644 index 0000000..8adb6f8 --- /dev/null +++ b/lib/open_api_typesense/schemas/preset_schema.ex @@ -0,0 +1,31 @@ +defmodule OpenApiTypesense.PresetSchema do + @moduledoc """ + Provides struct and type for a PresetSchema + """ + + @type t :: %__MODULE__{ + name: String.t() | nil, + value: + OpenApiTypesense.MultiSearchSearchesParameter.t() + | OpenApiTypesense.SearchParameters.t() + | nil + } + + defstruct [:name, :value] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + name: {:string, :generic}, + value: + {:union, + [ + {OpenApiTypesense.MultiSearchSearchesParameter, :t}, + {OpenApiTypesense.SearchParameters, :t} + ]} + ] + end +end diff --git a/lib/open_api_typesense/schemas/preset_upsert_schema.ex b/lib/open_api_typesense/schemas/preset_upsert_schema.ex new file mode 100644 index 0000000..6c5abdf --- /dev/null +++ b/lib/open_api_typesense/schemas/preset_upsert_schema.ex @@ -0,0 +1,28 @@ +defmodule OpenApiTypesense.PresetUpsertSchema do + @moduledoc """ + Provides struct and type for a PresetUpsertSchema + """ + + @type t :: %__MODULE__{ + value: + OpenApiTypesense.MultiSearchSearchesParameter.t() + | OpenApiTypesense.SearchParameters.t() + } + + defstruct [:value] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + value: + {:union, + [ + {OpenApiTypesense.MultiSearchSearchesParameter, :t}, + {OpenApiTypesense.SearchParameters, :t} + ]} + ] + end +end diff --git a/lib/open_api_typesense/schemas/presets_retrieve_schema.ex b/lib/open_api_typesense/schemas/presets_retrieve_schema.ex new file mode 100644 index 0000000..6b257b2 --- /dev/null +++ b/lib/open_api_typesense/schemas/presets_retrieve_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.PresetsRetrieveSchema do + @moduledoc """ + Provides struct and type for a PresetsRetrieveSchema + """ + + @type t :: %__MODULE__{presets: [OpenApiTypesense.PresetSchema.t()]} + + defstruct [:presets] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [presets: [{OpenApiTypesense.PresetSchema, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/search_grouped_hit.ex b/lib/open_api_typesense/schemas/search_grouped_hit.ex new file mode 100644 index 0000000..140b386 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_grouped_hit.ex @@ -0,0 +1,21 @@ +defmodule OpenApiTypesense.SearchGroupedHit do + @moduledoc """ + Provides struct and type for a SearchGroupedHit + """ + + @type t :: %__MODULE__{ + found: integer | nil, + group_key: [map], + hits: [OpenApiTypesense.SearchResultHit.t()] + } + + defstruct [:found, :group_key, :hits] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [found: :integer, group_key: [:map], hits: [{OpenApiTypesense.SearchResultHit, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/search_highlight.ex b/lib/open_api_typesense/schemas/search_highlight.ex new file mode 100644 index 0000000..5d613f3 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_highlight.ex @@ -0,0 +1,33 @@ +defmodule OpenApiTypesense.SearchHighlight do + @moduledoc """ + Provides struct and type for a SearchHighlight + """ + + @type t :: %__MODULE__{ + field: String.t() | nil, + indices: [integer] | nil, + matched_tokens: [map] | nil, + snippet: String.t() | nil, + snippets: [String.t()] | nil, + value: String.t() | nil, + values: [String.t()] | nil + } + + defstruct [:field, :indices, :matched_tokens, :snippet, :snippets, :value, :values] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + field: {:string, :generic}, + indices: [:integer], + matched_tokens: [:map], + snippet: {:string, :generic}, + snippets: [string: :generic], + value: {:string, :generic}, + values: [string: :generic] + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_override.ex b/lib/open_api_typesense/schemas/search_override.ex new file mode 100644 index 0000000..9f07e93 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_override.ex @@ -0,0 +1,59 @@ +defmodule OpenApiTypesense.SearchOverride do + @moduledoc """ + Provides struct and type for a SearchOverride + """ + + @type t :: %__MODULE__{ + effective_from_ts: integer | nil, + effective_to_ts: integer | nil, + excludes: [OpenApiTypesense.SearchOverrideExclude.t()] | nil, + filter_by: String.t() | nil, + filter_curated_hits: boolean | nil, + id: String.t() | nil, + includes: [OpenApiTypesense.SearchOverrideInclude.t()] | nil, + metadata: map | nil, + remove_matched_tokens: boolean | nil, + replace_query: String.t() | nil, + rule: OpenApiTypesense.SearchOverrideRule.t() | nil, + sort_by: String.t() | nil, + stop_processing: boolean | nil + } + + defstruct [ + :effective_from_ts, + :effective_to_ts, + :excludes, + :filter_by, + :filter_curated_hits, + :id, + :includes, + :metadata, + :remove_matched_tokens, + :replace_query, + :rule, + :sort_by, + :stop_processing + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + effective_from_ts: :integer, + effective_to_ts: :integer, + excludes: [{OpenApiTypesense.SearchOverrideExclude, :t}], + filter_by: {:string, :generic}, + filter_curated_hits: :boolean, + id: {:string, :generic}, + includes: [{OpenApiTypesense.SearchOverrideInclude, :t}], + metadata: :map, + remove_matched_tokens: :boolean, + replace_query: {:string, :generic}, + rule: {OpenApiTypesense.SearchOverrideRule, :t}, + sort_by: {:string, :generic}, + stop_processing: :boolean + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_override_exclude.ex b/lib/open_api_typesense/schemas/search_override_exclude.ex new file mode 100644 index 0000000..c614c34 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_override_exclude.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchOverrideExclude do + @moduledoc """ + Provides struct and type for a SearchOverrideExclude + """ + + @type t :: %__MODULE__{id: String.t()} + + defstruct [:id] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [id: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/search_override_include.ex b/lib/open_api_typesense/schemas/search_override_include.ex new file mode 100644 index 0000000..7cb49b5 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_override_include.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchOverrideInclude do + @moduledoc """ + Provides struct and type for a SearchOverrideInclude + """ + + @type t :: %__MODULE__{id: String.t(), position: integer} + + defstruct [:id, :position] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [id: {:string, :generic}, position: :integer] + end +end diff --git a/lib/open_api_typesense/schemas/search_override_rule.ex b/lib/open_api_typesense/schemas/search_override_rule.ex new file mode 100644 index 0000000..ec20a28 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_override_rule.ex @@ -0,0 +1,27 @@ +defmodule OpenApiTypesense.SearchOverrideRule do + @moduledoc """ + Provides struct and type for a SearchOverrideRule + """ + + @type t :: %__MODULE__{ + filter_by: String.t() | nil, + match: String.t() | nil, + query: String.t() | nil, + tags: [String.t()] | nil + } + + defstruct [:filter_by, :match, :query, :tags] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + filter_by: {:string, :generic}, + match: {:enum, ["exact", "contains"]}, + query: {:string, :generic}, + tags: [string: :generic] + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_override_schema.ex b/lib/open_api_typesense/schemas/search_override_schema.ex new file mode 100644 index 0000000..c8f8d70 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_override_schema.ex @@ -0,0 +1,56 @@ +defmodule OpenApiTypesense.SearchOverrideSchema do + @moduledoc """ + Provides struct and type for a SearchOverrideSchema + """ + + @type t :: %__MODULE__{ + effective_from_ts: integer | nil, + effective_to_ts: integer | nil, + excludes: [OpenApiTypesense.SearchOverrideExclude.t()] | nil, + filter_by: String.t() | nil, + filter_curated_hits: boolean | nil, + includes: [OpenApiTypesense.SearchOverrideInclude.t()] | nil, + metadata: map | nil, + remove_matched_tokens: boolean | nil, + replace_query: String.t() | nil, + rule: OpenApiTypesense.SearchOverrideRule.t(), + sort_by: String.t() | nil, + stop_processing: boolean | nil + } + + defstruct [ + :effective_from_ts, + :effective_to_ts, + :excludes, + :filter_by, + :filter_curated_hits, + :includes, + :metadata, + :remove_matched_tokens, + :replace_query, + :rule, + :sort_by, + :stop_processing + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + effective_from_ts: :integer, + effective_to_ts: :integer, + excludes: [{OpenApiTypesense.SearchOverrideExclude, :t}], + filter_by: {:string, :generic}, + filter_curated_hits: :boolean, + includes: [{OpenApiTypesense.SearchOverrideInclude, :t}], + metadata: :map, + remove_matched_tokens: :boolean, + replace_query: {:string, :generic}, + rule: {OpenApiTypesense.SearchOverrideRule, :t}, + sort_by: {:string, :generic}, + stop_processing: :boolean + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_overrides_response.ex b/lib/open_api_typesense/schemas/search_overrides_response.ex new file mode 100644 index 0000000..e34ec09 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_overrides_response.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchOverridesResponse do + @moduledoc """ + Provides struct and type for a SearchOverridesResponse + """ + + @type t :: %__MODULE__{overrides: [OpenApiTypesense.SearchOverride.t()]} + + defstruct [:overrides] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [overrides: [{OpenApiTypesense.SearchOverride, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/search_parameters.ex b/lib/open_api_typesense/schemas/search_parameters.ex new file mode 100644 index 0000000..e1bcf91 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_parameters.ex @@ -0,0 +1,185 @@ +defmodule OpenApiTypesense.SearchParameters do + @moduledoc """ + Provides struct and type for a SearchParameters + """ + + @type t :: %__MODULE__{ + cache_ttl: integer | nil, + drop_tokens_threshold: integer | nil, + enable_highlight_v1: boolean | nil, + enable_overrides: boolean | nil, + enable_typos_for_numerical_tokens: boolean | nil, + exclude_fields: String.t() | nil, + exhaustive_search: boolean | nil, + facet_by: String.t() | nil, + facet_query: String.t() | nil, + facet_return_parent: String.t() | nil, + facet_strategy: String.t() | nil, + filter_by: String.t() | nil, + group_by: String.t() | nil, + group_limit: integer | nil, + hidden_hits: String.t() | nil, + highlight_affix_num_tokens: integer | nil, + highlight_end_tag: String.t() | nil, + highlight_fields: String.t() | nil, + highlight_full_fields: String.t() | nil, + highlight_start_tag: String.t() | nil, + include_fields: String.t() | nil, + infix: String.t() | nil, + limit: integer | nil, + max_candidates: integer | nil, + max_extra_prefix: integer | nil, + max_extra_suffix: integer | nil, + max_facet_values: integer | nil, + min_len_1typo: integer | nil, + min_len_2typo: integer | nil, + num_typos: String.t() | nil, + offset: integer | nil, + override_tags: String.t() | nil, + page: integer | nil, + per_page: integer | nil, + pinned_hits: String.t() | nil, + pre_segmented_query: boolean | nil, + prefix: String.t() | nil, + preset: String.t() | nil, + prioritize_exact_match: boolean | nil, + prioritize_num_matching_fields: boolean | nil, + prioritize_token_position: boolean | nil, + q: String.t(), + query_by: String.t(), + query_by_weights: String.t() | nil, + remote_embedding_num_tries: integer | nil, + remote_embedding_timeout_ms: integer | nil, + search_cutoff_ms: integer | nil, + snippet_threshold: integer | nil, + sort_by: String.t() | nil, + split_join_tokens: String.t() | nil, + stopwords: String.t() | nil, + text_match_type: String.t() | nil, + typo_tokens_threshold: integer | nil, + use_cache: boolean | nil, + vector_query: String.t() | nil + } + + defstruct [ + :cache_ttl, + :drop_tokens_threshold, + :enable_highlight_v1, + :enable_overrides, + :enable_typos_for_numerical_tokens, + :exclude_fields, + :exhaustive_search, + :facet_by, + :facet_query, + :facet_return_parent, + :facet_strategy, + :filter_by, + :group_by, + :group_limit, + :hidden_hits, + :highlight_affix_num_tokens, + :highlight_end_tag, + :highlight_fields, + :highlight_full_fields, + :highlight_start_tag, + :include_fields, + :infix, + :limit, + :max_candidates, + :max_extra_prefix, + :max_extra_suffix, + :max_facet_values, + :min_len_1typo, + :min_len_2typo, + :num_typos, + :offset, + :override_tags, + :page, + :per_page, + :pinned_hits, + :pre_segmented_query, + :prefix, + :preset, + :prioritize_exact_match, + :prioritize_num_matching_fields, + :prioritize_token_position, + :q, + :query_by, + :query_by_weights, + :remote_embedding_num_tries, + :remote_embedding_timeout_ms, + :search_cutoff_ms, + :snippet_threshold, + :sort_by, + :split_join_tokens, + :stopwords, + :text_match_type, + :typo_tokens_threshold, + :use_cache, + :vector_query + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + cache_ttl: :integer, + drop_tokens_threshold: :integer, + enable_highlight_v1: :boolean, + enable_overrides: :boolean, + enable_typos_for_numerical_tokens: :boolean, + exclude_fields: {:string, :generic}, + exhaustive_search: :boolean, + facet_by: {:string, :generic}, + facet_query: {:string, :generic}, + facet_return_parent: {:string, :generic}, + facet_strategy: {:string, :generic}, + filter_by: {:string, :generic}, + group_by: {:string, :generic}, + group_limit: :integer, + hidden_hits: {:string, :generic}, + highlight_affix_num_tokens: :integer, + highlight_end_tag: {:string, :generic}, + highlight_fields: {:string, :generic}, + highlight_full_fields: {:string, :generic}, + highlight_start_tag: {:string, :generic}, + include_fields: {:string, :generic}, + infix: {:string, :generic}, + limit: :integer, + max_candidates: :integer, + max_extra_prefix: :integer, + max_extra_suffix: :integer, + max_facet_values: :integer, + min_len_1typo: :integer, + min_len_2typo: :integer, + num_typos: {:string, :generic}, + offset: :integer, + override_tags: {:string, :generic}, + page: :integer, + per_page: :integer, + pinned_hits: {:string, :generic}, + pre_segmented_query: :boolean, + prefix: {:string, :generic}, + preset: {:string, :generic}, + prioritize_exact_match: :boolean, + prioritize_num_matching_fields: :boolean, + prioritize_token_position: :boolean, + q: {:string, :generic}, + query_by: {:string, :generic}, + query_by_weights: {:string, :generic}, + remote_embedding_num_tries: :integer, + remote_embedding_timeout_ms: :integer, + search_cutoff_ms: :integer, + snippet_threshold: :integer, + sort_by: {:string, :generic}, + split_join_tokens: {:string, :generic}, + stopwords: {:string, :generic}, + text_match_type: {:string, :generic}, + typo_tokens_threshold: :integer, + use_cache: :boolean, + vector_query: {:string, :generic} + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_result.ex b/lib/open_api_typesense/schemas/search_result.ex new file mode 100644 index 0000000..6c5d09e --- /dev/null +++ b/lib/open_api_typesense/schemas/search_result.ex @@ -0,0 +1,47 @@ +defmodule OpenApiTypesense.SearchResult do + @moduledoc """ + Provides struct and type for a SearchResult + """ + + @type t :: %__MODULE__{ + facet_counts: [OpenApiTypesense.FacetCounts.t()] | nil, + found: integer | nil, + grouped_hits: [OpenApiTypesense.SearchGroupedHit.t()] | nil, + hits: [OpenApiTypesense.SearchResultHit.t()] | nil, + out_of: integer | nil, + page: integer | nil, + request_params: OpenApiTypesense.SearchResultRequestParams.t() | nil, + search_cutoff: boolean | nil, + search_time_ms: integer | nil + } + + defstruct [ + :facet_counts, + :found, + :grouped_hits, + :hits, + :out_of, + :page, + :request_params, + :search_cutoff, + :search_time_ms + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + facet_counts: [{OpenApiTypesense.FacetCounts, :t}], + found: :integer, + grouped_hits: [{OpenApiTypesense.SearchGroupedHit, :t}], + hits: [{OpenApiTypesense.SearchResultHit, :t}], + out_of: :integer, + page: :integer, + request_params: {OpenApiTypesense.SearchResultRequestParams, :t}, + search_cutoff: :boolean, + search_time_ms: :integer + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_result_hit.ex b/lib/open_api_typesense/schemas/search_result_hit.ex new file mode 100644 index 0000000..d0ab060 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_result_hit.ex @@ -0,0 +1,38 @@ +defmodule OpenApiTypesense.SearchResultHit do + @moduledoc """ + Provides struct and type for a SearchResultHit + """ + + @type t :: %__MODULE__{ + document: OpenApiTypesense.SearchResultHitDocument.t() | nil, + geo_distance_meters: OpenApiTypesense.SearchResultHitGeoDistanceMeters.t() | nil, + highlight: map | nil, + highlights: [OpenApiTypesense.SearchHighlight.t()] | nil, + text_match: integer | nil, + vector_distance: number | nil + } + + defstruct [ + :document, + :geo_distance_meters, + :highlight, + :highlights, + :text_match, + :vector_distance + ] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [ + document: {OpenApiTypesense.SearchResultHitDocument, :t}, + geo_distance_meters: {OpenApiTypesense.SearchResultHitGeoDistanceMeters, :t}, + highlight: :map, + highlights: [{OpenApiTypesense.SearchHighlight, :t}], + text_match: :integer, + vector_distance: :number + ] + end +end diff --git a/lib/open_api_typesense/schemas/search_result_hit_document.ex b/lib/open_api_typesense/schemas/search_result_hit_document.ex new file mode 100644 index 0000000..47d1ed0 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_result_hit_document.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchResultHitDocument do + @moduledoc """ + Provides struct and type for a SearchResultHitDocument + """ + + @type t :: %__MODULE__{} + + defstruct [] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [] + end +end diff --git a/lib/open_api_typesense/schemas/search_result_hit_geo_distance_meters.ex b/lib/open_api_typesense/schemas/search_result_hit_geo_distance_meters.ex new file mode 100644 index 0000000..5f89e97 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_result_hit_geo_distance_meters.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchResultHitGeoDistanceMeters do + @moduledoc """ + Provides struct and type for a SearchResultHitGeoDistanceMeters + """ + + @type t :: %__MODULE__{} + + defstruct [] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [] + end +end diff --git a/lib/open_api_typesense/schemas/search_result_request_params.ex b/lib/open_api_typesense/schemas/search_result_request_params.ex new file mode 100644 index 0000000..bdb478c --- /dev/null +++ b/lib/open_api_typesense/schemas/search_result_request_params.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchResultRequestParams do + @moduledoc """ + Provides struct and type for a SearchResultRequestParams + """ + + @type t :: %__MODULE__{collection_name: String.t(), per_page: integer, q: String.t()} + + defstruct [:collection_name, :per_page, :q] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [collection_name: {:string, :generic}, per_page: :integer, q: {:string, :generic}] + end +end diff --git a/lib/open_api_typesense/schemas/search_synonym.ex b/lib/open_api_typesense/schemas/search_synonym.ex new file mode 100644 index 0000000..94011c9 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_synonym.ex @@ -0,0 +1,21 @@ +defmodule OpenApiTypesense.SearchSynonym do + @moduledoc """ + Provides struct and type for a SearchSynonym + """ + + @type t :: %__MODULE__{ + id: String.t() | nil, + root: String.t() | nil, + synonyms: [String.t()] | nil + } + + defstruct [:id, :root, :synonyms] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [id: {:string, :generic}, root: {:string, :generic}, synonyms: [string: :generic]] + end +end diff --git a/lib/open_api_typesense/schemas/search_synonym_schema.ex b/lib/open_api_typesense/schemas/search_synonym_schema.ex new file mode 100644 index 0000000..479a628 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_synonym_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchSynonymSchema do + @moduledoc """ + Provides struct and type for a SearchSynonymSchema + """ + + @type t :: %__MODULE__{root: String.t() | nil, synonyms: [String.t()]} + + defstruct [:root, :synonyms] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [root: {:string, :generic}, synonyms: [string: :generic]] + end +end diff --git a/lib/open_api_typesense/schemas/search_synonyms_response.ex b/lib/open_api_typesense/schemas/search_synonyms_response.ex new file mode 100644 index 0000000..4b77646 --- /dev/null +++ b/lib/open_api_typesense/schemas/search_synonyms_response.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SearchSynonymsResponse do + @moduledoc """ + Provides struct and type for a SearchSynonymsResponse + """ + + @type t :: %__MODULE__{synonyms: [OpenApiTypesense.SearchSynonym.t()]} + + defstruct [:synonyms] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [synonyms: [{OpenApiTypesense.SearchSynonym, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/stopwords_set_retrieve_schema.ex b/lib/open_api_typesense/schemas/stopwords_set_retrieve_schema.ex new file mode 100644 index 0000000..8e5eb50 --- /dev/null +++ b/lib/open_api_typesense/schemas/stopwords_set_retrieve_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.StopwordsSetRetrieveSchema do + @moduledoc """ + Provides struct and type for a StopwordsSetRetrieveSchema + """ + + @type t :: %__MODULE__{stopwords: OpenApiTypesense.StopwordsSetSchema.t()} + + defstruct [:stopwords] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [stopwords: {OpenApiTypesense.StopwordsSetSchema, :t}] + end +end diff --git a/lib/open_api_typesense/schemas/stopwords_set_schema.ex b/lib/open_api_typesense/schemas/stopwords_set_schema.ex new file mode 100644 index 0000000..9d8481e --- /dev/null +++ b/lib/open_api_typesense/schemas/stopwords_set_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.StopwordsSetSchema do + @moduledoc """ + Provides struct and type for a StopwordsSetSchema + """ + + @type t :: %__MODULE__{id: String.t(), locale: String.t() | nil, stopwords: [String.t()]} + + defstruct [:id, :locale, :stopwords] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [id: {:string, :generic}, locale: {:string, :generic}, stopwords: [string: :generic]] + end +end diff --git a/lib/open_api_typesense/schemas/stopwords_set_upsert_schema.ex b/lib/open_api_typesense/schemas/stopwords_set_upsert_schema.ex new file mode 100644 index 0000000..977892c --- /dev/null +++ b/lib/open_api_typesense/schemas/stopwords_set_upsert_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.StopwordsSetUpsertSchema do + @moduledoc """ + Provides struct and type for a StopwordsSetUpsertSchema + """ + + @type t :: %__MODULE__{locale: String.t() | nil, stopwords: [String.t()]} + + defstruct [:locale, :stopwords] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [locale: {:string, :generic}, stopwords: [string: :generic]] + end +end diff --git a/lib/open_api_typesense/schemas/stopwords_sets_retrieve_all_schema.ex b/lib/open_api_typesense/schemas/stopwords_sets_retrieve_all_schema.ex new file mode 100644 index 0000000..4eb2008 --- /dev/null +++ b/lib/open_api_typesense/schemas/stopwords_sets_retrieve_all_schema.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.StopwordsSetsRetrieveAllSchema do + @moduledoc """ + Provides struct and type for a StopwordsSetsRetrieveAllSchema + """ + + @type t :: %__MODULE__{stopwords: [OpenApiTypesense.StopwordsSetSchema.t()]} + + defstruct [:stopwords] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [stopwords: [{OpenApiTypesense.StopwordsSetSchema, :t}]] + end +end diff --git a/lib/open_api_typesense/schemas/success_status.ex b/lib/open_api_typesense/schemas/success_status.ex new file mode 100644 index 0000000..bdd238c --- /dev/null +++ b/lib/open_api_typesense/schemas/success_status.ex @@ -0,0 +1,17 @@ +defmodule OpenApiTypesense.SuccessStatus do + @moduledoc """ + Provides struct and type for a SuccessStatus + """ + + @type t :: %__MODULE__{success: boolean} + + defstruct [:success] + + @doc false + @spec __fields__(atom) :: keyword + def __fields__(type \\ :t) + + def __fields__(:t) do + [success: :boolean] + end +end