···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
33+ SPDX-License-Identifier: ISC
44+ ---------------------------------------------------------------------------*)
55+66+(** Typesense API error handling.
77+88+ Typesense returns errors in a simple format: {"message": "..."} *)
99+1010+(** Typesense error response *)
1111+type t = {
1212+ message : string;
1313+ status_code : int;
1414+}
1515+1616+let error_jsont =
1717+ Jsont.Object.map ~kind:"TypesenseError"
1818+ (fun message -> message)
1919+ |> Jsont.Object.mem "message" Jsont.string ~enc:Fun.id
2020+ |> Jsont.Object.skip_unknown
2121+ |> Jsont.Object.finish
2222+2323+(** Parse an API error into a structured Typesense error. *)
2424+let of_api_error (e : Openapi.Runtime.api_error) : t option =
2525+ match Jsont_bytesrw.decode_string error_jsont e.body with
2626+ | Ok message -> Some { message; status_code = e.status }
2727+ | Error _ -> None
2828+2929+(** {1 Styled Output Helpers} *)
3030+3131+(** Style for error labels (red, bold) *)
3232+let error_style = Fmt.(styled (`Fg `Red) (styled `Bold string))
3333+3434+(** Style for status codes *)
3535+let status_style status =
3636+ if status >= 500 then Fmt.(styled (`Fg `Red) int)
3737+ else if status >= 400 then Fmt.(styled (`Fg `Yellow) int)
3838+ else Fmt.(styled (`Fg `Green) int)
3939+4040+(** Pretty-print a Typesense API error with colors. *)
4141+let pp ppf (e : t) =
4242+ Fmt.pf ppf "%s [%a]" e.message (status_style e.status_code) e.status_code
4343+4444+(** Convert to a human-readable string (without colors). *)
4545+let to_string (e : t) : string =
4646+ Printf.sprintf "%s [%d]" e.message e.status_code
4747+4848+(** Check if this is an authentication/authorization error. *)
4949+let is_auth_error (e : t) =
5050+ e.status_code = 401 || e.status_code = 403
5151+5252+(** Check if this is a "not found" error. *)
5353+let is_not_found (e : t) =
5454+ e.status_code = 404
5555+5656+(** Handle an exception, printing a nice error message if it's an API error.
5757+5858+ Returns an exit code:
5959+ - 1 for most API errors
6060+ - 77 for authentication errors (permission denied)
6161+ - 69 for not found errors *)
6262+let handle_exn exn =
6363+ match exn with
6464+ | Openapi.Runtime.Api_error e ->
6565+ (match of_api_error e with
6666+ | Some err ->
6767+ Fmt.epr "%a %a@." error_style "Error:" pp err;
6868+ if is_auth_error err then 77
6969+ else if is_not_found err then 69
7070+ else 1
7171+ | None ->
7272+ (* Not a Typesense error, show raw response *)
7373+ Fmt.epr "%a %s %s returned %a@.%s@."
7474+ error_style "API Error:"
7575+ e.method_ e.url
7676+ (status_style e.status) e.status
7777+ e.body;
7878+ 1)
7979+ | Failure msg ->
8080+ Fmt.epr "%a %s@." error_style "Error:" msg;
8181+ 1
8282+ | exn ->
8383+ (* Re-raise unknown exceptions *)
8484+ raise exn
8585+8686+(** Wrap a function to handle API errors gracefully. *)
8787+let run f =
8888+ try f (); 0
8989+ with exn -> handle_exn exn
9090+9191+(** Exception to signal desired exit code without calling [exit] directly.
9292+ This avoids issues when running inside Eio's event loop. *)
9393+exception Exit_code of int
9494+9595+(** Wrap a command action to handle API errors gracefully. *)
9696+let wrap f =
9797+ try f ()
9898+ with
9999+ | Stdlib.Exit ->
100100+ (* exit() was called somewhere - treat as success *)
101101+ ()
102102+ | Eio.Cancel.Cancelled Stdlib.Exit ->
103103+ (* Eio wraps Exit in Cancelled - treat as success *)
104104+ ()
105105+ | exn ->
106106+ let code = handle_exn exn in
107107+ raise (Exit_code code)
+76
lib/error.mli
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
33+ SPDX-License-Identifier: ISC
44+ ---------------------------------------------------------------------------*)
55+66+(** Typesense API error handling.
77+88+ The Typesense API returns errors in a simple format:
99+ {[
1010+ {
1111+ "message": "Collection not found"
1212+ }
1313+ ]}
1414+1515+ This module provides utilities for parsing and displaying these errors. *)
1616+1717+(** {1 Error Type} *)
1818+1919+type t = {
2020+ message : string;
2121+ status_code : int;
2222+}
2323+(** A structured Typesense API error. *)
2424+2525+(** {1 Parsing} *)
2626+2727+val of_api_error : Openapi.Runtime.api_error -> t option
2828+(** Parse an API error into a structured Typesense error.
2929+ Returns [None] if the error body is not valid JSON. *)
3030+3131+(** {1 Pretty Printing} *)
3232+3333+val pp : Format.formatter -> t -> unit
3434+(** Pretty-print a Typesense API error.
3535+3636+ Format: "Collection not found [404]" *)
3737+3838+val to_string : t -> string
3939+(** Convert to a human-readable string. *)
4040+4141+(** {1 Error Classification} *)
4242+4343+val is_auth_error : t -> bool
4444+(** Check if this is an authentication/authorization error (401 or 403). *)
4545+4646+val is_not_found : t -> bool
4747+(** Check if this is a "not found" error (404). *)
4848+4949+(** {1 Exception Handling} *)
5050+5151+exception Exit_code of int
5252+(** Exception raised to signal a desired exit code.
5353+ This is used instead of calling [exit] directly to avoid issues
5454+ when running inside Eio's event loop. Catch this exception in
5555+ the main program outside the Eio context. *)
5656+5757+val handle_exn : exn -> int
5858+(** Handle an exception, printing a nice error message if it's an API error.
5959+6060+ Returns an exit code:
6161+ - 1 for most API errors
6262+ - 77 for authentication errors (permission denied)
6363+ - 69 for not found errors
6464+6565+ @raise exn if the exception is not an API error or Failure *)
6666+6767+val run : (unit -> unit) -> int
6868+(** Wrap a function to handle API errors gracefully.
6969+7070+ Returns 0 on success, or an appropriate exit code on error. *)
7171+7272+val wrap : (unit -> unit) -> unit
7373+(** Wrap a command action to handle API errors gracefully.
7474+7575+ Catches API errors, prints a nice message, and raises {!Exit_code}
7676+ with an appropriate code. *)
+159
lib/session.ml
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
33+ SPDX-License-Identifier: ISC
44+ ---------------------------------------------------------------------------*)
55+66+(** Session data for Typesense authentication. *)
77+type t = {
88+ server_url : string;
99+ api_key : string;
1010+ created_at : string;
1111+}
1212+1313+let jsont =
1414+ Jsont.Object.map ~kind:"Session"
1515+ (fun server_url api_key created_at -> { server_url; api_key; created_at })
1616+ |> Jsont.Object.mem "server_url" Jsont.string ~enc:(fun s -> s.server_url)
1717+ |> Jsont.Object.mem "api_key" Jsont.string ~enc:(fun s -> s.api_key)
1818+ |> Jsont.Object.mem "created_at" Jsont.string ~enc:(fun s -> s.created_at)
1919+ |> Jsont.Object.finish
2020+2121+(* App config stores the current profile *)
2222+type app_config = { current_profile : string }
2323+2424+let app_config_jsont =
2525+ Jsont.Object.map ~kind:"AppConfig" (fun current_profile ->
2626+ { current_profile })
2727+ |> Jsont.Object.mem "current_profile" Jsont.string ~enc:(fun c ->
2828+ c.current_profile)
2929+ |> Jsont.Object.finish
3030+3131+let default_profile = "default"
3232+let app_name = "typesense"
3333+3434+(* Base config directory for the app *)
3535+let base_config_dir fs =
3636+ let home = Sys.getenv "HOME" in
3737+ let config_path = Eio.Path.(fs / home / ".config" / app_name) in
3838+ (try Eio.Path.mkdir ~perm:0o700 config_path
3939+ with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ());
4040+ config_path
4141+4242+(* Profiles directory *)
4343+let profiles_dir fs =
4444+ let base = base_config_dir fs in
4545+ let profiles = Eio.Path.(base / "profiles") in
4646+ (try Eio.Path.mkdir ~perm:0o700 profiles
4747+ with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ());
4848+ profiles
4949+5050+(* Config directory for a specific profile *)
5151+let config_dir fs ?profile () =
5252+ let profile_name = Option.value ~default:default_profile profile in
5353+ let profiles = profiles_dir fs in
5454+ let profile_dir = Eio.Path.(profiles / profile_name) in
5555+ (try Eio.Path.mkdir ~perm:0o700 profile_dir
5656+ with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ());
5757+ profile_dir
5858+5959+(* App config file (stores current profile) *)
6060+let app_config_file fs =
6161+ Eio.Path.(base_config_dir fs / "config.json")
6262+6363+let load_app_config fs =
6464+ let path = app_config_file fs in
6565+ try
6666+ Eio.Path.load path
6767+ |> Jsont_bytesrw.decode_string app_config_jsont
6868+ |> Result.to_option
6969+ with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> None
7070+7171+let save_app_config fs config =
7272+ let path = app_config_file fs in
7373+ match
7474+ Jsont_bytesrw.encode_string ~format:Jsont.Indent app_config_jsont config
7575+ with
7676+ | Ok content -> Eio.Path.save ~create:(`Or_truncate 0o600) path content
7777+ | Error e -> failwith ("Failed to encode app config: " ^ e)
7878+7979+(* Get the current profile name *)
8080+let get_current_profile fs =
8181+ match load_app_config fs with
8282+ | Some config -> config.current_profile
8383+ | None -> default_profile
8484+8585+(* Set the current profile *)
8686+let set_current_profile fs profile =
8787+ save_app_config fs { current_profile = profile }
8888+8989+(* List all available profiles *)
9090+let list_profiles fs =
9191+ let profiles = profiles_dir fs in
9292+ try
9393+ Eio.Path.read_dir profiles
9494+ |> List.filter (fun name ->
9595+ (* Check if it's a directory with a session.json *)
9696+ let dir = Eio.Path.(profiles / name) in
9797+ let session = Eio.Path.(dir / "session.json") in
9898+ try
9999+ ignore (Eio.Path.load session);
100100+ true
101101+ with _ -> false)
102102+ |> List.sort String.compare
103103+ with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> []
104104+105105+(* Session file within a profile directory *)
106106+let session_file fs ?profile () =
107107+ Eio.Path.(config_dir fs ?profile () / "session.json")
108108+109109+let load fs ?profile () =
110110+ let profile =
111111+ match profile with
112112+ | Some p -> Some p
113113+ | None ->
114114+ (* Use current profile if none specified *)
115115+ let current = get_current_profile fs in
116116+ Some current
117117+ in
118118+ let path = session_file fs ?profile () in
119119+ try
120120+ Eio.Path.load path |> Jsont_bytesrw.decode_string jsont |> Result.to_option
121121+ with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> None
122122+123123+let save fs ?profile session =
124124+ let profile =
125125+ match profile with
126126+ | Some p -> Some p
127127+ | None -> Some (get_current_profile fs)
128128+ in
129129+ let path = session_file fs ?profile () in
130130+ match Jsont_bytesrw.encode_string ~format:Jsont.Indent jsont session with
131131+ | Ok content -> Eio.Path.save ~create:(`Or_truncate 0o600) path content
132132+ | Error e -> failwith ("Failed to encode session: " ^ e)
133133+134134+let clear fs ?profile () =
135135+ let profile =
136136+ match profile with
137137+ | Some p -> Some p
138138+ | None -> Some (get_current_profile fs)
139139+ in
140140+ let path = session_file fs ?profile () in
141141+ try Eio.Path.unlink path
142142+ with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> ()
143143+144144+(* Styled output helpers *)
145145+let label_style = Fmt.(styled `Faint string)
146146+let value_style = Fmt.(styled (`Fg `Cyan) string)
147147+148148+let pp ppf session =
149149+ Fmt.pf ppf "@[<v>%a %a@,%a %a@,%a %a@]"
150150+ label_style "Server:" value_style session.server_url
151151+ label_style "API Key:" value_style (String.sub session.api_key 0 (min 8 (String.length session.api_key)) ^ "...")
152152+ label_style "Created:" value_style session.created_at
153153+154154+let server_url t = t.server_url
155155+let api_key t = t.api_key
156156+let created_at t = t.created_at
157157+158158+let create ~server_url ~api_key () =
159159+ { server_url; api_key; created_at = Ptime.to_rfc3339 (Ptime_clock.now ()) }
+105
lib/session.mli
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
33+ SPDX-License-Identifier: ISC
44+ ---------------------------------------------------------------------------*)
55+66+(** Session management for Typesense CLI with profile support.
77+88+ This module provides session persistence for Typesense authentication
99+ using API keys. Sessions are stored in profile-specific directories
1010+ under [~/.config/typesense/profiles/<profile>/session.json].
1111+1212+ {2 Directory Structure}
1313+1414+ {v
1515+ ~/.config/typesense/
1616+ config.json # Stores current_profile setting
1717+ profiles/
1818+ default/
1919+ session.json # Session for "default" profile
2020+ prod/
2121+ session.json # Session for "prod" profile
2222+ v}
2323+2424+ {[
2525+ (* Login with API key *)
2626+ let session = Session.create
2727+ ~server_url:"http://localhost:8108"
2828+ ~api_key:"xyz"
2929+ () in
3030+ Session.save fs ~profile:"default" session
3131+ ]} *)
3232+3333+(** {1 Types} *)
3434+3535+type t
3636+(** Session data. *)
3737+3838+val jsont : t Jsont.t
3939+(** JSON codec for sessions. *)
4040+4141+(** {1 Session Construction} *)
4242+4343+val create : server_url:string -> api_key:string -> unit -> t
4444+(** [create ~server_url ~api_key ()] creates a new session with the current timestamp. *)
4545+4646+(** {1 Session Accessors} *)
4747+4848+val server_url : t -> string
4949+(** [server_url t] returns the server URL. *)
5050+5151+val api_key : t -> string
5252+(** [api_key t] returns the API key. *)
5353+5454+val created_at : t -> string
5555+(** [created_at t] returns the creation timestamp (RFC 3339). *)
5656+5757+(** {1 Profile Management} *)
5858+5959+val default_profile : string
6060+(** The default profile name (["default"]). *)
6161+6262+val get_current_profile : Eio.Fs.dir_ty Eio.Path.t -> string
6363+(** [get_current_profile fs] returns the current profile name. Returns
6464+ {!default_profile} if no profile has been set. *)
6565+6666+val set_current_profile : Eio.Fs.dir_ty Eio.Path.t -> string -> unit
6767+(** [set_current_profile fs profile] sets the current profile. *)
6868+6969+val list_profiles : Eio.Fs.dir_ty Eio.Path.t -> string list
7070+(** [list_profiles fs] returns all profiles that have sessions.
7171+ Returns profile names sorted alphabetically. *)
7272+7373+(** {1 Directory Paths} *)
7474+7575+val base_config_dir : Eio.Fs.dir_ty Eio.Path.t -> Eio.Fs.dir_ty Eio.Path.t
7676+(** [base_config_dir fs] returns the base config directory
7777+ ([~/.config/typesense]), creating it if needed. *)
7878+7979+val config_dir :
8080+ Eio.Fs.dir_ty Eio.Path.t ->
8181+ ?profile:string ->
8282+ unit ->
8383+ Eio.Fs.dir_ty Eio.Path.t
8484+(** [config_dir fs ?profile ()] returns the config directory for a
8585+ profile, creating it if needed.
8686+ @param profile Profile name (default: current profile) *)
8787+8888+(** {1 Session Persistence} *)
8989+9090+val save : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> t -> unit
9191+(** [save fs ?profile session] saves the session.
9292+ @param profile Profile name (default: current profile) *)
9393+9494+val load : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> t option
9595+(** [load fs ?profile ()] loads a saved session.
9696+ @param profile Profile name (default: current profile) *)
9797+9898+val clear : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> unit
9999+(** [clear fs ?profile ()] removes the saved session.
100100+ @param profile Profile name (default: current profile) *)
101101+102102+(** {1 Session Utilities} *)
103103+104104+val pp : t Fmt.t
105105+(** Pretty-print a session. *)
-181
lib/typesense/analytics.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type rule_type = Popular_queries | Nohits_queries | Counter
77-88-let rule_type_to_string = function
99- | Popular_queries -> "popular_queries"
1010- | Nohits_queries -> "nohits_queries"
1111- | Counter -> "counter"
1212-1313-let rule_type_of_string = function
1414- | "popular_queries" -> Popular_queries
1515- | "nohits_queries" -> Nohits_queries
1616- | "counter" -> Counter
1717- | s -> failwith ("Unknown rule type: " ^ s)
1818-1919-let rule_type_jsont =
2020- Jsont.of_of_string ~kind:"RuleType" (fun s -> Ok (rule_type_of_string s))
2121- ~enc:rule_type_to_string
2222-2323-type destination = { collection : string }
2424-2525-let destination_jsont =
2626- Jsont.Object.map ~kind:"Destination" (fun collection -> { collection })
2727- |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun d -> d.collection)
2828- |> Jsont.Object.skip_unknown
2929- |> Jsont.Object.finish
3030-3131-type source = {
3232- collections : string list;
3333- events : Jsont.json option;
3434-}
3535-3636-let source_jsont =
3737- let make collections events = { collections; events } in
3838- Jsont.Object.map ~kind:"Source" make
3939- |> Jsont.Object.mem "collections" (Jsont.list Jsont.string)
4040- ~enc:(fun s -> s.collections)
4141- |> Jsont.Object.opt_mem "events" Jsont.json ~enc:(fun s -> s.events)
4242- |> Jsont.Object.skip_unknown
4343- |> Jsont.Object.finish
4444-4545-type rule_params = {
4646- source : source;
4747- destination : destination;
4848- limit : int option;
4949- expand_query : bool option;
5050-}
5151-5252-let rule_params_jsont =
5353- let make source destination limit expand_query =
5454- { source; destination; limit; expand_query }
5555- in
5656- Jsont.Object.map ~kind:"RuleParams" make
5757- |> Jsont.Object.mem "source" source_jsont ~enc:(fun p -> p.source)
5858- |> Jsont.Object.mem "destination" destination_jsont ~enc:(fun p -> p.destination)
5959- |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun p -> p.limit)
6060- |> Jsont.Object.opt_mem "expand_query" Jsont.bool ~enc:(fun p -> p.expand_query)
6161- |> Jsont.Object.skip_unknown
6262- |> Jsont.Object.finish
6363-6464-type rule = {
6565- name : string;
6666- type_ : rule_type;
6767- params : rule_params;
6868-}
6969-7070-let rule_jsont =
7171- let make name type_ params = { name; type_; params } in
7272- Jsont.Object.map ~kind:"Rule" make
7373- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
7474- |> Jsont.Object.mem "type" rule_type_jsont ~enc:(fun r -> r.type_)
7575- |> Jsont.Object.mem "params" rule_params_jsont ~enc:(fun r -> r.params)
7676- |> Jsont.Object.skip_unknown
7777- |> Jsont.Object.finish
7878-7979-let rule ~name ~type_ ~params = { name; type_; params }
8080-8181-let rule_params ~source_collections ~destination_collection ?limit
8282- ?expand_query ?events () =
8383- {
8484- source = { collections = source_collections; events };
8585- destination = { collection = destination_collection };
8686- limit;
8787- expand_query;
8888- }
8989-9090-type rules_response = { rules : rule list }
9191-9292-let rules_response_jsont =
9393- Jsont.Object.map ~kind:"RulesResponse" (fun rules -> { rules })
9494- |> Jsont.Object.mem "rules" (Jsont.list rule_jsont) ~enc:(fun r -> r.rules)
9595- |> Jsont.Object.skip_unknown
9696- |> Jsont.Object.finish
9797-9898-let list_rules client =
9999- let json = Client.request client ~method_:`GET ~path:"/analytics/rules" () in
100100- let response = Encode.decode_or_raise rules_response_jsont json "list rules" in
101101- response.rules
102102-103103-let get_rule client ~name =
104104- let path = "/analytics/rules/" ^ Uri.pct_encode name in
105105- let json = Client.request client ~method_:`GET ~path () in
106106- Encode.decode_or_raise rule_jsont json ("get rule " ^ name)
107107-108108-let create_rule client rule =
109109- let body = Encode.to_json_string rule_jsont rule in
110110- let json = Client.request client ~method_:`POST ~path:"/analytics/rules" ~body () in
111111- Encode.decode_or_raise rule_jsont json ("create rule " ^ rule.name)
112112-113113-let upsert_rule client rule =
114114- let path = "/analytics/rules/" ^ Uri.pct_encode rule.name in
115115- let body = Encode.to_json_string rule_jsont rule in
116116- let json = Client.request client ~method_:`PUT ~path ~body () in
117117- Encode.decode_or_raise rule_jsont json ("upsert rule " ^ rule.name)
118118-119119-type delete_result = { name : string }
120120-121121-let delete_result_jsont =
122122- Jsont.Object.map ~kind:"DeleteResult" (fun name -> { name })
123123- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
124124- |> Jsont.Object.skip_unknown
125125- |> Jsont.Object.finish
126126-127127-let delete_rule client ~name =
128128- let path = "/analytics/rules/" ^ Uri.pct_encode name in
129129- let json = Client.request client ~method_:`DELETE ~path () in
130130- let _ = Encode.decode_or_raise delete_result_jsont json ("delete rule " ^ name) in
131131- ()
132132-133133-type event_type = Search | Click | Conversion | Visit | Custom of string
134134-135135-let event_type_to_string = function
136136- | Search -> "search"
137137- | Click -> "click"
138138- | Conversion -> "conversion"
139139- | Visit -> "visit"
140140- | Custom s -> s
141141-142142-let event_type_of_string = function
143143- | "search" -> Search
144144- | "click" -> Click
145145- | "conversion" -> Conversion
146146- | "visit" -> Visit
147147- | s -> Custom s
148148-149149-let event_type_jsont =
150150- Jsont.of_of_string ~kind:"EventType" (fun s -> Ok (event_type_of_string s))
151151- ~enc:event_type_to_string
152152-153153-type event = {
154154- type_ : event_type;
155155- name : string;
156156- data : Jsont.json;
157157-}
158158-159159-let event_jsont =
160160- let make type_ name data = { type_; name; data } in
161161- Jsont.Object.map ~kind:"Event" make
162162- |> Jsont.Object.mem "type" event_type_jsont ~enc:(fun e -> e.type_)
163163- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun e -> e.name)
164164- |> Jsont.Object.mem "data" Jsont.json ~enc:(fun e -> e.data)
165165- |> Jsont.Object.finish
166166-167167-let event ~type_ ~name ~data = { type_; name; data }
168168-169169-type event_response = { ok : bool }
170170-171171-let event_response_jsont =
172172- Jsont.Object.map ~kind:"EventResponse" (fun ok -> { ok })
173173- |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok)
174174- |> Jsont.Object.skip_unknown
175175- |> Jsont.Object.finish
176176-177177-let create_event client event =
178178- let body = Encode.to_json_string event_jsont event in
179179- let json = Client.request client ~method_:`POST ~path:"/analytics/events" ~body () in
180180- let _ = Encode.decode_or_raise event_response_jsont json "create event" in
181181- ()
-113
lib/typesense/analytics.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense analytics rules and events.
77-88- This module provides support for creating and managing analytics rules
99- and tracking events. Analytics rules automatically aggregate search queries
1010- into collections for analysis. *)
1111-1212-(** {1 Rule Types} *)
1313-1414-type rule_type =
1515- | Popular_queries (** Track popular search queries *)
1616- | Nohits_queries (** Track queries with no results *)
1717- | Counter (** Generic counter for events *)
1818-(** Type of analytics rule. *)
1919-2020-val rule_type_jsont : rule_type Jsont.t
2121-2222-type destination = { collection : string }
2323-(** Destination collection for aggregated data. *)
2424-2525-type source = {
2626- collections : string list; (** Source collections to track *)
2727- events : Jsont.json option; (** Event configuration *)
2828-}
2929-(** Source configuration for analytics. *)
3030-3131-type rule_params = {
3232- source : source;
3333- destination : destination;
3434- limit : int option; (** Max entries to store *)
3535- expand_query : bool option; (** Expand queries before storing *)
3636-}
3737-(** Parameters for analytics rules. *)
3838-3939-val rule_params :
4040- source_collections:string list ->
4141- destination_collection:string ->
4242- ?limit:int ->
4343- ?expand_query:bool ->
4444- ?events:Jsont.json ->
4545- unit ->
4646- rule_params
4747-(** [rule_params ~source_collections ~destination_collection ...] creates rule
4848- parameters. *)
4949-5050-type rule = {
5151- name : string; (** Unique rule name *)
5252- type_ : rule_type; (** Rule type *)
5353- params : rule_params; (** Rule parameters *)
5454-}
5555-(** An analytics rule. *)
5656-5757-val rule : name:string -> type_:rule_type -> params:rule_params -> rule
5858-(** [rule ~name ~type_ ~params] creates an analytics rule. *)
5959-6060-val rule_jsont : rule Jsont.t
6161-(** JSON codec for rules. *)
6262-6363-(** {1 Rule Operations} *)
6464-6565-val list_rules : Client.t -> rule list
6666-(** [list_rules client] returns all analytics rules.
6767- @raise Eio.Io with [Error.E] on API errors *)
6868-6969-val get_rule : Client.t -> name:string -> rule
7070-(** [get_rule client ~name] retrieves a rule by name.
7171- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
7272-7373-val create_rule : Client.t -> rule -> rule
7474-(** [create_rule client rule] creates a new analytics rule.
7575- @raise Eio.Io with [Error.E { code = Conflict; _ }] if already exists *)
7676-7777-val upsert_rule : Client.t -> rule -> rule
7878-(** [upsert_rule client rule] creates or updates an analytics rule. *)
7979-8080-val delete_rule : Client.t -> name:string -> unit
8181-(** [delete_rule client ~name] deletes an analytics rule.
8282- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
8383-8484-(** {1 Event Types} *)
8585-8686-type event_type =
8787- | Search (** Search event *)
8888- | Click (** Click event *)
8989- | Conversion (** Conversion event *)
9090- | Visit (** Visit event *)
9191- | Custom of string (** Custom event type *)
9292-(** Type of analytics event. *)
9393-9494-val event_type_jsont : event_type Jsont.t
9595-9696-type event = {
9797- type_ : event_type; (** Event type *)
9898- name : string; (** Event name (rule name to track) *)
9999- data : Jsont.json; (** Event data *)
100100-}
101101-(** An analytics event. *)
102102-103103-val event : type_:event_type -> name:string -> data:Jsont.json -> event
104104-(** [event ~type_ ~name ~data] creates an analytics event. *)
105105-106106-val event_jsont : event Jsont.t
107107-(** JSON codec for events. *)
108108-109109-(** {1 Event Operations} *)
110110-111111-val create_event : Client.t -> event -> unit
112112-(** [create_event client event] records an analytics event.
113113- @raise Eio.Io with [Error.E] on API errors *)
-28
lib/typesense/auth.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type t = { endpoint : string; api_key : string }
77-88-let create ~endpoint ~api_key = { endpoint; api_key }
99-1010-let from_env ?endpoint_var ?api_key_var () =
1111- let endpoint_var = Option.value ~default:"TYPESENSE_API_ENDPOINT" endpoint_var in
1212- let api_key_var = Option.value ~default:"TYPESENSE_API_KEY" api_key_var in
1313- match (Sys.getenv_opt endpoint_var, Sys.getenv_opt api_key_var) with
1414- | Some endpoint, Some api_key -> Some { endpoint; api_key }
1515- | _ -> None
1616-1717-let endpoint t = t.endpoint
1818-let api_key t = t.api_key
1919-2020-let default_headers t =
2121- [
2222- ("X-TYPESENSE-API-KEY", t.api_key);
2323- ("Content-Type", "application/json");
2424- ("User-Agent", "OCaml-Typesense/1.0");
2525- ]
2626-2727-let pp fmt t =
2828- Format.fprintf fmt "Auth{endpoint=%s}" t.endpoint
-38
lib/typesense/auth.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Authentication for the Typesense API.
77-88- This module handles authentication credentials for connecting to a Typesense
99- server. Typesense uses API key authentication via the [X-TYPESENSE-API-KEY]
1010- header. *)
1111-1212-type t
1313-(** Authentication credentials. *)
1414-1515-val create : endpoint:string -> api_key:string -> t
1616-(** [create ~endpoint ~api_key] creates authentication credentials directly.
1717- @param endpoint The Typesense server URL (e.g., "http://localhost:8108")
1818- @param api_key The Typesense API key *)
1919-2020-val from_env : ?endpoint_var:string -> ?api_key_var:string -> unit -> t option
2121-(** [from_env ?endpoint_var ?api_key_var ()] loads credentials from environment
2222- variables.
2323- @param endpoint_var Environment variable for endpoint (default: TYPESENSE_API_ENDPOINT)
2424- @param api_key_var Environment variable for API key (default: TYPESENSE_API_KEY)
2525- @return [Some t] if both variables are set, [None] otherwise *)
2626-2727-val endpoint : t -> string
2828-(** [endpoint t] returns the Typesense server endpoint. *)
2929-3030-val api_key : t -> string
3131-(** [api_key t] returns the API key. *)
3232-3333-val default_headers : t -> (string * string) list
3434-(** [default_headers t] returns the default HTTP headers for authentication.
3535- Includes the API key header, Content-Type, and User-Agent. *)
3636-3737-val pp : Format.formatter -> t -> unit
3838-(** Pretty printer for authentication (shows endpoint only, not credentials). *)
-101
lib/typesense/client.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-let src = Logs.Src.create "typesense.client" ~doc:"Typesense API client"
77-88-module Log = (val Logs.src_log src : Logs.LOG)
99-1010-type t = { auth : Auth.t; session : Requests.t }
1111-1212-let create ?session ~sw env auth =
1313- Log.info (fun m -> m "Creating Typesense client for %s" (Auth.endpoint auth));
1414- let session = match session with
1515- | Some s -> s
1616- | None -> Requests.create ~sw ~follow_redirects:true ~verify_tls:true env
1717- in
1818- { auth; session }
1919-2020-let with_client ?session env auth f =
2121- Eio.Switch.run @@ fun sw ->
2222- let client = create ?session ~sw env auth in
2323- f client
2424-2525-let auth_headers t =
2626- Requests.Headers.of_list (Auth.default_headers t.auth)
2727-2828-let method_to_string = function
2929- | `GET -> "GET"
3030- | `POST -> "POST"
3131- | `PUT -> "PUT"
3232- | `DELETE -> "DELETE"
3333- | `PATCH -> "PATCH"
3434-3535-let build_url base_url params =
3636- match params with
3737- | None -> base_url
3838- | Some p ->
3939- Uri.of_string base_url
4040- |> Fun.flip
4141- (List.fold_left (fun u (k, v) -> Uri.add_query_param' u (k, v)))
4242- p
4343- |> Uri.to_string
4444-4545-let make_request t ~method_ ~url ~body_opt =
4646- let headers = auth_headers t in
4747- match method_ with
4848- | `GET -> Requests.get t.session ~headers url
4949- | `POST -> Requests.post t.session ~headers ?body:body_opt url
5050- | `PUT -> Requests.put t.session ~headers ?body:body_opt url
5151- | `DELETE -> Requests.delete t.session ~headers url
5252- | `PATCH -> Requests.patch t.session ~headers ?body:body_opt url
5353-5454-let request t ~method_ ~path ?params ?body () =
5555- let url = build_url (Auth.endpoint t.auth ^ path) params in
5656- Log.debug (fun m -> m "Request: %s %s" (method_to_string method_) path);
5757- let body_opt =
5858- Option.map (fun s -> Requests.Body.of_string Requests.Mime.json s) body
5959- in
6060- let response = make_request t ~method_ ~url ~body_opt in
6161- let status = Requests.Response.status_code response in
6262- Log.debug (fun m -> m "Response status: %d" status);
6363- let json = Requests.Response.json response in
6464- if status >= 400 then begin
6565- let message =
6666- match json with
6767- | Jsont.Object (fields, _) -> (
6868- let assoc = List.map (fun ((k, _), v) -> (k, v)) fields in
6969- match List.assoc_opt "message" assoc with
7070- | Some (Jsont.String (s, _)) -> s
7171- | _ -> "Unknown error")
7272- | _ -> "Unknown error"
7373- in
7474- Error.raise_with_context
7575- (Error.make ~code:(Error.code_of_status status) ~message)
7676- "%s" path
7777- end;
7878- json
7979-8080-let request_raw t ~method_ ~path ?params ?body () =
8181- let url = build_url (Auth.endpoint t.auth ^ path) params in
8282- Log.debug (fun m -> m "Request (raw): %s %s" (method_to_string method_) path);
8383- let body_opt =
8484- Option.map
8585- (fun s ->
8686- Requests.Body.of_string
8787- (Requests.Mime.of_string "application/x-ndjson")
8888- s)
8989- body
9090- in
9191- let response = make_request t ~method_ ~url ~body_opt in
9292- let status = Requests.Response.status_code response in
9393- Log.debug (fun m -> m "Response status: %d" status);
9494- let body_str = Requests.Response.text response in
9595- if status >= 400 then
9696- Error.raise_with_context
9797- (Error.make ~code:(Error.code_of_status status) ~message:body_str)
9898- "%s" path;
9999- body_str
100100-101101-let pp fmt t = Format.fprintf fmt "Client(endpoint=%s)" (Auth.endpoint t.auth)
-71
lib/typesense/client.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** HTTP client for making requests to the Typesense API.
77-88- This module provides the low-level HTTP client for communicating with the
99- Typesense API. All API errors are raised as [Eio.Io] exceptions with
1010- [Error.E] error codes, following the Eio error pattern.
1111-1212- @raise Eio.Io with [Error.E error] for API errors *)
1313-1414-type t
1515-(** Type representing a Typesense HTTP client *)
1616-1717-val create :
1818- ?session:Requests.t ->
1919- sw:Eio.Switch.t ->
2020- < clock : float Eio.Time.clock_ty Eio.Resource.t
2121- ; net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t
2222- ; fs : Eio.Fs.dir_ty Eio.Path.t
2323- ; .. > ->
2424- Auth.t ->
2525- t
2626-(** [create ?session ~sw env auth] creates a new client with the given switch,
2727- environment and authentication. If [session] is provided, it is reused;
2828- otherwise a new session is created. The environment must have clock, net,
2929- and fs capabilities. *)
3030-3131-val with_client :
3232- ?session:Requests.t ->
3333- < clock : float Eio.Time.clock_ty Eio.Resource.t
3434- ; net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t
3535- ; fs : Eio.Fs.dir_ty Eio.Path.t
3636- ; .. > ->
3737- Auth.t ->
3838- (t -> 'a) ->
3939- 'a
4040-(** [with_client ?session env auth f] runs [f] with a client that is
4141- automatically cleaned up. If [session] is provided, it is reused. The
4242- environment must have clock, net, and fs capabilities. *)
4343-4444-val request :
4545- t ->
4646- method_:[ `GET | `POST | `PUT | `DELETE | `PATCH ] ->
4747- path:string ->
4848- ?params:(string * string) list ->
4949- ?body:string ->
5050- unit ->
5151- Jsont.json
5252-(** [request t ~method_ ~path ?params ?body ()] makes an HTTP request to the
5353- Typesense API and returns the JSON response.
5454- @param params Optional query parameters
5555- @param body Optional JSON request body
5656- @raise Eio.Io with [Error.E error] on API errors *)
5757-5858-val request_raw :
5959- t ->
6060- method_:[ `GET | `POST | `PUT | `DELETE | `PATCH ] ->
6161- path:string ->
6262- ?params:(string * string) list ->
6363- ?body:string ->
6464- unit ->
6565- string
6666-(** [request_raw t ~method_ ~path ?params ?body ()] makes an HTTP request and
6767- returns the raw response body as a string. Used for JSONL import responses.
6868- @raise Eio.Io with [Error.E error] on API errors *)
6969-7070-val pp : Format.formatter -> t -> unit
7171-(** Pretty printer for client (shows endpoint only, not credentials) *)
-144
lib/typesense/collection.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type field = {
77- name : string;
88- type_ : string;
99- facet : bool option;
1010- optional : bool option;
1111- index : bool option;
1212- sort : bool option;
1313- infix : bool option;
1414- locale : string option;
1515- num_dim : int option;
1616-}
1717-1818-let field_jsont =
1919- let make name type_ facet optional index sort infix locale num_dim =
2020- { name; type_; facet; optional; index; sort; infix; locale; num_dim }
2121- in
2222- Jsont.Object.map ~kind:"Field" make
2323- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun f -> f.name)
2424- |> Jsont.Object.mem "type" Jsont.string ~enc:(fun f -> f.type_)
2525- |> Jsont.Object.opt_mem "facet" Jsont.bool ~enc:(fun f -> f.facet)
2626- |> Jsont.Object.opt_mem "optional" Jsont.bool ~enc:(fun f -> f.optional)
2727- |> Jsont.Object.opt_mem "index" Jsont.bool ~enc:(fun f -> f.index)
2828- |> Jsont.Object.opt_mem "sort" Jsont.bool ~enc:(fun f -> f.sort)
2929- |> Jsont.Object.opt_mem "infix" Jsont.bool ~enc:(fun f -> f.infix)
3030- |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun f -> f.locale)
3131- |> Jsont.Object.opt_mem "num_dim" Jsont.int ~enc:(fun f -> f.num_dim)
3232- |> Jsont.Object.skip_unknown
3333- |> Jsont.Object.finish
3434-3535-let field ~name ~type_ ?facet ?optional ?index ?sort ?infix ?locale ?num_dim () =
3636- { name; type_; facet; optional; index; sort; infix; locale; num_dim }
3737-3838-type schema = {
3939- name : string;
4040- fields : field list;
4141- default_sorting_field : string option;
4242- token_separators : string list option;
4343- symbols_to_index : string list option;
4444- enable_nested_fields : bool option;
4545-}
4646-4747-let schema_jsont =
4848- let make name fields default_sorting_field token_separators symbols_to_index
4949- enable_nested_fields =
5050- {
5151- name;
5252- fields;
5353- default_sorting_field;
5454- token_separators;
5555- symbols_to_index;
5656- enable_nested_fields;
5757- }
5858- in
5959- Jsont.Object.map ~kind:"Schema" make
6060- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun s -> s.name)
6161- |> Jsont.Object.mem "fields" (Jsont.list field_jsont) ~enc:(fun s -> s.fields)
6262- |> Jsont.Object.opt_mem "default_sorting_field" Jsont.string
6363- ~enc:(fun s -> s.default_sorting_field)
6464- |> Jsont.Object.opt_mem "token_separators" (Jsont.list Jsont.string)
6565- ~enc:(fun s -> s.token_separators)
6666- |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string)
6767- ~enc:(fun s -> s.symbols_to_index)
6868- |> Jsont.Object.opt_mem "enable_nested_fields" Jsont.bool
6969- ~enc:(fun s -> s.enable_nested_fields)
7070- |> Jsont.Object.skip_unknown
7171- |> Jsont.Object.finish
7272-7373-let schema ~name ~fields ?default_sorting_field ?token_separators
7474- ?symbols_to_index ?enable_nested_fields () =
7575- {
7676- name;
7777- fields;
7878- default_sorting_field;
7979- token_separators;
8080- symbols_to_index;
8181- enable_nested_fields;
8282- }
8383-8484-type t = {
8585- name : string;
8686- num_documents : int;
8787- fields : field list;
8888- default_sorting_field : string option;
8989- enable_nested_fields : bool option;
9090-}
9191-9292-let jsont =
9393- let make name num_documents fields default_sorting_field enable_nested_fields =
9494- { name; num_documents; fields; default_sorting_field; enable_nested_fields }
9595- in
9696- Jsont.Object.map ~kind:"Collection" make
9797- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun c -> c.name)
9898- |> Jsont.Object.mem "num_documents" Jsont.int ~enc:(fun c -> c.num_documents)
9999- |> Jsont.Object.mem "fields" (Jsont.list field_jsont) ~enc:(fun c -> c.fields)
100100- |> Jsont.Object.opt_mem "default_sorting_field" Jsont.string
101101- ~enc:(fun c -> c.default_sorting_field)
102102- |> Jsont.Object.opt_mem "enable_nested_fields" Jsont.bool
103103- ~enc:(fun c -> c.enable_nested_fields)
104104- |> Jsont.Object.skip_unknown
105105- |> Jsont.Object.finish
106106-107107-let name t = t.name
108108-let num_documents t = t.num_documents
109109-let fields t = t.fields
110110-let default_sorting_field t = t.default_sorting_field
111111-112112-let list client =
113113- let json = Client.request client ~method_:`GET ~path:"/collections" () in
114114- Encode.decode_or_raise (Jsont.list jsont) json "listing collections"
115115-116116-let get client ~name =
117117- let path = "/collections/" ^ Uri.pct_encode name in
118118- let json = Client.request client ~method_:`GET ~path () in
119119- Encode.decode_or_raise jsont json ("getting collection " ^ name)
120120-121121-let create client schema =
122122- let body = Encode.to_json_string schema_jsont schema in
123123- let json = Client.request client ~method_:`POST ~path:"/collections" ~body () in
124124- Encode.decode_or_raise jsont json ("creating collection " ^ schema.name)
125125-126126-type delete_result = { name : string }
127127-128128-let delete_result_jsont =
129129- Jsont.Object.map ~kind:"DeleteResult" (fun name -> { name })
130130- |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
131131- |> Jsont.Object.skip_unknown
132132- |> Jsont.Object.finish
133133-134134-let delete client ~name =
135135- let path = "/collections/" ^ Uri.pct_encode name in
136136- let json = Client.request client ~method_:`DELETE ~path () in
137137- let _ = Encode.decode_or_raise delete_result_jsont json ("deleting collection " ^ name) in
138138- ()
139139-140140-let exists client ~name =
141141- try
142142- let _ = get client ~name in
143143- true
144144- with Eio.Io (Error.E { code = Not_found; _ }, _) -> false
-114
lib/typesense/collection.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense collection management.
77-88- This module provides types and operations for managing Typesense collections.
99- A collection is a group of related documents with a defined schema. *)
1010-1111-(** {1 Field Types} *)
1212-1313-type field = {
1414- name : string; (** Field name *)
1515- type_ : string; (** Field type (string, int32, float, bool, etc.) *)
1616- facet : bool option; (** Whether field is facetable *)
1717- optional : bool option; (** Whether field is optional *)
1818- index : bool option; (** Whether to index this field *)
1919- sort : bool option; (** Whether field is sortable *)
2020- infix : bool option; (** Enable infix search *)
2121- locale : string option; (** Locale for string fields *)
2222- num_dim : int option; (** Number of dimensions for vector fields *)
2323-}
2424-(** A field definition in a collection schema. *)
2525-2626-val field :
2727- name:string ->
2828- type_:string ->
2929- ?facet:bool ->
3030- ?optional:bool ->
3131- ?index:bool ->
3232- ?sort:bool ->
3333- ?infix:bool ->
3434- ?locale:string ->
3535- ?num_dim:int ->
3636- unit ->
3737- field
3838-(** [field ~name ~type_ ...] creates a field definition. Common types:
3939- - ["string"], ["string[]] - Text fields
4040- - ["int32"], ["int64"], ["float"] - Numeric fields
4141- - ["bool"] - Boolean field
4242- - ["auto"] - Auto-detect type
4343- - ["float[]] - Vector field (requires [num_dim]) *)
4444-4545-val field_jsont : field Jsont.t
4646-(** JSON codec for fields. *)
4747-4848-(** {1 Schema Types} *)
4949-5050-type schema = {
5151- name : string; (** Collection name *)
5252- fields : field list; (** Field definitions *)
5353- default_sorting_field : string option; (** Default field for sorting *)
5454- token_separators : string list option; (** Custom token separators *)
5555- symbols_to_index : string list option; (** Symbols to index *)
5656- enable_nested_fields : bool option; (** Enable nested object fields *)
5757-}
5858-(** A collection schema for creating new collections. *)
5959-6060-val schema :
6161- name:string ->
6262- fields:field list ->
6363- ?default_sorting_field:string ->
6464- ?token_separators:string list ->
6565- ?symbols_to_index:string list ->
6666- ?enable_nested_fields:bool ->
6767- unit ->
6868- schema
6969-(** [schema ~name ~fields ...] creates a collection schema. *)
7070-7171-val schema_jsont : schema Jsont.t
7272-(** JSON codec for schemas. *)
7373-7474-(** {1 Collection Type} *)
7575-7676-type t = {
7777- name : string; (** Collection name *)
7878- num_documents : int; (** Number of documents in collection *)
7979- fields : field list; (** Field definitions *)
8080- default_sorting_field : string option; (** Default sorting field *)
8181- enable_nested_fields : bool option; (** Whether nested fields are enabled *)
8282-}
8383-(** A collection as returned by the API. *)
8484-8585-val jsont : t Jsont.t
8686-(** JSON codec for collections. *)
8787-8888-(** {1 Accessors} *)
8989-9090-val name : t -> string
9191-val num_documents : t -> int
9292-val fields : t -> field list
9393-val default_sorting_field : t -> string option
9494-9595-(** {1 Operations} *)
9696-9797-val list : Client.t -> t list
9898-(** [list client] returns all collections.
9999- @raise Eio.Io with [Error.E] on API errors *)
100100-101101-val get : Client.t -> name:string -> t
102102-(** [get client ~name] retrieves a collection by name.
103103- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
104104-105105-val create : Client.t -> schema -> t
106106-(** [create client schema] creates a new collection.
107107- @raise Eio.Io with [Error.E { code = Conflict; _ }] if already exists *)
108108-109109-val delete : Client.t -> name:string -> unit
110110-(** [delete client ~name] deletes a collection.
111111- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
112112-113113-val exists : Client.t -> name:string -> bool
114114-(** [exists client ~name] returns [true] if the collection exists. *)
-128
lib/typesense/document.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type action = Create | Upsert | Update | Emplace
77-88-let action_to_string = function
99- | Create -> "create"
1010- | Upsert -> "upsert"
1111- | Update -> "update"
1212- | Emplace -> "emplace"
1313-1414-type import_result = {
1515- success : bool;
1616- error : string option;
1717- document : string option;
1818-}
1919-2020-let import_result_jsont =
2121- let make success error document = { success; error; document } in
2222- Jsont.Object.map ~kind:"ImportResult" make
2323- |> Jsont.Object.mem "success" Jsont.bool ~enc:(fun r -> r.success)
2424- |> Jsont.Object.opt_mem "error" Jsont.string ~enc:(fun r -> r.error)
2525- |> Jsont.Object.opt_mem "document" Jsont.string ~enc:(fun r -> r.document)
2626- |> Jsont.Object.skip_unknown
2727- |> Jsont.Object.finish
2828-2929-let import client ~collection ?(action = Upsert) ?(batch_size = 40)
3030- ?(return_doc = false) ?(return_id = false) documents =
3131- let path =
3232- "/collections/" ^ Uri.pct_encode collection ^ "/documents/import"
3333- in
3434- let params =
3535- [
3636- ("action", action_to_string action);
3737- ("batch_size", string_of_int batch_size);
3838- ("return_doc", string_of_bool return_doc);
3939- ("return_id", string_of_bool return_id);
4040- ]
4141- in
4242- (* Convert documents to JSONL format *)
4343- let body =
4444- documents
4545- |> List.map (fun doc -> Encode.to_json_string Jsont.json doc)
4646- |> String.concat "\n"
4747- in
4848- let response = Client.request_raw client ~method_:`POST ~path ~params ~body () in
4949- Encode.parse_jsonl import_result_jsont response
5050-5151-let get client ~collection ~id =
5252- let path =
5353- "/collections/" ^ Uri.pct_encode collection ^ "/documents/"
5454- ^ Uri.pct_encode id
5555- in
5656- Client.request client ~method_:`GET ~path ()
5757-5858-let delete client ~collection ~id =
5959- let path =
6060- "/collections/" ^ Uri.pct_encode collection ^ "/documents/"
6161- ^ Uri.pct_encode id
6262- in
6363- Client.request client ~method_:`DELETE ~path ()
6464-6565-let update client ~collection ~id document =
6666- let path =
6767- "/collections/" ^ Uri.pct_encode collection ^ "/documents/"
6868- ^ Uri.pct_encode id
6969- in
7070- let body = Encode.to_json_string Jsont.json document in
7171- Client.request client ~method_:`PATCH ~path ~body ()
7272-7373-let create client ~collection document =
7474- let path = "/collections/" ^ Uri.pct_encode collection ^ "/documents" in
7575- let body = Encode.to_json_string Jsont.json document in
7676- Client.request client ~method_:`POST ~path ~body ()
7777-7878-type delete_by_query_result = { num_deleted : int }
7979-8080-let delete_by_query_result_jsont =
8181- Jsont.Object.map ~kind:"DeleteByQueryResult" (fun num_deleted ->
8282- { num_deleted })
8383- |> Jsont.Object.mem "num_deleted" Jsont.int ~enc:(fun r -> r.num_deleted)
8484- |> Jsont.Object.skip_unknown
8585- |> Jsont.Object.finish
8686-8787-let delete_by_query client ~collection ~filter_by =
8888- let path =
8989- "/collections/" ^ Uri.pct_encode collection ^ "/documents"
9090- in
9191- let params = [ ("filter_by", filter_by) ] in
9292- let json = Client.request client ~method_:`DELETE ~path ~params () in
9393- let result =
9494- Encode.decode_or_raise delete_by_query_result_jsont json "delete by query"
9595- in
9696- result.num_deleted
9797-9898-type export_params = {
9999- filter_by : string option;
100100- include_fields : string list option;
101101- exclude_fields : string list option;
102102-}
103103-104104-let export_params ?filter_by ?include_fields ?exclude_fields () =
105105- { filter_by; include_fields; exclude_fields }
106106-107107-let export client ~collection ?params () =
108108- let path =
109109- "/collections/" ^ Uri.pct_encode collection ^ "/documents/export"
110110- in
111111- let query_params =
112112- match params with
113113- | None -> []
114114- | Some p ->
115115- List.filter_map Fun.id
116116- [
117117- Option.map (fun v -> ("filter_by", v)) p.filter_by;
118118- Option.map
119119- (fun v -> ("include_fields", String.concat "," v))
120120- p.include_fields;
121121- Option.map
122122- (fun v -> ("exclude_fields", String.concat "," v))
123123- p.exclude_fields;
124124- ]
125125- in
126126- let params = if query_params = [] then None else Some query_params in
127127- let response = Client.request_raw client ~method_:`GET ~path ?params () in
128128- Encode.parse_jsonl Jsont.json response
-97
lib/typesense/document.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense document operations.
77-88- This module provides operations for managing documents in Typesense
99- collections. Documents are JSON objects stored in collections. *)
1010-1111-(** {1 Import Actions} *)
1212-1313-type action =
1414- | Create (** Only create new documents (fail if exists) *)
1515- | Upsert (** Create or replace documents *)
1616- | Update (** Only update existing documents *)
1717- | Emplace (** Create or update (merge) documents *)
1818-(** Action to take during document import. *)
1919-2020-(** {1 Import Results} *)
2121-2222-type import_result = {
2323- success : bool; (** Whether the import succeeded *)
2424- error : string option; (** Error message if failed *)
2525- document : string option; (** Document JSON if return_doc was true *)
2626-}
2727-(** Result for a single document in a batch import. *)
2828-2929-val import_result_jsont : import_result Jsont.t
3030-(** JSON codec for import results. *)
3131-3232-(** {1 Document Operations} *)
3333-3434-val import :
3535- Client.t ->
3636- collection:string ->
3737- ?action:action ->
3838- ?batch_size:int ->
3939- ?return_doc:bool ->
4040- ?return_id:bool ->
4141- Jsont.json list ->
4242- import_result list
4343-(** [import client ~collection ?action ?batch_size documents] imports documents
4444- in batch.
4545- @param action Import action (default: Upsert)
4646- @param batch_size Number of documents per batch (default: 40)
4747- @param return_doc Return the document in the result
4848- @param return_id Return the document ID in the result
4949- @return List of import results, one per document *)
5050-5151-val get : Client.t -> collection:string -> id:string -> Jsont.json
5252-(** [get client ~collection ~id] retrieves a document by ID.
5353- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
5454-5555-val delete : Client.t -> collection:string -> id:string -> Jsont.json
5656-(** [delete client ~collection ~id] deletes a document by ID.
5757- @return The deleted document
5858- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
5959-6060-val update : Client.t -> collection:string -> id:string -> Jsont.json -> Jsont.json
6161-(** [update client ~collection ~id document] updates a document by ID. Only the
6262- fields present in [document] are updated.
6363- @return The updated document
6464- @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *)
6565-6666-val create : Client.t -> collection:string -> Jsont.json -> Jsont.json
6767-(** [create client ~collection document] creates a new document.
6868- @return The created document with auto-generated ID if not specified
6969- @raise Eio.Io with [Error.E { code = Conflict; _ }] if ID already exists *)
7070-7171-val delete_by_query : Client.t -> collection:string -> filter_by:string -> int
7272-(** [delete_by_query client ~collection ~filter_by] deletes all documents
7373- matching the filter.
7474- @return Number of documents deleted *)
7575-7676-(** {1 Export Operations} *)
7777-7878-type export_params = {
7979- filter_by : string option;
8080- include_fields : string list option;
8181- exclude_fields : string list option;
8282-}
8383-(** Parameters for exporting documents. *)
8484-8585-val export_params :
8686- ?filter_by:string ->
8787- ?include_fields:string list ->
8888- ?exclude_fields:string list ->
8989- unit ->
9090- export_params
9191-(** [export_params ...] creates export parameters. *)
9292-9393-val export :
9494- Client.t -> collection:string -> ?params:export_params -> unit -> Jsont.json list
9595-(** [export client ~collection ?params ()] exports all documents from a
9696- collection.
9797- @return List of documents as JSON *)
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Encoding utilities for Typesense API requests *)
77-88-let to_json_string : 'a Jsont.t -> 'a -> string =
99- fun codec value ->
1010- match Jsont_bytesrw.encode_string' codec value with
1111- | Ok s -> s
1212- | Error e -> failwith ("JSON encoding error: " ^ Jsont.Error.to_string e)
1313-1414-let from_json_string : 'a Jsont.t -> string -> ('a, string) result =
1515- fun codec json_str ->
1616- match Jsont_bytesrw.decode_string' codec json_str with
1717- | Ok v -> Ok v
1818- | Error e -> Error (Jsont.Error.to_string e)
1919-2020-let from_json : 'a Jsont.t -> Jsont.json -> ('a, string) result =
2121- fun codec json ->
2222- let json_str =
2323- match Jsont_bytesrw.encode_string' Jsont.json json with
2424- | Ok s -> s
2525- | Error e ->
2626- failwith ("Failed to re-encode json: " ^ Jsont.Error.to_string e)
2727- in
2828- from_json_string codec json_str
2929-3030-let to_json : 'a Jsont.t -> 'a -> (Jsont.json, string) result =
3131- fun codec value ->
3232- let json_str = to_json_string codec value in
3333- match Jsont_bytesrw.decode_string' Jsont.json json_str with
3434- | Ok json -> Ok json
3535- | Error e -> Error (Jsont.Error.to_string e)
3636-3737-let decode_or_raise : 'a Jsont.t -> Jsont.json -> string -> 'a =
3838- fun codec json context ->
3939- match from_json codec json with
4040- | Ok v -> v
4141- | Error msg ->
4242- Error.raise_with_context
4343- (Error.make ~code:(Other 0) ~message:msg)
4444- "%s" context
4545-4646-let parse_jsonl : 'a Jsont.t -> string -> 'a list =
4747- fun codec response ->
4848- String.split_on_char '\n' response
4949- |> List.filter_map (fun line ->
5050- let line = String.trim line in
5151- if line = "" then None
5252- else
5353- match from_json_string codec line with
5454- | Ok result -> Some result
5555- | Error _ -> None)
-28
lib/typesense/encode.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Encoding utilities for Typesense API requests *)
77-88-val to_json_string : 'a Jsont.t -> 'a -> string
99-(** [to_json_string codec value] converts a value to JSON string using its
1010- jsont codec. *)
1111-1212-val from_json_string : 'a Jsont.t -> string -> ('a, string) result
1313-(** [from_json_string codec str] parses a JSON string using a jsont codec. *)
1414-1515-val from_json : 'a Jsont.t -> Jsont.json -> ('a, string) result
1616-(** [from_json codec json] parses a Jsont.json value using a codec. *)
1717-1818-val to_json : 'a Jsont.t -> 'a -> (Jsont.json, string) result
1919-(** [to_json codec value] converts a value to Jsont.json using a codec. *)
2020-2121-val decode_or_raise : 'a Jsont.t -> Jsont.json -> string -> 'a
2222-(** [decode_or_raise codec json context] decodes JSON using the codec, or
2323- raises a Typesense error with the given context if decoding fails. *)
2424-2525-val parse_jsonl : 'a Jsont.t -> string -> 'a list
2626-(** [parse_jsonl codec response] parses a JSONL (newline-delimited JSON)
2727- response string into a list of values. Empty lines are skipped and
2828- parse errors are silently dropped. *)
-54
lib/typesense/error.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type code =
77- | Bad_request
88- | Unauthorized
99- | Not_found
1010- | Conflict
1111- | Unprocessable_entity
1212- | Service_unavailable
1313- | Other of int
1414-1515-type t = { code : code; message : string }
1616-type Eio.Exn.err += E of t
1717-1818-let pp_code fmt = function
1919- | Bad_request -> Format.fprintf fmt "Bad_request"
2020- | Unauthorized -> Format.fprintf fmt "Unauthorized"
2121- | Not_found -> Format.fprintf fmt "Not_found"
2222- | Conflict -> Format.fprintf fmt "Conflict"
2323- | Unprocessable_entity -> Format.fprintf fmt "Unprocessable_entity"
2424- | Service_unavailable -> Format.fprintf fmt "Service_unavailable"
2525- | Other n -> Format.fprintf fmt "Other(%d)" n
2626-2727-let pp fmt t = Format.fprintf fmt "%a: %s" pp_code t.code t.message
2828-2929-let () =
3030- Eio.Exn.register_pp (fun f -> function
3131- | E e ->
3232- Format.fprintf f "Typesense %a" pp e;
3333- true
3434- | _ -> false)
3535-3636-let code_of_status = function
3737- | 400 -> Bad_request
3838- | 401 -> Unauthorized
3939- | 404 -> Not_found
4040- | 409 -> Conflict
4141- | 422 -> Unprocessable_entity
4242- | 503 -> Service_unavailable
4343- | n -> Other n
4444-4545-let make ~code ~message = { code; message }
4646-let code t = t.code
4747-let message t = t.message
4848-let raise e = Stdlib.raise (Eio.Exn.create (E e))
4949-5050-let raise_with_context e fmt =
5151- Format.kasprintf
5252- (fun context ->
5353- Stdlib.raise (Eio.Exn.add_context (Eio.Exn.create (E e)) "%s" context))
5454- fmt
-71
lib/typesense/error.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense API error handling.
77-88- This module defines protocol-level errors for the Typesense API, following
99- the Eio error pattern for context-aware error handling.
1010-1111- Errors are raised as [Eio.Io] exceptions:
1212- {[
1313- try Typesense.Collection.create client schema with
1414- | Eio.Io (Typesense.Error.E { code = Unauthorized; message; _ }, _) ->
1515- Printf.eprintf "Authentication failed: %s\n" message
1616- | Eio.Io (Typesense.Error.E err, _) ->
1717- Printf.eprintf "API error: %a\n" Typesense.Error.pp err
1818- ]} *)
1919-2020-(** {1 Error Codes}
2121-2222- These error codes correspond to HTTP status codes returned by Typesense. *)
2323-2424-type code =
2525- | Bad_request (** 400 - Malformed request *)
2626- | Unauthorized (** 401 - Invalid API key *)
2727- | Not_found (** 404 - Resource not found *)
2828- | Conflict (** 409 - Resource already exists *)
2929- | Unprocessable_entity (** 422 - Invalid data *)
3030- | Service_unavailable (** 503 - Server temporarily unavailable *)
3131- | Other of int (** Other HTTP status code *)
3232-3333-(** {1 Error Type} *)
3434-3535-type t = {
3636- code : code; (** The error code *)
3737- message : string; (** Human-readable error message *)
3838-}
3939-(** The protocol-level error type. *)
4040-4141-(** {1 Eio Integration} *)
4242-4343-type Eio.Exn.err +=
4444- | E of t (** Extend [Eio.Exn.err] with Typesense protocol errors. *)
4545-4646-val raise : t -> 'a
4747-(** [raise e] raises an [Eio.Io] exception for error [e]. Equivalent to
4848- [Stdlib.raise (Eio.Exn.create (E e))]. *)
4949-5050-val raise_with_context : t -> ('a, Format.formatter, unit, 'b) format4 -> 'a
5151-(** [raise_with_context e fmt ...] raises an [Eio.Io] exception with context.
5252- Equivalent to
5353- [Stdlib.raise (Eio.Exn.add_context (Eio.Exn.create (E e)) fmt ...)]. *)
5454-5555-(** {1 Error Construction} *)
5656-5757-val make : code:code -> message:string -> t
5858-(** [make ~code ~message] creates an error value. *)
5959-6060-val code_of_status : int -> code
6161-(** [code_of_status status] converts an HTTP status code to an error code. *)
6262-6363-(** {1 Accessors} *)
6464-6565-val code : t -> code
6666-val message : t -> string
6767-6868-(** {1 Pretty Printing} *)
6969-7070-val pp_code : Format.formatter -> code -> unit
7171-val pp : Format.formatter -> t -> unit
-97
lib/typesense/multi_search.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type search_request = {
77- collection : string;
88- q : string;
99- query_by : string list;
1010- filter_by : string option;
1111- sort_by : string option;
1212- facet_by : string list option;
1313- per_page : int option;
1414- page : int option;
1515- prefix : bool option;
1616- include_fields : string list option;
1717- exclude_fields : string list option;
1818-}
1919-2020-let search_request ~collection ~q ~query_by ?filter_by ?sort_by ?facet_by
2121- ?per_page ?page ?prefix ?include_fields ?exclude_fields () =
2222- {
2323- collection;
2424- q;
2525- query_by;
2626- filter_by;
2727- sort_by;
2828- facet_by;
2929- per_page;
3030- page;
3131- prefix;
3232- include_fields;
3333- exclude_fields;
3434- }
3535-3636-(* Helper codec for comma-separated string lists *)
3737-let comma_list_jsont =
3838- let of_string s = Ok (String.split_on_char ',' s |> List.map String.trim) in
3939- let to_string l = String.concat "," l in
4040- Jsont.of_of_string ~kind:"comma_list" of_string ~enc:to_string
4141-4242-let search_request_jsont =
4343- let make collection q query_by filter_by sort_by facet_by per_page page prefix
4444- include_fields exclude_fields =
4545- {
4646- collection;
4747- q;
4848- query_by;
4949- filter_by;
5050- sort_by;
5151- facet_by;
5252- per_page;
5353- page;
5454- prefix;
5555- include_fields;
5656- exclude_fields;
5757- }
5858- in
5959- Jsont.Object.map ~kind:"SearchRequest" make
6060- |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection)
6161- |> Jsont.Object.mem "q" Jsont.string ~enc:(fun r -> r.q)
6262- |> Jsont.Object.mem "query_by" comma_list_jsont ~enc:(fun r -> r.query_by)
6363- |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
6464- |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
6565- |> Jsont.Object.opt_mem "facet_by" comma_list_jsont ~enc:(fun r -> r.facet_by)
6666- |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page)
6767- |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
6868- |> Jsont.Object.opt_mem "prefix" Jsont.bool ~enc:(fun r -> r.prefix)
6969- |> Jsont.Object.opt_mem "include_fields" comma_list_jsont
7070- ~enc:(fun r -> r.include_fields)
7171- |> Jsont.Object.opt_mem "exclude_fields" comma_list_jsont
7272- ~enc:(fun r -> r.exclude_fields)
7373- |> Jsont.Object.skip_unknown
7474- |> Jsont.Object.finish
7575-7676-type request = { searches : search_request list }
7777-7878-let request_jsont =
7979- Jsont.Object.map ~kind:"MultiSearchRequest" (fun searches -> { searches })
8080- |> Jsont.Object.mem "searches" (Jsont.list search_request_jsont)
8181- ~enc:(fun r -> r.searches)
8282- |> Jsont.Object.finish
8383-8484-type result = { results : Search.result list }
8585-8686-let result_jsont =
8787- Jsont.Object.map ~kind:"MultiSearchResult" (fun results -> { results })
8888- |> Jsont.Object.mem "results" (Jsont.list Search.result_jsont)
8989- ~enc:(fun r -> r.results)
9090- |> Jsont.Object.skip_unknown
9191- |> Jsont.Object.finish
9292-9393-let search client requests =
9494- let req = { searches = requests } in
9595- let body = Encode.to_json_string request_jsont req in
9696- let json = Client.request client ~method_:`POST ~path:"/multi_search" ~body () in
9797- Encode.decode_or_raise result_jsont json "multi_search"
-61
lib/typesense/multi_search.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense multi-search operations.
77-88- This module provides support for executing multiple searches across different
99- collections in a single request. This is more efficient than making separate
1010- search requests. *)
1111-1212-(** {1 Search Request Type} *)
1313-1414-type search_request = {
1515- collection : string; (** Collection to search *)
1616- q : string; (** Query string *)
1717- query_by : string list; (** Fields to search in *)
1818- filter_by : string option; (** Filter expression *)
1919- sort_by : string option; (** Sort expression *)
2020- facet_by : string list option; (** Fields to facet on *)
2121- per_page : int option; (** Results per page *)
2222- page : int option; (** Page number *)
2323- prefix : bool option; (** Enable prefix search *)
2424- include_fields : string list option; (** Fields to include *)
2525- exclude_fields : string list option; (** Fields to exclude *)
2626-}
2727-(** A single search request within a multi-search operation. *)
2828-2929-val search_request :
3030- collection:string ->
3131- q:string ->
3232- query_by:string list ->
3333- ?filter_by:string ->
3434- ?sort_by:string ->
3535- ?facet_by:string list ->
3636- ?per_page:int ->
3737- ?page:int ->
3838- ?prefix:bool ->
3939- ?include_fields:string list ->
4040- ?exclude_fields:string list ->
4141- unit ->
4242- search_request
4343-(** [search_request ~collection ~q ~query_by ...] creates a search request. *)
4444-4545-val search_request_jsont : search_request Jsont.t
4646-(** JSON codec for search requests. *)
4747-4848-(** {1 Multi-Search Result} *)
4949-5050-type result = { results : Search.result list }
5151-(** Multi-search result containing results for each search request. *)
5252-5353-val result_jsont : result Jsont.t
5454-(** JSON codec for multi-search results. *)
5555-5656-(** {1 Multi-Search Operation} *)
5757-5858-val search : Client.t -> search_request list -> result
5959-(** [search client requests] executes multiple searches in a single request.
6060- The results are returned in the same order as the requests.
6161- @raise Eio.Io with [Error.E] on API errors *)
-261
lib/typesense/search.ml
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-type highlight = {
77- field : string;
88- snippet : string option;
99- snippets : string list option;
1010- matched_tokens : string list option;
1111- indices : int list option;
1212-}
1313-1414-let highlight_jsont =
1515- let make field snippet snippets matched_tokens indices =
1616- { field; snippet; snippets; matched_tokens; indices }
1717- in
1818- Jsont.Object.map ~kind:"Highlight" make
1919- |> Jsont.Object.mem "field" Jsont.string ~enc:(fun h -> h.field)
2020- |> Jsont.Object.opt_mem "snippet" Jsont.string ~enc:(fun h -> h.snippet)
2121- |> Jsont.Object.opt_mem "snippets" (Jsont.list Jsont.string)
2222- ~enc:(fun h -> h.snippets)
2323- |> Jsont.Object.opt_mem "matched_tokens" (Jsont.list Jsont.string)
2424- ~enc:(fun h -> h.matched_tokens)
2525- |> Jsont.Object.opt_mem "indices" (Jsont.list Jsont.int)
2626- ~enc:(fun h -> h.indices)
2727- |> Jsont.Object.skip_unknown
2828- |> Jsont.Object.finish
2929-3030-type hit = {
3131- document : Jsont.json;
3232- highlights : highlight list option;
3333- text_match : int64 option;
3434- text_match_info : Jsont.json option;
3535-}
3636-3737-let hit_jsont =
3838- let make document highlights text_match text_match_info =
3939- { document; highlights; text_match; text_match_info }
4040- in
4141- Jsont.Object.map ~kind:"Hit" make
4242- |> Jsont.Object.mem "document" Jsont.json ~enc:(fun h -> h.document)
4343- |> Jsont.Object.opt_mem "highlights" (Jsont.list highlight_jsont)
4444- ~enc:(fun h -> h.highlights)
4545- |> Jsont.Object.opt_mem "text_match" Jsont.int64 ~enc:(fun h -> h.text_match)
4646- |> Jsont.Object.opt_mem "text_match_info" Jsont.json
4747- ~enc:(fun h -> h.text_match_info)
4848- |> Jsont.Object.skip_unknown
4949- |> Jsont.Object.finish
5050-5151-type facet_count = {
5252- value : string;
5353- count : int;
5454- highlighted : string option;
5555-}
5656-5757-let facet_count_jsont =
5858- let make value count highlighted = { value; count; highlighted } in
5959- Jsont.Object.map ~kind:"FacetCount" make
6060- |> Jsont.Object.mem "value" Jsont.string ~enc:(fun f -> f.value)
6161- |> Jsont.Object.mem "count" Jsont.int ~enc:(fun f -> f.count)
6262- |> Jsont.Object.opt_mem "highlighted" Jsont.string ~enc:(fun f -> f.highlighted)
6363- |> Jsont.Object.skip_unknown
6464- |> Jsont.Object.finish
6565-6666-type facet_stats = {
6767- min : float option;
6868- max : float option;
6969- sum : float option;
7070- avg : float option;
7171- total_values : int option;
7272-}
7373-7474-let facet_stats_jsont =
7575- let make min max sum avg total_values =
7676- { min; max; sum; avg; total_values }
7777- in
7878- Jsont.Object.map ~kind:"FacetStats" make
7979- |> Jsont.Object.opt_mem "min" Jsont.number ~enc:(fun f -> f.min)
8080- |> Jsont.Object.opt_mem "max" Jsont.number ~enc:(fun f -> f.max)
8181- |> Jsont.Object.opt_mem "sum" Jsont.number ~enc:(fun f -> f.sum)
8282- |> Jsont.Object.opt_mem "avg" Jsont.number ~enc:(fun f -> f.avg)
8383- |> Jsont.Object.opt_mem "total_values" Jsont.int ~enc:(fun f -> f.total_values)
8484- |> Jsont.Object.skip_unknown
8585- |> Jsont.Object.finish
8686-8787-type facet = {
8888- field_name : string;
8989- counts : facet_count list;
9090- stats : facet_stats option;
9191-}
9292-9393-let facet_jsont =
9494- let make field_name counts stats = { field_name; counts; stats } in
9595- Jsont.Object.map ~kind:"Facet" make
9696- |> Jsont.Object.mem "field_name" Jsont.string ~enc:(fun f -> f.field_name)
9797- |> Jsont.Object.mem "counts" (Jsont.list facet_count_jsont) ~enc:(fun f -> f.counts)
9898- |> Jsont.Object.opt_mem "stats" facet_stats_jsont ~enc:(fun f -> f.stats)
9999- |> Jsont.Object.skip_unknown
100100- |> Jsont.Object.finish
101101-102102-type result = {
103103- hits : hit list;
104104- found : int;
105105- search_time_ms : int;
106106- page : int option;
107107- out_of : int option;
108108- facet_counts : facet list option;
109109- request_params : Jsont.json option;
110110-}
111111-112112-let result_jsont =
113113- let make hits found search_time_ms page out_of facet_counts request_params =
114114- { hits; found; search_time_ms; page; out_of; facet_counts; request_params }
115115- in
116116- Jsont.Object.map ~kind:"SearchResult" make
117117- |> Jsont.Object.mem "hits" (Jsont.list hit_jsont) ~enc:(fun r -> r.hits)
118118- |> Jsont.Object.mem "found" Jsont.int ~enc:(fun r -> r.found)
119119- |> Jsont.Object.mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms)
120120- |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
121121- |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of)
122122- |> Jsont.Object.opt_mem "facet_counts" (Jsont.list facet_jsont)
123123- ~enc:(fun r -> r.facet_counts)
124124- |> Jsont.Object.opt_mem "request_params" Jsont.json
125125- ~enc:(fun r -> r.request_params)
126126- |> Jsont.Object.skip_unknown
127127- |> Jsont.Object.finish
128128-129129-type params = {
130130- q : string;
131131- query_by : string list;
132132- filter_by : string option;
133133- sort_by : string option;
134134- facet_by : string list option;
135135- max_facet_values : int option;
136136- per_page : int option;
137137- page : int option;
138138- prefix : bool option;
139139- infix : string option;
140140- highlight_fields : string list option;
141141- highlight_full_fields : string list option;
142142- highlight_affix_num_tokens : int option;
143143- highlight_start_tag : string option;
144144- highlight_end_tag : string option;
145145- snippet_threshold : int option;
146146- num_typos : int option;
147147- typo_tokens_threshold : int option;
148148- drop_tokens_threshold : int option;
149149- include_fields : string list option;
150150- exclude_fields : string list option;
151151- group_by : string list option;
152152- group_limit : int option;
153153- limit_hits : int option;
154154- prioritize_exact_match : bool option;
155155- prioritize_token_position : bool option;
156156- exhaustive_search : bool option;
157157- search_cutoff_ms : int option;
158158- use_cache : bool option;
159159- cache_ttl : int option;
160160- enable_highlight_v1 : bool option;
161161-}
162162-163163-let params ~q ~query_by ?filter_by ?sort_by ?facet_by ?max_facet_values ?per_page
164164- ?page ?prefix ?infix ?highlight_fields ?highlight_full_fields
165165- ?highlight_affix_num_tokens ?highlight_start_tag ?highlight_end_tag
166166- ?snippet_threshold ?num_typos ?typo_tokens_threshold ?drop_tokens_threshold
167167- ?include_fields ?exclude_fields ?group_by ?group_limit ?limit_hits
168168- ?prioritize_exact_match ?prioritize_token_position ?exhaustive_search
169169- ?search_cutoff_ms ?use_cache ?cache_ttl ?enable_highlight_v1 () =
170170- {
171171- q;
172172- query_by;
173173- filter_by;
174174- sort_by;
175175- facet_by;
176176- max_facet_values;
177177- per_page;
178178- page;
179179- prefix;
180180- infix;
181181- highlight_fields;
182182- highlight_full_fields;
183183- highlight_affix_num_tokens;
184184- highlight_start_tag;
185185- highlight_end_tag;
186186- snippet_threshold;
187187- num_typos;
188188- typo_tokens_threshold;
189189- drop_tokens_threshold;
190190- include_fields;
191191- exclude_fields;
192192- group_by;
193193- group_limit;
194194- limit_hits;
195195- prioritize_exact_match;
196196- prioritize_token_position;
197197- exhaustive_search;
198198- search_cutoff_ms;
199199- use_cache;
200200- cache_ttl;
201201- enable_highlight_v1;
202202- }
203203-204204-let params_to_query_params p =
205205- let add_opt name opt acc =
206206- match opt with Some v -> (name, v) :: acc | None -> acc
207207- in
208208- let add_opt_bool name opt acc =
209209- match opt with
210210- | Some v -> (name, string_of_bool v) :: acc
211211- | None -> acc
212212- in
213213- let add_opt_int name opt acc =
214214- match opt with Some v -> (name, string_of_int v) :: acc | None -> acc
215215- in
216216- let add_opt_list name opt acc =
217217- match opt with
218218- | Some v when v <> [] -> (name, String.concat "," v) :: acc
219219- | _ -> acc
220220- in
221221- []
222222- |> add_opt "q" (Some p.q)
223223- |> add_opt "query_by" (Some (String.concat "," p.query_by))
224224- |> add_opt "filter_by" p.filter_by
225225- |> add_opt "sort_by" p.sort_by
226226- |> add_opt_list "facet_by" p.facet_by
227227- |> add_opt_int "max_facet_values" p.max_facet_values
228228- |> add_opt_int "per_page" p.per_page
229229- |> add_opt_int "page" p.page
230230- |> add_opt_bool "prefix" p.prefix
231231- |> add_opt "infix" p.infix
232232- |> add_opt_list "highlight_fields" p.highlight_fields
233233- |> add_opt_list "highlight_full_fields" p.highlight_full_fields
234234- |> add_opt_int "highlight_affix_num_tokens" p.highlight_affix_num_tokens
235235- |> add_opt "highlight_start_tag" p.highlight_start_tag
236236- |> add_opt "highlight_end_tag" p.highlight_end_tag
237237- |> add_opt_int "snippet_threshold" p.snippet_threshold
238238- |> add_opt_int "num_typos" p.num_typos
239239- |> add_opt_int "typo_tokens_threshold" p.typo_tokens_threshold
240240- |> add_opt_int "drop_tokens_threshold" p.drop_tokens_threshold
241241- |> add_opt_list "include_fields" p.include_fields
242242- |> add_opt_list "exclude_fields" p.exclude_fields
243243- |> add_opt_list "group_by" p.group_by
244244- |> add_opt_int "group_limit" p.group_limit
245245- |> add_opt_int "limit_hits" p.limit_hits
246246- |> add_opt_bool "prioritize_exact_match" p.prioritize_exact_match
247247- |> add_opt_bool "prioritize_token_position" p.prioritize_token_position
248248- |> add_opt_bool "exhaustive_search" p.exhaustive_search
249249- |> add_opt_int "search_cutoff_ms" p.search_cutoff_ms
250250- |> add_opt_bool "use_cache" p.use_cache
251251- |> add_opt_int "cache_ttl" p.cache_ttl
252252- |> add_opt_bool "enable_highlight_v1" p.enable_highlight_v1
253253- |> List.rev
254254-255255-let search client ~collection p =
256256- let path =
257257- "/collections/" ^ Uri.pct_encode collection ^ "/documents/search"
258258- in
259259- let params = params_to_query_params p in
260260- let json = Client.request client ~method_:`GET ~path ~params () in
261261- Encode.decode_or_raise result_jsont json "search"
-153
lib/typesense/search.mli
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** Typesense search operations.
77-88- This module provides types and functions for searching documents in
99- Typesense collections. *)
1010-1111-(** {1 Search Result Types} *)
1212-1313-type highlight = {
1414- field : string; (** Field name that was highlighted *)
1515- snippet : string option; (** Highlighted snippet (single value) *)
1616- snippets : string list option; (** Highlighted snippets (array fields) *)
1717- matched_tokens : string list option; (** Tokens that matched *)
1818- indices : int list option; (** Indices of matched values in array *)
1919-}
2020-(** Highlighting information for a matched field. *)
2121-2222-val highlight_jsont : highlight Jsont.t
2323-2424-type hit = {
2525- document : Jsont.json; (** The matched document *)
2626- highlights : highlight list option; (** Highlighting information *)
2727- text_match : int64 option; (** Text match score *)
2828- text_match_info : Jsont.json option; (** Detailed match info *)
2929-}
3030-(** A single search hit. *)
3131-3232-val hit_jsont : hit Jsont.t
3333-3434-type facet_count = {
3535- value : string; (** Facet value *)
3636- count : int; (** Number of documents with this value *)
3737- highlighted : string option; (** Highlighted value for facet search *)
3838-}
3939-(** Count for a single facet value. *)
4040-4141-val facet_count_jsont : facet_count Jsont.t
4242-4343-type facet_stats = {
4444- min : float option;
4545- max : float option;
4646- sum : float option;
4747- avg : float option;
4848- total_values : int option;
4949-}
5050-(** Statistics for numeric facets. *)
5151-5252-val facet_stats_jsont : facet_stats Jsont.t
5353-5454-type facet = {
5555- field_name : string; (** Faceted field name *)
5656- counts : facet_count list; (** Value counts *)
5757- stats : facet_stats option; (** Numeric statistics *)
5858-}
5959-(** Facet results for a field. *)
6060-6161-val facet_jsont : facet Jsont.t
6262-6363-type result = {
6464- hits : hit list; (** Matched documents *)
6565- found : int; (** Total documents matching query *)
6666- search_time_ms : int; (** Search time in milliseconds *)
6767- page : int option; (** Current page number *)
6868- out_of : int option; (** Total documents in collection *)
6969- facet_counts : facet list option; (** Facet results *)
7070- request_params : Jsont.json option; (** Echo of request parameters *)
7171-}
7272-(** Search result containing hits and metadata. *)
7373-7474-val result_jsont : result Jsont.t
7575-7676-(** {1 Search Parameters} *)
7777-7878-type params = {
7979- q : string; (** Query string (use "*" for all documents) *)
8080- query_by : string list; (** Fields to search in *)
8181- filter_by : string option; (** Filter expression *)
8282- sort_by : string option; (** Sort expression *)
8383- facet_by : string list option; (** Fields to facet on *)
8484- max_facet_values : int option; (** Max facet values to return *)
8585- per_page : int option; (** Results per page (default: 10) *)
8686- page : int option; (** Page number (default: 1) *)
8787- prefix : bool option; (** Enable prefix search *)
8888- infix : string option; (** Infix search mode *)
8989- highlight_fields : string list option; (** Fields to highlight *)
9090- highlight_full_fields : string list option; (** Fields for full highlight *)
9191- highlight_affix_num_tokens : int option; (** Tokens around highlight *)
9292- highlight_start_tag : string option; (** Start tag for highlighting *)
9393- highlight_end_tag : string option; (** End tag for highlighting *)
9494- snippet_threshold : int option; (** Threshold for snippets *)
9595- num_typos : int option; (** Max typos allowed *)
9696- typo_tokens_threshold : int option; (** Typo token threshold *)
9797- drop_tokens_threshold : int option; (** Token dropping threshold *)
9898- include_fields : string list option; (** Fields to include in results *)
9999- exclude_fields : string list option; (** Fields to exclude from results *)
100100- group_by : string list option; (** Fields to group by *)
101101- group_limit : int option; (** Max documents per group *)
102102- limit_hits : int option; (** Max total hits *)
103103- prioritize_exact_match : bool option; (** Prioritize exact matches *)
104104- prioritize_token_position : bool option; (** Prioritize token position *)
105105- exhaustive_search : bool option; (** Exhaustive search mode *)
106106- search_cutoff_ms : int option; (** Search timeout *)
107107- use_cache : bool option; (** Use search cache *)
108108- cache_ttl : int option; (** Cache TTL in seconds *)
109109- enable_highlight_v1 : bool option; (** Use v1 highlighting *)
110110-}
111111-(** Search parameters. *)
112112-113113-val params :
114114- q:string ->
115115- query_by:string list ->
116116- ?filter_by:string ->
117117- ?sort_by:string ->
118118- ?facet_by:string list ->
119119- ?max_facet_values:int ->
120120- ?per_page:int ->
121121- ?page:int ->
122122- ?prefix:bool ->
123123- ?infix:string ->
124124- ?highlight_fields:string list ->
125125- ?highlight_full_fields:string list ->
126126- ?highlight_affix_num_tokens:int ->
127127- ?highlight_start_tag:string ->
128128- ?highlight_end_tag:string ->
129129- ?snippet_threshold:int ->
130130- ?num_typos:int ->
131131- ?typo_tokens_threshold:int ->
132132- ?drop_tokens_threshold:int ->
133133- ?include_fields:string list ->
134134- ?exclude_fields:string list ->
135135- ?group_by:string list ->
136136- ?group_limit:int ->
137137- ?limit_hits:int ->
138138- ?prioritize_exact_match:bool ->
139139- ?prioritize_token_position:bool ->
140140- ?exhaustive_search:bool ->
141141- ?search_cutoff_ms:int ->
142142- ?use_cache:bool ->
143143- ?cache_ttl:int ->
144144- ?enable_highlight_v1:bool ->
145145- unit ->
146146- params
147147-(** [params ~q ~query_by ...] creates search parameters. *)
148148-149149-(** {1 Search Operation} *)
150150-151151-val search : Client.t -> collection:string -> params -> result
152152-(** [search client ~collection params] searches for documents.
153153- @raise Eio.Io with [Error.E] on API errors *)
···11-(*---------------------------------------------------------------------------
22- Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33- SPDX-License-Identifier: ISC
44- ---------------------------------------------------------------------------*)
55-66-(** OCaml bindings for the Typesense search API.
77-88- Typesense is a fast, typo-tolerant search engine. This library provides
99- high-quality OCaml bindings using Eio for async operations.
1010-1111- {2 Quick Start}
1212-1313- {[
1414- open Typesense
1515-1616- let () =
1717- Eio_main.run @@ fun env ->
1818- let auth = Auth.create ~endpoint:"http://localhost:8108" ~api_key:"xyz" in
1919- Client.with_client env auth @@ fun client ->
2020-2121- (* Create a collection *)
2222- let schema =
2323- Collection.schema ~name:"books"
2424- ~fields:
2525- [
2626- Collection.field ~name:"title" ~type_:"string" ();
2727- Collection.field ~name:"author" ~type_:"string" ~facet:true ();
2828- Collection.field ~name:"year" ~type_:"int32" ();
2929- ]
3030- ~default_sorting_field:"year" ()
3131- in
3232- let _ = Collection.create client schema in
3333-3434- (* Search *)
3535- let params = Search.params ~q:"harry" ~query_by:["title"; "author"] () in
3636- let result = Search.search client ~collection:"books" params in
3737- Printf.printf "Found %d books\n" result.found
3838- ]}
3939-4040- {2 Error Handling}
4141-4242- All API operations raise [Eio.Io] exceptions with [Error.E] error codes:
4343-4444- {[
4545- try Collection.get client ~name:"nonexistent" with
4646- | Eio.Io (Error.E { code = Not_found; message; _ }, _) ->
4747- Printf.eprintf "Collection not found: %s\n" message
4848- ]}
4949-*)
5050-5151-(** {1 Authentication} *)
5252-5353-module Auth = Auth
5454-(** API key authentication for Typesense. *)
5555-5656-(** {1 Error Handling} *)
5757-5858-module Error = Error
5959-(** Protocol-level errors with Eio integration. *)
6060-6161-(** {1 HTTP Client} *)
6262-6363-module Client = Client
6464-(** Low-level HTTP client for the Typesense API. *)
6565-6666-(** {1 Collections} *)
6767-6868-module Collection = Collection
6969-(** Collection schema and CRUD operations. *)
7070-7171-(** {1 Documents} *)
7272-7373-module Document = Document
7474-(** Document import, export, and CRUD operations. *)
7575-7676-(** {1 Search} *)
7777-7878-module Search = Search
7979-(** Search parameters and results. *)
8080-8181-(** {1 Multi-Search} *)
8282-8383-module Multi_search = Multi_search
8484-(** Search multiple collections in one request. *)
8585-8686-(** {1 Analytics} *)
8787-8888-module Analytics = Analytics
8989-(** Analytics rules and event tracking. *)
+14
lib/typesense_auth.ml
···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
33+ SPDX-License-Identifier: ISC
44+ ---------------------------------------------------------------------------*)
55+66+(** Typesense authentication library.
77+88+ This library provides authentication support for the Typesense API client,
99+ with profile-based session management. *)
1010+1111+module Session = Session
1212+module Client = Client
1313+module Cmd = Cmd
1414+module Error = Error
+4620
typesense-openapi.yaml
···11+openapi: 3.0.3
22+info:
33+ title: Typesense API
44+ description: "An open source search engine for building delightful search experiences."
55+ version: '30.0'
66+ license:
77+ name: GPL-3.0
88+ url: https://opensource.org/licenses/GPL-3.0
99+servers:
1010+ - url: "{protocol}://{hostname}:{port}"
1111+ description: Typesense Server
1212+ variables:
1313+ protocol:
1414+ default: http
1515+ description: The protocol of your Typesense server
1616+ hostname:
1717+ default: localhost
1818+ description: The hostname of your Typesense server
1919+ port:
2020+ default: "8108"
2121+ description: The port of your Typesense server
2222+externalDocs:
2323+ description: Find out more about Typsesense
2424+ url: https://typesense.org
2525+security:
2626+ - api_key_header: []
2727+tags:
2828+ - name: collections
2929+ description: A collection is defined by a schema
3030+ externalDocs:
3131+ description: Find out more
3232+ url: https://typesense.org/api/#create-collection
3333+ - name: documents
3434+ description: A document is an individual record to be indexed and belongs to a collection
3535+ externalDocs:
3636+ description: Find out more
3737+ url: https://typesense.org/api/#index-document
3838+ - name: analytics
3939+ description: Typesense can aggregate search queries for both analytics purposes and for query suggestions.
4040+ externalDocs:
4141+ description: Find out more
4242+ url: https://typesense.org/docs/28.0/api/analytics-query-suggestions.html
4343+ - name: keys
4444+ description: Manage API Keys with fine-grain access control
4545+ externalDocs:
4646+ description: Find out more
4747+ url: https://typesense.org/docs/0.23.0/api/#api-keys
4848+ - name: debug
4949+ description: Debugging information
5050+ - name: operations
5151+ description: Manage Typesense cluster
5252+ externalDocs:
5353+ description: Find out more
5454+ url: https://typesense.org/docs/28.0/api/cluster-operations.html
5555+ - name: stopwords
5656+ description: Manage stopwords sets
5757+ externalDocs:
5858+ description: Find out more
5959+ url: https://typesense.org/docs/28.0/api/stopwords.html
6060+ - name: presets
6161+ description: Store and reference search parameters
6262+ externalDocs:
6363+ description: Find out more
6464+ url: https://typesense.org/docs/28.0/api/search.html#presets
6565+ - name: conversations
6666+ description: Conversational Search (RAG)
6767+ externalDocs:
6868+ description: Find out more
6969+ url: https://typesense.org/docs/28.0/api/conversational-search-rag.html
7070+ - name: synonyms
7171+ description: Manage synonyms
7272+ externalDocs:
7373+ description: Find out more
7474+ url: https://typesense.org/docs/28.0/api/synonyms.html
7575+ - name: curation_sets
7676+ description: Manage curation sets
7777+ - name: stemming
7878+ description: Manage stemming dictionaries
7979+ externalDocs:
8080+ description: Find out more
8181+ url: https://typesense.org/docs/28.0/api/stemming.html
8282+ - name: nl_search_models
8383+ description: Manage NL search models
8484+ externalDocs:
8585+ description: Find out more
8686+ url: https://typesense.org/docs/29.0/api/natural-language-search.html
8787+8888+paths:
8989+ /collections:
9090+ get:
9191+ tags:
9292+ - collections
9393+ summary: List all collections
9494+ description:
9595+ Returns a summary of all your collections. The collections are
9696+ returned sorted by creation date, with the most recent collections appearing
9797+ first.
9898+ operationId: getCollections
9999+ parameters:
100100+ - name: getCollectionsParameters
101101+ in: query
102102+ schema:
103103+ type: object
104104+ properties:
105105+ exclude_fields:
106106+ description: Comma-separated list of fields from the collection to exclude from the response
107107+ type: string
108108+ limit:
109109+ description: >
110110+ Number of collections to fetch.
111111+ Default: returns all collections.
112112+ type: integer
113113+ offset:
114114+ description: Identifies the starting point to return collections when paginating.
115115+ type: integer
116116+ responses:
117117+ '200':
118118+ description: List of all collections
119119+ content:
120120+ application/json:
121121+ schema:
122122+ type: array
123123+ x-go-type: "[]*CollectionResponse"
124124+ items:
125125+ $ref: "#/components/schemas/CollectionResponse"
126126+ post:
127127+ tags:
128128+ - collections
129129+ summary: Create a new collection
130130+ description:
131131+ When a collection is created, we give it a name and describe the
132132+ fields that will be indexed from the documents added to the collection.
133133+ operationId: createCollection
134134+ requestBody:
135135+ description: The collection object to be created
136136+ content:
137137+ application/json:
138138+ schema:
139139+ $ref: "#/components/schemas/CollectionSchema"
140140+ required: true
141141+ responses:
142142+ '201':
143143+ description: Collection successfully created
144144+ content:
145145+ application/json:
146146+ schema:
147147+ $ref: "#/components/schemas/CollectionResponse"
148148+ '400':
149149+ description: Bad request, see error message for details
150150+ content:
151151+ application/json:
152152+ schema:
153153+ $ref: "#/components/schemas/ApiResponse"
154154+ '409':
155155+ description: Collection already exists
156156+ content:
157157+ application/json:
158158+ schema:
159159+ $ref: "#/components/schemas/ApiResponse"
160160+ /collections/{collectionName}:
161161+ get:
162162+ tags:
163163+ - collections
164164+ summary: Retrieve a single collection
165165+ description: Retrieve the details of a collection, given its name.
166166+ operationId: getCollection
167167+ parameters:
168168+ - name: collectionName
169169+ in: path
170170+ description: The name of the collection to retrieve
171171+ required: true
172172+ schema:
173173+ type: string
174174+ responses:
175175+ '200':
176176+ description: Collection fetched
177177+ content:
178178+ application/json:
179179+ schema:
180180+ $ref: "#/components/schemas/CollectionResponse"
181181+ '404':
182182+ description: Collection not found
183183+ content:
184184+ application/json:
185185+ schema:
186186+ $ref: "#/components/schemas/ApiResponse"
187187+ patch:
188188+ tags:
189189+ - collections
190190+ summary: Update a collection
191191+ description:
192192+ Update a collection's schema to modify the fields and their types.
193193+ operationId: updateCollection
194194+ parameters:
195195+ - name: collectionName
196196+ in: path
197197+ description: The name of the collection to update
198198+ required: true
199199+ schema:
200200+ type: string
201201+ requestBody:
202202+ description: The document object with fields to be updated
203203+ content:
204204+ application/json:
205205+ schema:
206206+ $ref: "#/components/schemas/CollectionUpdateSchema"
207207+ required: true
208208+ responses:
209209+ '200':
210210+ description: The updated partial collection schema
211211+ content:
212212+ application/json:
213213+ schema:
214214+ $ref: "#/components/schemas/CollectionUpdateSchema"
215215+ '400':
216216+ description: Bad request, see error message for details
217217+ content:
218218+ application/json:
219219+ schema:
220220+ $ref: "#/components/schemas/ApiResponse"
221221+ '404':
222222+ description: The collection was not found
223223+ content:
224224+ application/json:
225225+ schema:
226226+ $ref: "#/components/schemas/ApiResponse"
227227+ delete:
228228+ tags:
229229+ - collections
230230+ summary: Delete a collection
231231+ description:
232232+ Permanently drops a collection. This action cannot be undone. For
233233+ large collections, this might have an impact on read latencies.
234234+ operationId: deleteCollection
235235+ parameters:
236236+ - name: collectionName
237237+ in: path
238238+ description: The name of the collection to delete
239239+ required: true
240240+ schema:
241241+ type: string
242242+ responses:
243243+ '200':
244244+ description: Collection deleted
245245+ content:
246246+ application/json:
247247+ schema:
248248+ $ref: "#/components/schemas/CollectionResponse"
249249+ '404':
250250+ description: Collection not found
251251+ content:
252252+ application/json:
253253+ schema:
254254+ $ref: "#/components/schemas/ApiResponse"
255255+ /collections/{collectionName}/documents:
256256+ post:
257257+ tags:
258258+ - documents
259259+ summary: Index a document
260260+ description:
261261+ A document to be indexed in a given collection must conform to
262262+ the schema of the collection.
263263+ operationId: indexDocument
264264+ parameters:
265265+ - name: collectionName
266266+ in: path
267267+ description: The name of the collection to add the document to
268268+ required: true
269269+ schema:
270270+ type: string
271271+ - name: action
272272+ in: query
273273+ description: Additional action to perform
274274+ schema:
275275+ type: string
276276+ example: upsert
277277+ $ref: "#/components/schemas/IndexAction"
278278+ - name: dirty_values
279279+ in: query
280280+ description: Dealing with Dirty Data
281281+ schema:
282282+ $ref: "#/components/schemas/DirtyValues"
283283+ requestBody:
284284+ description: The document object to be indexed
285285+ content:
286286+ application/json:
287287+ schema:
288288+ type: object
289289+ description: Can be any key-value pair
290290+ x-go-type: "interface{}"
291291+ required: true
292292+ responses:
293293+ '201':
294294+ description: Document successfully created/indexed
295295+ content:
296296+ application/json:
297297+ schema:
298298+ type: object
299299+ description: Can be any key-value pair
300300+ '404':
301301+ description: Collection not found
302302+ content:
303303+ application/json:
304304+ schema:
305305+ $ref: "#/components/schemas/ApiResponse"
306306+ patch:
307307+ tags:
308308+ - documents
309309+ summary: Update documents with conditional query
310310+ description:
311311+ The filter_by query parameter is used to filter to specify a condition against which the documents are matched.
312312+ The request body contains the fields that should be updated for any documents that match the filter condition.
313313+ This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later.
314314+ operationId: updateDocuments
315315+ parameters:
316316+ - name: collectionName
317317+ in: path
318318+ description: The name of the collection to update documents in
319319+ required: true
320320+ schema:
321321+ type: string
322322+ - name: updateDocumentsParameters
323323+ in: query
324324+ schema:
325325+ type: object
326326+ properties:
327327+ filter_by:
328328+ type: string
329329+ example: "num_employees:>100 && country: [USA, UK]"
330330+ responses:
331331+ '200':
332332+ description:
333333+ The response contains a single field, `num_updated`, indicating the number of documents affected.
334334+ content:
335335+ application/json:
336336+ schema:
337337+ type: object
338338+ required:
339339+ - num_updated
340340+ properties:
341341+ num_updated:
342342+ type: integer
343343+ description: The number of documents that have been updated
344344+ example: 1
345345+ '400':
346346+ description: 'Bad request, see error message for details'
347347+ content:
348348+ application/json:
349349+ schema:
350350+ $ref: '#/components/schemas/ApiResponse'
351351+ '404':
352352+ description: The collection was not found
353353+ content:
354354+ application/json:
355355+ schema:
356356+ $ref: '#/components/schemas/ApiResponse'
357357+ requestBody:
358358+ description: The document fields to be updated
359359+ content:
360360+ application/json:
361361+ schema:
362362+ type: object
363363+ description: Can be any key-value pair
364364+ x-go-type: "interface{}"
365365+ required: true
366366+ delete:
367367+ tags:
368368+ - documents
369369+ summary: Delete a bunch of documents
370370+ description:
371371+ Delete a bunch of documents that match a specific filter condition.
372372+ Use the `batch_size` parameter to control the number of documents that
373373+ should deleted at a time. A larger value will speed up deletions, but will
374374+ impact performance of other operations running on the server.
375375+ operationId: deleteDocuments
376376+ parameters:
377377+ - name: collectionName
378378+ in: path
379379+ description: The name of the collection to delete documents from
380380+ required: true
381381+ schema:
382382+ type: string
383383+ - name: deleteDocumentsParameters
384384+ in: query
385385+ schema:
386386+ type: object
387387+ required:
388388+ - filter_by
389389+ properties:
390390+ filter_by:
391391+ type: string
392392+ example: "num_employees:>100 && country: [USA, UK]"
393393+ batch_size:
394394+ description:
395395+ Batch size parameter controls the number of documents that should be deleted
396396+ at a time. A larger value will speed up deletions, but will impact performance
397397+ of other operations running on the server.
398398+ type: integer
399399+ ignore_not_found:
400400+ type: boolean
401401+ truncate:
402402+ description: When true, removes all documents from the collection while preserving the collection and its schema.
403403+ type: boolean
404404+ responses:
405405+ '200':
406406+ description: Documents successfully deleted
407407+ content:
408408+ application/json:
409409+ schema:
410410+ type: object
411411+ required:
412412+ - num_deleted
413413+ properties:
414414+ num_deleted:
415415+ type: integer
416416+ '404':
417417+ description: Collection not found
418418+ content:
419419+ application/json:
420420+ schema:
421421+ $ref: "#/components/schemas/ApiResponse"
422422+ /collections/{collectionName}/documents/search:
423423+ get:
424424+ tags:
425425+ - documents
426426+ summary: Search for documents in a collection
427427+ description: Search for documents in a collection that match the search criteria.
428428+ operationId: searchCollection
429429+ parameters:
430430+ - name: collectionName
431431+ in: path
432432+ description: The name of the collection to search for the document under
433433+ required: true
434434+ schema:
435435+ type: string
436436+ - name: searchParameters
437437+ required: true
438438+ in: query
439439+ schema:
440440+ $ref: "#/components/schemas/SearchParameters"
441441+ responses:
442442+ '200':
443443+ description: Search results
444444+ content:
445445+ application/json:
446446+ schema:
447447+ $ref: "#/components/schemas/SearchResult"
448448+ '400':
449449+ description: Bad request, see error message for details
450450+ content:
451451+ application/json:
452452+ schema:
453453+ $ref: "#/components/schemas/ApiResponse"
454454+ '404':
455455+ description: The collection or field was not found
456456+ content:
457457+ application/json:
458458+ schema:
459459+ $ref: "#/components/schemas/ApiResponse"
460460+461461+ /synonym_sets:
462462+ get:
463463+ tags:
464464+ - synonyms
465465+ summary: List all synonym sets
466466+ description: Retrieve all synonym sets
467467+ operationId: retrieveSynonymSets
468468+ responses:
469469+ "200":
470470+ description: List of all synonym sets
471471+ content:
472472+ application/json:
473473+ schema:
474474+ type: array
475475+ items:
476476+ $ref: "#/components/schemas/SynonymSetSchema"
477477+478478+ /synonym_sets/{synonymSetName}:
479479+ get:
480480+ tags:
481481+ - synonyms
482482+ summary: Retrieve a synonym set
483483+ description: Retrieve a specific synonym set by its name
484484+ operationId: retrieveSynonymSet
485485+ parameters:
486486+ - name: synonymSetName
487487+ in: path
488488+ description: The name of the synonym set to retrieve
489489+ required: true
490490+ schema:
491491+ type: string
492492+ responses:
493493+ "200":
494494+ description: Synonym set fetched
495495+ content:
496496+ application/json:
497497+ schema:
498498+ $ref: "#/components/schemas/SynonymSetSchema"
499499+ "404":
500500+ description: Synonym set not found
501501+ content:
502502+ application/json:
503503+ schema:
504504+ $ref: "#/components/schemas/ApiResponse"
505505+506506+ put:
507507+ tags:
508508+ - synonyms
509509+ summary: Create or update a synonym set
510510+ description: Create or update a synonym set with the given name
511511+ operationId: upsertSynonymSet
512512+ parameters:
513513+ - name: synonymSetName
514514+ in: path
515515+ description: The name of the synonym set to create/update
516516+ required: true
517517+ schema:
518518+ type: string
519519+ requestBody:
520520+ description: The synonym set to be created/updated
521521+ content:
522522+ application/json:
523523+ schema:
524524+ $ref: "#/components/schemas/SynonymSetCreateSchema"
525525+ required: true
526526+ responses:
527527+ "200":
528528+ description: Synonym set successfully created/updated
529529+ content:
530530+ application/json:
531531+ schema:
532532+ $ref: "#/components/schemas/SynonymSetSchema"
533533+ "400":
534534+ description: Bad request, see error message for details
535535+ content:
536536+ application/json:
537537+ schema:
538538+ $ref: "#/components/schemas/ApiResponse"
539539+ delete:
540540+ tags:
541541+ - synonyms
542542+ summary: Delete a synonym set
543543+ description: Delete a specific synonym set by its name
544544+ operationId: deleteSynonymSet
545545+ parameters:
546546+ - name: synonymSetName
547547+ in: path
548548+ description: The name of the synonym set to delete
549549+ required: true
550550+ schema:
551551+ type: string
552552+ responses:
553553+ "200":
554554+ description: Synonym set successfully deleted
555555+ content:
556556+ application/json:
557557+ schema:
558558+ $ref: "#/components/schemas/SynonymSetDeleteSchema"
559559+ "404":
560560+ description: Synonym set not found
561561+ content:
562562+ application/json:
563563+ schema:
564564+ $ref: "#/components/schemas/ApiResponse"
565565+566566+ /synonym_sets/{synonymSetName}/items:
567567+ get:
568568+ tags:
569569+ - synonyms
570570+ summary: List items in a synonym set
571571+ description: Retrieve all synonym items in a set
572572+ operationId: retrieveSynonymSetItems
573573+ parameters:
574574+ - name: synonymSetName
575575+ in: path
576576+ description: The name of the synonym set to retrieve items for
577577+ required: true
578578+ schema:
579579+ type: string
580580+ responses:
581581+ "200":
582582+ description: List of synonym items
583583+ content:
584584+ application/json:
585585+ schema:
586586+ type: array
587587+ items:
588588+ $ref: "#/components/schemas/SynonymItemSchema"
589589+ "404":
590590+ description: Synonym set not found
591591+ content:
592592+ application/json:
593593+ schema:
594594+ $ref: "#/components/schemas/ApiResponse"
595595+596596+ /synonym_sets/{synonymSetName}/items/{itemId}:
597597+ get:
598598+ tags:
599599+ - synonyms
600600+ summary: Retrieve a synonym set item
601601+ description: Retrieve a specific synonym item by its id
602602+ operationId: retrieveSynonymSetItem
603603+ parameters:
604604+ - name: synonymSetName
605605+ in: path
606606+ description: The name of the synonym set
607607+ required: true
608608+ schema:
609609+ type: string
610610+ - name: itemId
611611+ in: path
612612+ description: The id of the synonym item to retrieve
613613+ required: true
614614+ schema:
615615+ type: string
616616+ responses:
617617+ "200":
618618+ description: Synonym item fetched
619619+ content:
620620+ application/json:
621621+ schema:
622622+ $ref: "#/components/schemas/SynonymItemSchema"
623623+ "404":
624624+ description: Synonym item not found
625625+ content:
626626+ application/json:
627627+ schema:
628628+ $ref: "#/components/schemas/ApiResponse"
629629+ put:
630630+ tags:
631631+ - synonyms
632632+ summary: Create or update a synonym set item
633633+ description: Create or update a synonym set item with the given id
634634+ operationId: upsertSynonymSetItem
635635+ parameters:
636636+ - name: synonymSetName
637637+ in: path
638638+ description: The name of the synonym set
639639+ required: true
640640+ schema:
641641+ type: string
642642+ - name: itemId
643643+ in: path
644644+ description: The id of the synonym item to upsert
645645+ required: true
646646+ schema:
647647+ type: string
648648+ requestBody:
649649+ description: The synonym item to be created/updated
650650+ content:
651651+ application/json:
652652+ schema:
653653+ $ref: "#/components/schemas/SynonymItemUpsertSchema"
654654+ required: true
655655+ responses:
656656+ "200":
657657+ description: Synonym item successfully created/updated
658658+ content:
659659+ application/json:
660660+ schema:
661661+ $ref: "#/components/schemas/SynonymItemSchema"
662662+ "400":
663663+ description: Bad request, see error message for details
664664+ content:
665665+ application/json:
666666+ schema:
667667+ $ref: "#/components/schemas/ApiResponse"
668668+ delete:
669669+ tags:
670670+ - synonyms
671671+ summary: Delete a synonym set item
672672+ description: Delete a specific synonym item by its id
673673+ operationId: deleteSynonymSetItem
674674+ parameters:
675675+ - name: synonymSetName
676676+ in: path
677677+ description: The name of the synonym set
678678+ required: true
679679+ schema:
680680+ type: string
681681+ - name: itemId
682682+ in: path
683683+ description: The id of the synonym item to delete
684684+ required: true
685685+ schema:
686686+ type: string
687687+ responses:
688688+ "200":
689689+ description: Synonym item successfully deleted
690690+ content:
691691+ application/json:
692692+ schema:
693693+ $ref: "#/components/schemas/SynonymItemDeleteSchema"
694694+ "404":
695695+ description: Synonym item not found
696696+ content:
697697+ application/json:
698698+ schema:
699699+ $ref: "#/components/schemas/ApiResponse"
700700+701701+ /curation_sets:
702702+ get:
703703+ tags:
704704+ - curation_sets
705705+ summary: List all curation sets
706706+ description: Retrieve all curation sets
707707+ operationId: retrieveCurationSets
708708+ responses:
709709+ "200":
710710+ description: List of all curation sets
711711+ content:
712712+ application/json:
713713+ schema:
714714+ type: array
715715+ items:
716716+ $ref: "#/components/schemas/CurationSetSchema"
717717+718718+ /curation_sets/{curationSetName}:
719719+ get:
720720+ tags:
721721+ - curation_sets
722722+ summary: Retrieve a curation set
723723+ description: Retrieve a specific curation set by its name
724724+ operationId: retrieveCurationSet
725725+ parameters:
726726+ - name: curationSetName
727727+ in: path
728728+ description: The name of the curation set to retrieve
729729+ required: true
730730+ schema:
731731+ type: string
732732+ responses:
733733+ "200":
734734+ description: Curation set fetched
735735+ content:
736736+ application/json:
737737+ schema:
738738+ $ref: "#/components/schemas/CurationSetSchema"
739739+ "404":
740740+ description: Curation set not found
741741+ content:
742742+ application/json:
743743+ schema:
744744+ $ref: "#/components/schemas/ApiResponse"
745745+ put:
746746+ tags:
747747+ - curation_sets
748748+ summary: Create or update a curation set
749749+ description: Create or update a curation set with the given name
750750+ operationId: upsertCurationSet
751751+ parameters:
752752+ - name: curationSetName
753753+ in: path
754754+ description: The name of the curation set to create/update
755755+ required: true
756756+ schema:
757757+ type: string
758758+ requestBody:
759759+ description: The curation set to be created/updated
760760+ content:
761761+ application/json:
762762+ schema:
763763+ $ref: "#/components/schemas/CurationSetCreateSchema"
764764+ required: true
765765+ responses:
766766+ "200":
767767+ description: Curation set successfully created/updated
768768+ content:
769769+ application/json:
770770+ schema:
771771+ $ref: "#/components/schemas/CurationSetSchema"
772772+ "400":
773773+ description: Bad request, see error message for details
774774+ content:
775775+ application/json:
776776+ schema:
777777+ $ref: "#/components/schemas/ApiResponse"
778778+ delete:
779779+ tags:
780780+ - curation_sets
781781+ summary: Delete a curation set
782782+ description: Delete a specific curation set by its name
783783+ operationId: deleteCurationSet
784784+ parameters:
785785+ - name: curationSetName
786786+ in: path
787787+ description: The name of the curation set to delete
788788+ required: true
789789+ schema:
790790+ type: string
791791+ responses:
792792+ "200":
793793+ description: Curation set successfully deleted
794794+ content:
795795+ application/json:
796796+ schema:
797797+ $ref: "#/components/schemas/CurationSetDeleteSchema"
798798+ "404":
799799+ description: Curation set not found
800800+ content:
801801+ application/json:
802802+ schema:
803803+ $ref: "#/components/schemas/ApiResponse"
804804+805805+ /curation_sets/{curationSetName}/items:
806806+ get:
807807+ tags:
808808+ - curation_sets
809809+ summary: List items in a curation set
810810+ description: Retrieve all curation items in a set
811811+ operationId: retrieveCurationSetItems
812812+ parameters:
813813+ - name: curationSetName
814814+ in: path
815815+ description: The name of the curation set to retrieve items for
816816+ required: true
817817+ schema:
818818+ type: string
819819+ responses:
820820+ "200":
821821+ description: List of curation items
822822+ content:
823823+ application/json:
824824+ schema:
825825+ type: array
826826+ items:
827827+ $ref: "#/components/schemas/CurationItemSchema"
828828+ "404":
829829+ description: Curation set not found
830830+ content:
831831+ application/json:
832832+ schema:
833833+ $ref: "#/components/schemas/ApiResponse"
834834+835835+ /curation_sets/{curationSetName}/items/{itemId}:
836836+ get:
837837+ tags:
838838+ - curation_sets
839839+ summary: Retrieve a curation set item
840840+ description: Retrieve a specific curation item by its id
841841+ operationId: retrieveCurationSetItem
842842+ parameters:
843843+ - name: curationSetName
844844+ in: path
845845+ description: The name of the curation set
846846+ required: true
847847+ schema:
848848+ type: string
849849+ - name: itemId
850850+ in: path
851851+ description: The id of the curation item to retrieve
852852+ required: true
853853+ schema:
854854+ type: string
855855+ responses:
856856+ "200":
857857+ description: Curation item fetched
858858+ content:
859859+ application/json:
860860+ schema:
861861+ $ref: "#/components/schemas/CurationItemSchema"
862862+ "404":
863863+ description: Curation item not found
864864+ content:
865865+ application/json:
866866+ schema:
867867+ $ref: "#/components/schemas/ApiResponse"
868868+ put:
869869+ tags:
870870+ - curation_sets
871871+ summary: Create or update a curation set item
872872+ description: Create or update a curation set item with the given id
873873+ operationId: upsertCurationSetItem
874874+ parameters:
875875+ - name: curationSetName
876876+ in: path
877877+ description: The name of the curation set
878878+ required: true
879879+ schema:
880880+ type: string
881881+ - name: itemId
882882+ in: path
883883+ description: The id of the curation item to upsert
884884+ required: true
885885+ schema:
886886+ type: string
887887+ requestBody:
888888+ description: The curation item to be created/updated
889889+ content:
890890+ application/json:
891891+ schema:
892892+ $ref: "#/components/schemas/CurationItemCreateSchema"
893893+ required: true
894894+ responses:
895895+ "200":
896896+ description: Curation item successfully created/updated
897897+ content:
898898+ application/json:
899899+ schema:
900900+ $ref: "#/components/schemas/CurationItemSchema"
901901+ "400":
902902+ description: Bad request, see error message for details
903903+ content:
904904+ application/json:
905905+ schema:
906906+ $ref: "#/components/schemas/ApiResponse"
907907+ delete:
908908+ tags:
909909+ - curation_sets
910910+ summary: Delete a curation set item
911911+ description: Delete a specific curation item by its id
912912+ operationId: deleteCurationSetItem
913913+ parameters:
914914+ - name: curationSetName
915915+ in: path
916916+ description: The name of the curation set
917917+ required: true
918918+ schema:
919919+ type: string
920920+ - name: itemId
921921+ in: path
922922+ description: The id of the curation item to delete
923923+ required: true
924924+ schema:
925925+ type: string
926926+ responses:
927927+ "200":
928928+ description: Curation item successfully deleted
929929+ content:
930930+ application/json:
931931+ schema:
932932+ $ref: "#/components/schemas/CurationItemDeleteSchema"
933933+ "404":
934934+ description: Curation item not found
935935+ content:
936936+ application/json:
937937+ schema:
938938+ $ref: "#/components/schemas/ApiResponse"
939939+940940+ /collections/{collectionName}/documents/export:
941941+ get:
942942+ tags:
943943+ - documents
944944+ summary: Export all documents in a collection
945945+ description: Export all documents in a collection in JSON lines format.
946946+ operationId: exportDocuments
947947+ parameters:
948948+ - name: collectionName
949949+ in: path
950950+ description: The name of the collection
951951+ required: true
952952+ schema:
953953+ type: string
954954+ - name: exportDocumentsParameters
955955+ in: query
956956+ schema:
957957+ type: object
958958+ properties:
959959+ filter_by:
960960+ description:
961961+ Filter conditions for refining your search results. Separate
962962+ multiple conditions with &&.
963963+ type: string
964964+ include_fields:
965965+ description: List of fields from the document to include in the search result
966966+ type: string
967967+ exclude_fields:
968968+ description: List of fields from the document to exclude in the search result
969969+ type: string
970970+971971+ responses:
972972+ '200':
973973+ description: Exports all the documents in a given collection.
974974+ content:
975975+ application/octet-stream:
976976+ schema:
977977+ type: string
978978+ example: |
979979+ {"id": "124", "company_name": "Stark Industries", "num_employees": 5215, "country": "US"}
980980+ {"id": "125", "company_name": "Future Technology", "num_employees": 1232,"country": "UK"}
981981+ {"id": "126", "company_name": "Random Corp.", "num_employees": 531,"country": "AU"}
982982+ '404':
983983+ description: The collection was not found
984984+ content:
985985+ application/json:
986986+ schema:
987987+ $ref: "#/components/schemas/ApiResponse"
988988+ /collections/{collectionName}/documents/import:
989989+ post:
990990+ tags:
991991+ - documents
992992+ summary: Import documents into a collection
993993+ description:
994994+ The documents to be imported must be formatted in a newline delimited
995995+ JSON structure. You can feed the output file from a Typesense export operation
996996+ directly as import.
997997+ operationId: importDocuments
998998+ parameters:
999999+ - name: collectionName
10001000+ in: path
10011001+ description: The name of the collection
10021002+ required: true
10031003+ schema:
10041004+ type: string
10051005+ # Do not change the index position of this param
10061006+ - name: importDocumentsParameters
10071007+ in: query
10081008+ schema:
10091009+ type: object
10101010+ properties:
10111011+ batch_size:
10121012+ type: integer
10131013+ return_id:
10141014+ type: boolean
10151015+ description:
10161016+ Returning the id of the imported documents. If you want the
10171017+ import response to return the ingested document's id in the
10181018+ response, you can use the return_id parameter.
10191019+ remote_embedding_batch_size:
10201020+ type: integer
10211021+ return_doc:
10221022+ type: boolean
10231023+ action:
10241024+ $ref: "#/components/schemas/IndexAction"
10251025+ dirty_values:
10261026+ $ref: "#/components/schemas/DirtyValues"
10271027+ requestBody:
10281028+ description: The json array of documents or the JSONL file to import
10291029+ content:
10301030+ application/octet-stream:
10311031+ schema:
10321032+ type: string
10331033+ description: The JSONL file to import
10341034+ required: true
10351035+ responses:
10361036+ '200':
10371037+ description:
10381038+ Result of the import operation. Each line of the response indicates the result
10391039+ of each document present in the request body (in the same order). If the import
10401040+ of a single document fails, it does not affect the other documents.
10411041+ If there is a failure, the response line will include a corresponding error
10421042+ message and as well as the actual document content.
10431043+ content:
10441044+ application/octet-stream:
10451045+ schema:
10461046+ type: string
10471047+ example: |
10481048+ {"success": true}
10491049+ {"success": false, "error": "Bad JSON.", "document": "[bad doc"}
10501050+ '400':
10511051+ description: Bad request, see error message for details
10521052+ content:
10531053+ application/json:
10541054+ schema:
10551055+ $ref: "#/components/schemas/ApiResponse"
10561056+ '404':
10571057+ description: The collection was not found
10581058+ content:
10591059+ application/json:
10601060+ schema:
10611061+ $ref: "#/components/schemas/ApiResponse"
10621062+ /collections/{collectionName}/documents/{documentId}:
10631063+ get:
10641064+ tags:
10651065+ - documents
10661066+ summary: Retrieve a document
10671067+ description: Fetch an individual document from a collection by using its ID.
10681068+ operationId: getDocument
10691069+ parameters:
10701070+ - name: collectionName
10711071+ in: path
10721072+ description: The name of the collection to search for the document under
10731073+ required: true
10741074+ schema:
10751075+ type: string
10761076+ - name: documentId
10771077+ in: path
10781078+ description: The Document ID
10791079+ required: true
10801080+ schema:
10811081+ type: string
10821082+ responses:
10831083+ '200':
10841084+ description: The document referenced by the ID
10851085+ content:
10861086+ application/json:
10871087+ schema:
10881088+ type: object
10891089+ description: Can be any key-value pair
10901090+ '404':
10911091+ description: The document or collection was not found
10921092+ content:
10931093+ application/json:
10941094+ schema:
10951095+ $ref: "#/components/schemas/ApiResponse"
10961096+ patch:
10971097+ tags:
10981098+ - documents
10991099+ summary: Update a document
11001100+ description:
11011101+ Update an individual document from a collection by using its ID.
11021102+ The update can be partial.
11031103+ operationId: updateDocument
11041104+ parameters:
11051105+ - name: collectionName
11061106+ in: path
11071107+ description: The name of the collection to search for the document under
11081108+ required: true
11091109+ schema:
11101110+ type: string
11111111+ - name: documentId
11121112+ in: path
11131113+ description: The Document ID
11141114+ required: true
11151115+ schema:
11161116+ type: string
11171117+ - name: dirty_values
11181118+ in: query
11191119+ description: Dealing with Dirty Data
11201120+ schema:
11211121+ $ref: "#/components/schemas/DirtyValues"
11221122+ requestBody:
11231123+ description: The document object with fields to be updated
11241124+ content:
11251125+ application/json:
11261126+ schema:
11271127+ type: object
11281128+ description: Can be any key-value pair
11291129+ x-go-type: "interface{}"
11301130+ required: true
11311131+ responses:
11321132+ '200':
11331133+ description: The document referenced by the ID was updated
11341134+ content:
11351135+ application/json:
11361136+ schema:
11371137+ type: object
11381138+ description: Can be any key-value pair
11391139+ '404':
11401140+ description: The document or collection was not found
11411141+ content:
11421142+ application/json:
11431143+ schema:
11441144+ $ref: "#/components/schemas/ApiResponse"
11451145+ delete:
11461146+ tags:
11471147+ - documents
11481148+ summary: Delete a document
11491149+ description: Delete an individual document from a collection by using its ID.
11501150+ operationId: deleteDocument
11511151+ parameters:
11521152+ - name: collectionName
11531153+ in: path
11541154+ description: The name of the collection to search for the document under
11551155+ required: true
11561156+ schema:
11571157+ type: string
11581158+ - name: documentId
11591159+ in: path
11601160+ description: The Document ID
11611161+ required: true
11621162+ schema:
11631163+ type: string
11641164+ responses:
11651165+ '200':
11661166+ description: The document referenced by the ID was deleted
11671167+ content:
11681168+ application/json:
11691169+ schema:
11701170+ type: object
11711171+ description: Can be any key-value pair
11721172+ '404':
11731173+ description: The document or collection was not found
11741174+ content:
11751175+ application/json:
11761176+ schema:
11771177+ $ref: "#/components/schemas/ApiResponse"
11781178+ /conversations/models:
11791179+ get:
11801180+ description: Retrieve all conversation models
11811181+ operationId: retrieveAllConversationModels
11821182+ responses:
11831183+ '200':
11841184+ content:
11851185+ application/json:
11861186+ schema:
11871187+ items:
11881188+ $ref: '#/components/schemas/ConversationModelSchema'
11891189+ type: array
11901190+ x-go-type: '[]*ConversationModelSchema'
11911191+ description: List of all conversation models
11921192+ summary: List all conversation models
11931193+ tags:
11941194+ - conversations
11951195+ post:
11961196+ summary: Create a conversation model
11971197+ description: Create a Conversation Model
11981198+ operationId: createConversationModel
11991199+ requestBody:
12001200+ content:
12011201+ application/json:
12021202+ schema:
12031203+ $ref: '#/components/schemas/ConversationModelCreateSchema'
12041204+ required: true
12051205+ responses:
12061206+ '201':
12071207+ content:
12081208+ application/json:
12091209+ schema:
12101210+ $ref: '#/components/schemas/ConversationModelSchema'
12111211+ description: Created Conversation Model
12121212+ '400':
12131213+ content:
12141214+ application/json:
12151215+ schema:
12161216+ $ref: '#/components/schemas/ApiResponse'
12171217+ description: Bad request, see error message for details
12181218+ tags:
12191219+ - conversations
12201220+ /conversations/models/{modelId}:
12211221+ get:
12221222+ description: Retrieve a conversation model
12231223+ operationId: retrieveConversationModel
12241224+ parameters:
12251225+ - name: modelId
12261226+ in: path
12271227+ description: The id of the conversation model to retrieve
12281228+ required: true
12291229+ schema:
12301230+ type: string
12311231+ responses:
12321232+ '200':
12331233+ content:
12341234+ application/json:
12351235+ schema:
12361236+ $ref: '#/components/schemas/ConversationModelSchema'
12371237+ description: A conversation model
12381238+ summary: Retrieve a conversation model
12391239+ tags:
12401240+ - conversations
12411241+ put:
12421242+ description: Update a conversation model
12431243+ operationId: updateConversationModel
12441244+ requestBody:
12451245+ content:
12461246+ application/json:
12471247+ schema:
12481248+ $ref: '#/components/schemas/ConversationModelUpdateSchema'
12491249+ required: true
12501250+ parameters:
12511251+ - name: modelId
12521252+ in: path
12531253+ description: The id of the conversation model to update
12541254+ required: true
12551255+ schema:
12561256+ type: string
12571257+ responses:
12581258+ '200':
12591259+ content:
12601260+ application/json:
12611261+ schema:
12621262+ $ref: '#/components/schemas/ConversationModelSchema'
12631263+ description: The conversation model was successfully updated
12641264+ summary: Update a conversation model
12651265+ tags:
12661266+ - conversations
12671267+ delete:
12681268+ description: Delete a conversation model
12691269+ operationId: deleteConversationModel
12701270+ parameters:
12711271+ - name: modelId
12721272+ in: path
12731273+ description: The id of the conversation model to delete
12741274+ required: true
12751275+ schema:
12761276+ type: string
12771277+ responses:
12781278+ '200':
12791279+ content:
12801280+ application/json:
12811281+ schema:
12821282+ $ref: '#/components/schemas/ConversationModelSchema'
12831283+ description: The conversation model was successfully deleted
12841284+ summary: Delete a conversation model
12851285+ tags:
12861286+ - conversations
12871287+ /keys:
12881288+ get:
12891289+ tags:
12901290+ - keys
12911291+ summary: Retrieve (metadata about) all keys.
12921292+ operationId: getKeys
12931293+ responses:
12941294+ '200':
12951295+ description: List of all keys
12961296+ content:
12971297+ application/json:
12981298+ schema:
12991299+ $ref: "#/components/schemas/ApiKeysResponse"
13001300+ post:
13011301+ tags:
13021302+ - keys
13031303+ summary: Create an API Key
13041304+ description:
13051305+ Create an API Key with fine-grain access control. You can restrict access
13061306+ on both a per-collection and per-action level.
13071307+ The generated key is returned only during creation. You want to store
13081308+ this key carefully in a secure place.
13091309+ operationId: createKey
13101310+ requestBody:
13111311+ description: The object that describes API key scope
13121312+ content:
13131313+ application/json:
13141314+ schema:
13151315+ $ref: "#/components/schemas/ApiKeySchema"
13161316+ responses:
13171317+ '201':
13181318+ description: Created API key
13191319+ content:
13201320+ application/json:
13211321+ schema:
13221322+ $ref: "#/components/schemas/ApiKey"
13231323+ '400':
13241324+ description: Bad request, see error message for details
13251325+ content:
13261326+ application/json:
13271327+ schema:
13281328+ $ref: "#/components/schemas/ApiResponse"
13291329+ '409':
13301330+ description: API key generation conflict
13311331+ content:
13321332+ application/json:
13331333+ schema:
13341334+ $ref: "#/components/schemas/ApiResponse"
13351335+ /keys/{keyId}:
13361336+ get:
13371337+ tags:
13381338+ - keys
13391339+ summary: Retrieve (metadata about) a key
13401340+ description:
13411341+ Retrieve (metadata about) a key. Only the key prefix is returned
13421342+ when you retrieve a key. Due to security reasons, only the create endpoint
13431343+ returns the full API key.
13441344+ operationId: getKey
13451345+ parameters:
13461346+ - name: keyId
13471347+ in: path
13481348+ description: The ID of the key to retrieve
13491349+ required: true
13501350+ schema:
13511351+ type: integer
13521352+ format: int64
13531353+ responses:
13541354+ '200':
13551355+ description: The key referenced by the ID
13561356+ content:
13571357+ application/json:
13581358+ schema:
13591359+ $ref: "#/components/schemas/ApiKey"
13601360+ '404':
13611361+ description: The key was not found
13621362+ content:
13631363+ application/json:
13641364+ schema:
13651365+ $ref: "#/components/schemas/ApiResponse"
13661366+ delete:
13671367+ tags:
13681368+ - keys
13691369+ summary: Delete an API key given its ID.
13701370+ operationId: deleteKey
13711371+ parameters:
13721372+ - name: keyId
13731373+ in: path
13741374+ description: The ID of the key to delete
13751375+ required: true
13761376+ schema:
13771377+ type: integer
13781378+ format: int64
13791379+ responses:
13801380+ '200':
13811381+ description: The key referenced by the ID
13821382+ content:
13831383+ application/json:
13841384+ schema:
13851385+ $ref: "#/components/schemas/ApiKeyDeleteResponse"
13861386+ '400':
13871387+ description: Bad request, see error message for details
13881388+ content:
13891389+ application/json:
13901390+ schema:
13911391+ $ref: "#/components/schemas/ApiResponse"
13921392+ '404':
13931393+ description: Key not found
13941394+ content:
13951395+ application/json:
13961396+ schema:
13971397+ $ref: "#/components/schemas/ApiResponse"
13981398+ /aliases:
13991399+ get:
14001400+ tags:
14011401+ - collections
14021402+ summary: List all aliases
14031403+ description: List all aliases and the corresponding collections that they map to.
14041404+ operationId: getAliases
14051405+ responses:
14061406+ '200':
14071407+ description: List of all collection aliases
14081408+ content:
14091409+ application/json:
14101410+ schema:
14111411+ $ref: "#/components/schemas/CollectionAliasesResponse"
14121412+ /aliases/{aliasName}:
14131413+ put:
14141414+ tags:
14151415+ - collections
14161416+ summary: Create or update a collection alias
14171417+ description:
14181418+ Create or update a collection alias. An alias is a virtual collection name that points
14191419+ to a real collection. If you're familiar with symbolic links on Linux, it's very similar
14201420+ to that. Aliases are useful when you want to reindex your data in the
14211421+ background on a new collection and switch your application to it without any changes to
14221422+ your code.
14231423+ operationId: upsertAlias
14241424+ parameters:
14251425+ - name: aliasName
14261426+ in: path
14271427+ description: The name of the alias to create/update
14281428+ required: true
14291429+ schema:
14301430+ type: string
14311431+ requestBody:
14321432+ description: Collection alias to be created/updated
14331433+ content:
14341434+ application/json:
14351435+ schema:
14361436+ $ref: "#/components/schemas/CollectionAliasSchema"
14371437+ responses:
14381438+ '200':
14391439+ description: The collection alias was created/updated
14401440+ content:
14411441+ application/json:
14421442+ schema:
14431443+ $ref: "#/components/schemas/CollectionAlias"
14441444+ '400':
14451445+ description: Bad request, see error message for details
14461446+ content:
14471447+ application/json:
14481448+ schema:
14491449+ $ref: "#/components/schemas/ApiResponse"
14501450+ '404':
14511451+ description: Alias not found
14521452+ content:
14531453+ application/json:
14541454+ schema:
14551455+ $ref: "#/components/schemas/ApiResponse"
14561456+ get:
14571457+ tags:
14581458+ - collections
14591459+ summary: Retrieve an alias
14601460+ description: Find out which collection an alias points to by fetching it
14611461+ operationId: getAlias
14621462+ parameters:
14631463+ - name: aliasName
14641464+ in: path
14651465+ description: The name of the alias to retrieve
14661466+ required: true
14671467+ schema:
14681468+ type: string
14691469+ responses:
14701470+ '200':
14711471+ description: Collection alias fetched
14721472+ content:
14731473+ application/json:
14741474+ schema:
14751475+ $ref: "#/components/schemas/CollectionAlias"
14761476+ '404':
14771477+ description: The alias was not found
14781478+ content:
14791479+ application/json:
14801480+ schema:
14811481+ $ref: "#/components/schemas/ApiResponse"
14821482+ delete:
14831483+ tags:
14841484+ - collections
14851485+ summary: Delete an alias
14861486+ operationId: deleteAlias
14871487+ parameters:
14881488+ - name: aliasName
14891489+ in: path
14901490+ description: The name of the alias to delete
14911491+ required: true
14921492+ schema:
14931493+ type: string
14941494+ responses:
14951495+ '200':
14961496+ description: Collection alias was deleted
14971497+ content:
14981498+ application/json:
14991499+ schema:
15001500+ $ref: "#/components/schemas/CollectionAlias"
15011501+ '404':
15021502+ description: Alias not found
15031503+ content:
15041504+ application/json:
15051505+ schema:
15061506+ $ref: "#/components/schemas/ApiResponse"
15071507+ /debug:
15081508+ get:
15091509+ tags:
15101510+ - debug
15111511+ summary: Print debugging information
15121512+ description: Print debugging information
15131513+ operationId: debug
15141514+ responses:
15151515+ '200':
15161516+ description: Debugging information
15171517+ content:
15181518+ application/json:
15191519+ schema:
15201520+ type: object
15211521+ properties:
15221522+ version:
15231523+ type: string
15241524+ /health:
15251525+ get:
15261526+ tags:
15271527+ - health
15281528+ summary: Checks if Typesense server is ready to accept requests.
15291529+ description: Checks if Typesense server is ready to accept requests.
15301530+ operationId: health
15311531+ responses:
15321532+ '200':
15331533+ description: Search service is ready for requests.
15341534+ content:
15351535+ application/json:
15361536+ schema:
15371537+ $ref: "#/components/schemas/HealthStatus"
15381538+ /operations/schema_changes:
15391539+ get:
15401540+ tags:
15411541+ - operations
15421542+ summary: Get the status of in-progress schema change operations
15431543+ description: Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response.
15441544+ operationId: getSchemaChanges
15451545+ responses:
15461546+ '200':
15471547+ description: List of schema changes in progress
15481548+ content:
15491549+ application/json:
15501550+ schema:
15511551+ type: array
15521552+ items:
15531553+ $ref: "#/components/schemas/SchemaChangeStatus"
15541554+ /operations/snapshot:
15551555+ post:
15561556+ tags:
15571557+ - operations
15581558+ summary: Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.
15591559+ description:
15601560+ Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.
15611561+ You can then backup the snapshot directory that gets created and later restore it
15621562+ as a data directory, as needed.
15631563+ operationId: takeSnapshot
15641564+ parameters:
15651565+ - name: snapshot_path
15661566+ in: query
15671567+ description: The directory on the server where the snapshot should be saved.
15681568+ required: true
15691569+ schema:
15701570+ type: string
15711571+ responses:
15721572+ '201':
15731573+ description: Snapshot is created.
15741574+ content:
15751575+ application/json:
15761576+ schema:
15771577+ $ref: "#/components/schemas/SuccessStatus"
15781578+ /operations/vote:
15791579+ post:
15801580+ tags:
15811581+ - operations
15821582+ summary: Triggers a follower node to initiate the raft voting process, which triggers leader re-election.
15831583+ description:
15841584+ Triggers a follower node to initiate the raft voting process, which triggers leader re-election.
15851585+ The follower node that you run this operation against will become the new leader,
15861586+ once this command succeeds.
15871587+ operationId: vote
15881588+ responses:
15891589+ '200':
15901590+ description: Re-election is performed.
15911591+ content:
15921592+ application/json:
15931593+ schema:
15941594+ $ref: "#/components/schemas/SuccessStatus"
15951595+ /operations/cache/clear:
15961596+ post:
15971597+ tags:
15981598+ - operations
15991599+ summary: Clear the cached responses of search requests in the LRU cache.
16001600+ description:
16011601+ Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache.
16021602+ operationId: clearCache
16031603+ responses:
16041604+ '200':
16051605+ description: Clear cache succeeded.
16061606+ content:
16071607+ application/json:
16081608+ schema:
16091609+ $ref: "#/components/schemas/SuccessStatus"
16101610+ /operations/db/compact:
16111611+ post:
16121612+ tags:
16131613+ - operations
16141614+ summary: Compacting the on-disk database
16151615+ description:
16161616+ Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database.
16171617+ This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours.
16181618+ operationId: compactDb
16191619+ responses:
16201620+ '200':
16211621+ description: Compacting the on-disk database succeeded.
16221622+ content:
16231623+ application/json:
16241624+ schema:
16251625+ $ref: "#/components/schemas/SuccessStatus"
16261626+ /config:
16271627+ post:
16281628+ tags:
16291629+ - operations
16301630+ summary: Toggle Slow Request Log
16311631+ description:
16321632+ Enable logging of requests that take over a defined threshold of time.
16331633+ Default is `-1` which disables slow request logging.
16341634+ Slow requests are logged to the primary log file, with the prefix SLOW REQUEST.
16351635+ operationId: toggleSlowRequestLog
16361636+ requestBody:
16371637+ content:
16381638+ application/json:
16391639+ schema:
16401640+ type: object
16411641+ properties:
16421642+ log-slow-requests-time-ms:
16431643+ type: integer
16441644+ required:
16451645+ - log-slow-requests-time-ms
16461646+ example: |
16471647+ {"log-slow-requests-time-ms": 2000}
16481648+ responses:
16491649+ '200':
16501650+ description: Toggle Slow Request Log database succeeded.
16511651+ content:
16521652+ application/json:
16531653+ schema:
16541654+ $ref: "#/components/schemas/SuccessStatus"
16551655+ /multi_search:
16561656+ post:
16571657+ operationId: multiSearch
16581658+ tags:
16591659+ - documents
16601660+ summary: send multiple search requests in a single HTTP request
16611661+ description:
16621662+ This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests.
16631663+ You can also use this feature to do a federated search across multiple collections in a single HTTP request.
16641664+ parameters:
16651665+ - name: multiSearchParameters
16661666+ required: true
16671667+ in: query
16681668+ schema:
16691669+ $ref: "#/components/schemas/MultiSearchParameters"
16701670+ requestBody:
16711671+ content:
16721672+ application/json:
16731673+ schema:
16741674+ $ref: "#/components/schemas/MultiSearchSearchesParameter"
16751675+ responses:
16761676+ '200':
16771677+ description: Search results
16781678+ content:
16791679+ application/json:
16801680+ schema:
16811681+ $ref: "#/components/schemas/MultiSearchResult"
16821682+ '400':
16831683+ description: Bad request, see error message for details
16841684+ content:
16851685+ application/json:
16861686+ schema:
16871687+ $ref: "#/components/schemas/ApiResponse"
16881688+ /analytics/events:
16891689+ post:
16901690+ tags:
16911691+ - analytics
16921692+ summary: Create an analytics event
16931693+ description: Submit a single analytics event. The event must correspond to an existing analytics rule by name.
16941694+ operationId: createAnalyticsEvent
16951695+ requestBody:
16961696+ description: The analytics event to be created
16971697+ content:
16981698+ application/json:
16991699+ schema:
17001700+ $ref: '#/components/schemas/AnalyticsEvent'
17011701+ required: true
17021702+ responses:
17031703+ '200':
17041704+ description: Analytics event successfully created
17051705+ content:
17061706+ application/json:
17071707+ schema:
17081708+ $ref: '#/components/schemas/AnalyticsEventCreateResponse'
17091709+ '400':
17101710+ description: Bad request, see error message for details
17111711+ content:
17121712+ application/json:
17131713+ schema:
17141714+ $ref: '#/components/schemas/ApiResponse'
17151715+ get:
17161716+ tags:
17171717+ - analytics
17181718+ summary: Retrieve analytics events
17191719+ description: Retrieve the most recent events for a user and rule.
17201720+ operationId: getAnalyticsEvents
17211721+ parameters:
17221722+ - name: user_id
17231723+ in: query
17241724+ required: true
17251725+ schema:
17261726+ type: string
17271727+ - name: name
17281728+ in: query
17291729+ description: Analytics rule name
17301730+ required: true
17311731+ schema:
17321732+ type: string
17331733+ - name: n
17341734+ in: query
17351735+ description: Number of events to return (max 1000)
17361736+ required: true
17371737+ schema:
17381738+ type: integer
17391739+ responses:
17401740+ '200':
17411741+ description: Events fetched
17421742+ content:
17431743+ application/json:
17441744+ schema:
17451745+ $ref: '#/components/schemas/AnalyticsEventsResponse'
17461746+ '400':
17471747+ description: Bad request, see error message for details
17481748+ content:
17491749+ application/json:
17501750+ schema:
17511751+ $ref: '#/components/schemas/ApiResponse'
17521752+ /analytics/flush:
17531753+ post:
17541754+ tags:
17551755+ - analytics
17561756+ summary: Flush in-memory analytics to disk
17571757+ description: Triggers a flush of analytics data to persistent storage.
17581758+ operationId: flushAnalytics
17591759+ responses:
17601760+ '200':
17611761+ description: Flush triggered
17621762+ content:
17631763+ application/json:
17641764+ schema:
17651765+ $ref: '#/components/schemas/AnalyticsEventCreateResponse'
17661766+ /analytics/status:
17671767+ get:
17681768+ tags:
17691769+ - analytics
17701770+ summary: Get analytics subsystem status
17711771+ description: Returns sizes of internal analytics buffers and queues.
17721772+ operationId: getAnalyticsStatus
17731773+ responses:
17741774+ '200':
17751775+ description: Status fetched
17761776+ content:
17771777+ application/json:
17781778+ schema:
17791779+ $ref: '#/components/schemas/AnalyticsStatus'
17801780+ /analytics/rules:
17811781+ post:
17821782+ tags:
17831783+ - analytics
17841784+ summary: Create analytics rule(s)
17851785+ description: Create one or more analytics rules. You can send a single rule object or an array of rule objects.
17861786+ operationId: createAnalyticsRule
17871787+ requestBody:
17881788+ description: The analytics rule(s) to be created
17891789+ content:
17901790+ application/json:
17911791+ schema:
17921792+ oneOf:
17931793+ - $ref: "#/components/schemas/AnalyticsRuleCreate"
17941794+ - type: array
17951795+ items:
17961796+ $ref: "#/components/schemas/AnalyticsRuleCreate"
17971797+ required: true
17981798+ responses:
17991799+ '200':
18001800+ description: Analytics rule(s) successfully created
18011801+ content:
18021802+ application/json:
18031803+ schema:
18041804+ oneOf:
18051805+ - $ref: "#/components/schemas/AnalyticsRule"
18061806+ - type: array
18071807+ items:
18081808+ oneOf:
18091809+ - $ref: "#/components/schemas/AnalyticsRule"
18101810+ - type: object
18111811+ properties:
18121812+ error:
18131813+ type: string
18141814+ '400':
18151815+ description: Bad request, see error message for details
18161816+ content:
18171817+ application/json:
18181818+ schema:
18191819+ $ref: "#/components/schemas/ApiResponse"
18201820+ get:
18211821+ tags:
18221822+ - analytics
18231823+ summary: Retrieve analytics rules
18241824+ description: Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results.
18251825+ operationId: retrieveAnalyticsRules
18261826+ parameters:
18271827+ - in: query
18281828+ name: rule_tag
18291829+ schema:
18301830+ type: string
18311831+ required: false
18321832+ description: Filter rules by rule_tag
18331833+ responses:
18341834+ '200':
18351835+ description: Analytics rules fetched
18361836+ content:
18371837+ application/json:
18381838+ schema:
18391839+ type: array
18401840+ items:
18411841+ $ref: "#/components/schemas/AnalyticsRule"
18421842+ /analytics/rules/{ruleName}:
18431843+ put:
18441844+ tags:
18451845+ - analytics
18461846+ summary: Upserts an analytics rule
18471847+ description:
18481848+ Upserts an analytics rule with the given name.
18491849+ operationId: upsertAnalyticsRule
18501850+ parameters:
18511851+ - in: path
18521852+ name: ruleName
18531853+ description: The name of the analytics rule to upsert
18541854+ schema:
18551855+ type: string
18561856+ required: true
18571857+ requestBody:
18581858+ description: The Analytics rule to be upserted
18591859+ content:
18601860+ application/json:
18611861+ schema:
18621862+ $ref: "#/components/schemas/AnalyticsRuleUpdate"
18631863+ required: true
18641864+ responses:
18651865+ '200':
18661866+ description: Analytics rule successfully upserted
18671867+ content:
18681868+ application/json:
18691869+ schema:
18701870+ $ref: "#/components/schemas/AnalyticsRule"
18711871+ '400':
18721872+ description: Bad request, see error message for details
18731873+ content:
18741874+ application/json:
18751875+ schema:
18761876+ $ref: "#/components/schemas/ApiResponse"
18771877+ get:
18781878+ tags:
18791879+ - analytics
18801880+ summary: Retrieves an analytics rule
18811881+ description:
18821882+ Retrieve the details of an analytics rule, given it's name
18831883+ operationId: retrieveAnalyticsRule
18841884+ parameters:
18851885+ - in: path
18861886+ name: ruleName
18871887+ description: The name of the analytics rule to retrieve
18881888+ schema:
18891889+ type: string
18901890+ required: true
18911891+ responses:
18921892+ '200':
18931893+ description: Analytics rule fetched
18941894+ content:
18951895+ application/json:
18961896+ schema:
18971897+ $ref: "#/components/schemas/AnalyticsRule"
18981898+ '404':
18991899+ description: Analytics rule not found
19001900+ content:
19011901+ application/json:
19021902+ schema:
19031903+ $ref: "#/components/schemas/ApiResponse"
19041904+ delete:
19051905+ tags:
19061906+ - analytics
19071907+ summary: Delete an analytics rule
19081908+ description:
19091909+ Permanently deletes an analytics rule, given it's name
19101910+ operationId: deleteAnalyticsRule
19111911+ parameters:
19121912+ - in: path
19131913+ name: ruleName
19141914+ description: The name of the analytics rule to delete
19151915+ schema:
19161916+ type: string
19171917+ required: true
19181918+ responses:
19191919+ '200':
19201920+ description: Analytics rule deleted
19211921+ content:
19221922+ application/json:
19231923+ schema:
19241924+ $ref: "#/components/schemas/AnalyticsRule"
19251925+ '404':
19261926+ description: Analytics rule not found
19271927+ content:
19281928+ application/json:
19291929+ schema:
19301930+ $ref: "#/components/schemas/ApiResponse"
19311931+ /metrics.json:
19321932+ get:
19331933+ tags:
19341934+ - operations
19351935+ summary: Get current RAM, CPU, Disk & Network usage metrics.
19361936+ description:
19371937+ Retrieve the metrics.
19381938+ operationId: retrieveMetrics
19391939+ responses:
19401940+ '200':
19411941+ description: Metrics fetched.
19421942+ content:
19431943+ application/json:
19441944+ schema:
19451945+ type: object
19461946+ /stats.json:
19471947+ get:
19481948+ tags:
19491949+ - operations
19501950+ summary: Get stats about API endpoints.
19511951+ description:
19521952+ Retrieve the stats about API endpoints.
19531953+ operationId: retrieveAPIStats
19541954+ responses:
19551955+ '200':
19561956+ description: Stats fetched.
19571957+ content:
19581958+ application/json:
19591959+ schema:
19601960+ $ref: "#/components/schemas/APIStatsResponse"
19611961+ /stopwords:
19621962+ get:
19631963+ tags:
19641964+ - stopwords
19651965+ summary: Retrieves all stopwords sets.
19661966+ description:
19671967+ Retrieve the details of all stopwords sets
19681968+ operationId: retrieveStopwordsSets
19691969+ responses:
19701970+ '200':
19711971+ description: Stopwords sets fetched.
19721972+ content:
19731973+ application/json:
19741974+ schema:
19751975+ $ref: "#/components/schemas/StopwordsSetsRetrieveAllSchema"
19761976+ /stopwords/{setId}:
19771977+ put:
19781978+ tags:
19791979+ - stopwords
19801980+ summary: Upserts a stopwords set.
19811981+ description:
19821982+ When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection.
19831983+ operationId: upsertStopwordsSet
19841984+ parameters:
19851985+ - in: path
19861986+ name: setId
19871987+ description: The ID of the stopwords set to upsert.
19881988+ schema:
19891989+ type: string
19901990+ required: true
19911991+ example: countries
19921992+ requestBody:
19931993+ description: The stopwords set to upsert.
19941994+ content:
19951995+ application/json:
19961996+ schema:
19971997+ $ref: "#/components/schemas/StopwordsSetUpsertSchema"
19981998+ required: true
19991999+ responses:
20002000+ '200':
20012001+ description: Stopwords set successfully upserted.
20022002+ content:
20032003+ application/json:
20042004+ schema:
20052005+ $ref: "#/components/schemas/StopwordsSetSchema"
20062006+ '400':
20072007+ description: Bad request, see error message for details.
20082008+ content:
20092009+ application/json:
20102010+ schema:
20112011+ $ref: "#/components/schemas/ApiResponse"
20122012+ get:
20132013+ tags:
20142014+ - stopwords
20152015+ summary: Retrieves a stopwords set.
20162016+ description:
20172017+ Retrieve the details of a stopwords set, given it's name.
20182018+ operationId: retrieveStopwordsSet
20192019+ parameters:
20202020+ - in: path
20212021+ name: setId
20222022+ description: The ID of the stopwords set to retrieve.
20232023+ schema:
20242024+ type: string
20252025+ required: true
20262026+ example: countries
20272027+ responses:
20282028+ '200':
20292029+ description: Stopwords set fetched.
20302030+ content:
20312031+ application/json:
20322032+ schema:
20332033+ $ref: "#/components/schemas/StopwordsSetRetrieveSchema"
20342034+ '404':
20352035+ description: Stopwords set not found.
20362036+ content:
20372037+ application/json:
20382038+ schema:
20392039+ $ref: "#/components/schemas/ApiResponse"
20402040+ delete:
20412041+ tags:
20422042+ - stopwords
20432043+ summary: Delete a stopwords set.
20442044+ description:
20452045+ Permanently deletes a stopwords set, given it's name.
20462046+ operationId: deleteStopwordsSet
20472047+ parameters:
20482048+ - in: path
20492049+ name: setId
20502050+ description: The ID of the stopwords set to delete.
20512051+ schema:
20522052+ type: string
20532053+ required: true
20542054+ example: countries
20552055+ responses:
20562056+ '200':
20572057+ description: Stopwords set rule deleted.
20582058+ content:
20592059+ application/json:
20602060+ schema:
20612061+ type: object
20622062+ properties:
20632063+ id:
20642064+ type: string
20652065+ required:
20662066+ - id
20672067+ example: |
20682068+ {"id": "countries"}
20692069+ '404':
20702070+ description: Stopwords set not found.
20712071+ content:
20722072+ application/json:
20732073+ schema:
20742074+ $ref: "#/components/schemas/ApiResponse"
20752075+ /presets:
20762076+ get:
20772077+ tags:
20782078+ - presets
20792079+ summary: Retrieves all presets.
20802080+ description: Retrieve the details of all presets
20812081+ operationId: retrieveAllPresets
20822082+ responses:
20832083+ '200':
20842084+ description: Presets fetched.
20852085+ content:
20862086+ application/json:
20872087+ schema:
20882088+ $ref: '#/components/schemas/PresetsRetrieveSchema'
20892089+ /presets/{presetId}:
20902090+ get:
20912091+ tags:
20922092+ - presets
20932093+ summary: Retrieves a preset.
20942094+ description: Retrieve the details of a preset, given it's name.
20952095+ operationId: retrievePreset
20962096+ parameters:
20972097+ - in: path
20982098+ name: presetId
20992099+ description: The ID of the preset to retrieve.
21002100+ schema:
21012101+ type: string
21022102+ required: true
21032103+ example: listing_view
21042104+ responses:
21052105+ '200':
21062106+ description: Preset fetched.
21072107+ content:
21082108+ application/json:
21092109+ schema:
21102110+ $ref: '#/components/schemas/PresetSchema'
21112111+ '404':
21122112+ description: Preset not found.
21132113+ content:
21142114+ application/json:
21152115+ schema:
21162116+ $ref: '#/components/schemas/ApiResponse'
21172117+ put:
21182118+ tags:
21192119+ - presets
21202120+ summary: Upserts a preset.
21212121+ description: Create or update an existing preset.
21222122+ operationId: upsertPreset
21232123+ parameters:
21242124+ - in: path
21252125+ name: presetId
21262126+ description: The name of the preset set to upsert.
21272127+ schema:
21282128+ type: string
21292129+ required: true
21302130+ example: listing_view
21312131+ requestBody:
21322132+ description: The stopwords set to upsert.
21332133+ content:
21342134+ application/json:
21352135+ schema:
21362136+ $ref: '#/components/schemas/PresetUpsertSchema'
21372137+ required: true
21382138+ responses:
21392139+ '200':
21402140+ description: Preset successfully upserted.
21412141+ content:
21422142+ application/json:
21432143+ schema:
21442144+ $ref: '#/components/schemas/PresetSchema'
21452145+ '400':
21462146+ description: Bad request, see error message for details
21472147+ content:
21482148+ application/json:
21492149+ schema:
21502150+ $ref: '#/components/schemas/ApiResponse'
21512151+ delete:
21522152+ tags:
21532153+ - presets
21542154+ summary: Delete a preset.
21552155+ description: Permanently deletes a preset, given it's name.
21562156+ operationId: deletePreset
21572157+ parameters:
21582158+ - in: path
21592159+ name: presetId
21602160+ description: The ID of the preset to delete.
21612161+ schema:
21622162+ type: string
21632163+ required: true
21642164+ example: listing_view
21652165+ responses:
21662166+ '200':
21672167+ description: Preset deleted.
21682168+ content:
21692169+ application/json:
21702170+ schema:
21712171+ $ref: '#/components/schemas/PresetDeleteSchema'
21722172+ '404':
21732173+ description: Preset not found.
21742174+ content:
21752175+ application/json:
21762176+ schema:
21772177+ $ref: '#/components/schemas/ApiResponse'
21782178+ /stemming/dictionaries:
21792179+ get:
21802180+ tags:
21812181+ - stemming
21822182+ summary: List all stemming dictionaries
21832183+ description: Retrieve a list of all available stemming dictionaries.
21842184+ operationId: listStemmingDictionaries
21852185+ responses:
21862186+ '200':
21872187+ description: List of all dictionaries
21882188+ content:
21892189+ application/json:
21902190+ schema:
21912191+ type: object
21922192+ properties:
21932193+ dictionaries:
21942194+ type: array
21952195+ items:
21962196+ type: string
21972197+ example: ["irregular-plurals", "company-terms"]
21982198+21992199+ /stemming/dictionaries/{dictionaryId}:
22002200+ get:
22012201+ tags:
22022202+ - stemming
22032203+ summary: Retrieve a stemming dictionary
22042204+ description: Fetch details of a specific stemming dictionary.
22052205+ operationId: getStemmingDictionary
22062206+ parameters:
22072207+ - name: dictionaryId
22082208+ in: path
22092209+ description: The ID of the dictionary to retrieve
22102210+ required: true
22112211+ schema:
22122212+ type: string
22132213+ example: irregular-plurals
22142214+ responses:
22152215+ '200':
22162216+ description: Stemming dictionary details
22172217+ content:
22182218+ application/json:
22192219+ schema:
22202220+ $ref: "#/components/schemas/StemmingDictionary"
22212221+ '404':
22222222+ description: Dictionary not found
22232223+ content:
22242224+ application/json:
22252225+ schema:
22262226+ $ref: "#/components/schemas/ApiResponse"
22272227+22282228+ /stemming/dictionaries/import:
22292229+ post:
22302230+ tags:
22312231+ - stemming
22322232+ summary: Import a stemming dictionary
22332233+ description: Upload a JSONL file containing word mappings to create or update a stemming dictionary.
22342234+ operationId: importStemmingDictionary
22352235+ parameters:
22362236+ - name: id
22372237+ in: query
22382238+ description: The ID to assign to the dictionary
22392239+ required: true
22402240+ schema:
22412241+ type: string
22422242+ example: irregular-plurals
22432243+ requestBody:
22442244+ description: The JSONL file containing word mappings
22452245+ required: true
22462246+ content:
22472247+ application/json:
22482248+ schema:
22492249+ type: string
22502250+ example: |
22512251+ {"word": "people", "root": "person"}
22522252+ {"word": "children", "root": "child"}
22532253+ responses:
22542254+ '200':
22552255+ description: Dictionary successfully imported
22562256+ content:
22572257+ application/octet-stream:
22582258+ schema:
22592259+ type: string
22602260+ example: >
22612261+ {"word": "people", "root": "person"}
22622262+ {"word": "children", "root": "child"}
22632263+ '400':
22642264+ description: Bad request, see error message for details
22652265+ content:
22662266+ application/json:
22672267+ schema:
22682268+ $ref: "#/components/schemas/ApiResponse"
22692269+ /nl_search_models:
22702270+ get:
22712271+ tags:
22722272+ - nl_search_models
22732273+ summary: List all NL search models
22742274+ description: Retrieve all NL search models.
22752275+ operationId: retrieveAllNLSearchModels
22762276+ responses:
22772277+ '200':
22782278+ description: List of all NL search models
22792279+ content:
22802280+ application/json:
22812281+ schema:
22822282+ type: array
22832283+ items:
22842284+ $ref: '#/components/schemas/NLSearchModelSchema'
22852285+ post:
22862286+ tags:
22872287+ - nl_search_models
22882288+ summary: Create a NL search model
22892289+ description: Create a new NL search model.
22902290+ operationId: createNLSearchModel
22912291+ requestBody:
22922292+ description: The NL search model to be created
22932293+ content:
22942294+ application/json:
22952295+ schema:
22962296+ $ref: '#/components/schemas/NLSearchModelCreateSchema'
22972297+ required: true
22982298+ responses:
22992299+ '201':
23002300+ description: NL search model successfully created
23012301+ content:
23022302+ application/json:
23032303+ schema:
23042304+ $ref: '#/components/schemas/NLSearchModelSchema'
23052305+ '400':
23062306+ description: Bad request, see error message for details
23072307+ content:
23082308+ application/json:
23092309+ schema:
23102310+ $ref: '#/components/schemas/ApiResponse'
23112311+ /nl_search_models/{modelId}:
23122312+ get:
23132313+ tags:
23142314+ - nl_search_models
23152315+ summary: Retrieve a NL search model
23162316+ description: Retrieve a specific NL search model by its ID.
23172317+ operationId: retrieveNLSearchModel
23182318+ parameters:
23192319+ - name: modelId
23202320+ in: path
23212321+ description: The ID of the NL search model to retrieve
23222322+ required: true
23232323+ schema:
23242324+ type: string
23252325+ responses:
23262326+ '200':
23272327+ description: NL search model fetched
23282328+ content:
23292329+ application/json:
23302330+ schema:
23312331+ $ref: '#/components/schemas/NLSearchModelSchema'
23322332+ '404':
23332333+ description: NL search model not found
23342334+ content:
23352335+ application/json:
23362336+ schema:
23372337+ $ref: '#/components/schemas/ApiResponse'
23382338+ put:
23392339+ tags:
23402340+ - nl_search_models
23412341+ summary: Update a NL search model
23422342+ description: Update an existing NL search model.
23432343+ operationId: updateNLSearchModel
23442344+ parameters:
23452345+ - name: modelId
23462346+ in: path
23472347+ description: The ID of the NL search model to update
23482348+ required: true
23492349+ schema:
23502350+ type: string
23512351+ requestBody:
23522352+ description: The NL search model fields to update
23532353+ content:
23542354+ application/json:
23552355+ schema:
23562356+ $ref: '#/components/schemas/NLSearchModelUpdateSchema'
23572357+ required: true
23582358+ responses:
23592359+ '200':
23602360+ description: NL search model successfully updated
23612361+ content:
23622362+ application/json:
23632363+ schema:
23642364+ $ref: '#/components/schemas/NLSearchModelSchema'
23652365+ '400':
23662366+ description: Bad request, see error message for details
23672367+ content:
23682368+ application/json:
23692369+ schema:
23702370+ $ref: '#/components/schemas/ApiResponse'
23712371+ '404':
23722372+ description: NL search model not found
23732373+ content:
23742374+ application/json:
23752375+ schema:
23762376+ $ref: '#/components/schemas/ApiResponse'
23772377+ delete:
23782378+ tags:
23792379+ - nl_search_models
23802380+ summary: Delete a NL search model
23812381+ description: Delete a specific NL search model by its ID.
23822382+ operationId: deleteNLSearchModel
23832383+ parameters:
23842384+ - name: modelId
23852385+ in: path
23862386+ description: The ID of the NL search model to delete
23872387+ required: true
23882388+ schema:
23892389+ type: string
23902390+ responses:
23912391+ '200':
23922392+ description: NL search model successfully deleted
23932393+ content:
23942394+ application/json:
23952395+ schema:
23962396+ $ref: '#/components/schemas/NLSearchModelDeleteSchema'
23972397+ '404':
23982398+ description: NL search model not found
23992399+ content:
24002400+ application/json:
24012401+ schema:
24022402+ $ref: '#/components/schemas/ApiResponse'
24032403+24042404+components:
24052405+ schemas:
24062406+ CollectionSchema:
24072407+ required:
24082408+ - name
24092409+ - fields
24102410+ type: object
24112411+ properties:
24122412+ name:
24132413+ type: string
24142414+ description: Name of the collection
24152415+ example: companies
24162416+ fields:
24172417+ type: array
24182418+ description: A list of fields for querying, filtering and faceting
24192419+ example:
24202420+ - name: num_employees
24212421+ type: int32
24222422+ facet: false
24232423+ - name: company_name
24242424+ type: string
24252425+ facet: false
24262426+ - name: country
24272427+ type: string
24282428+ facet: true
24292429+ items:
24302430+ $ref: "#/components/schemas/Field"
24312431+ default_sorting_field:
24322432+ type: string
24332433+ description:
24342434+ The name of an int32 / float field that determines the order in which
24352435+ the search results are ranked when a sort_by clause is not provided during
24362436+ searching. This field must indicate some kind of popularity.
24372437+ example: num_employees # Go with the first field name listed above to produce sane defaults
24382438+ default: ""
24392439+ token_separators:
24402440+ type: array
24412441+ description: >
24422442+ List of symbols or special characters to be used for
24432443+ splitting the text into individual words in addition to space and new-line characters.
24442444+ items:
24452445+ type: string # characters only
24462446+ # Could `enum` be used instead, given it's symbols/special *characters*, e.g.:
24472447+ # enum: ["@", "!", ".", "/", ","]
24482448+ minLength: 1
24492449+ maxLength: 1
24502450+ default: []
24512451+ synonym_sets:
24522452+ type: array
24532453+ description: List of synonym set names to associate with this collection
24542454+ items:
24552455+ type: string
24562456+ example: "synonym_set_1"
24572457+ enable_nested_fields:
24582458+ type: boolean
24592459+ description:
24602460+ Enables experimental support at a collection level for nested object or object array fields.
24612461+ This field is only available if the Typesense server is version `0.24.0.rcn34` or later.
24622462+ default: false
24632463+ example: true
24642464+ symbols_to_index:
24652465+ type: array
24662466+ description: >
24672467+ List of symbols or special characters to be indexed.
24682468+ items:
24692469+ type: string # characters only
24702470+ # Could `enum` be used instead, given it's symbols/special *characters*, e.g.:
24712471+ # enum: ["@", "!", ".", "/", ","]
24722472+ minLength: 1
24732473+ maxLength: 1
24742474+ default: []
24752475+ voice_query_model:
24762476+ $ref: "#/components/schemas/VoiceQueryModelCollectionConfig"
24772477+ metadata:
24782478+ type: object
24792479+ description: >
24802480+ Optional details about the collection, e.g., when it was created, who created it etc.
24812481+ CollectionUpdateSchema:
24822482+ required:
24832483+ - fields
24842484+ type: object
24852485+ properties:
24862486+ fields:
24872487+ type: array
24882488+ description: A list of fields for querying, filtering and faceting
24892489+ example:
24902490+ - name: company_name
24912491+ type: string
24922492+ facet: false
24932493+ - name: num_employees
24942494+ type: int32
24952495+ facet: false
24962496+ - name: country
24972497+ type: string
24982498+ facet: true
24992499+ items:
25002500+ $ref: "#/components/schemas/Field"
25012501+ synonym_sets:
25022502+ type: array
25032503+ description: List of synonym set names to associate with this collection
25042504+ items:
25052505+ type: string
25062506+ example: "synonym_set_1"
25072507+ metadata:
25082508+ type: object
25092509+ description: >
25102510+ Optional details about the collection, e.g., when it was created, who created it etc.
25112511+ CollectionResponse:
25122512+ allOf:
25132513+ - $ref: "#/components/schemas/CollectionSchema"
25142514+ - type: object
25152515+ required:
25162516+ - num_documents
25172517+ - created_at
25182518+ properties:
25192519+ num_documents:
25202520+ type: integer
25212521+ description: Number of documents in the collection
25222522+ format: int64
25232523+ readOnly: true
25242524+ created_at:
25252525+ type: integer
25262526+ description: Timestamp of when the collection was created (Unix epoch in seconds)
25272527+ format: int64
25282528+ readOnly: true
25292529+ Field:
25302530+ required:
25312531+ - name
25322532+ - type
25332533+ type: object
25342534+ properties:
25352535+ name:
25362536+ type: string
25372537+ example: company_name
25382538+ type:
25392539+ type: string
25402540+ example: string
25412541+ optional:
25422542+ type: boolean
25432543+ example: true
25442544+ facet:
25452545+ type: boolean
25462546+ example: false
25472547+ index:
25482548+ type: boolean
25492549+ example: true
25502550+ default: true
25512551+ locale:
25522552+ type: string
25532553+ example: el
25542554+ sort:
25552555+ type: boolean
25562556+ example: true
25572557+ infix:
25582558+ type: boolean
25592559+ example: true
25602560+ default: false
25612561+ reference:
25622562+ type: string
25632563+ description: >
25642564+ Name of a field in another collection that should be linked to this collection so that it can be joined during query.
25652565+ async_reference:
25662566+ type: boolean
25672567+ description: >
25682568+ Allow documents to be indexed successfully even when the referenced document doesn't exist yet.
25692569+ num_dim:
25702570+ type: integer
25712571+ example: 256
25722572+ drop:
25732573+ type: boolean
25742574+ example: true
25752575+ # omitting default value since we want it to be null
25762576+ store:
25772577+ type: boolean
25782578+ description: >
25792579+ When set to false, the field value will not be stored on disk. Default: true.
25802580+ vec_dist:
25812581+ type: string
25822582+ description: >
25832583+ The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product.
25842584+ range_index:
25852585+ type: boolean
25862586+ description: >
25872587+ Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false.
25882588+ stem:
25892589+ type: boolean
25902590+ description: >
25912591+ Values are stemmed before indexing in-memory. Default: false.
25922592+ stem_dictionary:
25932593+ type: string
25942594+ description: Name of the stemming dictionary to use for this field
25952595+ example: irregular-plurals
25962596+ token_separators:
25972597+ type: array
25982598+ description: >
25992599+ List of symbols or special characters to be used for
26002600+ splitting the text into individual words in addition to space and new-line characters.
26012601+ items:
26022602+ type: string # characters only
26032603+ # Could `enum` be used instead, given it's symbols/special *characters*, e.g.:
26042604+ # enum: ["@", "!", ".", "/", ","]
26052605+ minLength: 1
26062606+ maxLength: 1
26072607+ default: []
26082608+ symbols_to_index:
26092609+ type: array
26102610+ description: >
26112611+ List of symbols or special characters to be indexed.
26122612+ items:
26132613+ type: string # characters only
26142614+ # Could `enum` be used instead, given it's symbols/special *characters*, e.g.:
26152615+ # enum: ["@", "!", ".", "/", ","]
26162616+ minLength: 1
26172617+ maxLength: 1
26182618+ default: []
26192619+ embed:
26202620+ type: object
26212621+ required:
26222622+ - from
26232623+ - model_config
26242624+ properties:
26252625+ from:
26262626+ type: array
26272627+ items:
26282628+ type: string
26292629+ model_config:
26302630+ type: object
26312631+ required:
26322632+ - model_name
26332633+ properties:
26342634+ model_name:
26352635+ type: string
26362636+ api_key:
26372637+ type: string
26382638+ url:
26392639+ type: string
26402640+ access_token:
26412641+ type: string
26422642+ refresh_token:
26432643+ type: string
26442644+ client_id:
26452645+ type: string
26462646+ client_secret:
26472647+ type: string
26482648+ project_id:
26492649+ type: string
26502650+ indexing_prefix:
26512651+ type: string
26522652+ query_prefix:
26532653+ type: string
26542654+ VoiceQueryModelCollectionConfig:
26552655+ type: object
26562656+ description: >
26572657+ Configuration for the voice query model
26582658+ properties:
26592659+ model_name:
26602660+ type: string
26612661+ example: "ts/whisper/base.en"
26622662+ CollectionAliasSchema:
26632663+ type: object
26642664+ required:
26652665+ - collection_name
26662666+ properties:
26672667+ collection_name:
26682668+ type: string
26692669+ description: Name of the collection you wish to map the alias to
26702670+ CollectionAlias:
26712671+ type: object
26722672+ required:
26732673+ - collection_name
26742674+ - name
26752675+ properties:
26762676+ name:
26772677+ type: string
26782678+ readOnly: true
26792679+ description: Name of the collection alias
26802680+ collection_name:
26812681+ type: string
26822682+ description: Name of the collection the alias mapped to
26832683+ CollectionAliasesResponse:
26842684+ type: object
26852685+ required:
26862686+ - aliases
26872687+ properties:
26882688+ aliases:
26892689+ type: array
26902690+ x-go-type: "[]*CollectionAlias"
26912691+ items:
26922692+ $ref: "#/components/schemas/CollectionAlias"
26932693+ SearchResult:
26942694+ type: object
26952695+ properties:
26962696+ facet_counts:
26972697+ type: array
26982698+ items:
26992699+ $ref: "#/components/schemas/FacetCounts"
27002700+ found:
27012701+ type: integer
27022702+ description: The number of documents found
27032703+ found_docs:
27042704+ type: integer
27052705+ search_time_ms:
27062706+ type: integer
27072707+ description: The number of milliseconds the search took
27082708+ out_of:
27092709+ type: integer
27102710+ description: The total number of documents in the collection
27112711+ search_cutoff:
27122712+ type: boolean
27132713+ description: Whether the search was cut off
27142714+ page:
27152715+ type: integer
27162716+ description: The search result page number
27172717+ grouped_hits:
27182718+ type: array
27192719+ items:
27202720+ $ref: "#/components/schemas/SearchGroupedHit"
27212721+ hits:
27222722+ type: array
27232723+ description: The documents that matched the search query
27242724+ items:
27252725+ $ref: "#/components/schemas/SearchResultHit"
27262726+ request_params:
27272727+ $ref: "#/components/schemas/SearchRequestParams"
27282728+ conversation:
27292729+ $ref: "#/components/schemas/SearchResultConversation"
27302730+ union_request_params:
27312731+ type: array
27322732+ description: Returned only for union query response.
27332733+ items:
27342734+ $ref: "#/components/schemas/SearchRequestParams"
27352735+ metadata:
27362736+ type: object
27372737+ description: Custom JSON object that can be returned in the search response
27382738+ additionalProperties: true
27392739+ SearchRequestParams:
27402740+ type: object
27412741+ required:
27422742+ - collection_name
27432743+ - q
27442744+ - per_page
27452745+ properties:
27462746+ collection_name:
27472747+ type: string
27482748+ q:
27492749+ type: string
27502750+ per_page:
27512751+ type: integer
27522752+ voice_query:
27532753+ type: object
27542754+ properties:
27552755+ transcribed_query:
27562756+ type: string
27572757+ SearchResultConversation:
27582758+ type: object
27592759+ required:
27602760+ - answer
27612761+ - conversation_history
27622762+ - conversation_id
27632763+ - query
27642764+ properties:
27652765+ answer:
27662766+ type: string
27672767+ conversation_history:
27682768+ type: array
27692769+ items:
27702770+ type: object
27712771+ conversation_id:
27722772+ type: string
27732773+ query:
27742774+ type: string
27752775+ SearchGroupedHit:
27762776+ type: object
27772777+ required:
27782778+ - group_key
27792779+ - hits
27802780+ properties:
27812781+ found:
27822782+ type: integer
27832783+ group_key:
27842784+ type: array
27852785+ items: {}
27862786+ hits:
27872787+ type: array
27882788+ description: The documents that matched the search query
27892789+ items:
27902790+ $ref: "#/components/schemas/SearchResultHit"
27912791+ SearchResultHit:
27922792+ type: object
27932793+ properties:
27942794+ highlights:
27952795+ type: array
27962796+ description: (Deprecated) Contains highlighted portions of the search fields
27972797+ items:
27982798+ $ref: "#/components/schemas/SearchHighlight"
27992799+ highlight:
28002800+ type: object
28012801+ description: Highlighted version of the matching document
28022802+ additionalProperties: true
28032803+ document:
28042804+ type: object
28052805+ description: Can be any key-value pair
28062806+ additionalProperties:
28072807+ type: object
28082808+ text_match:
28092809+ type: integer
28102810+ format: int64
28112811+ text_match_info:
28122812+ type: object
28132813+ properties:
28142814+ best_field_score:
28152815+ type: string
28162816+ best_field_weight:
28172817+ type: integer
28182818+ fields_matched:
28192819+ type: integer
28202820+ num_tokens_dropped:
28212821+ type: integer
28222822+ format: int64
28232823+ x-go-type: uint64
28242824+ score:
28252825+ type: string
28262826+ tokens_matched:
28272827+ type: integer
28282828+ typo_prefix_score:
28292829+ type: integer
28302830+ geo_distance_meters:
28312831+ type: object
28322832+ description: Can be any key-value pair
28332833+ additionalProperties:
28342834+ type: integer
28352835+ vector_distance:
28362836+ type: number
28372837+ format: float
28382838+ description: Distance between the query vector and matching document's vector value
28392839+ hybrid_search_info:
28402840+ type: object
28412841+ description: Information about hybrid search scoring
28422842+ properties:
28432843+ rank_fusion_score:
28442844+ type: number
28452845+ format: float
28462846+ description: Combined score from rank fusion of text and vector search
28472847+ search_index:
28482848+ type: integer
28492849+ description: Returned only for union query response. Indicates the index of the query which this document matched to.
28502850+ example:
28512851+ highlights:
28522852+ company_name:
28532853+ field: company_name
28542854+ snippet: <mark>Stark</mark> Industries
28552855+ document:
28562856+ id: "124"
28572857+ company_name: Stark Industries
28582858+ num_employees: 5215
28592859+ country: USA
28602860+ text_match: 1234556
28612861+ SearchHighlight:
28622862+ type: object
28632863+ properties:
28642864+ field:
28652865+ type: string
28662866+ example: company_name
28672867+ snippet:
28682868+ type: string
28692869+ description: Present only for (non-array) string fields
28702870+ example: <mark>Stark</mark> Industries
28712871+ snippets:
28722872+ type: array
28732873+ description: Present only for (array) string[] fields
28742874+ example:
28752875+ - <mark>Stark</mark> Industries
28762876+ - <mark>Stark</mark> Corp
28772877+ items:
28782878+ type: string
28792879+ value:
28802880+ type: string
28812881+ description: Full field value with highlighting, present only for (non-array) string fields
28822882+ example: <mark>Stark</mark> Industries is a major supplier of space equipment.
28832883+ values:
28842884+ type: array
28852885+ description: Full field value with highlighting, present only for (array) string[] fields
28862886+ example:
28872887+ - <mark>Stark</mark> Industries
28882888+ - <mark>Stark</mark> Corp
28892889+ items:
28902890+ type: string
28912891+ indices:
28922892+ type: array
28932893+ description: The indices property will be present only for string[]
28942894+ fields and will contain the corresponding indices of the snippets
28952895+ in the search field
28962896+ example: 1
28972897+ items:
28982898+ type: integer
28992899+ matched_tokens:
29002900+ type: array
29012901+ items:
29022902+ type: object
29032903+ x-go-type: "interface{}"
29042904+ SearchSynonymSchema:
29052905+ type: object
29062906+ required:
29072907+ - synonyms
29082908+ properties:
29092909+ root:
29102910+ type: string
29112911+ description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to.
29122912+ synonyms:
29132913+ type: array
29142914+ description: Array of words that should be considered as synonyms.
29152915+ items:
29162916+ type: string
29172917+ locale:
29182918+ type: string
29192919+ description: Locale for the synonym, leave blank to use the standard tokenizer.
29202920+ symbols_to_index:
29212921+ type: array
29222922+ description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is.
29232923+ items:
29242924+ type: string
29252925+ SearchSynonym:
29262926+ allOf:
29272927+ - $ref: "#/components/schemas/SearchSynonymSchema"
29282928+ - type: object
29292929+ required:
29302930+ - id
29312931+ properties:
29322932+ id:
29332933+ type: string
29342934+ readOnly: true
29352935+ SearchSynonymDeleteResponse:
29362936+ type: object
29372937+ required:
29382938+ - id
29392939+ properties:
29402940+ id:
29412941+ type: string
29422942+ description: The id of the synonym that was deleted
29432943+ SearchSynonymsResponse:
29442944+ type: object
29452945+ required:
29462946+ - synonyms
29472947+ properties:
29482948+ synonyms:
29492949+ type: array
29502950+ x-go-type: "[]*SearchSynonym"
29512951+ items:
29522952+ $ref: "#/components/schemas/SearchSynonym"
29532953+ HealthStatus:
29542954+ type: object
29552955+ required:
29562956+ - ok
29572957+ properties:
29582958+ ok:
29592959+ type: boolean
29602960+ SchemaChangeStatus:
29612961+ type: object
29622962+ properties:
29632963+ collection:
29642964+ type: string
29652965+ description: Name of the collection being modified
29662966+ validated_docs:
29672967+ type: integer
29682968+ description: Number of documents that have been validated
29692969+ altered_docs:
29702970+ type: integer
29712971+ description: Number of documents that have been altered
29722972+ SuccessStatus:
29732973+ type: object
29742974+ required:
29752975+ - success
29762976+ properties:
29772977+ success:
29782978+ type: boolean
29792979+ ApiResponse:
29802980+ type: object
29812981+ required:
29822982+ - message
29832983+ properties:
29842984+ message:
29852985+ type: string
29862986+ ApiKeySchema:
29872987+ type: object
29882988+ required:
29892989+ - actions
29902990+ - collections
29912991+ - description
29922992+ properties:
29932993+ value:
29942994+ type: string
29952995+ description:
29962996+ type: string
29972997+ actions:
29982998+ type: array
29992999+ items:
30003000+ type: string
30013001+ collections:
30023002+ type: array
30033003+ items:
30043004+ type: string
30053005+ expires_at:
30063006+ type: integer
30073007+ format: int64
30083008+ ApiKey:
30093009+ allOf:
30103010+ - $ref: "#/components/schemas/ApiKeySchema"
30113011+ - type: object
30123012+ properties:
30133013+ id:
30143014+ type: integer
30153015+ format: int64
30163016+ readOnly: true
30173017+ value_prefix:
30183018+ type: string
30193019+ readOnly: true
30203020+ ApiKeyDeleteResponse:
30213021+ type: object
30223022+ required:
30233023+ - id
30243024+ properties:
30253025+ id:
30263026+ type: integer
30273027+ format: int64
30283028+ description: The id of the API key that was deleted
30293029+ ApiKeysResponse:
30303030+ type: object
30313031+ required:
30323032+ - keys
30333033+ properties:
30343034+ keys:
30353035+ type: array
30363036+ x-go-type: "[]*ApiKey"
30373037+ items:
30383038+ $ref: "#/components/schemas/ApiKey"
30393039+ MultiSearchResult:
30403040+ type: object
30413041+ required:
30423042+ - results
30433043+ properties:
30443044+ results:
30453045+ type: array
30463046+ items:
30473047+ $ref: "#/components/schemas/MultiSearchResultItem"
30483048+ conversation:
30493049+ $ref: "#/components/schemas/SearchResultConversation"
30503050+ MultiSearchResultItem:
30513051+ allOf:
30523052+ - $ref: "#/components/schemas/SearchResult"
30533053+ - type: object
30543054+ properties:
30553055+ code:
30563056+ type: integer
30573057+ description: HTTP error code
30583058+ format: int64
30593059+ error:
30603060+ type: string
30613061+ description: Error description
30623062+ SearchParameters:
30633063+ type: object
30643064+ properties:
30653065+ q:
30663066+ description: The query text to search for in the collection.
30673067+ Use * as the search string to return all documents.
30683068+ This is typically useful when used in conjunction with filter_by.
30693069+ type: string
30703070+30713071+ query_by:
30723072+ description: A list of `string` fields that should be queried
30733073+ against. Multiple fields are separated with a comma.
30743074+ type: string
30753075+30763076+ nl_query:
30773077+ description: Whether to use natural language processing to parse the query.
30783078+ type: boolean
30793079+30803080+ nl_model_id:
30813081+ description: The ID of the natural language model to use.
30823082+ type: string
30833083+30843084+ query_by_weights:
30853085+ description:
30863086+ The relative weight to give each `query_by` field when ranking results.
30873087+ This can be used to boost fields in priority, when looking for matches.
30883088+ Multiple fields are separated with a comma.
30893089+ type: string
30903090+30913091+ text_match_type:
30923092+ description:
30933093+ In a multi-field matching context, this parameter determines how the representative text match
30943094+ score of a record is calculated. Possible values are max_score (default) or max_weight.
30953095+ type: string
30963096+30973097+ prefix:
30983098+ description:
30993099+ Boolean field to indicate that the last word in the query should
31003100+ be treated as a prefix, and not as a whole word. This is used for building
31013101+ autocomplete and instant search interfaces. Defaults to true.
31023102+ type: string
31033103+31043104+ infix:
31053105+ description:
31063106+ If infix index is enabled for this field, infix searching can be done on a per-field
31073107+ basis by sending a comma separated string parameter called infix to the search query.
31083108+ This parameter can have 3 values; `off` infix search is disabled, which is default
31093109+ `always` infix search is performed along with regular search
31103110+ `fallback` infix search is performed if regular search does not produce results
31113111+ type: string
31123112+31133113+ max_extra_prefix:
31143114+ description:
31153115+ There are also 2 parameters that allow you to control the extent of infix searching
31163116+ max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before
31173117+ or after the query that can be present in the token. For example query "K2100" has 2 extra
31183118+ symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match.
31193119+ type: integer
31203120+31213121+ max_extra_suffix:
31223122+ description:
31233123+ There are also 2 parameters that allow you to control the extent of infix searching
31243124+ max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before
31253125+ or after the query that can be present in the token. For example query "K2100" has 2 extra
31263126+ symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match.
31273127+ type: integer
31283128+31293129+ filter_by:
31303130+ description:
31313131+ Filter conditions for refining your open api validator search results. Separate
31323132+ multiple conditions with &&.
31333133+ type: string
31343134+ example: "num_employees:>100 && country: [USA, UK]"
31353135+31363136+ max_filter_by_candidates:
31373137+ description:
31383138+ Controls the number of similar words that Typesense considers during fuzzy search
31393139+ on filter_by values. Useful for controlling prefix matches like company_name:Acm*.
31403140+ type: integer
31413141+31423142+ sort_by:
31433143+ description:
31443144+ A list of numerical fields and their corresponding sort orders
31453145+ that will be used for ordering your results.
31463146+ Up to 3 sort fields can be specified.
31473147+ The text similarity score is exposed as a special `_text_match` field that
31483148+ you can use in the list of sorting fields.
31493149+ If no `sort_by` parameter is specified, results are sorted by
31503150+ `_text_match:desc,default_sorting_field:desc`
31513151+ type: string
31523152+ example: num_employees:desc
31533153+31543154+ facet_by:
31553155+ description:
31563156+ A list of fields that will be used for faceting your results
31573157+ on. Separate multiple fields with a comma.
31583158+ type: string
31593159+31603160+ max_facet_values:
31613161+ description: Maximum number of facet values to be returned.
31623162+ type: integer
31633163+31643164+ facet_query:
31653165+ description:
31663166+ Facet values that are returned can now be filtered via this parameter.
31673167+ The matching facet text is also highlighted. For example, when faceting
31683168+ by `category`, you can set `facet_query=category:shoe` to return only
31693169+ facet values that contain the prefix "shoe".
31703170+ type: string
31713171+31723172+ num_typos:
31733173+ description: >
31743174+ The number of typographical errors (1 or 2) that would be tolerated.
31753175+ Default: 2
31763176+ type: string
31773177+31783178+ page:
31793179+ description: Results from this specific page number would be fetched.
31803180+ type: integer
31813181+31823182+ per_page:
31833183+ description: "Number of results to fetch per page. Default: 10"
31843184+ type: integer
31853185+31863186+ limit:
31873187+ description: >
31883188+ Number of hits to fetch. Can be used as an alternative to the per_page parameter.
31893189+ Default: 10.
31903190+ type: integer
31913191+31923192+ offset:
31933193+ description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter.
31943194+ type: integer
31953195+31963196+ group_by:
31973197+ description:
31983198+ You can aggregate search results into groups or buckets by specify
31993199+ one or more `group_by` fields. Separate multiple fields with a comma.
32003200+ To group on a particular field, it must be a faceted field.
32013201+ type: string
32023202+32033203+ group_limit:
32043204+ description: >
32053205+ Maximum number of hits to be returned for every group. If the `group_limit` is
32063206+ set as `K` then only the top K hits in each group are returned in the response.
32073207+ Default: 3
32083208+ type: integer
32093209+32103210+ group_missing_values:
32113211+ description: >
32123212+ Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group.
32133213+ Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents.
32143214+ Default: true
32153215+ type: boolean
32163216+32173217+ include_fields:
32183218+ description: List of fields from the document to include in the search result
32193219+ type: string
32203220+32213221+ exclude_fields:
32223222+ description: List of fields from the document to exclude in the search result
32233223+ type: string
32243224+32253225+ highlight_full_fields:
32263226+ description: List of fields which should be highlighted fully without snippeting
32273227+ type: string
32283228+32293229+ highlight_affix_num_tokens:
32303230+ description: >
32313231+ The number of tokens that should surround the highlighted text on each side.
32323232+ Default: 4
32333233+ type: integer
32343234+32353235+ highlight_start_tag:
32363236+ description: >
32373237+ The start tag used for the highlighted snippets.
32383238+ Default: `<mark>`
32393239+ type: string
32403240+ highlight_end_tag:
32413241+ description: >
32423242+ The end tag used for the highlighted snippets.
32433243+ Default: `</mark>`
32443244+ type: string
32453245+32463246+ enable_highlight_v1:
32473247+ description: >
32483248+ Flag for enabling/disabling the deprecated, old highlight structure in the response.
32493249+ Default: true
32503250+ type: boolean
32513251+ default: true
32523252+32533253+ enable_analytics:
32543254+ description: >
32553255+ Flag for enabling/disabling analytics aggregation for specific search
32563256+ queries (for e.g. those originating from a test script).
32573257+ type: boolean
32583258+ default: true
32593259+32603260+ snippet_threshold:
32613261+ description: >
32623262+ Field values under this length will be fully highlighted, instead of showing
32633263+ a snippet of relevant portion. Default: 30
32643264+ type: integer
32653265+32663266+ synonym_sets:
32673267+ type: string
32683268+ description: List of synonym set names to associate with this search query
32693269+ example: "synonym_set_1,synonym_set_2"
32703270+32713271+ drop_tokens_threshold:
32723272+ description: >
32733273+ If the number of results found for a specific query is less than
32743274+ this number, Typesense will attempt to drop the tokens in the query until
32753275+ enough results are found. Tokens that have the least individual hits
32763276+ are dropped first. Set to 0 to disable. Default: 10
32773277+ type: integer
32783278+ drop_tokens_mode:
32793279+ $ref: "#/components/schemas/DropTokensMode"
32803280+ typo_tokens_threshold:
32813281+ description: >
32823282+ If the number of results found for a specific query is less than this number,
32833283+ Typesense will attempt to look for tokens with more typos until
32843284+ enough results are found. Default: 100
32853285+ type: integer
32863286+ enable_typos_for_alpha_numerical_tokens:
32873287+ type: boolean
32883288+ description: >
32893289+ Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
32903290+32913291+ filter_curated_hits:
32923292+ type: boolean
32933293+ description: >
32943294+ Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
32953295+ enable_synonyms:
32963296+ type: boolean
32973297+ description: >
32983298+ If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
32993299+ synonym_prefix:
33003300+ type: boolean
33013301+ description: >
33023302+ Allow synonym resolution on word prefixes in the query. Default: false
33033303+ synonym_num_typos:
33043304+ type: integer
33053305+ description: >
33063306+ Allow synonym resolution on typo-corrected words in the query. Default: 0
33073307+33083308+ pinned_hits:
33093309+ description: >
33103310+ A list of records to unconditionally include in the search results
33113311+ at specific positions. An example use case would be to feature or promote
33123312+ certain items on the top of search results.
33133313+ A list of `record_id:hit_position`. Eg: to include a record with ID 123
33143314+ at Position 1 and another record with ID 456 at Position 5,
33153315+ you'd specify `123:1,456:5`.
33163316+33173317+ You could also use the Overrides feature to override search results based
33183318+ on rules. Overrides are applied first, followed by `pinned_hits` and
33193319+ finally `hidden_hits`.
33203320+ type: string
33213321+33223322+ hidden_hits:
33233323+ description: >
33243324+ A list of records to unconditionally hide from search results.
33253325+ A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456,
33263326+ you'd specify `123,456`.
33273327+33283328+ You could also use the Overrides feature to override search results based
33293329+ on rules. Overrides are applied first, followed by `pinned_hits` and
33303330+ finally `hidden_hits`.
33313331+ type: string
33323332+33333333+ override_tags:
33343334+ description: Comma separated list of tags to trigger the curations rules that match the tags.
33353335+ type: string
33363336+33373337+ highlight_fields:
33383338+ description: >
33393339+ A list of custom fields that must be highlighted even if you don't query
33403340+ for them
33413341+ type: string
33423342+33433343+ split_join_tokens:
33443344+ description: >
33453345+ Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa.
33463346+ Splitting/joining of tokens will only be attempted if the original query produces no results.
33473347+ To always trigger this behavior, set value to `always``.
33483348+ To disable, set value to `off`. Default is `fallback`.
33493349+ type: string
33503350+33513351+ pre_segmented_query:
33523352+ description: >
33533353+ You can index content from any logographic language into Typesense if you
33543354+ are able to segment / split the text into space-separated words yourself
33553355+ before indexing and querying.
33563356+33573357+ Set this parameter to true to do the same
33583358+ type: boolean
33593359+33603360+ preset:
33613361+ description: >
33623362+ Search using a bunch of search parameters by setting this parameter to
33633363+ the name of the existing Preset.
33643364+ type: string
33653365+33663366+ enable_overrides:
33673367+ description: >
33683368+ If you have some overrides defined but want to disable all of them during
33693369+ query time, you can do that by setting this parameter to false
33703370+ type: boolean
33713371+ default: false
33723372+33733373+ prioritize_exact_match:
33743374+ description: >
33753375+ Set this parameter to true to ensure that an exact match is ranked above
33763376+ the others
33773377+ type: boolean
33783378+ default: true
33793379+ max_candidates:
33803380+ description: >
33813381+ Control the number of words that Typesense considers for typo and prefix searching.
33823382+ type: integer
33833383+ prioritize_token_position:
33843384+ description: >
33853385+ Make Typesense prioritize documents where the query words appear earlier in the text.
33863386+ type: boolean
33873387+ default: false
33883388+ prioritize_num_matching_fields:
33893389+ description: >
33903390+ Make Typesense prioritize documents where the query words appear in more number of fields.
33913391+ type: boolean
33923392+ default: true
33933393+ enable_typos_for_numerical_tokens:
33943394+ description: >
33953395+ Make Typesense disable typos for numerical tokens.
33963396+ type: boolean
33973397+ default: true
33983398+ exhaustive_search:
33993399+ description: >
34003400+ Setting this to true will make Typesense consider all prefixes and typo
34013401+ corrections of the words in the query without stopping early when enough results are found
34023402+ (drop_tokens_threshold and typo_tokens_threshold configurations are ignored).
34033403+ type: boolean
34043404+ search_cutoff_ms:
34053405+ description: >
34063406+ Typesense will attempt to return results early if the cutoff time has elapsed.
34073407+ This is not a strict guarantee and facet computation is not bound by this parameter.
34083408+ type: integer
34093409+ use_cache:
34103410+ description: >
34113411+ Enable server side caching of search query results. By default, caching is disabled.
34123412+ type: boolean
34133413+ cache_ttl:
34143414+ description: >
34153415+ The duration (in seconds) that determines how long the search query is cached.
34163416+ This value can be set on a per-query basis. Default: 60.
34173417+ type: integer
34183418+ min_len_1typo:
34193419+ description: >
34203420+ Minimum word length for 1-typo correction to be applied.
34213421+ The value of num_typos is still treated as the maximum allowed typos.
34223422+ type: integer
34233423+ min_len_2typo:
34243424+ description: >
34253425+ Minimum word length for 2-typo correction to be applied.
34263426+ The value of num_typos is still treated as the maximum allowed typos.
34273427+ type: integer
34283428+ vector_query:
34293429+ description: >
34303430+ Vector query expression for fetching documents "closest" to a given query/document vector.
34313431+ type: string
34323432+ remote_embedding_timeout_ms:
34333433+ description: >
34343434+ Timeout (in milliseconds) for fetching remote embeddings.
34353435+ type: integer
34363436+ remote_embedding_num_tries:
34373437+ description: >
34383438+ Number of times to retry fetching remote embeddings.
34393439+ type: integer
34403440+ facet_strategy:
34413441+ description: >
34423442+ Choose the underlying faceting strategy used. Comma separated string of allows values:
34433443+ exhaustive, top_values or automatic (default).
34443444+ type: string
34453445+ stopwords:
34463446+ description: >
34473447+ Name of the stopwords set to apply for this search,
34483448+ the keywords present in the set will be removed from the search query.
34493449+ type: string
34503450+ facet_return_parent:
34513451+ description: >
34523452+ Comma separated string of nested facet fields whose parent object should be returned in facet response.
34533453+ type: string
34543454+ voice_query:
34553455+ description: >
34563456+ The base64 encoded audio file in 16 khz 16-bit WAV format.
34573457+ type: string
34583458+ conversation:
34593459+ description: >
34603460+ Enable conversational search.
34613461+ type: boolean
34623462+ conversation_model_id:
34633463+ description: >
34643464+ The Id of Conversation Model to be used.
34653465+ type: string
34663466+ conversation_id:
34673467+ description: >
34683468+ The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
34693469+ type: string
34703470+34713471+ MultiSearchParameters:
34723472+ description: >
34733473+ Parameters for the multi search API.
34743474+ type: object
34753475+ properties:
34763476+ q:
34773477+ description: The query text to search for in the collection.
34783478+ Use * as the search string to return all documents.
34793479+ This is typically useful when used in conjunction with filter_by.
34803480+ type: string
34813481+34823482+ query_by:
34833483+ description: A list of `string` fields that should be queried
34843484+ against. Multiple fields are separated with a comma.
34853485+ type: string
34863486+34873487+ query_by_weights:
34883488+ description:
34893489+ The relative weight to give each `query_by` field when ranking results.
34903490+ This can be used to boost fields in priority, when looking for matches.
34913491+ Multiple fields are separated with a comma.
34923492+ type: string
34933493+34943494+ text_match_type:
34953495+ description:
34963496+ In a multi-field matching context, this parameter determines how the representative text match
34973497+ score of a record is calculated. Possible values are max_score (default) or max_weight.
34983498+ type: string
34993499+35003500+ prefix:
35013501+ description:
35023502+ Boolean field to indicate that the last word in the query should
35033503+ be treated as a prefix, and not as a whole word. This is used for building
35043504+ autocomplete and instant search interfaces. Defaults to true.
35053505+ type: string
35063506+35073507+ infix:
35083508+ description:
35093509+ If infix index is enabled for this field, infix searching can be done on a per-field
35103510+ basis by sending a comma separated string parameter called infix to the search query.
35113511+ This parameter can have 3 values; `off` infix search is disabled, which is default
35123512+ `always` infix search is performed along with regular search
35133513+ `fallback` infix search is performed if regular search does not produce results
35143514+ type: string
35153515+35163516+ max_extra_prefix:
35173517+ description:
35183518+ There are also 2 parameters that allow you to control the extent of infix searching
35193519+ max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before
35203520+ or after the query that can be present in the token. For example query "K2100" has 2 extra
35213521+ symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match.
35223522+ type: integer
35233523+35243524+ max_extra_suffix:
35253525+ description:
35263526+ There are also 2 parameters that allow you to control the extent of infix searching
35273527+ max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before
35283528+ or after the query that can be present in the token. For example query "K2100" has 2 extra
35293529+ symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match.
35303530+ type: integer
35313531+35323532+ filter_by:
35333533+ description:
35343534+ Filter conditions for refining youropen api validator search results. Separate
35353535+ multiple conditions with &&.
35363536+ type: string
35373537+ example: "num_employees:>100 && country: [USA, UK]"
35383538+35393539+ sort_by:
35403540+ description:
35413541+ A list of numerical fields and their corresponding sort orders
35423542+ that will be used for ordering your results.
35433543+ Up to 3 sort fields can be specified.
35443544+ The text similarity score is exposed as a special `_text_match` field that
35453545+ you can use in the list of sorting fields.
35463546+ If no `sort_by` parameter is specified, results are sorted by
35473547+ `_text_match:desc,default_sorting_field:desc`
35483548+ type: string
35493549+35503550+ facet_by:
35513551+ description:
35523552+ A list of fields that will be used for faceting your results
35533553+ on. Separate multiple fields with a comma.
35543554+ type: string
35553555+35563556+ max_facet_values:
35573557+ description: Maximum number of facet values to be returned.
35583558+ type: integer
35593559+35603560+ facet_query:
35613561+ description:
35623562+ Facet values that are returned can now be filtered via this parameter.
35633563+ The matching facet text is also highlighted. For example, when faceting
35643564+ by `category`, you can set `facet_query=category:shoe` to return only
35653565+ facet values that contain the prefix "shoe".
35663566+ type: string
35673567+35683568+ num_typos:
35693569+ description: >
35703570+ The number of typographical errors (1 or 2) that would be tolerated.
35713571+ Default: 2
35723572+ type: string
35733573+35743574+ page:
35753575+ description: Results from this specific page number would be fetched.
35763576+ type: integer
35773577+35783578+ per_page:
35793579+ description: "Number of results to fetch per page. Default: 10"
35803580+ type: integer
35813581+35823582+ limit:
35833583+ description: >
35843584+ Number of hits to fetch. Can be used as an alternative to the per_page parameter.
35853585+ Default: 10.
35863586+ type: integer
35873587+35883588+ offset:
35893589+ description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter.
35903590+ type: integer
35913591+35923592+ group_by:
35933593+ description:
35943594+ You can aggregate search results into groups or buckets by specify
35953595+ one or more `group_by` fields. Separate multiple fields with a comma.
35963596+ To group on a particular field, it must be a faceted field.
35973597+ type: string
35983598+35993599+ group_limit:
36003600+ description: >
36013601+ Maximum number of hits to be returned for every group. If the `group_limit` is
36023602+ set as `K` then only the top K hits in each group are returned in the response.
36033603+ Default: 3
36043604+ type: integer
36053605+36063606+ group_missing_values:
36073607+ description: >
36083608+ Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group.
36093609+ Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents.
36103610+ Default: true
36113611+ type: boolean
36123612+36133613+ include_fields:
36143614+ description: List of fields from the document to include in the search result
36153615+ type: string
36163616+36173617+ exclude_fields:
36183618+ description: List of fields from the document to exclude in the search result
36193619+ type: string
36203620+36213621+ highlight_full_fields:
36223622+ description: List of fields which should be highlighted fully without snippeting
36233623+ type: string
36243624+36253625+ highlight_affix_num_tokens:
36263626+ description: >
36273627+ The number of tokens that should surround the highlighted text on each side.
36283628+ Default: 4
36293629+ type: integer
36303630+36313631+ highlight_start_tag:
36323632+ description: >
36333633+ The start tag used for the highlighted snippets.
36343634+ Default: `<mark>`
36353635+ type: string
36363636+ highlight_end_tag:
36373637+ description: >
36383638+ The end tag used for the highlighted snippets.
36393639+ Default: `</mark>`
36403640+ type: string
36413641+36423642+ snippet_threshold:
36433643+ description: >
36443644+ Field values under this length will be fully highlighted, instead of showing
36453645+ a snippet of relevant portion. Default: 30
36463646+ type: integer
36473647+36483648+ drop_tokens_threshold:
36493649+ description: >
36503650+ If the number of results found for a specific query is less than
36513651+ this number, Typesense will attempt to drop the tokens in the query until
36523652+ enough results are found. Tokens that have the least individual hits
36533653+ are dropped first. Set to 0 to disable. Default: 10
36543654+ type: integer
36553655+ drop_tokens_mode:
36563656+ $ref: "#/components/schemas/DropTokensMode"
36573657+ typo_tokens_threshold:
36583658+ description: >
36593659+ If the number of results found for a specific query is less than this number,
36603660+ Typesense will attempt to look for tokens with more typos until
36613661+ enough results are found. Default: 100
36623662+ type: integer
36633663+ enable_typos_for_alpha_numerical_tokens:
36643664+ type: boolean
36653665+ description: >
36663666+ Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
36673667+36683668+ filter_curated_hits:
36693669+ type: boolean
36703670+ description: >
36713671+ Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
36723672+ enable_synonyms:
36733673+ type: boolean
36743674+ description: >
36753675+ If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
36763676+36773677+ enable_analytics:
36783678+ description: >
36793679+ Flag for enabling/disabling analytics aggregation for specific search
36803680+ queries (for e.g. those originating from a test script).
36813681+ type: boolean
36823682+ default: true
36833683+36843684+ synonym_prefix:
36853685+ type: boolean
36863686+ description: >
36873687+ Allow synonym resolution on word prefixes in the query. Default: false
36883688+ synonym_num_typos:
36893689+ type: integer
36903690+ description: >
36913691+ Allow synonym resolution on typo-corrected words in the query. Default: 0
36923692+36933693+ pinned_hits:
36943694+ description: >
36953695+ A list of records to unconditionally include in the search results
36963696+ at specific positions. An example use case would be to feature or promote
36973697+ certain items on the top of search results.
36983698+ A list of `record_id:hit_position`. Eg: to include a record with ID 123
36993699+ at Position 1 and another record with ID 456 at Position 5,
37003700+ you'd specify `123:1,456:5`.
37013701+37023702+ You could also use the Overrides feature to override search results based
37033703+ on rules. Overrides are applied first, followed by `pinned_hits` and
37043704+ finally `hidden_hits`.
37053705+ type: string
37063706+37073707+ hidden_hits:
37083708+ description: >
37093709+ A list of records to unconditionally hide from search results.
37103710+ A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456,
37113711+ you'd specify `123,456`.
37123712+37133713+ You could also use the Overrides feature to override search results based
37143714+ on rules. Overrides are applied first, followed by `pinned_hits` and
37153715+ finally `hidden_hits`.
37163716+ type: string
37173717+37183718+ override_tags:
37193719+ description: Comma separated list of tags to trigger the curations rules that match the tags.
37203720+ type: string
37213721+37223722+ highlight_fields:
37233723+ description: >
37243724+ A list of custom fields that must be highlighted even if you don't query
37253725+ for them
37263726+ type: string
37273727+37283728+ pre_segmented_query:
37293729+ description: >
37303730+ You can index content from any logographic language into Typesense if you
37313731+ are able to segment / split the text into space-separated words yourself
37323732+ before indexing and querying.
37333733+37343734+ Set this parameter to true to do the same
37353735+ type: boolean
37363736+ default: false
37373737+37383738+ preset:
37393739+ description: >
37403740+ Search using a bunch of search parameters by setting this parameter to
37413741+ the name of the existing Preset.
37423742+ type: string
37433743+37443744+ enable_overrides:
37453745+ description: >
37463746+ If you have some overrides defined but want to disable all of them during
37473747+ query time, you can do that by setting this parameter to false
37483748+ type: boolean
37493749+ default: false
37503750+37513751+ prioritize_exact_match:
37523752+ description: >
37533753+ Set this parameter to true to ensure that an exact match is ranked above
37543754+ the others
37553755+ type: boolean
37563756+ default: true
37573757+37583758+ prioritize_token_position:
37593759+ description: >
37603760+ Make Typesense prioritize documents where the query words appear earlier in the text.
37613761+ type: boolean
37623762+ default: false
37633763+37643764+ prioritize_num_matching_fields:
37653765+ description: >
37663766+ Make Typesense prioritize documents where the query words appear in more number of fields.
37673767+ type: boolean
37683768+ default: true
37693769+37703770+ enable_typos_for_numerical_tokens:
37713771+ description: >
37723772+ Make Typesense disable typos for numerical tokens.
37733773+ type: boolean
37743774+ default: true
37753775+37763776+ exhaustive_search:
37773777+ description: >
37783778+ Setting this to true will make Typesense consider all prefixes and typo
37793779+ corrections of the words in the query without stopping early when enough results are found
37803780+ (drop_tokens_threshold and typo_tokens_threshold configurations are ignored).
37813781+ type: boolean
37823782+ search_cutoff_ms:
37833783+ description: >
37843784+ Typesense will attempt to return results early if the cutoff time has elapsed.
37853785+ This is not a strict guarantee and facet computation is not bound by this parameter.
37863786+ type: integer
37873787+ use_cache:
37883788+ description: >
37893789+ Enable server side caching of search query results. By default, caching is disabled.
37903790+ type: boolean
37913791+ cache_ttl:
37923792+ description: >
37933793+ The duration (in seconds) that determines how long the search query is cached.
37943794+ This value can be set on a per-query basis. Default: 60.
37953795+ type: integer
37963796+ min_len_1typo:
37973797+ description: >
37983798+ Minimum word length for 1-typo correction to be applied.
37993799+ The value of num_typos is still treated as the maximum allowed typos.
38003800+ type: integer
38013801+ min_len_2typo:
38023802+ description: >
38033803+ Minimum word length for 2-typo correction to be applied.
38043804+ The value of num_typos is still treated as the maximum allowed typos.
38053805+ type: integer
38063806+ vector_query:
38073807+ description: >
38083808+ Vector query expression for fetching documents "closest" to a given query/document vector.
38093809+ type: string
38103810+ remote_embedding_timeout_ms:
38113811+ description: >
38123812+ Timeout (in milliseconds) for fetching remote embeddings.
38133813+ type: integer
38143814+ remote_embedding_num_tries:
38153815+ description: >
38163816+ Number of times to retry fetching remote embeddings.
38173817+ type: integer
38183818+ facet_strategy:
38193819+ description: >
38203820+ Choose the underlying faceting strategy used. Comma separated string of allows values:
38213821+ exhaustive, top_values or automatic (default).
38223822+ type: string
38233823+ stopwords:
38243824+ description: >
38253825+ Name of the stopwords set to apply for this search,
38263826+ the keywords present in the set will be removed from the search query.
38273827+ type: string
38283828+ facet_return_parent:
38293829+ description: >
38303830+ Comma separated string of nested facet fields whose parent object should be returned in facet response.
38313831+ type: string
38323832+ voice_query:
38333833+ description: >
38343834+ The base64 encoded audio file in 16 khz 16-bit WAV format.
38353835+ type: string
38363836+ conversation:
38373837+ description: >
38383838+ Enable conversational search.
38393839+ type: boolean
38403840+ conversation_model_id:
38413841+ description: >
38423842+ The Id of Conversation Model to be used.
38433843+ type: string
38443844+ conversation_id:
38453845+ description: >
38463846+ The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
38473847+ type: string
38483848+ MultiSearchSearchesParameter:
38493849+ type: object
38503850+ required:
38513851+ - searches
38523852+ properties:
38533853+ union:
38543854+ type: boolean
38553855+ default: false
38563856+ description: When true, merges the search results from each search query into a single ordered set of hits.
38573857+ searches:
38583858+ type: array
38593859+ items:
38603860+ $ref: "#/components/schemas/MultiSearchCollectionParameters"
38613861+ MultiSearchCollectionParameters:
38623862+ allOf:
38633863+ - $ref: "#/components/schemas/MultiSearchParameters"
38643864+ - type: object
38653865+ properties:
38663866+ collection:
38673867+ type: string
38683868+ description: >
38693869+ The collection to search in.
38703870+ x-typesense-api-key:
38713871+ type: string
38723872+ description: A separate search API key for each search within a multi_search request
38733873+ rerank_hybrid_matches:
38743874+ type: boolean
38753875+ description: >
38763876+ When true, computes both text match and vector distance scores for all matches in hybrid search.
38773877+ Documents found only through keyword search will get a vector distance score, and
38783878+ documents found only through vector search will get a text match score.
38793879+ default: false
38803880+ FacetCounts:
38813881+ type: object
38823882+ properties:
38833883+ counts:
38843884+ type: array
38853885+ items:
38863886+ type: object
38873887+ properties:
38883888+ count:
38893889+ type: integer
38903890+ highlighted:
38913891+ type: string
38923892+ value:
38933893+ type: string
38943894+ parent:
38953895+ type: object
38963896+ field_name:
38973897+ type: string
38983898+ stats:
38993899+ type: object
39003900+ properties:
39013901+ max:
39023902+ type: number
39033903+ format: double
39043904+ min:
39053905+ type: number
39063906+ format: double
39073907+ sum:
39083908+ type: number
39093909+ format: double
39103910+ total_values:
39113911+ type: integer
39123912+ avg:
39133913+ type: number
39143914+ format: double
39153915+ AnalyticsEventCreateResponse:
39163916+ type: object
39173917+ required:
39183918+ - ok
39193919+ properties:
39203920+ ok:
39213921+ type: boolean
39223922+ AnalyticsEvent:
39233923+ type: object
39243924+ required:
39253925+ - name
39263926+ - event_type
39273927+ - data
39283928+ properties:
39293929+ name:
39303930+ type: string
39313931+ description: Name of the analytics rule this event corresponds to
39323932+ event_type:
39333933+ type: string
39343934+ description: Type of event (e.g., click, conversion, query, visit)
39353935+ data:
39363936+ type: object
39373937+ description: Event payload
39383938+ properties:
39393939+ user_id:
39403940+ type: string
39413941+ doc_id:
39423942+ type: string
39433943+ doc_ids:
39443944+ type: array
39453945+ items:
39463946+ type: string
39473947+ q:
39483948+ type: string
39493949+ analytics_tag:
39503950+ type: string
39513951+ AnalyticsEventsResponse:
39523952+ type: object
39533953+ required:
39543954+ - events
39553955+ properties:
39563956+ events:
39573957+ type: array
39583958+ items:
39593959+ type: object
39603960+ properties:
39613961+ name: { type: string }
39623962+ event_type: { type: string }
39633963+ collection: { type: string }
39643964+ timestamp: { type: integer, format: int64 }
39653965+ user_id: { type: string }
39663966+ doc_id: { type: string }
39673967+ doc_ids:
39683968+ type: array
39693969+ items: { type: string }
39703970+ query: { type: string }
39713971+ AnalyticsRuleCreate:
39723972+ type: object
39733973+ required:
39743974+ - name
39753975+ - type
39763976+ - collection
39773977+ - event_type
39783978+ properties:
39793979+ name:
39803980+ type: string
39813981+ type:
39823982+ $ref: "#/components/schemas/AnalyticsRuleType"
39833983+ collection:
39843984+ type: string
39853985+ event_type:
39863986+ type: string
39873987+ rule_tag:
39883988+ type: string
39893989+ params:
39903990+ type: object
39913991+ properties:
39923992+ destination_collection:
39933993+ type: string
39943994+ limit:
39953995+ type: integer
39963996+ capture_search_requests:
39973997+ type: boolean
39983998+ meta_fields:
39993999+ type: array
40004000+ items: { type: string }
40014001+ expand_query:
40024002+ type: boolean
40034003+ counter_field:
40044004+ type: string
40054005+ weight:
40064006+ type: integer
40074007+ AnalyticsRuleType:
40084008+ type: string
40094009+ enum: [popular_queries, nohits_queries, counter, log]
40104010+ AnalyticsRuleUpdate:
40114011+ type: object
40124012+ description: Fields allowed to update on an analytics rule
40134013+ properties:
40144014+ name:
40154015+ type: string
40164016+ rule_tag:
40174017+ type: string
40184018+ params:
40194019+ type: object
40204020+ properties:
40214021+ destination_collection:
40224022+ type: string
40234023+ limit:
40244024+ type: integer
40254025+ capture_search_requests:
40264026+ type: boolean
40274027+ meta_fields:
40284028+ type: array
40294029+ items: { type: string }
40304030+ expand_query:
40314031+ type: boolean
40324032+ counter_field:
40334033+ type: string
40344034+ weight:
40354035+ type: integer
40364036+ AnalyticsRule:
40374037+ allOf:
40384038+ - $ref: '#/components/schemas/AnalyticsRuleCreate'
40394039+ - type: object
40404040+ AnalyticsStatus:
40414041+ type: object
40424042+ properties:
40434043+ popular_prefix_queries: { type: integer }
40444044+ nohits_prefix_queries: { type: integer }
40454045+ log_prefix_queries: { type: integer }
40464046+ query_log_events: { type: integer }
40474047+ query_counter_events: { type: integer }
40484048+ doc_log_events: { type: integer }
40494049+ doc_counter_events: { type: integer }
40504050+40514051+ APIStatsResponse:
40524052+ type: object
40534053+ properties:
40544054+ delete_latency_ms:
40554055+ type: number
40564056+ format: double
40574057+ delete_requests_per_second:
40584058+ type: number
40594059+ format: double
40604060+ import_latency_ms:
40614061+ type: number
40624062+ format: double
40634063+ import_requests_per_second:
40644064+ type: number
40654065+ format: double
40664066+ latency_ms:
40674067+ type: object
40684068+ x-go-type: "map[string]float64"
40694069+ overloaded_requests_per_second:
40704070+ type: number
40714071+ format: double
40724072+ pending_write_batches:
40734073+ type: number
40744074+ format: double
40754075+ requests_per_second:
40764076+ type: object
40774077+ x-go-type: "map[string]float64"
40784078+ search_latency_ms:
40794079+ type: number
40804080+ format: double
40814081+ search_requests_per_second:
40824082+ type: number
40834083+ format: double
40844084+ total_requests_per_second:
40854085+ type: number
40864086+ format: double
40874087+ write_latency_ms:
40884088+ type: number
40894089+ format: double
40904090+ write_requests_per_second:
40914091+ type: number
40924092+ format: double
40934093+ StopwordsSetUpsertSchema:
40944094+ type: object
40954095+ properties:
40964096+ stopwords:
40974097+ type: array
40984098+ items:
40994099+ type: string
41004100+ locale:
41014101+ type: string
41024102+ required:
41034103+ - stopwords
41044104+ example: |
41054105+ {"stopwords": ["Germany", "France", "Italy"], "locale": "en"}
41064106+ StopwordsSetSchema:
41074107+ type: object
41084108+ properties:
41094109+ id:
41104110+ type: string
41114111+ stopwords:
41124112+ type: array
41134113+ items:
41144114+ type: string
41154115+ locale:
41164116+ type: string
41174117+ required:
41184118+ - id
41194119+ - stopwords
41204120+ example: |
41214121+ {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}
41224122+ StopwordsSetRetrieveSchema:
41234123+ type: object
41244124+ properties:
41254125+ stopwords:
41264126+ $ref: "#/components/schemas/StopwordsSetSchema"
41274127+ required:
41284128+ - stopwords
41294129+ example: |
41304130+ {"stopwords": {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}}
41314131+ StopwordsSetsRetrieveAllSchema:
41324132+ type: object
41334133+ properties:
41344134+ stopwords:
41354135+ type: array
41364136+ items:
41374137+ $ref: "#/components/schemas/StopwordsSetSchema"
41384138+ required:
41394139+ - stopwords
41404140+ example: |
41414141+ {"stopwords": [{"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}]}
41424142+ PresetUpsertSchema:
41434143+ properties:
41444144+ value:
41454145+ oneOf:
41464146+ - $ref: '#/components/schemas/SearchParameters'
41474147+ - $ref: '#/components/schemas/MultiSearchSearchesParameter'
41484148+ required:
41494149+ - value
41504150+ PresetSchema:
41514151+ allOf:
41524152+ - $ref: '#/components/schemas/PresetUpsertSchema'
41534153+ - type: object
41544154+ required:
41554155+ - name
41564156+ properties:
41574157+ name:
41584158+ type: string
41594159+ PresetsRetrieveSchema:
41604160+ type: object
41614161+ required:
41624162+ - presets
41634163+ properties:
41644164+ presets:
41654165+ type: array
41664166+ items:
41674167+ $ref: '#/components/schemas/PresetSchema'
41684168+ x-go-type: '[]*PresetSchema'
41694169+ PresetDeleteSchema:
41704170+ type: object
41714171+ required:
41724172+ - name
41734173+ properties:
41744174+ name:
41754175+ type: string
41764176+ DirtyValues:
41774177+ type: string
41784178+ enum: [coerce_or_reject, coerce_or_drop, drop, reject]
41794179+ IndexAction:
41804180+ type: string
41814181+ enum: [create, update, upsert, emplace]
41824182+ DropTokensMode:
41834183+ type: string
41844184+ enum: [right_to_left, left_to_right, both_sides:3]
41854185+ description: >
41864186+ Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document.
41874187+ Values: right_to_left (default), left_to_right, both_sides:3
41884188+ A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results.
41894189+ If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left
41904190+ ConversationModelCreateSchema:
41914191+ required:
41924192+ - model_name
41934193+ - max_bytes
41944194+ allOf:
41954195+ - $ref: '#/components/schemas/ConversationModelUpdateSchema'
41964196+ - type: object
41974197+ required:
41984198+ - model_name
41994199+ - max_bytes
42004200+ - history_collection
42014201+ properties:
42024202+ model_name:
42034203+ description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM
42044204+ type: string
42054205+ max_bytes:
42064206+ description: |
42074207+ The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
42084208+ type: integer
42094209+ history_collection:
42104210+ type: string
42114211+ description: Typesense collection that stores the historical conversations
42124212+ ConversationModelUpdateSchema:
42134213+ type: object
42144214+ properties:
42154215+ id:
42164216+ type: string
42174217+ description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id.
42184218+ model_name:
42194219+ description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM
42204220+ type: string
42214221+ api_key:
42224222+ description: The LLM service's API Key
42234223+ type: string
42244224+ history_collection:
42254225+ type: string
42264226+ description: Typesense collection that stores the historical conversations
42274227+ account_id:
42284228+ description: LLM service's account ID (only applicable for Cloudflare)
42294229+ type: string
42304230+ system_prompt:
42314231+ description: The system prompt that contains special instructions to the LLM
42324232+ type: string
42334233+ ttl:
42344234+ type: integer
42354235+ description: |
42364236+ Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
42374237+ max_bytes:
42384238+ description: |
42394239+ The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
42404240+ type: integer
42414241+ vllm_url:
42424242+ description: URL of vLLM service
42434243+ type: string
42444244+ ConversationModelSchema:
42454245+ allOf:
42464246+ - $ref: '#/components/schemas/ConversationModelCreateSchema'
42474247+ - type: object
42484248+ required:
42494249+ - id
42504250+ properties:
42514251+ id:
42524252+ type: string
42534253+ description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id.
42544254+ StemmingDictionary:
42554255+ type: object
42564256+ required:
42574257+ - id
42584258+ - words
42594259+ properties:
42604260+ id:
42614261+ type: string
42624262+ description: Unique identifier for the dictionary
42634263+ example: irregular-plurals
42644264+ words:
42654265+ type: array
42664266+ description: List of word mappings in the dictionary
42674267+ items:
42684268+ type: object
42694269+ required:
42704270+ - word
42714271+ - root
42724272+ properties:
42734273+ word:
42744274+ type: string
42754275+ description: The word form to be stemmed
42764276+ example: people
42774277+ root:
42784278+ type: string
42794279+ description: The root form of the word
42804280+ example: person
42814281+ NLSearchModelBase:
42824282+ type: object
42834283+ properties:
42844284+ model_name:
42854285+ type: string
42864286+ description: Name of the NL model to use
42874287+ api_key:
42884288+ type: string
42894289+ description: API key for the NL model service
42904290+ api_url:
42914291+ type: string
42924292+ description: Custom API URL for the NL model service
42934293+ max_bytes:
42944294+ type: integer
42954295+ description: Maximum number of bytes to process
42964296+ temperature:
42974297+ type: number
42984298+ description: Temperature parameter for the NL model
42994299+ system_prompt:
43004300+ type: string
43014301+ description: System prompt for the NL model
43024302+ top_p:
43034303+ type: number
43044304+ description: Top-p parameter for the NL model (Google-specific)
43054305+ top_k:
43064306+ type: integer
43074307+ description: Top-k parameter for the NL model (Google-specific)
43084308+ stop_sequences:
43094309+ type: array
43104310+ items:
43114311+ type: string
43124312+ description: Stop sequences for the NL model (Google-specific)
43134313+ api_version:
43144314+ type: string
43154315+ description: API version for the NL model service
43164316+ project_id:
43174317+ type: string
43184318+ description: Project ID for GCP Vertex AI
43194319+ access_token:
43204320+ type: string
43214321+ description: Access token for GCP Vertex AI
43224322+ refresh_token:
43234323+ type: string
43244324+ description: Refresh token for GCP Vertex AI
43254325+ client_id:
43264326+ type: string
43274327+ description: Client ID for GCP Vertex AI
43284328+ client_secret:
43294329+ type: string
43304330+ description: Client secret for GCP Vertex AI
43314331+ region:
43324332+ type: string
43334333+ description: Region for GCP Vertex AI
43344334+ max_output_tokens:
43354335+ type: integer
43364336+ description: Maximum output tokens for GCP Vertex AI
43374337+ account_id:
43384338+ type: string
43394339+ description: Account ID for Cloudflare-specific models
43404340+43414341+ NLSearchModelCreateSchema:
43424342+ allOf:
43434343+ - $ref: '#/components/schemas/NLSearchModelBase'
43444344+ - type: object
43454345+ properties:
43464346+ id:
43474347+ type: string
43484348+ description: Optional ID for the NL search model
43494349+43504350+ NLSearchModelSchema:
43514351+ allOf:
43524352+ - $ref: '#/components/schemas/NLSearchModelCreateSchema'
43534353+ - type: object
43544354+ required:
43554355+ - id
43564356+ properties:
43574357+ id:
43584358+ type: string
43594359+ description: ID of the NL search model
43604360+43614361+ NLSearchModelUpdateSchema:
43624362+ $ref: '#/components/schemas/NLSearchModelCreateSchema'
43634363+43644364+ NLSearchModelDeleteSchema:
43654365+ type: object
43664366+ required:
43674367+ - id
43684368+ properties:
43694369+ id:
43704370+ type: string
43714371+ description: ID of the deleted NL search model
43724372+43734373+ SynonymItemUpsertSchema:
43744374+ type: object
43754375+ required:
43764376+ - synonyms
43774377+ properties:
43784378+ synonyms:
43794379+ type: array
43804380+ description: Array of words that should be considered as synonyms
43814381+ items:
43824382+ type: string
43834383+ root:
43844384+ type: string
43854385+ description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to
43864386+ locale:
43874387+ type: string
43884388+ description: Locale for the synonym, leave blank to use the standard tokenizer
43894389+ symbols_to_index:
43904390+ type: array
43914391+ description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is
43924392+ items:
43934393+ type: string
43944394+43954395+ SynonymItemSchema:
43964396+ allOf:
43974397+ - type: object
43984398+ required:
43994399+ - id
44004400+ properties:
44014401+ id:
44024402+ type: string
44034403+ description: Unique identifier for the synonym item
44044404+ - $ref: "#/components/schemas/SynonymItemUpsertSchema"
44054405+44064406+ SynonymSetCreateSchema:
44074407+ type: object
44084408+ required:
44094409+ - items
44104410+ properties:
44114411+ items:
44124412+ type: array
44134413+ description: Array of synonym items
44144414+ items:
44154415+ $ref: "#/components/schemas/SynonymItemSchema"
44164416+44174417+ SynonymSetSchema:
44184418+ allOf:
44194419+ - $ref: "#/components/schemas/SynonymSetCreateSchema"
44204420+ - type: object
44214421+ required:
44224422+ - name
44234423+ properties:
44244424+ name:
44254425+ type: string
44264426+ description: Name of the synonym set
44274427+44284428+ SynonymSetsRetrieveSchema:
44294429+ type: object
44304430+ required:
44314431+ - synonym_sets
44324432+ properties:
44334433+ synonym_sets:
44344434+ type: array
44354435+ description: Array of synonym sets
44364436+ items:
44374437+ $ref: "#/components/schemas/SynonymSetSchema"
44384438+44394439+ SynonymSetDeleteSchema:
44404440+ type: object
44414441+ required:
44424442+ - name
44434443+ properties:
44444444+ name:
44454445+ type: string
44464446+ description: Name of the deleted synonym set
44474447+44484448+ SynonymItemDeleteSchema:
44494449+ type: object
44504450+ required:
44514451+ - id
44524452+ properties:
44534453+ id:
44544454+ type: string
44554455+ description: ID of the deleted synonym item
44564456+44574457+ CurationItemCreateSchema:
44584458+ type: object
44594459+ required:
44604460+ - rule
44614461+ properties:
44624462+ rule:
44634463+ $ref: '#/components/schemas/CurationRule'
44644464+ includes:
44654465+ type: array
44664466+ description:
44674467+ List of document `id`s that should be included in the search results with their
44684468+ corresponding `position`s.
44694469+ items:
44704470+ $ref: '#/components/schemas/CurationInclude'
44714471+ excludes:
44724472+ type: array
44734473+ description: List of document `id`s that should be excluded from the search results.
44744474+ items:
44754475+ $ref: '#/components/schemas/CurationExclude'
44764476+ filter_by:
44774477+ type: string
44784478+ description: >
44794479+ A filter by clause that is applied to any search query that matches the curation rule.
44804480+ remove_matched_tokens:
44814481+ type: boolean
44824482+ description: >
44834483+ Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
44844484+ metadata:
44854485+ type: object
44864486+ description: >
44874487+ 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.
44884488+ sort_by:
44894489+ type: string
44904490+ description: >
44914491+ A sort by clause that is applied to any search query that matches the curation rule.
44924492+ replace_query:
44934493+ type: string
44944494+ description: >
44954495+ Replaces the current search query with this value, when the search query matches the curation rule.
44964496+ filter_curated_hits:
44974497+ type: boolean
44984498+ description: >
44994499+ When set to true, the filter conditions of the query is applied to the curated records as well.
45004500+ Default: false.
45014501+ effective_from_ts:
45024502+ type: integer
45034503+ description: >
45044504+ A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
45054505+ effective_to_ts:
45064506+ type: integer
45074507+ description: >
45084508+ A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
45094509+ stop_processing:
45104510+ type: boolean
45114511+ description: >
45124512+ When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence.
45134513+ Curations are processed in the lexical sort order of their id field.
45144514+ id:
45154515+ type: string
45164516+ description: ID of the curation item
45174517+45184518+45194519+ CurationItemSchema:
45204520+ allOf:
45214521+ - $ref: '#/components/schemas/CurationItemCreateSchema'
45224522+ - type: object
45234523+ required:
45244524+ - id
45254525+ properties:
45264526+ id:
45274527+ type: string
45284528+45294529+ CurationSetCreateSchema:
45304530+ type: object
45314531+ required:
45324532+ - items
45334533+ properties:
45344534+ items:
45354535+ type: array
45364536+ description: Array of curation items
45374537+ items:
45384538+ $ref: '#/components/schemas/CurationItemCreateSchema'
45394539+ description:
45404540+ type: string
45414541+ description: Optional description for the curation set
45424542+45434543+ CurationSetSchema:
45444544+ allOf:
45454545+ - $ref: '#/components/schemas/CurationSetCreateSchema'
45464546+ - type: object
45474547+ required:
45484548+ - name
45494549+ properties:
45504550+ name:
45514551+ type: string
45524552+45534553+ CurationRule:
45544554+ type: object
45554555+ properties:
45564556+ tags:
45574557+ type: array
45584558+ description: List of tag values to associate with this curation rule.
45594559+ items:
45604560+ type: string
45614561+ query:
45624562+ type: string
45634563+ description: Indicates what search queries should be curated
45644564+ match:
45654565+ type: string
45664566+ description: >
45674567+ Indicates whether the match on the query term should be `exact` or `contains`.
45684568+ If we want to match all queries that contained the word `apple`, we will use the `contains` match instead.
45694569+ enum:
45704570+ - exact
45714571+ - contains
45724572+ filter_by:
45734573+ type: string
45744574+ description: >
45754575+ Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc).
45764576+45774577+ CurationInclude:
45784578+ type: object
45794579+ required:
45804580+ - id
45814581+ - position
45824582+ properties:
45834583+ id:
45844584+ type: string
45854585+ description: document id that should be included
45864586+ position:
45874587+ type: integer
45884588+ description: position number where document should be included in the search results
45894589+45904590+ CurationExclude:
45914591+ type: object
45924592+ required:
45934593+ - id
45944594+ properties:
45954595+ id:
45964596+ type: string
45974597+ description: document id that should be excluded from the search results.
45984598+45994599+ CurationSetDeleteSchema:
46004600+ type: object
46014601+ required:
46024602+ - name
46034603+ properties:
46044604+ name:
46054605+ type: string
46064606+ description: Name of the deleted curation set
46074607+ CurationItemDeleteSchema:
46084608+ type: object
46094609+ required:
46104610+ - id
46114611+ properties:
46124612+ id:
46134613+ type: string
46144614+ description: ID of the deleted curation item
46154615+46164616+ securitySchemes:
46174617+ api_key_header:
46184618+ type: apiKey
46194619+ name: X-TYPESENSE-API-KEY
46204620+ in: header
+6524
typesense.ml
···11+(** {1 Typesense}
22+33+ An open source search engine for building delightful search experiences.
44+55+ @version 30.0 *)
66+77+type t = {
88+ session : Requests.t;
99+ base_url : string;
1010+}
1111+1212+let create ?session ~sw env ~base_url =
1313+ let session = match session with
1414+ | Some s -> s
1515+ | None -> Requests.create ~sw env
1616+ in
1717+ { session; base_url }
1818+1919+let base_url t = t.base_url
2020+let session t = t.session
2121+2222+module VoiceQueryModelCollection = struct
2323+ module Types = struct
2424+ module Config = struct
2525+ (** Configuration for the voice query model
2626+ *)
2727+ type t = {
2828+ model_name : string option;
2929+ }
3030+ end
3131+ end
3232+3333+ module Config = struct
3434+ include Types.Config
3535+3636+ let v ?model_name () = { model_name }
3737+3838+ let model_name t = t.model_name
3939+4040+ let jsont : t Jsont.t =
4141+ Jsont.Object.map ~kind:"VoiceQueryModelCollectionConfig"
4242+ (fun model_name -> { model_name })
4343+ |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
4444+ |> Jsont.Object.skip_unknown
4545+ |> Jsont.Object.finish
4646+ end
4747+end
4848+4949+module SynonymSetDeleteSchema = struct
5050+ module Types = struct
5151+ module T = struct
5252+ type t = {
5353+ name : string; (** Name of the deleted synonym set *)
5454+ }
5555+ end
5656+ end
5757+5858+ module T = struct
5959+ include Types.T
6060+6161+ let v ~name () = { name }
6262+6363+ let name t = t.name
6464+6565+ let jsont : t Jsont.t =
6666+ Jsont.Object.map ~kind:"SynonymSetDeleteSchema"
6767+ (fun name -> { name })
6868+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
6969+ |> Jsont.Object.skip_unknown
7070+ |> Jsont.Object.finish
7171+ end
7272+7373+ (** Delete a synonym set
7474+7575+ Delete a specific synonym set by its name
7676+ @param synonym_set_name The name of the synonym set to delete
7777+ *)
7878+ let delete_synonym_set ~synonym_set_name client () =
7979+ let op_name = "delete_synonym_set" in
8080+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in
8181+ let query = "" in
8282+ let url = client.base_url ^ url_path ^ query in
8383+ let response =
8484+ try Requests.delete client.session url
8585+ with Eio.Io _ as ex ->
8686+ let bt = Printexc.get_raw_backtrace () in
8787+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
8888+ in
8989+ if Requests.Response.ok response then
9090+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
9191+ else
9292+ let body = Requests.Response.text response in
9393+ let status = Requests.Response.status_code response in
9494+ let parsed_body = match status with
9595+ | 404 ->
9696+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
9797+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
9898+ | Error _ -> None)
9999+ | _ ->
100100+ (match Jsont_bytesrw.decode_string Jsont.json body with
101101+ | Ok json -> Some (Openapi.Runtime.Json json)
102102+ | Error _ -> Some (Openapi.Runtime.Raw body))
103103+ in
104104+ raise (Openapi.Runtime.Api_error {
105105+ operation = op_name;
106106+ method_ = "DELETE";
107107+ url;
108108+ status;
109109+ body;
110110+ parsed_body;
111111+ })
112112+end
113113+114114+module SynonymItemUpsertSchema = struct
115115+ module Types = struct
116116+ module T = struct
117117+ type t = {
118118+ locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer *)
119119+ root : string option; (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *)
120120+ symbols_to_index : string list option; (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *)
121121+ synonyms : string list; (** Array of words that should be considered as synonyms *)
122122+ }
123123+ end
124124+ end
125125+126126+ module T = struct
127127+ include Types.T
128128+129129+ let v ~synonyms ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms }
130130+131131+ let locale t = t.locale
132132+ let root t = t.root
133133+ let symbols_to_index t = t.symbols_to_index
134134+ let synonyms t = t.synonyms
135135+136136+ let jsont : t Jsont.t =
137137+ Jsont.Object.map ~kind:"SynonymItemUpsertSchema"
138138+ (fun locale root symbols_to_index synonyms -> { locale; root; symbols_to_index; synonyms })
139139+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
140140+ |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root)
141141+ |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index)
142142+ |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms)
143143+ |> Jsont.Object.skip_unknown
144144+ |> Jsont.Object.finish
145145+ end
146146+end
147147+148148+module SynonymItemSchema = struct
149149+ module Types = struct
150150+ module T = struct
151151+ type t = {
152152+ id : string; (** Unique identifier for the synonym item *)
153153+ locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer *)
154154+ root : string option; (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *)
155155+ symbols_to_index : string list option; (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *)
156156+ synonyms : string list; (** Array of words that should be considered as synonyms *)
157157+ }
158158+ end
159159+ end
160160+161161+ module T = struct
162162+ include Types.T
163163+164164+ let v ~id ~synonyms ?locale ?root ?symbols_to_index () = { id; locale; root; symbols_to_index; synonyms }
165165+166166+ let id t = t.id
167167+ let locale t = t.locale
168168+ let root t = t.root
169169+ let symbols_to_index t = t.symbols_to_index
170170+ let synonyms t = t.synonyms
171171+172172+ let jsont : t Jsont.t =
173173+ Jsont.Object.map ~kind:"SynonymItemSchema"
174174+ (fun id locale root symbols_to_index synonyms -> { id; locale; root; symbols_to_index; synonyms })
175175+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
176176+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
177177+ |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root)
178178+ |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index)
179179+ |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms)
180180+ |> Jsont.Object.skip_unknown
181181+ |> Jsont.Object.finish
182182+ end
183183+184184+ (** List items in a synonym set
185185+186186+ Retrieve all synonym items in a set
187187+ @param synonym_set_name The name of the synonym set to retrieve items for
188188+ *)
189189+ let retrieve_synonym_set_items ~synonym_set_name client () =
190190+ let op_name = "retrieve_synonym_set_items" in
191191+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}/items" in
192192+ let query = "" in
193193+ let url = client.base_url ^ url_path ^ query in
194194+ let response =
195195+ try Requests.get client.session url
196196+ with Eio.Io _ as ex ->
197197+ let bt = Printexc.get_raw_backtrace () in
198198+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
199199+ in
200200+ if Requests.Response.ok response then
201201+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
202202+ else
203203+ let body = Requests.Response.text response in
204204+ let status = Requests.Response.status_code response in
205205+ let parsed_body = match status with
206206+ | 404 ->
207207+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
208208+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
209209+ | Error _ -> None)
210210+ | _ ->
211211+ (match Jsont_bytesrw.decode_string Jsont.json body with
212212+ | Ok json -> Some (Openapi.Runtime.Json json)
213213+ | Error _ -> Some (Openapi.Runtime.Raw body))
214214+ in
215215+ raise (Openapi.Runtime.Api_error {
216216+ operation = op_name;
217217+ method_ = "GET";
218218+ url;
219219+ status;
220220+ body;
221221+ parsed_body;
222222+ })
223223+224224+ (** Retrieve a synonym set item
225225+226226+ Retrieve a specific synonym item by its id
227227+ @param synonym_set_name The name of the synonym set
228228+ @param item_id The id of the synonym item to retrieve
229229+ *)
230230+ let retrieve_synonym_set_item ~synonym_set_name ~item_id client () =
231231+ let op_name = "retrieve_synonym_set_item" in
232232+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in
233233+ let query = "" in
234234+ let url = client.base_url ^ url_path ^ query in
235235+ let response =
236236+ try Requests.get client.session url
237237+ with Eio.Io _ as ex ->
238238+ let bt = Printexc.get_raw_backtrace () in
239239+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
240240+ in
241241+ if Requests.Response.ok response then
242242+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
243243+ else
244244+ let body = Requests.Response.text response in
245245+ let status = Requests.Response.status_code response in
246246+ let parsed_body = match status with
247247+ | 404 ->
248248+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
249249+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
250250+ | Error _ -> None)
251251+ | _ ->
252252+ (match Jsont_bytesrw.decode_string Jsont.json body with
253253+ | Ok json -> Some (Openapi.Runtime.Json json)
254254+ | Error _ -> Some (Openapi.Runtime.Raw body))
255255+ in
256256+ raise (Openapi.Runtime.Api_error {
257257+ operation = op_name;
258258+ method_ = "GET";
259259+ url;
260260+ status;
261261+ body;
262262+ parsed_body;
263263+ })
264264+265265+ (** Create or update a synonym set item
266266+267267+ Create or update a synonym set item with the given id
268268+ @param synonym_set_name The name of the synonym set
269269+ @param item_id The id of the synonym item to upsert
270270+ *)
271271+ let upsert_synonym_set_item ~synonym_set_name ~item_id ~body client () =
272272+ let op_name = "upsert_synonym_set_item" in
273273+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in
274274+ let query = "" in
275275+ let url = client.base_url ^ url_path ^ query in
276276+ let response =
277277+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json SynonymItemUpsertSchema.T.jsont body)) url
278278+ with Eio.Io _ as ex ->
279279+ let bt = Printexc.get_raw_backtrace () in
280280+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
281281+ in
282282+ if Requests.Response.ok response then
283283+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
284284+ else
285285+ let body = Requests.Response.text response in
286286+ let status = Requests.Response.status_code response in
287287+ let parsed_body = match status with
288288+ | 400 ->
289289+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
290290+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
291291+ | Error _ -> None)
292292+ | _ ->
293293+ (match Jsont_bytesrw.decode_string Jsont.json body with
294294+ | Ok json -> Some (Openapi.Runtime.Json json)
295295+ | Error _ -> Some (Openapi.Runtime.Raw body))
296296+ in
297297+ raise (Openapi.Runtime.Api_error {
298298+ operation = op_name;
299299+ method_ = "PUT";
300300+ url;
301301+ status;
302302+ body;
303303+ parsed_body;
304304+ })
305305+end
306306+307307+module SynonymSetCreateSchema = struct
308308+ module Types = struct
309309+ module T = struct
310310+ type t = {
311311+ items : SynonymItemSchema.T.t list; (** Array of synonym items *)
312312+ }
313313+ end
314314+ end
315315+316316+ module T = struct
317317+ include Types.T
318318+319319+ let v ~items () = { items }
320320+321321+ let items t = t.items
322322+323323+ let jsont : t Jsont.t =
324324+ Jsont.Object.map ~kind:"SynonymSetCreateSchema"
325325+ (fun items -> { items })
326326+ |> Jsont.Object.mem "items" (Jsont.list SynonymItemSchema.T.jsont) ~enc:(fun r -> r.items)
327327+ |> Jsont.Object.skip_unknown
328328+ |> Jsont.Object.finish
329329+ end
330330+end
331331+332332+module SynonymSetSchema = struct
333333+ module Types = struct
334334+ module T = struct
335335+ type t = {
336336+ items : SynonymItemSchema.T.t list; (** Array of synonym items *)
337337+ name : string; (** Name of the synonym set *)
338338+ }
339339+ end
340340+ end
341341+342342+ module T = struct
343343+ include Types.T
344344+345345+ let v ~items ~name () = { items; name }
346346+347347+ let items t = t.items
348348+ let name t = t.name
349349+350350+ let jsont : t Jsont.t =
351351+ Jsont.Object.map ~kind:"SynonymSetSchema"
352352+ (fun items name -> { items; name })
353353+ |> Jsont.Object.mem "items" (Jsont.list SynonymItemSchema.T.jsont) ~enc:(fun r -> r.items)
354354+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
355355+ |> Jsont.Object.skip_unknown
356356+ |> Jsont.Object.finish
357357+ end
358358+359359+ (** List all synonym sets
360360+361361+ Retrieve all synonym sets *)
362362+ let retrieve_synonym_sets client () =
363363+ let op_name = "retrieve_synonym_sets" in
364364+ let url_path = "/synonym_sets" in
365365+ let query = "" in
366366+ let url = client.base_url ^ url_path ^ query in
367367+ let response =
368368+ try Requests.get client.session url
369369+ with Eio.Io _ as ex ->
370370+ let bt = Printexc.get_raw_backtrace () in
371371+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
372372+ in
373373+ if Requests.Response.ok response then
374374+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
375375+ else
376376+ let body = Requests.Response.text response in
377377+ let parsed_body =
378378+ match Jsont_bytesrw.decode_string Jsont.json body with
379379+ | Ok json -> Some (Openapi.Runtime.Json json)
380380+ | Error _ -> Some (Openapi.Runtime.Raw body)
381381+ in
382382+ raise (Openapi.Runtime.Api_error {
383383+ operation = op_name;
384384+ method_ = "GET";
385385+ url;
386386+ status = Requests.Response.status_code response;
387387+ body;
388388+ parsed_body;
389389+ })
390390+391391+ (** Retrieve a synonym set
392392+393393+ Retrieve a specific synonym set by its name
394394+ @param synonym_set_name The name of the synonym set to retrieve
395395+ *)
396396+ let retrieve_synonym_set ~synonym_set_name client () =
397397+ let op_name = "retrieve_synonym_set" in
398398+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in
399399+ let query = "" in
400400+ let url = client.base_url ^ url_path ^ query in
401401+ let response =
402402+ try Requests.get client.session url
403403+ with Eio.Io _ as ex ->
404404+ let bt = Printexc.get_raw_backtrace () in
405405+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
406406+ in
407407+ if Requests.Response.ok response then
408408+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
409409+ else
410410+ let body = Requests.Response.text response in
411411+ let status = Requests.Response.status_code response in
412412+ let parsed_body = match status with
413413+ | 404 ->
414414+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
415415+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
416416+ | Error _ -> None)
417417+ | _ ->
418418+ (match Jsont_bytesrw.decode_string Jsont.json body with
419419+ | Ok json -> Some (Openapi.Runtime.Json json)
420420+ | Error _ -> Some (Openapi.Runtime.Raw body))
421421+ in
422422+ raise (Openapi.Runtime.Api_error {
423423+ operation = op_name;
424424+ method_ = "GET";
425425+ url;
426426+ status;
427427+ body;
428428+ parsed_body;
429429+ })
430430+431431+ (** Create or update a synonym set
432432+433433+ Create or update a synonym set with the given name
434434+ @param synonym_set_name The name of the synonym set to create/update
435435+ *)
436436+ let upsert_synonym_set ~synonym_set_name ~body client () =
437437+ let op_name = "upsert_synonym_set" in
438438+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in
439439+ let query = "" in
440440+ let url = client.base_url ^ url_path ^ query in
441441+ let response =
442442+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json SynonymSetCreateSchema.T.jsont body)) url
443443+ with Eio.Io _ as ex ->
444444+ let bt = Printexc.get_raw_backtrace () in
445445+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
446446+ in
447447+ if Requests.Response.ok response then
448448+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
449449+ else
450450+ let body = Requests.Response.text response in
451451+ let status = Requests.Response.status_code response in
452452+ let parsed_body = match status with
453453+ | 400 ->
454454+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
455455+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
456456+ | Error _ -> None)
457457+ | _ ->
458458+ (match Jsont_bytesrw.decode_string Jsont.json body with
459459+ | Ok json -> Some (Openapi.Runtime.Json json)
460460+ | Error _ -> Some (Openapi.Runtime.Raw body))
461461+ in
462462+ raise (Openapi.Runtime.Api_error {
463463+ operation = op_name;
464464+ method_ = "PUT";
465465+ url;
466466+ status;
467467+ body;
468468+ parsed_body;
469469+ })
470470+end
471471+472472+module SynonymSetsRetrieveSchema = struct
473473+ module Types = struct
474474+ module T = struct
475475+ type t = {
476476+ synonym_sets : SynonymSetSchema.T.t list; (** Array of synonym sets *)
477477+ }
478478+ end
479479+ end
480480+481481+ module T = struct
482482+ include Types.T
483483+484484+ let v ~synonym_sets () = { synonym_sets }
485485+486486+ let synonym_sets t = t.synonym_sets
487487+488488+ let jsont : t Jsont.t =
489489+ Jsont.Object.map ~kind:"SynonymSetsRetrieveSchema"
490490+ (fun synonym_sets -> { synonym_sets })
491491+ |> Jsont.Object.mem "synonym_sets" (Jsont.list SynonymSetSchema.T.jsont) ~enc:(fun r -> r.synonym_sets)
492492+ |> Jsont.Object.skip_unknown
493493+ |> Jsont.Object.finish
494494+ end
495495+end
496496+497497+module SynonymItemDeleteSchema = struct
498498+ module Types = struct
499499+ module T = struct
500500+ type t = {
501501+ id : string; (** ID of the deleted synonym item *)
502502+ }
503503+ end
504504+ end
505505+506506+ module T = struct
507507+ include Types.T
508508+509509+ let v ~id () = { id }
510510+511511+ let id t = t.id
512512+513513+ let jsont : t Jsont.t =
514514+ Jsont.Object.map ~kind:"SynonymItemDeleteSchema"
515515+ (fun id -> { id })
516516+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
517517+ |> Jsont.Object.skip_unknown
518518+ |> Jsont.Object.finish
519519+ end
520520+521521+ (** Delete a synonym set item
522522+523523+ Delete a specific synonym item by its id
524524+ @param synonym_set_name The name of the synonym set
525525+ @param item_id The id of the synonym item to delete
526526+ *)
527527+ let delete_synonym_set_item ~synonym_set_name ~item_id client () =
528528+ let op_name = "delete_synonym_set_item" in
529529+ let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in
530530+ let query = "" in
531531+ let url = client.base_url ^ url_path ^ query in
532532+ let response =
533533+ try Requests.delete client.session url
534534+ with Eio.Io _ as ex ->
535535+ let bt = Printexc.get_raw_backtrace () in
536536+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
537537+ in
538538+ if Requests.Response.ok response then
539539+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
540540+ else
541541+ let body = Requests.Response.text response in
542542+ let status = Requests.Response.status_code response in
543543+ let parsed_body = match status with
544544+ | 404 ->
545545+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
546546+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
547547+ | Error _ -> None)
548548+ | _ ->
549549+ (match Jsont_bytesrw.decode_string Jsont.json body with
550550+ | Ok json -> Some (Openapi.Runtime.Json json)
551551+ | Error _ -> Some (Openapi.Runtime.Raw body))
552552+ in
553553+ raise (Openapi.Runtime.Api_error {
554554+ operation = op_name;
555555+ method_ = "DELETE";
556556+ url;
557557+ status;
558558+ body;
559559+ parsed_body;
560560+ })
561561+end
562562+563563+module Success = struct
564564+ module Types = struct
565565+ module Status = struct
566566+ type t = {
567567+ success : bool;
568568+ }
569569+ end
570570+ end
571571+572572+ module Status = struct
573573+ include Types.Status
574574+575575+ let v ~success () = { success }
576576+577577+ let success t = t.success
578578+579579+ let jsont : t Jsont.t =
580580+ Jsont.Object.map ~kind:"SuccessStatus"
581581+ (fun success -> { success })
582582+ |> Jsont.Object.mem "success" Jsont.bool ~enc:(fun r -> r.success)
583583+ |> Jsont.Object.skip_unknown
584584+ |> Jsont.Object.finish
585585+ end
586586+587587+ (** Toggle Slow Request Log
588588+589589+ Enable logging of requests that take over a defined threshold of time. Default is `-1` which disables slow request logging. Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. *)
590590+ let toggle_slow_request_log client () =
591591+ let op_name = "toggle_slow_request_log" in
592592+ let url_path = "/config" in
593593+ let query = "" in
594594+ let url = client.base_url ^ url_path ^ query in
595595+ let response =
596596+ try Requests.post client.session url
597597+ with Eio.Io _ as ex ->
598598+ let bt = Printexc.get_raw_backtrace () in
599599+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
600600+ in
601601+ if Requests.Response.ok response then
602602+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
603603+ else
604604+ let body = Requests.Response.text response in
605605+ let parsed_body =
606606+ match Jsont_bytesrw.decode_string Jsont.json body with
607607+ | Ok json -> Some (Openapi.Runtime.Json json)
608608+ | Error _ -> Some (Openapi.Runtime.Raw body)
609609+ in
610610+ raise (Openapi.Runtime.Api_error {
611611+ operation = op_name;
612612+ method_ = "POST";
613613+ url;
614614+ status = Requests.Response.status_code response;
615615+ body;
616616+ parsed_body;
617617+ })
618618+619619+ (** Clear the cached responses of search requests in the LRU cache.
620620+621621+ Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. *)
622622+ let clear_cache client () =
623623+ let op_name = "clear_cache" in
624624+ let url_path = "/operations/cache/clear" in
625625+ let query = "" in
626626+ let url = client.base_url ^ url_path ^ query in
627627+ let response =
628628+ try Requests.post client.session url
629629+ with Eio.Io _ as ex ->
630630+ let bt = Printexc.get_raw_backtrace () in
631631+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
632632+ in
633633+ if Requests.Response.ok response then
634634+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
635635+ else
636636+ let body = Requests.Response.text response in
637637+ let parsed_body =
638638+ match Jsont_bytesrw.decode_string Jsont.json body with
639639+ | Ok json -> Some (Openapi.Runtime.Json json)
640640+ | Error _ -> Some (Openapi.Runtime.Raw body)
641641+ in
642642+ raise (Openapi.Runtime.Api_error {
643643+ operation = op_name;
644644+ method_ = "POST";
645645+ url;
646646+ status = Requests.Response.status_code response;
647647+ body;
648648+ parsed_body;
649649+ })
650650+651651+ (** Compacting the on-disk database
652652+653653+ Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours. *)
654654+ let compact_db client () =
655655+ let op_name = "compact_db" in
656656+ let url_path = "/operations/db/compact" in
657657+ let query = "" in
658658+ let url = client.base_url ^ url_path ^ query in
659659+ let response =
660660+ try Requests.post client.session url
661661+ with Eio.Io _ as ex ->
662662+ let bt = Printexc.get_raw_backtrace () in
663663+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
664664+ in
665665+ if Requests.Response.ok response then
666666+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
667667+ else
668668+ let body = Requests.Response.text response in
669669+ let parsed_body =
670670+ match Jsont_bytesrw.decode_string Jsont.json body with
671671+ | Ok json -> Some (Openapi.Runtime.Json json)
672672+ | Error _ -> Some (Openapi.Runtime.Raw body)
673673+ in
674674+ raise (Openapi.Runtime.Api_error {
675675+ operation = op_name;
676676+ method_ = "POST";
677677+ url;
678678+ status = Requests.Response.status_code response;
679679+ body;
680680+ parsed_body;
681681+ })
682682+683683+ (** Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.
684684+685685+ 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.
686686+ @param snapshot_path The directory on the server where the snapshot should be saved.
687687+ *)
688688+ let take_snapshot ~snapshot_path client () =
689689+ let op_name = "take_snapshot" in
690690+ let url_path = "/operations/snapshot" in
691691+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"snapshot_path" ~value:snapshot_path]) in
692692+ let url = client.base_url ^ url_path ^ query in
693693+ let response =
694694+ try Requests.post client.session url
695695+ with Eio.Io _ as ex ->
696696+ let bt = Printexc.get_raw_backtrace () in
697697+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
698698+ in
699699+ if Requests.Response.ok response then
700700+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
701701+ else
702702+ let body = Requests.Response.text response in
703703+ let parsed_body =
704704+ match Jsont_bytesrw.decode_string Jsont.json body with
705705+ | Ok json -> Some (Openapi.Runtime.Json json)
706706+ | Error _ -> Some (Openapi.Runtime.Raw body)
707707+ in
708708+ raise (Openapi.Runtime.Api_error {
709709+ operation = op_name;
710710+ method_ = "POST";
711711+ url;
712712+ status = Requests.Response.status_code response;
713713+ body;
714714+ parsed_body;
715715+ })
716716+717717+ (** Triggers a follower node to initiate the raft voting process, which triggers leader re-election.
718718+719719+ 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. *)
720720+ let vote client () =
721721+ let op_name = "vote" in
722722+ let url_path = "/operations/vote" in
723723+ let query = "" in
724724+ let url = client.base_url ^ url_path ^ query in
725725+ let response =
726726+ try Requests.post client.session url
727727+ with Eio.Io _ as ex ->
728728+ let bt = Printexc.get_raw_backtrace () in
729729+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
730730+ in
731731+ if Requests.Response.ok response then
732732+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
733733+ else
734734+ let body = Requests.Response.text response in
735735+ let parsed_body =
736736+ match Jsont_bytesrw.decode_string Jsont.json body with
737737+ | Ok json -> Some (Openapi.Runtime.Json json)
738738+ | Error _ -> Some (Openapi.Runtime.Raw body)
739739+ in
740740+ raise (Openapi.Runtime.Api_error {
741741+ operation = op_name;
742742+ method_ = "POST";
743743+ url;
744744+ status = Requests.Response.status_code response;
745745+ body;
746746+ parsed_body;
747747+ })
748748+end
749749+750750+module StopwordsSetUpsertSchema = struct
751751+ module Types = struct
752752+ module T = struct
753753+ type t = {
754754+ locale : string option;
755755+ stopwords : string list;
756756+ }
757757+ end
758758+ end
759759+760760+ module T = struct
761761+ include Types.T
762762+763763+ let v ~stopwords ?locale () = { locale; stopwords }
764764+765765+ let locale t = t.locale
766766+ let stopwords t = t.stopwords
767767+768768+ let jsont : t Jsont.t =
769769+ Jsont.Object.map ~kind:"StopwordsSetUpsertSchema"
770770+ (fun locale stopwords -> { locale; stopwords })
771771+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
772772+ |> Jsont.Object.mem "stopwords" (Jsont.list Jsont.string) ~enc:(fun r -> r.stopwords)
773773+ |> Jsont.Object.skip_unknown
774774+ |> Jsont.Object.finish
775775+ end
776776+end
777777+778778+module StopwordsSetSchema = struct
779779+ module Types = struct
780780+ module T = struct
781781+ type t = {
782782+ id : string;
783783+ locale : string option;
784784+ stopwords : string list;
785785+ }
786786+ end
787787+ end
788788+789789+ module T = struct
790790+ include Types.T
791791+792792+ let v ~id ~stopwords ?locale () = { id; locale; stopwords }
793793+794794+ let id t = t.id
795795+ let locale t = t.locale
796796+ let stopwords t = t.stopwords
797797+798798+ let jsont : t Jsont.t =
799799+ Jsont.Object.map ~kind:"StopwordsSetSchema"
800800+ (fun id locale stopwords -> { id; locale; stopwords })
801801+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
802802+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
803803+ |> Jsont.Object.mem "stopwords" (Jsont.list Jsont.string) ~enc:(fun r -> r.stopwords)
804804+ |> Jsont.Object.skip_unknown
805805+ |> Jsont.Object.finish
806806+ end
807807+808808+ (** Upserts a stopwords set.
809809+810810+ When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection.
811811+ @param set_id The ID of the stopwords set to upsert.
812812+ *)
813813+ let upsert_stopwords_set ~set_id ~body client () =
814814+ let op_name = "upsert_stopwords_set" in
815815+ let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in
816816+ let query = "" in
817817+ let url = client.base_url ^ url_path ^ query in
818818+ let response =
819819+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json StopwordsSetUpsertSchema.T.jsont body)) url
820820+ with Eio.Io _ as ex ->
821821+ let bt = Printexc.get_raw_backtrace () in
822822+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
823823+ in
824824+ if Requests.Response.ok response then
825825+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
826826+ else
827827+ let body = Requests.Response.text response in
828828+ let status = Requests.Response.status_code response in
829829+ let parsed_body = match status with
830830+ | 400 ->
831831+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
832832+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
833833+ | Error _ -> None)
834834+ | _ ->
835835+ (match Jsont_bytesrw.decode_string Jsont.json body with
836836+ | Ok json -> Some (Openapi.Runtime.Json json)
837837+ | Error _ -> Some (Openapi.Runtime.Raw body))
838838+ in
839839+ raise (Openapi.Runtime.Api_error {
840840+ operation = op_name;
841841+ method_ = "PUT";
842842+ url;
843843+ status;
844844+ body;
845845+ parsed_body;
846846+ })
847847+end
848848+849849+module StopwordsSetsRetrieveAllSchema = struct
850850+ module Types = struct
851851+ module T = struct
852852+ type t = {
853853+ stopwords : StopwordsSetSchema.T.t list;
854854+ }
855855+ end
856856+ end
857857+858858+ module T = struct
859859+ include Types.T
860860+861861+ let v ~stopwords () = { stopwords }
862862+863863+ let stopwords t = t.stopwords
864864+865865+ let jsont : t Jsont.t =
866866+ Jsont.Object.map ~kind:"StopwordsSetsRetrieveAllSchema"
867867+ (fun stopwords -> { stopwords })
868868+ |> Jsont.Object.mem "stopwords" (Jsont.list StopwordsSetSchema.T.jsont) ~enc:(fun r -> r.stopwords)
869869+ |> Jsont.Object.skip_unknown
870870+ |> Jsont.Object.finish
871871+ end
872872+873873+ (** Retrieves all stopwords sets.
874874+875875+ Retrieve the details of all stopwords sets *)
876876+ let retrieve_stopwords_sets client () =
877877+ let op_name = "retrieve_stopwords_sets" in
878878+ let url_path = "/stopwords" in
879879+ let query = "" in
880880+ let url = client.base_url ^ url_path ^ query in
881881+ let response =
882882+ try Requests.get client.session url
883883+ with Eio.Io _ as ex ->
884884+ let bt = Printexc.get_raw_backtrace () in
885885+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
886886+ in
887887+ if Requests.Response.ok response then
888888+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
889889+ else
890890+ let body = Requests.Response.text response in
891891+ let parsed_body =
892892+ match Jsont_bytesrw.decode_string Jsont.json body with
893893+ | Ok json -> Some (Openapi.Runtime.Json json)
894894+ | Error _ -> Some (Openapi.Runtime.Raw body)
895895+ in
896896+ raise (Openapi.Runtime.Api_error {
897897+ operation = op_name;
898898+ method_ = "GET";
899899+ url;
900900+ status = Requests.Response.status_code response;
901901+ body;
902902+ parsed_body;
903903+ })
904904+end
905905+906906+module StopwordsSetRetrieveSchema = struct
907907+ module Types = struct
908908+ module T = struct
909909+ type t = {
910910+ stopwords : StopwordsSetSchema.T.t;
911911+ }
912912+ end
913913+ end
914914+915915+ module T = struct
916916+ include Types.T
917917+918918+ let v ~stopwords () = { stopwords }
919919+920920+ let stopwords t = t.stopwords
921921+922922+ let jsont : t Jsont.t =
923923+ Jsont.Object.map ~kind:"StopwordsSetRetrieveSchema"
924924+ (fun stopwords -> { stopwords })
925925+ |> Jsont.Object.mem "stopwords" StopwordsSetSchema.T.jsont ~enc:(fun r -> r.stopwords)
926926+ |> Jsont.Object.skip_unknown
927927+ |> Jsont.Object.finish
928928+ end
929929+930930+ (** Retrieves a stopwords set.
931931+932932+ Retrieve the details of a stopwords set, given it's name.
933933+ @param set_id The ID of the stopwords set to retrieve.
934934+ *)
935935+ let retrieve_stopwords_set ~set_id client () =
936936+ let op_name = "retrieve_stopwords_set" in
937937+ let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in
938938+ let query = "" in
939939+ let url = client.base_url ^ url_path ^ query in
940940+ let response =
941941+ try Requests.get client.session url
942942+ with Eio.Io _ as ex ->
943943+ let bt = Printexc.get_raw_backtrace () in
944944+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
945945+ in
946946+ if Requests.Response.ok response then
947947+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
948948+ else
949949+ let body = Requests.Response.text response in
950950+ let status = Requests.Response.status_code response in
951951+ let parsed_body = match status with
952952+ | 404 ->
953953+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
954954+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
955955+ | Error _ -> None)
956956+ | _ ->
957957+ (match Jsont_bytesrw.decode_string Jsont.json body with
958958+ | Ok json -> Some (Openapi.Runtime.Json json)
959959+ | Error _ -> Some (Openapi.Runtime.Raw body))
960960+ in
961961+ raise (Openapi.Runtime.Api_error {
962962+ operation = op_name;
963963+ method_ = "GET";
964964+ url;
965965+ status;
966966+ body;
967967+ parsed_body;
968968+ })
969969+end
970970+971971+module StemmingDictionary = struct
972972+ module Types = struct
973973+ module T = struct
974974+ type t = {
975975+ id : string; (** Unique identifier for the dictionary *)
976976+ words : Jsont.json list; (** List of word mappings in the dictionary *)
977977+ }
978978+ end
979979+ end
980980+981981+ module T = struct
982982+ include Types.T
983983+984984+ let v ~id ~words () = { id; words }
985985+986986+ let id t = t.id
987987+ let words t = t.words
988988+989989+ let jsont : t Jsont.t =
990990+ Jsont.Object.map ~kind:"StemmingDictionary"
991991+ (fun id words -> { id; words })
992992+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
993993+ |> Jsont.Object.mem "words" (Jsont.list Jsont.json) ~enc:(fun r -> r.words)
994994+ |> Jsont.Object.skip_unknown
995995+ |> Jsont.Object.finish
996996+ end
997997+998998+ (** Retrieve a stemming dictionary
999999+10001000+ Fetch details of a specific stemming dictionary.
10011001+ @param dictionary_id The ID of the dictionary to retrieve
10021002+ *)
10031003+ let get_stemming_dictionary ~dictionary_id client () =
10041004+ let op_name = "get_stemming_dictionary" in
10051005+ let url_path = Openapi.Runtime.Path.render ~params:[("dictionaryId", dictionary_id)] "/stemming/dictionaries/{dictionaryId}" in
10061006+ let query = "" in
10071007+ let url = client.base_url ^ url_path ^ query in
10081008+ let response =
10091009+ try Requests.get client.session url
10101010+ with Eio.Io _ as ex ->
10111011+ let bt = Printexc.get_raw_backtrace () in
10121012+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
10131013+ in
10141014+ if Requests.Response.ok response then
10151015+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
10161016+ else
10171017+ let body = Requests.Response.text response in
10181018+ let status = Requests.Response.status_code response in
10191019+ let parsed_body = match status with
10201020+ | 404 ->
10211021+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
10221022+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
10231023+ | Error _ -> None)
10241024+ | _ ->
10251025+ (match Jsont_bytesrw.decode_string Jsont.json body with
10261026+ | Ok json -> Some (Openapi.Runtime.Json json)
10271027+ | Error _ -> Some (Openapi.Runtime.Raw body))
10281028+ in
10291029+ raise (Openapi.Runtime.Api_error {
10301030+ operation = op_name;
10311031+ method_ = "GET";
10321032+ url;
10331033+ status;
10341034+ body;
10351035+ parsed_body;
10361036+ })
10371037+end
10381038+10391039+module SearchSynonymSchema = struct
10401040+ module Types = struct
10411041+ module T = struct
10421042+ type t = {
10431043+ locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer. *)
10441044+ root : string option; (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *)
10451045+ symbols_to_index : string list option; (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *)
10461046+ synonyms : string list; (** Array of words that should be considered as synonyms. *)
10471047+ }
10481048+ end
10491049+ end
10501050+10511051+ module T = struct
10521052+ include Types.T
10531053+10541054+ let v ~synonyms ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms }
10551055+10561056+ let locale t = t.locale
10571057+ let root t = t.root
10581058+ let symbols_to_index t = t.symbols_to_index
10591059+ let synonyms t = t.synonyms
10601060+10611061+ let jsont : t Jsont.t =
10621062+ Jsont.Object.map ~kind:"SearchSynonymSchema"
10631063+ (fun locale root symbols_to_index synonyms -> { locale; root; symbols_to_index; synonyms })
10641064+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
10651065+ |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root)
10661066+ |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index)
10671067+ |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms)
10681068+ |> Jsont.Object.skip_unknown
10691069+ |> Jsont.Object.finish
10701070+ end
10711071+end
10721072+10731073+module SearchSynonymDelete = struct
10741074+ module Types = struct
10751075+ module Response = struct
10761076+ type t = {
10771077+ id : string; (** The id of the synonym that was deleted *)
10781078+ }
10791079+ end
10801080+ end
10811081+10821082+ module Response = struct
10831083+ include Types.Response
10841084+10851085+ let v ~id () = { id }
10861086+10871087+ let id t = t.id
10881088+10891089+ let jsont : t Jsont.t =
10901090+ Jsont.Object.map ~kind:"SearchSynonymDeleteResponse"
10911091+ (fun id -> { id })
10921092+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
10931093+ |> Jsont.Object.skip_unknown
10941094+ |> Jsont.Object.finish
10951095+ end
10961096+end
10971097+10981098+module SearchSynonym = struct
10991099+ module Types = struct
11001100+ module T = struct
11011101+ type t = {
11021102+ locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer. *)
11031103+ root : string option; (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *)
11041104+ symbols_to_index : string list option; (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *)
11051105+ synonyms : string list; (** Array of words that should be considered as synonyms. *)
11061106+ id : string;
11071107+ }
11081108+ end
11091109+ end
11101110+11111111+ module T = struct
11121112+ include Types.T
11131113+11141114+ let v ~synonyms ~id ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms; id }
11151115+11161116+ let locale t = t.locale
11171117+ let root t = t.root
11181118+ let symbols_to_index t = t.symbols_to_index
11191119+ let synonyms t = t.synonyms
11201120+ let id t = t.id
11211121+11221122+ let jsont : t Jsont.t =
11231123+ Jsont.Object.map ~kind:"SearchSynonym"
11241124+ (fun locale root symbols_to_index synonyms id -> { locale; root; symbols_to_index; synonyms; id })
11251125+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
11261126+ |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root)
11271127+ |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index)
11281128+ |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms)
11291129+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
11301130+ |> Jsont.Object.skip_unknown
11311131+ |> Jsont.Object.finish
11321132+ end
11331133+end
11341134+11351135+module SearchSynonyms = struct
11361136+ module Types = struct
11371137+ module Response = struct
11381138+ type t = {
11391139+ synonyms : SearchSynonym.T.t list;
11401140+ }
11411141+ end
11421142+ end
11431143+11441144+ module Response = struct
11451145+ include Types.Response
11461146+11471147+ let v ~synonyms () = { synonyms }
11481148+11491149+ let synonyms t = t.synonyms
11501150+11511151+ let jsont : t Jsont.t =
11521152+ Jsont.Object.map ~kind:"SearchSynonymsResponse"
11531153+ (fun synonyms -> { synonyms })
11541154+ |> Jsont.Object.mem "synonyms" (Jsont.list SearchSynonym.T.jsont) ~enc:(fun r -> r.synonyms)
11551155+ |> Jsont.Object.skip_unknown
11561156+ |> Jsont.Object.finish
11571157+ end
11581158+end
11591159+11601160+module SearchResultConversation = struct
11611161+ module Types = struct
11621162+ module T = struct
11631163+ type t = {
11641164+ answer : string;
11651165+ conversation_history : Jsont.json list;
11661166+ conversation_id : string;
11671167+ query : string;
11681168+ }
11691169+ end
11701170+ end
11711171+11721172+ module T = struct
11731173+ include Types.T
11741174+11751175+ let v ~answer ~conversation_history ~conversation_id ~query () = { answer; conversation_history; conversation_id; query }
11761176+11771177+ let answer t = t.answer
11781178+ let conversation_history t = t.conversation_history
11791179+ let conversation_id t = t.conversation_id
11801180+ let query t = t.query
11811181+11821182+ let jsont : t Jsont.t =
11831183+ Jsont.Object.map ~kind:"SearchResultConversation"
11841184+ (fun answer conversation_history conversation_id query -> { answer; conversation_history; conversation_id; query })
11851185+ |> Jsont.Object.mem "answer" Jsont.string ~enc:(fun r -> r.answer)
11861186+ |> Jsont.Object.mem "conversation_history" (Jsont.list Jsont.json) ~enc:(fun r -> r.conversation_history)
11871187+ |> Jsont.Object.mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id)
11881188+ |> Jsont.Object.mem "query" Jsont.string ~enc:(fun r -> r.query)
11891189+ |> Jsont.Object.skip_unknown
11901190+ |> Jsont.Object.finish
11911191+ end
11921192+end
11931193+11941194+module SearchRequestParams = struct
11951195+ module Types = struct
11961196+ module T = struct
11971197+ type t = {
11981198+ collection_name : string;
11991199+ per_page : int;
12001200+ q : string;
12011201+ voice_query : Jsont.json option;
12021202+ }
12031203+ end
12041204+ end
12051205+12061206+ module T = struct
12071207+ include Types.T
12081208+12091209+ let v ~collection_name ~per_page ~q ?voice_query () = { collection_name; per_page; q; voice_query }
12101210+12111211+ let collection_name t = t.collection_name
12121212+ let per_page t = t.per_page
12131213+ let q t = t.q
12141214+ let voice_query t = t.voice_query
12151215+12161216+ let jsont : t Jsont.t =
12171217+ Jsont.Object.map ~kind:"SearchRequestParams"
12181218+ (fun collection_name per_page q voice_query -> { collection_name; per_page; q; voice_query })
12191219+ |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name)
12201220+ |> Jsont.Object.mem "per_page" Jsont.int ~enc:(fun r -> r.per_page)
12211221+ |> Jsont.Object.mem "q" Jsont.string ~enc:(fun r -> r.q)
12221222+ |> Jsont.Object.opt_mem "voice_query" Jsont.json ~enc:(fun r -> r.voice_query)
12231223+ |> Jsont.Object.skip_unknown
12241224+ |> Jsont.Object.finish
12251225+ end
12261226+end
12271227+12281228+module SearchHighlight = struct
12291229+ module Types = struct
12301230+ module T = struct
12311231+ type t = {
12321232+ field : string option;
12331233+ indices : int list option; (** The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field *)
12341234+ matched_tokens : Jsont.json list option;
12351235+ snippet : string option; (** Present only for (non-array) string fields *)
12361236+ snippets : string list option; (** Present only for (array) string[] fields *)
12371237+ value : string option; (** Full field value with highlighting, present only for (non-array) string fields *)
12381238+ values : string list option; (** Full field value with highlighting, present only for (array) string[] fields *)
12391239+ }
12401240+ end
12411241+ end
12421242+12431243+ module T = struct
12441244+ include Types.T
12451245+12461246+ let v ?field ?indices ?matched_tokens ?snippet ?snippets ?value ?values () = { field; indices; matched_tokens; snippet; snippets; value; values }
12471247+12481248+ let field t = t.field
12491249+ let indices t = t.indices
12501250+ let matched_tokens t = t.matched_tokens
12511251+ let snippet t = t.snippet
12521252+ let snippets t = t.snippets
12531253+ let value t = t.value
12541254+ let values t = t.values
12551255+12561256+ let jsont : t Jsont.t =
12571257+ Jsont.Object.map ~kind:"SearchHighlight"
12581258+ (fun field indices matched_tokens snippet snippets value values -> { field; indices; matched_tokens; snippet; snippets; value; values })
12591259+ |> Jsont.Object.opt_mem "field" Jsont.string ~enc:(fun r -> r.field)
12601260+ |> Jsont.Object.opt_mem "indices" (Jsont.list Jsont.int) ~enc:(fun r -> r.indices)
12611261+ |> Jsont.Object.opt_mem "matched_tokens" (Jsont.list Jsont.json) ~enc:(fun r -> r.matched_tokens)
12621262+ |> Jsont.Object.opt_mem "snippet" Jsont.string ~enc:(fun r -> r.snippet)
12631263+ |> Jsont.Object.opt_mem "snippets" (Jsont.list Jsont.string) ~enc:(fun r -> r.snippets)
12641264+ |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value)
12651265+ |> Jsont.Object.opt_mem "values" (Jsont.list Jsont.string) ~enc:(fun r -> r.values)
12661266+ |> Jsont.Object.skip_unknown
12671267+ |> Jsont.Object.finish
12681268+ end
12691269+end
12701270+12711271+module SearchResultHit = struct
12721272+ module Types = struct
12731273+ module T = struct
12741274+ type t = {
12751275+ document : Jsont.json option; (** Can be any key-value pair *)
12761276+ geo_distance_meters : Jsont.json option; (** Can be any key-value pair *)
12771277+ highlight : Jsont.json option; (** Highlighted version of the matching document *)
12781278+ highlights : SearchHighlight.T.t list option; (** (Deprecated) Contains highlighted portions of the search fields *)
12791279+ hybrid_search_info : Jsont.json option; (** Information about hybrid search scoring *)
12801280+ search_index : int option; (** Returned only for union query response. Indicates the index of the query which this document matched to. *)
12811281+ text_match : int64 option;
12821282+ text_match_info : Jsont.json option;
12831283+ vector_distance : float option; (** Distance between the query vector and matching document's vector value *)
12841284+ }
12851285+ end
12861286+ end
12871287+12881288+ module T = struct
12891289+ include Types.T
12901290+12911291+ let v ?document ?geo_distance_meters ?highlight ?highlights ?hybrid_search_info ?search_index ?text_match ?text_match_info ?vector_distance () = { document; geo_distance_meters; highlight; highlights; hybrid_search_info; search_index; text_match; text_match_info; vector_distance }
12921292+12931293+ let document t = t.document
12941294+ let geo_distance_meters t = t.geo_distance_meters
12951295+ let highlight t = t.highlight
12961296+ let highlights t = t.highlights
12971297+ let hybrid_search_info t = t.hybrid_search_info
12981298+ let search_index t = t.search_index
12991299+ let text_match t = t.text_match
13001300+ let text_match_info t = t.text_match_info
13011301+ let vector_distance t = t.vector_distance
13021302+13031303+ let jsont : t Jsont.t =
13041304+ Jsont.Object.map ~kind:"SearchResultHit"
13051305+ (fun document geo_distance_meters highlight highlights hybrid_search_info search_index text_match text_match_info vector_distance -> { document; geo_distance_meters; highlight; highlights; hybrid_search_info; search_index; text_match; text_match_info; vector_distance })
13061306+ |> Jsont.Object.opt_mem "document" Jsont.json ~enc:(fun r -> r.document)
13071307+ |> Jsont.Object.opt_mem "geo_distance_meters" Jsont.json ~enc:(fun r -> r.geo_distance_meters)
13081308+ |> Jsont.Object.opt_mem "highlight" Jsont.json ~enc:(fun r -> r.highlight)
13091309+ |> Jsont.Object.opt_mem "highlights" (Jsont.list SearchHighlight.T.jsont) ~enc:(fun r -> r.highlights)
13101310+ |> Jsont.Object.opt_mem "hybrid_search_info" Jsont.json ~enc:(fun r -> r.hybrid_search_info)
13111311+ |> Jsont.Object.opt_mem "search_index" Jsont.int ~enc:(fun r -> r.search_index)
13121312+ |> Jsont.Object.opt_mem "text_match" Jsont.int64 ~enc:(fun r -> r.text_match)
13131313+ |> Jsont.Object.opt_mem "text_match_info" Jsont.json ~enc:(fun r -> r.text_match_info)
13141314+ |> Jsont.Object.opt_mem "vector_distance" Jsont.number ~enc:(fun r -> r.vector_distance)
13151315+ |> Jsont.Object.skip_unknown
13161316+ |> Jsont.Object.finish
13171317+ end
13181318+end
13191319+13201320+module SearchGroupedHit = struct
13211321+ module Types = struct
13221322+ module T = struct
13231323+ type t = {
13241324+ found : int option;
13251325+ group_key : Jsont.json list;
13261326+ hits : SearchResultHit.T.t list; (** The documents that matched the search query *)
13271327+ }
13281328+ end
13291329+ end
13301330+13311331+ module T = struct
13321332+ include Types.T
13331333+13341334+ let v ~group_key ~hits ?found () = { found; group_key; hits }
13351335+13361336+ let found t = t.found
13371337+ let group_key t = t.group_key
13381338+ let hits t = t.hits
13391339+13401340+ let jsont : t Jsont.t =
13411341+ Jsont.Object.map ~kind:"SearchGroupedHit"
13421342+ (fun found group_key hits -> { found; group_key; hits })
13431343+ |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found)
13441344+ |> Jsont.Object.mem "group_key" (Jsont.list Jsont.json) ~enc:(fun r -> r.group_key)
13451345+ |> Jsont.Object.mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits)
13461346+ |> Jsont.Object.skip_unknown
13471347+ |> Jsont.Object.finish
13481348+ end
13491349+end
13501350+13511351+module SchemaChange = struct
13521352+ module Types = struct
13531353+ module Status = struct
13541354+ type t = {
13551355+ altered_docs : int option; (** Number of documents that have been altered *)
13561356+ collection : string option; (** Name of the collection being modified *)
13571357+ validated_docs : int option; (** Number of documents that have been validated *)
13581358+ }
13591359+ end
13601360+ end
13611361+13621362+ module Status = struct
13631363+ include Types.Status
13641364+13651365+ let v ?altered_docs ?collection ?validated_docs () = { altered_docs; collection; validated_docs }
13661366+13671367+ let altered_docs t = t.altered_docs
13681368+ let collection t = t.collection
13691369+ let validated_docs t = t.validated_docs
13701370+13711371+ let jsont : t Jsont.t =
13721372+ Jsont.Object.map ~kind:"SchemaChangeStatus"
13731373+ (fun altered_docs collection validated_docs -> { altered_docs; collection; validated_docs })
13741374+ |> Jsont.Object.opt_mem "altered_docs" Jsont.int ~enc:(fun r -> r.altered_docs)
13751375+ |> Jsont.Object.opt_mem "collection" Jsont.string ~enc:(fun r -> r.collection)
13761376+ |> Jsont.Object.opt_mem "validated_docs" Jsont.int ~enc:(fun r -> r.validated_docs)
13771377+ |> Jsont.Object.skip_unknown
13781378+ |> Jsont.Object.finish
13791379+ end
13801380+13811381+ (** Get the status of in-progress schema change operations
13821382+13831383+ Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. *)
13841384+ let get_schema_changes client () =
13851385+ let op_name = "get_schema_changes" in
13861386+ let url_path = "/operations/schema_changes" in
13871387+ let query = "" in
13881388+ let url = client.base_url ^ url_path ^ query in
13891389+ let response =
13901390+ try Requests.get client.session url
13911391+ with Eio.Io _ as ex ->
13921392+ let bt = Printexc.get_raw_backtrace () in
13931393+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
13941394+ in
13951395+ if Requests.Response.ok response then
13961396+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
13971397+ else
13981398+ let body = Requests.Response.text response in
13991399+ let parsed_body =
14001400+ match Jsont_bytesrw.decode_string Jsont.json body with
14011401+ | Ok json -> Some (Openapi.Runtime.Json json)
14021402+ | Error _ -> Some (Openapi.Runtime.Raw body)
14031403+ in
14041404+ raise (Openapi.Runtime.Api_error {
14051405+ operation = op_name;
14061406+ method_ = "GET";
14071407+ url;
14081408+ status = Requests.Response.status_code response;
14091409+ body;
14101410+ parsed_body;
14111411+ })
14121412+end
14131413+14141414+module PresetUpsertSchema = struct
14151415+ module Types = struct
14161416+ module T = struct
14171417+ type t = {
14181418+ value : Jsont.json;
14191419+ }
14201420+ end
14211421+ end
14221422+14231423+ module T = struct
14241424+ include Types.T
14251425+14261426+ let v ~value () = { value }
14271427+14281428+ let value t = t.value
14291429+14301430+ let jsont : t Jsont.t =
14311431+ Jsont.Object.map ~kind:"PresetUpsertSchema"
14321432+ (fun value -> { value })
14331433+ |> Jsont.Object.mem "value" Jsont.json ~enc:(fun r -> r.value)
14341434+ |> Jsont.Object.skip_unknown
14351435+ |> Jsont.Object.finish
14361436+ end
14371437+end
14381438+14391439+module PresetSchema = struct
14401440+ module Types = struct
14411441+ module T = struct
14421442+ type t = {
14431443+ value : Jsont.json;
14441444+ name : string;
14451445+ }
14461446+ end
14471447+ end
14481448+14491449+ module T = struct
14501450+ include Types.T
14511451+14521452+ let v ~value ~name () = { value; name }
14531453+14541454+ let value t = t.value
14551455+ let name t = t.name
14561456+14571457+ let jsont : t Jsont.t =
14581458+ Jsont.Object.map ~kind:"PresetSchema"
14591459+ (fun value name -> { value; name })
14601460+ |> Jsont.Object.mem "value" Jsont.json ~enc:(fun r -> r.value)
14611461+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
14621462+ |> Jsont.Object.skip_unknown
14631463+ |> Jsont.Object.finish
14641464+ end
14651465+14661466+ (** Retrieves a preset.
14671467+14681468+ Retrieve the details of a preset, given it's name.
14691469+ @param preset_id The ID of the preset to retrieve.
14701470+ *)
14711471+ let retrieve_preset ~preset_id client () =
14721472+ let op_name = "retrieve_preset" in
14731473+ let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in
14741474+ let query = "" in
14751475+ let url = client.base_url ^ url_path ^ query in
14761476+ let response =
14771477+ try Requests.get client.session url
14781478+ with Eio.Io _ as ex ->
14791479+ let bt = Printexc.get_raw_backtrace () in
14801480+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
14811481+ in
14821482+ if Requests.Response.ok response then
14831483+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
14841484+ else
14851485+ let body = Requests.Response.text response in
14861486+ let status = Requests.Response.status_code response in
14871487+ let parsed_body = match status with
14881488+ | 404 ->
14891489+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
14901490+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
14911491+ | Error _ -> None)
14921492+ | _ ->
14931493+ (match Jsont_bytesrw.decode_string Jsont.json body with
14941494+ | Ok json -> Some (Openapi.Runtime.Json json)
14951495+ | Error _ -> Some (Openapi.Runtime.Raw body))
14961496+ in
14971497+ raise (Openapi.Runtime.Api_error {
14981498+ operation = op_name;
14991499+ method_ = "GET";
15001500+ url;
15011501+ status;
15021502+ body;
15031503+ parsed_body;
15041504+ })
15051505+15061506+ (** Upserts a preset.
15071507+15081508+ Create or update an existing preset.
15091509+ @param preset_id The name of the preset set to upsert.
15101510+ *)
15111511+ let upsert_preset ~preset_id ~body client () =
15121512+ let op_name = "upsert_preset" in
15131513+ let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in
15141514+ let query = "" in
15151515+ let url = client.base_url ^ url_path ^ query in
15161516+ let response =
15171517+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json PresetUpsertSchema.T.jsont body)) url
15181518+ with Eio.Io _ as ex ->
15191519+ let bt = Printexc.get_raw_backtrace () in
15201520+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
15211521+ in
15221522+ if Requests.Response.ok response then
15231523+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
15241524+ else
15251525+ let body = Requests.Response.text response in
15261526+ let status = Requests.Response.status_code response in
15271527+ let parsed_body = match status with
15281528+ | 400 ->
15291529+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
15301530+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
15311531+ | Error _ -> None)
15321532+ | _ ->
15331533+ (match Jsont_bytesrw.decode_string Jsont.json body with
15341534+ | Ok json -> Some (Openapi.Runtime.Json json)
15351535+ | Error _ -> Some (Openapi.Runtime.Raw body))
15361536+ in
15371537+ raise (Openapi.Runtime.Api_error {
15381538+ operation = op_name;
15391539+ method_ = "PUT";
15401540+ url;
15411541+ status;
15421542+ body;
15431543+ parsed_body;
15441544+ })
15451545+end
15461546+15471547+module PresetsRetrieveSchema = struct
15481548+ module Types = struct
15491549+ module T = struct
15501550+ type t = {
15511551+ presets : PresetSchema.T.t list;
15521552+ }
15531553+ end
15541554+ end
15551555+15561556+ module T = struct
15571557+ include Types.T
15581558+15591559+ let v ~presets () = { presets }
15601560+15611561+ let presets t = t.presets
15621562+15631563+ let jsont : t Jsont.t =
15641564+ Jsont.Object.map ~kind:"PresetsRetrieveSchema"
15651565+ (fun presets -> { presets })
15661566+ |> Jsont.Object.mem "presets" (Jsont.list PresetSchema.T.jsont) ~enc:(fun r -> r.presets)
15671567+ |> Jsont.Object.skip_unknown
15681568+ |> Jsont.Object.finish
15691569+ end
15701570+15711571+ (** Retrieves all presets.
15721572+15731573+ Retrieve the details of all presets *)
15741574+ let retrieve_all_presets client () =
15751575+ let op_name = "retrieve_all_presets" in
15761576+ let url_path = "/presets" in
15771577+ let query = "" in
15781578+ let url = client.base_url ^ url_path ^ query in
15791579+ let response =
15801580+ try Requests.get client.session url
15811581+ with Eio.Io _ as ex ->
15821582+ let bt = Printexc.get_raw_backtrace () in
15831583+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
15841584+ in
15851585+ if Requests.Response.ok response then
15861586+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
15871587+ else
15881588+ let body = Requests.Response.text response in
15891589+ let parsed_body =
15901590+ match Jsont_bytesrw.decode_string Jsont.json body with
15911591+ | Ok json -> Some (Openapi.Runtime.Json json)
15921592+ | Error _ -> Some (Openapi.Runtime.Raw body)
15931593+ in
15941594+ raise (Openapi.Runtime.Api_error {
15951595+ operation = op_name;
15961596+ method_ = "GET";
15971597+ url;
15981598+ status = Requests.Response.status_code response;
15991599+ body;
16001600+ parsed_body;
16011601+ })
16021602+end
16031603+16041604+module PresetDeleteSchema = struct
16051605+ module Types = struct
16061606+ module T = struct
16071607+ type t = {
16081608+ name : string;
16091609+ }
16101610+ end
16111611+ end
16121612+16131613+ module T = struct
16141614+ include Types.T
16151615+16161616+ let v ~name () = { name }
16171617+16181618+ let name t = t.name
16191619+16201620+ let jsont : t Jsont.t =
16211621+ Jsont.Object.map ~kind:"PresetDeleteSchema"
16221622+ (fun name -> { name })
16231623+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
16241624+ |> Jsont.Object.skip_unknown
16251625+ |> Jsont.Object.finish
16261626+ end
16271627+16281628+ (** Delete a preset.
16291629+16301630+ Permanently deletes a preset, given it's name.
16311631+ @param preset_id The ID of the preset to delete.
16321632+ *)
16331633+ let delete_preset ~preset_id client () =
16341634+ let op_name = "delete_preset" in
16351635+ let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in
16361636+ let query = "" in
16371637+ let url = client.base_url ^ url_path ^ query in
16381638+ let response =
16391639+ try Requests.delete client.session url
16401640+ with Eio.Io _ as ex ->
16411641+ let bt = Printexc.get_raw_backtrace () in
16421642+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
16431643+ in
16441644+ if Requests.Response.ok response then
16451645+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
16461646+ else
16471647+ let body = Requests.Response.text response in
16481648+ let status = Requests.Response.status_code response in
16491649+ let parsed_body = match status with
16501650+ | 404 ->
16511651+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
16521652+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
16531653+ | Error _ -> None)
16541654+ | _ ->
16551655+ (match Jsont_bytesrw.decode_string Jsont.json body with
16561656+ | Ok json -> Some (Openapi.Runtime.Json json)
16571657+ | Error _ -> Some (Openapi.Runtime.Raw body))
16581658+ in
16591659+ raise (Openapi.Runtime.Api_error {
16601660+ operation = op_name;
16611661+ method_ = "DELETE";
16621662+ url;
16631663+ status;
16641664+ body;
16651665+ parsed_body;
16661666+ })
16671667+end
16681668+16691669+module NlsearchModelDeleteSchema = struct
16701670+ module Types = struct
16711671+ module T = struct
16721672+ type t = {
16731673+ id : string; (** ID of the deleted NL search model *)
16741674+ }
16751675+ end
16761676+ end
16771677+16781678+ module T = struct
16791679+ include Types.T
16801680+16811681+ let v ~id () = { id }
16821682+16831683+ let id t = t.id
16841684+16851685+ let jsont : t Jsont.t =
16861686+ Jsont.Object.map ~kind:"NLSearchModelDeleteSchema"
16871687+ (fun id -> { id })
16881688+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
16891689+ |> Jsont.Object.skip_unknown
16901690+ |> Jsont.Object.finish
16911691+ end
16921692+16931693+ (** Delete a NL search model
16941694+16951695+ Delete a specific NL search model by its ID.
16961696+ @param model_id The ID of the NL search model to delete
16971697+ *)
16981698+ let delete_nlsearch_model ~model_id client () =
16991699+ let op_name = "delete_nlsearch_model" in
17001700+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in
17011701+ let query = "" in
17021702+ let url = client.base_url ^ url_path ^ query in
17031703+ let response =
17041704+ try Requests.delete client.session url
17051705+ with Eio.Io _ as ex ->
17061706+ let bt = Printexc.get_raw_backtrace () in
17071707+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
17081708+ in
17091709+ if Requests.Response.ok response then
17101710+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
17111711+ else
17121712+ let body = Requests.Response.text response in
17131713+ let status = Requests.Response.status_code response in
17141714+ let parsed_body = match status with
17151715+ | 404 ->
17161716+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
17171717+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
17181718+ | Error _ -> None)
17191719+ | _ ->
17201720+ (match Jsont_bytesrw.decode_string Jsont.json body with
17211721+ | Ok json -> Some (Openapi.Runtime.Json json)
17221722+ | Error _ -> Some (Openapi.Runtime.Raw body))
17231723+ in
17241724+ raise (Openapi.Runtime.Api_error {
17251725+ operation = op_name;
17261726+ method_ = "DELETE";
17271727+ url;
17281728+ status;
17291729+ body;
17301730+ parsed_body;
17311731+ })
17321732+end
17331733+17341734+module NlsearchModelCreateSchema = struct
17351735+ module Types = struct
17361736+ module T = struct
17371737+ type t = {
17381738+ access_token : string option; (** Access token for GCP Vertex AI *)
17391739+ account_id : string option; (** Account ID for Cloudflare-specific models *)
17401740+ api_key : string option; (** API key for the NL model service *)
17411741+ api_url : string option; (** Custom API URL for the NL model service *)
17421742+ api_version : string option; (** API version for the NL model service *)
17431743+ client_id : string option; (** Client ID for GCP Vertex AI *)
17441744+ client_secret : string option; (** Client secret for GCP Vertex AI *)
17451745+ max_bytes : int option; (** Maximum number of bytes to process *)
17461746+ max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *)
17471747+ model_name : string option; (** Name of the NL model to use *)
17481748+ project_id : string option; (** Project ID for GCP Vertex AI *)
17491749+ refresh_token : string option; (** Refresh token for GCP Vertex AI *)
17501750+ region : string option; (** Region for GCP Vertex AI *)
17511751+ stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *)
17521752+ system_prompt : string option; (** System prompt for the NL model *)
17531753+ temperature : float option; (** Temperature parameter for the NL model *)
17541754+ top_k : int option; (** Top-k parameter for the NL model (Google-specific) *)
17551755+ top_p : float option; (** Top-p parameter for the NL model (Google-specific) *)
17561756+ id : string option; (** Optional ID for the NL search model *)
17571757+ }
17581758+ end
17591759+ end
17601760+17611761+ module T = struct
17621762+ include Types.T
17631763+17641764+ let v ?access_token ?account_id ?api_key ?api_url ?api_version ?client_id ?client_secret ?max_bytes ?max_output_tokens ?model_name ?project_id ?refresh_token ?region ?stop_sequences ?system_prompt ?temperature ?top_k ?top_p ?id () = { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p; id }
17651765+17661766+ let access_token t = t.access_token
17671767+ let account_id t = t.account_id
17681768+ let api_key t = t.api_key
17691769+ let api_url t = t.api_url
17701770+ let api_version t = t.api_version
17711771+ let client_id t = t.client_id
17721772+ let client_secret t = t.client_secret
17731773+ let max_bytes t = t.max_bytes
17741774+ let max_output_tokens t = t.max_output_tokens
17751775+ let model_name t = t.model_name
17761776+ let project_id t = t.project_id
17771777+ let refresh_token t = t.refresh_token
17781778+ let region t = t.region
17791779+ let stop_sequences t = t.stop_sequences
17801780+ let system_prompt t = t.system_prompt
17811781+ let temperature t = t.temperature
17821782+ let top_k t = t.top_k
17831783+ let top_p t = t.top_p
17841784+ let id t = t.id
17851785+17861786+ let jsont : t Jsont.t =
17871787+ Jsont.Object.map ~kind:"NLSearchModelCreateSchema"
17881788+ (fun access_token account_id api_key api_url api_version client_id client_secret max_bytes max_output_tokens model_name project_id refresh_token region stop_sequences system_prompt temperature top_k top_p id -> { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p; id })
17891789+ |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token)
17901790+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
17911791+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
17921792+ |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url)
17931793+ |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version)
17941794+ |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id)
17951795+ |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret)
17961796+ |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
17971797+ |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens)
17981798+ |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
17991799+ |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id)
18001800+ |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token)
18011801+ |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region)
18021802+ |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences)
18031803+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
18041804+ |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature)
18051805+ |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k)
18061806+ |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p)
18071807+ |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id)
18081808+ |> Jsont.Object.skip_unknown
18091809+ |> Jsont.Object.finish
18101810+ end
18111811+end
18121812+18131813+module NlsearchModelSchema = struct
18141814+ module Types = struct
18151815+ module T = struct
18161816+ type t = {
18171817+ access_token : string option; (** Access token for GCP Vertex AI *)
18181818+ account_id : string option; (** Account ID for Cloudflare-specific models *)
18191819+ api_key : string option; (** API key for the NL model service *)
18201820+ api_url : string option; (** Custom API URL for the NL model service *)
18211821+ api_version : string option; (** API version for the NL model service *)
18221822+ client_id : string option; (** Client ID for GCP Vertex AI *)
18231823+ client_secret : string option; (** Client secret for GCP Vertex AI *)
18241824+ max_bytes : int option; (** Maximum number of bytes to process *)
18251825+ max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *)
18261826+ model_name : string option; (** Name of the NL model to use *)
18271827+ project_id : string option; (** Project ID for GCP Vertex AI *)
18281828+ refresh_token : string option; (** Refresh token for GCP Vertex AI *)
18291829+ region : string option; (** Region for GCP Vertex AI *)
18301830+ stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *)
18311831+ system_prompt : string option; (** System prompt for the NL model *)
18321832+ temperature : float option; (** Temperature parameter for the NL model *)
18331833+ top_k : int option; (** Top-k parameter for the NL model (Google-specific) *)
18341834+ top_p : float option; (** Top-p parameter for the NL model (Google-specific) *)
18351835+ id : string; (** ID of the NL search model *)
18361836+ }
18371837+ end
18381838+ end
18391839+18401840+ module T = struct
18411841+ include Types.T
18421842+18431843+ let v ~id ?access_token ?account_id ?api_key ?api_url ?api_version ?client_id ?client_secret ?max_bytes ?max_output_tokens ?model_name ?project_id ?refresh_token ?region ?stop_sequences ?system_prompt ?temperature ?top_k ?top_p () = { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p; id }
18441844+18451845+ let access_token t = t.access_token
18461846+ let account_id t = t.account_id
18471847+ let api_key t = t.api_key
18481848+ let api_url t = t.api_url
18491849+ let api_version t = t.api_version
18501850+ let client_id t = t.client_id
18511851+ let client_secret t = t.client_secret
18521852+ let max_bytes t = t.max_bytes
18531853+ let max_output_tokens t = t.max_output_tokens
18541854+ let model_name t = t.model_name
18551855+ let project_id t = t.project_id
18561856+ let refresh_token t = t.refresh_token
18571857+ let region t = t.region
18581858+ let stop_sequences t = t.stop_sequences
18591859+ let system_prompt t = t.system_prompt
18601860+ let temperature t = t.temperature
18611861+ let top_k t = t.top_k
18621862+ let top_p t = t.top_p
18631863+ let id t = t.id
18641864+18651865+ let jsont : t Jsont.t =
18661866+ Jsont.Object.map ~kind:"NLSearchModelSchema"
18671867+ (fun access_token account_id api_key api_url api_version client_id client_secret max_bytes max_output_tokens model_name project_id refresh_token region stop_sequences system_prompt temperature top_k top_p id -> { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p; id })
18681868+ |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token)
18691869+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
18701870+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
18711871+ |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url)
18721872+ |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version)
18731873+ |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id)
18741874+ |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret)
18751875+ |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
18761876+ |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens)
18771877+ |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
18781878+ |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id)
18791879+ |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token)
18801880+ |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region)
18811881+ |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences)
18821882+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
18831883+ |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature)
18841884+ |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k)
18851885+ |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p)
18861886+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
18871887+ |> Jsont.Object.skip_unknown
18881888+ |> Jsont.Object.finish
18891889+ end
18901890+18911891+ (** List all NL search models
18921892+18931893+ Retrieve all NL search models. *)
18941894+ let retrieve_all_nlsearch_models client () =
18951895+ let op_name = "retrieve_all_nlsearch_models" in
18961896+ let url_path = "/nl_search_models" in
18971897+ let query = "" in
18981898+ let url = client.base_url ^ url_path ^ query in
18991899+ let response =
19001900+ try Requests.get client.session url
19011901+ with Eio.Io _ as ex ->
19021902+ let bt = Printexc.get_raw_backtrace () in
19031903+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
19041904+ in
19051905+ if Requests.Response.ok response then
19061906+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
19071907+ else
19081908+ let body = Requests.Response.text response in
19091909+ let parsed_body =
19101910+ match Jsont_bytesrw.decode_string Jsont.json body with
19111911+ | Ok json -> Some (Openapi.Runtime.Json json)
19121912+ | Error _ -> Some (Openapi.Runtime.Raw body)
19131913+ in
19141914+ raise (Openapi.Runtime.Api_error {
19151915+ operation = op_name;
19161916+ method_ = "GET";
19171917+ url;
19181918+ status = Requests.Response.status_code response;
19191919+ body;
19201920+ parsed_body;
19211921+ })
19221922+19231923+ (** Create a NL search model
19241924+19251925+ Create a new NL search model. *)
19261926+ let create_nlsearch_model ~body client () =
19271927+ let op_name = "create_nlsearch_model" in
19281928+ let url_path = "/nl_search_models" in
19291929+ let query = "" in
19301930+ let url = client.base_url ^ url_path ^ query in
19311931+ let response =
19321932+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json NlsearchModelCreateSchema.T.jsont body)) url
19331933+ with Eio.Io _ as ex ->
19341934+ let bt = Printexc.get_raw_backtrace () in
19351935+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
19361936+ in
19371937+ if Requests.Response.ok response then
19381938+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
19391939+ else
19401940+ let body = Requests.Response.text response in
19411941+ let status = Requests.Response.status_code response in
19421942+ let parsed_body = match status with
19431943+ | 400 ->
19441944+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
19451945+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
19461946+ | Error _ -> None)
19471947+ | _ ->
19481948+ (match Jsont_bytesrw.decode_string Jsont.json body with
19491949+ | Ok json -> Some (Openapi.Runtime.Json json)
19501950+ | Error _ -> Some (Openapi.Runtime.Raw body))
19511951+ in
19521952+ raise (Openapi.Runtime.Api_error {
19531953+ operation = op_name;
19541954+ method_ = "POST";
19551955+ url;
19561956+ status;
19571957+ body;
19581958+ parsed_body;
19591959+ })
19601960+19611961+ (** Retrieve a NL search model
19621962+19631963+ Retrieve a specific NL search model by its ID.
19641964+ @param model_id The ID of the NL search model to retrieve
19651965+ *)
19661966+ let retrieve_nlsearch_model ~model_id client () =
19671967+ let op_name = "retrieve_nlsearch_model" in
19681968+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in
19691969+ let query = "" in
19701970+ let url = client.base_url ^ url_path ^ query in
19711971+ let response =
19721972+ try Requests.get client.session url
19731973+ with Eio.Io _ as ex ->
19741974+ let bt = Printexc.get_raw_backtrace () in
19751975+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
19761976+ in
19771977+ if Requests.Response.ok response then
19781978+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
19791979+ else
19801980+ let body = Requests.Response.text response in
19811981+ let status = Requests.Response.status_code response in
19821982+ let parsed_body = match status with
19831983+ | 404 ->
19841984+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
19851985+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
19861986+ | Error _ -> None)
19871987+ | _ ->
19881988+ (match Jsont_bytesrw.decode_string Jsont.json body with
19891989+ | Ok json -> Some (Openapi.Runtime.Json json)
19901990+ | Error _ -> Some (Openapi.Runtime.Raw body))
19911991+ in
19921992+ raise (Openapi.Runtime.Api_error {
19931993+ operation = op_name;
19941994+ method_ = "GET";
19951995+ url;
19961996+ status;
19971997+ body;
19981998+ parsed_body;
19991999+ })
20002000+20012001+ (** Update a NL search model
20022002+20032003+ Update an existing NL search model.
20042004+ @param model_id The ID of the NL search model to update
20052005+ *)
20062006+ let update_nlsearch_model ~model_id client () =
20072007+ let op_name = "update_nlsearch_model" in
20082008+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in
20092009+ let query = "" in
20102010+ let url = client.base_url ^ url_path ^ query in
20112011+ let response =
20122012+ try Requests.put client.session url
20132013+ with Eio.Io _ as ex ->
20142014+ let bt = Printexc.get_raw_backtrace () in
20152015+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
20162016+ in
20172017+ if Requests.Response.ok response then
20182018+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
20192019+ else
20202020+ let body = Requests.Response.text response in
20212021+ let status = Requests.Response.status_code response in
20222022+ let parsed_body = match status with
20232023+ | 400 ->
20242024+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
20252025+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
20262026+ | Error _ -> None)
20272027+ | 404 ->
20282028+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
20292029+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
20302030+ | Error _ -> None)
20312031+ | _ ->
20322032+ (match Jsont_bytesrw.decode_string Jsont.json body with
20332033+ | Ok json -> Some (Openapi.Runtime.Json json)
20342034+ | Error _ -> Some (Openapi.Runtime.Raw body))
20352035+ in
20362036+ raise (Openapi.Runtime.Api_error {
20372037+ operation = op_name;
20382038+ method_ = "PUT";
20392039+ url;
20402040+ status;
20412041+ body;
20422042+ parsed_body;
20432043+ })
20442044+end
20452045+20462046+module NlsearchModelBase = struct
20472047+ module Types = struct
20482048+ module T = struct
20492049+ type t = {
20502050+ access_token : string option; (** Access token for GCP Vertex AI *)
20512051+ account_id : string option; (** Account ID for Cloudflare-specific models *)
20522052+ api_key : string option; (** API key for the NL model service *)
20532053+ api_url : string option; (** Custom API URL for the NL model service *)
20542054+ api_version : string option; (** API version for the NL model service *)
20552055+ client_id : string option; (** Client ID for GCP Vertex AI *)
20562056+ client_secret : string option; (** Client secret for GCP Vertex AI *)
20572057+ max_bytes : int option; (** Maximum number of bytes to process *)
20582058+ max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *)
20592059+ model_name : string option; (** Name of the NL model to use *)
20602060+ project_id : string option; (** Project ID for GCP Vertex AI *)
20612061+ refresh_token : string option; (** Refresh token for GCP Vertex AI *)
20622062+ region : string option; (** Region for GCP Vertex AI *)
20632063+ stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *)
20642064+ system_prompt : string option; (** System prompt for the NL model *)
20652065+ temperature : float option; (** Temperature parameter for the NL model *)
20662066+ top_k : int option; (** Top-k parameter for the NL model (Google-specific) *)
20672067+ top_p : float option; (** Top-p parameter for the NL model (Google-specific) *)
20682068+ }
20692069+ end
20702070+ end
20712071+20722072+ module T = struct
20732073+ include Types.T
20742074+20752075+ let v ?access_token ?account_id ?api_key ?api_url ?api_version ?client_id ?client_secret ?max_bytes ?max_output_tokens ?model_name ?project_id ?refresh_token ?region ?stop_sequences ?system_prompt ?temperature ?top_k ?top_p () = { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p }
20762076+20772077+ let access_token t = t.access_token
20782078+ let account_id t = t.account_id
20792079+ let api_key t = t.api_key
20802080+ let api_url t = t.api_url
20812081+ let api_version t = t.api_version
20822082+ let client_id t = t.client_id
20832083+ let client_secret t = t.client_secret
20842084+ let max_bytes t = t.max_bytes
20852085+ let max_output_tokens t = t.max_output_tokens
20862086+ let model_name t = t.model_name
20872087+ let project_id t = t.project_id
20882088+ let refresh_token t = t.refresh_token
20892089+ let region t = t.region
20902090+ let stop_sequences t = t.stop_sequences
20912091+ let system_prompt t = t.system_prompt
20922092+ let temperature t = t.temperature
20932093+ let top_k t = t.top_k
20942094+ let top_p t = t.top_p
20952095+20962096+ let jsont : t Jsont.t =
20972097+ Jsont.Object.map ~kind:"NLSearchModelBase"
20982098+ (fun access_token account_id api_key api_url api_version client_id client_secret max_bytes max_output_tokens model_name project_id refresh_token region stop_sequences system_prompt temperature top_k top_p -> { access_token; account_id; api_key; api_url; api_version; client_id; client_secret; max_bytes; max_output_tokens; model_name; project_id; refresh_token; region; stop_sequences; system_prompt; temperature; top_k; top_p })
20992099+ |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token)
21002100+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
21012101+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
21022102+ |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url)
21032103+ |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version)
21042104+ |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id)
21052105+ |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret)
21062106+ |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
21072107+ |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens)
21082108+ |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
21092109+ |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id)
21102110+ |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token)
21112111+ |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region)
21122112+ |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences)
21132113+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
21142114+ |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature)
21152115+ |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k)
21162116+ |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p)
21172117+ |> Jsont.Object.skip_unknown
21182118+ |> Jsont.Object.finish
21192119+ end
21202120+end
21212121+21222122+module IndexAction = struct
21232123+ module Types = struct
21242124+ module T = struct
21252125+ type t = [
21262126+ | `Create
21272127+ | `Update
21282128+ | `Upsert
21292129+ | `Emplace
21302130+ ]
21312131+ end
21322132+ end
21332133+21342134+ module T = struct
21352135+ include Types.T
21362136+21372137+ let jsont : t Jsont.t =
21382138+ Jsont.map Jsont.string ~kind:"IndexAction"
21392139+ ~dec:(function
21402140+ | "create" -> `Create
21412141+ | "update" -> `Update
21422142+ | "upsert" -> `Upsert
21432143+ | "emplace" -> `Emplace
21442144+ | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s)
21452145+ ~enc:(function
21462146+ | `Create -> "create"
21472147+ | `Update -> "update"
21482148+ | `Upsert -> "upsert"
21492149+ | `Emplace -> "emplace")
21502150+ end
21512151+end
21522152+21532153+module Health = struct
21542154+ module Types = struct
21552155+ module Status = struct
21562156+ type t = {
21572157+ ok : bool;
21582158+ }
21592159+ end
21602160+ end
21612161+21622162+ module Status = struct
21632163+ include Types.Status
21642164+21652165+ let v ~ok () = { ok }
21662166+21672167+ let ok t = t.ok
21682168+21692169+ let jsont : t Jsont.t =
21702170+ Jsont.Object.map ~kind:"HealthStatus"
21712171+ (fun ok -> { ok })
21722172+ |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok)
21732173+ |> Jsont.Object.skip_unknown
21742174+ |> Jsont.Object.finish
21752175+ end
21762176+21772177+ (** Checks if Typesense server is ready to accept requests.
21782178+21792179+ Checks if Typesense server is ready to accept requests. *)
21802180+ let health client () =
21812181+ let op_name = "health" in
21822182+ let url_path = "/health" in
21832183+ let query = "" in
21842184+ let url = client.base_url ^ url_path ^ query in
21852185+ let response =
21862186+ try Requests.get client.session url
21872187+ with Eio.Io _ as ex ->
21882188+ let bt = Printexc.get_raw_backtrace () in
21892189+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
21902190+ in
21912191+ if Requests.Response.ok response then
21922192+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
21932193+ else
21942194+ let body = Requests.Response.text response in
21952195+ let parsed_body =
21962196+ match Jsont_bytesrw.decode_string Jsont.json body with
21972197+ | Ok json -> Some (Openapi.Runtime.Json json)
21982198+ | Error _ -> Some (Openapi.Runtime.Raw body)
21992199+ in
22002200+ raise (Openapi.Runtime.Api_error {
22012201+ operation = op_name;
22022202+ method_ = "GET";
22032203+ url;
22042204+ status = Requests.Response.status_code response;
22052205+ body;
22062206+ parsed_body;
22072207+ })
22082208+end
22092209+22102210+module Field = struct
22112211+ module Types = struct
22122212+ module T = struct
22132213+ type t = {
22142214+ async_reference : bool option; (** Allow documents to be indexed successfully even when the referenced document doesn't exist yet.
22152215+ *)
22162216+ drop : bool option;
22172217+ embed : Jsont.json option;
22182218+ facet : bool option;
22192219+ index : bool;
22202220+ infix : bool;
22212221+ locale : string option;
22222222+ name : string;
22232223+ num_dim : int option;
22242224+ optional : bool option;
22252225+ range_index : bool option; (** Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false.
22262226+ *)
22272227+ reference : string option; (** Name of a field in another collection that should be linked to this collection so that it can be joined during query.
22282228+ *)
22292229+ sort : bool option;
22302230+ stem : bool option; (** Values are stemmed before indexing in-memory. Default: false.
22312231+ *)
22322232+ stem_dictionary : string option; (** Name of the stemming dictionary to use for this field *)
22332233+ store : bool option; (** When set to false, the field value will not be stored on disk. Default: true.
22342234+ *)
22352235+ symbols_to_index : string list; (** List of symbols or special characters to be indexed.
22362236+ *)
22372237+ token_separators : string list; (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
22382238+ *)
22392239+ type_ : string;
22402240+ vec_dist : string option; (** The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product.
22412241+ *)
22422242+ }
22432243+ end
22442244+ end
22452245+22462246+ module T = struct
22472247+ include Types.T
22482248+22492249+ let v ~name ~type_ ?(index=true) ?(infix=false) ?(symbols_to_index=[]) ?(token_separators=[]) ?async_reference ?drop ?embed ?facet ?locale ?num_dim ?optional ?range_index ?reference ?sort ?stem ?stem_dictionary ?store ?vec_dist () = { async_reference; drop; embed; facet; index; infix; locale; name; num_dim; optional; range_index; reference; sort; stem; stem_dictionary; store; symbols_to_index; token_separators; type_; vec_dist }
22502250+22512251+ let async_reference t = t.async_reference
22522252+ let drop t = t.drop
22532253+ let embed t = t.embed
22542254+ let facet t = t.facet
22552255+ let index t = t.index
22562256+ let infix t = t.infix
22572257+ let locale t = t.locale
22582258+ let name t = t.name
22592259+ let num_dim t = t.num_dim
22602260+ let optional t = t.optional
22612261+ let range_index t = t.range_index
22622262+ let reference t = t.reference
22632263+ let sort t = t.sort
22642264+ let stem t = t.stem
22652265+ let stem_dictionary t = t.stem_dictionary
22662266+ let store t = t.store
22672267+ let symbols_to_index t = t.symbols_to_index
22682268+ let token_separators t = t.token_separators
22692269+ let type_ t = t.type_
22702270+ let vec_dist t = t.vec_dist
22712271+22722272+ let jsont : t Jsont.t =
22732273+ Jsont.Object.map ~kind:"Field"
22742274+ (fun async_reference drop embed facet index infix locale name num_dim optional range_index reference sort stem stem_dictionary store symbols_to_index token_separators type_ vec_dist -> { async_reference; drop; embed; facet; index; infix; locale; name; num_dim; optional; range_index; reference; sort; stem; stem_dictionary; store; symbols_to_index; token_separators; type_; vec_dist })
22752275+ |> Jsont.Object.opt_mem "async_reference" Jsont.bool ~enc:(fun r -> r.async_reference)
22762276+ |> Jsont.Object.opt_mem "drop" Jsont.bool ~enc:(fun r -> r.drop)
22772277+ |> Jsont.Object.opt_mem "embed" Jsont.json ~enc:(fun r -> r.embed)
22782278+ |> Jsont.Object.opt_mem "facet" Jsont.bool ~enc:(fun r -> r.facet)
22792279+ |> Jsont.Object.mem "index" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.index)
22802280+ |> Jsont.Object.mem "infix" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.infix)
22812281+ |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale)
22822282+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
22832283+ |> Jsont.Object.opt_mem "num_dim" Jsont.int ~enc:(fun r -> r.num_dim)
22842284+ |> Jsont.Object.opt_mem "optional" Jsont.bool ~enc:(fun r -> r.optional)
22852285+ |> Jsont.Object.opt_mem "range_index" Jsont.bool ~enc:(fun r -> r.range_index)
22862286+ |> Jsont.Object.opt_mem "reference" Jsont.string ~enc:(fun r -> r.reference)
22872287+ |> Jsont.Object.opt_mem "sort" Jsont.bool ~enc:(fun r -> r.sort)
22882288+ |> Jsont.Object.opt_mem "stem" Jsont.bool ~enc:(fun r -> r.stem)
22892289+ |> Jsont.Object.opt_mem "stem_dictionary" Jsont.string ~enc:(fun r -> r.stem_dictionary)
22902290+ |> Jsont.Object.opt_mem "store" Jsont.bool ~enc:(fun r -> r.store)
22912291+ |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index)
22922292+ |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators)
22932293+ |> Jsont.Object.mem "type" Jsont.string ~enc:(fun r -> r.type_)
22942294+ |> Jsont.Object.opt_mem "vec_dist" Jsont.string ~enc:(fun r -> r.vec_dist)
22952295+ |> Jsont.Object.skip_unknown
22962296+ |> Jsont.Object.finish
22972297+ end
22982298+end
22992299+23002300+module CollectionUpdateSchema = struct
23012301+ module Types = struct
23022302+ module T = struct
23032303+ type t = {
23042304+ fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *)
23052305+ metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc.
23062306+ *)
23072307+ synonym_sets : string list option; (** List of synonym set names to associate with this collection *)
23082308+ }
23092309+ end
23102310+ end
23112311+23122312+ module T = struct
23132313+ include Types.T
23142314+23152315+ let v ~fields ?metadata ?synonym_sets () = { fields; metadata; synonym_sets }
23162316+23172317+ let fields t = t.fields
23182318+ let metadata t = t.metadata
23192319+ let synonym_sets t = t.synonym_sets
23202320+23212321+ let jsont : t Jsont.t =
23222322+ Jsont.Object.map ~kind:"CollectionUpdateSchema"
23232323+ (fun fields metadata synonym_sets -> { fields; metadata; synonym_sets })
23242324+ |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields)
23252325+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
23262326+ |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets)
23272327+ |> Jsont.Object.skip_unknown
23282328+ |> Jsont.Object.finish
23292329+ end
23302330+23312331+ (** Update a collection
23322332+23332333+ Update a collection's schema to modify the fields and their types.
23342334+ @param collection_name The name of the collection to update
23352335+ *)
23362336+ let update_collection ~collection_name ~body client () =
23372337+ let op_name = "update_collection" in
23382338+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in
23392339+ let query = "" in
23402340+ let url = client.base_url ^ url_path ^ query in
23412341+ let response =
23422342+ try Requests.patch client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json T.jsont body)) url
23432343+ with Eio.Io _ as ex ->
23442344+ let bt = Printexc.get_raw_backtrace () in
23452345+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url
23462346+ in
23472347+ if Requests.Response.ok response then
23482348+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
23492349+ else
23502350+ let body = Requests.Response.text response in
23512351+ let status = Requests.Response.status_code response in
23522352+ let parsed_body = match status with
23532353+ | 400 ->
23542354+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
23552355+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
23562356+ | Error _ -> None)
23572357+ | 404 ->
23582358+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
23592359+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
23602360+ | Error _ -> None)
23612361+ | _ ->
23622362+ (match Jsont_bytesrw.decode_string Jsont.json body with
23632363+ | Ok json -> Some (Openapi.Runtime.Json json)
23642364+ | Error _ -> Some (Openapi.Runtime.Raw body))
23652365+ in
23662366+ raise (Openapi.Runtime.Api_error {
23672367+ operation = op_name;
23682368+ method_ = "PATCH";
23692369+ url;
23702370+ status;
23712371+ body;
23722372+ parsed_body;
23732373+ })
23742374+end
23752375+23762376+module CollectionSchema = struct
23772377+ module Types = struct
23782378+ module T = struct
23792379+ type t = {
23802380+ default_sorting_field : string; (** 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. *)
23812381+ enable_nested_fields : bool; (** 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. *)
23822382+ fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *)
23832383+ metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc.
23842384+ *)
23852385+ name : string; (** Name of the collection *)
23862386+ symbols_to_index : string list; (** List of symbols or special characters to be indexed.
23872387+ *)
23882388+ synonym_sets : string list option; (** List of synonym set names to associate with this collection *)
23892389+ token_separators : string list; (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
23902390+ *)
23912391+ voice_query_model : VoiceQueryModelCollection.Config.t option;
23922392+ }
23932393+ end
23942394+ end
23952395+23962396+ module T = struct
23972397+ include Types.T
23982398+23992399+ let v ~fields ~name ?(default_sorting_field="") ?(enable_nested_fields=false) ?(symbols_to_index=[]) ?(token_separators=[]) ?metadata ?synonym_sets ?voice_query_model () = { default_sorting_field; enable_nested_fields; fields; metadata; name; symbols_to_index; synonym_sets; token_separators; voice_query_model }
24002400+24012401+ let default_sorting_field t = t.default_sorting_field
24022402+ let enable_nested_fields t = t.enable_nested_fields
24032403+ let fields t = t.fields
24042404+ let metadata t = t.metadata
24052405+ let name t = t.name
24062406+ let symbols_to_index t = t.symbols_to_index
24072407+ let synonym_sets t = t.synonym_sets
24082408+ let token_separators t = t.token_separators
24092409+ let voice_query_model t = t.voice_query_model
24102410+24112411+ let jsont : t Jsont.t =
24122412+ Jsont.Object.map ~kind:"CollectionSchema"
24132413+ (fun default_sorting_field enable_nested_fields fields metadata name symbols_to_index synonym_sets token_separators voice_query_model -> { default_sorting_field; enable_nested_fields; fields; metadata; name; symbols_to_index; synonym_sets; token_separators; voice_query_model })
24142414+ |> Jsont.Object.mem "default_sorting_field" Jsont.string ~dec_absent:"" ~enc:(fun r -> r.default_sorting_field)
24152415+ |> Jsont.Object.mem "enable_nested_fields" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_nested_fields)
24162416+ |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields)
24172417+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
24182418+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
24192419+ |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index)
24202420+ |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets)
24212421+ |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators)
24222422+ |> Jsont.Object.opt_mem "voice_query_model" VoiceQueryModelCollection.Config.jsont ~enc:(fun r -> r.voice_query_model)
24232423+ |> Jsont.Object.skip_unknown
24242424+ |> Jsont.Object.finish
24252425+ end
24262426+end
24272427+24282428+module Collection = struct
24292429+ module Types = struct
24302430+ module Response = struct
24312431+ type t = {
24322432+ default_sorting_field : string; (** 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. *)
24332433+ enable_nested_fields : bool; (** 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. *)
24342434+ fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *)
24352435+ metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc.
24362436+ *)
24372437+ name : string; (** Name of the collection *)
24382438+ symbols_to_index : string list; (** List of symbols or special characters to be indexed.
24392439+ *)
24402440+ synonym_sets : string list option; (** List of synonym set names to associate with this collection *)
24412441+ token_separators : string list; (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
24422442+ *)
24432443+ voice_query_model : VoiceQueryModelCollection.Config.t option;
24442444+ num_documents : int64; (** Number of documents in the collection *)
24452445+ created_at : int64; (** Timestamp of when the collection was created (Unix epoch in seconds) *)
24462446+ }
24472447+ end
24482448+ end
24492449+24502450+ module Response = struct
24512451+ include Types.Response
24522452+24532453+ let v ~fields ~name ~num_documents ~created_at ?(default_sorting_field="") ?(enable_nested_fields=false) ?(symbols_to_index=[]) ?(token_separators=[]) ?metadata ?synonym_sets ?voice_query_model () = { default_sorting_field; enable_nested_fields; fields; metadata; name; symbols_to_index; synonym_sets; token_separators; voice_query_model; num_documents; created_at }
24542454+24552455+ let default_sorting_field t = t.default_sorting_field
24562456+ let enable_nested_fields t = t.enable_nested_fields
24572457+ let fields t = t.fields
24582458+ let metadata t = t.metadata
24592459+ let name t = t.name
24602460+ let symbols_to_index t = t.symbols_to_index
24612461+ let synonym_sets t = t.synonym_sets
24622462+ let token_separators t = t.token_separators
24632463+ let voice_query_model t = t.voice_query_model
24642464+ let num_documents t = t.num_documents
24652465+ let created_at t = t.created_at
24662466+24672467+ let jsont : t Jsont.t =
24682468+ Jsont.Object.map ~kind:"CollectionResponse"
24692469+ (fun default_sorting_field enable_nested_fields fields metadata name symbols_to_index synonym_sets token_separators voice_query_model num_documents created_at -> { default_sorting_field; enable_nested_fields; fields; metadata; name; symbols_to_index; synonym_sets; token_separators; voice_query_model; num_documents; created_at })
24702470+ |> Jsont.Object.mem "default_sorting_field" Jsont.string ~dec_absent:"" ~enc:(fun r -> r.default_sorting_field)
24712471+ |> Jsont.Object.mem "enable_nested_fields" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_nested_fields)
24722472+ |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields)
24732473+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
24742474+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
24752475+ |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index)
24762476+ |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets)
24772477+ |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators)
24782478+ |> Jsont.Object.opt_mem "voice_query_model" VoiceQueryModelCollection.Config.jsont ~enc:(fun r -> r.voice_query_model)
24792479+ |> Jsont.Object.mem "num_documents" Jsont.int64 ~enc:(fun r -> r.num_documents)
24802480+ |> Jsont.Object.mem "created_at" Jsont.int64 ~enc:(fun r -> r.created_at)
24812481+ |> Jsont.Object.skip_unknown
24822482+ |> Jsont.Object.finish
24832483+ end
24842484+24852485+ (** List all collections
24862486+24872487+ Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. *)
24882488+ let get_collections ?get_collections_parameters client () =
24892489+ let op_name = "get_collections" in
24902490+ let url_path = "/collections" in
24912491+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"getCollectionsParameters" ~value:get_collections_parameters]) in
24922492+ let url = client.base_url ^ url_path ^ query in
24932493+ let response =
24942494+ try Requests.get client.session url
24952495+ with Eio.Io _ as ex ->
24962496+ let bt = Printexc.get_raw_backtrace () in
24972497+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
24982498+ in
24992499+ if Requests.Response.ok response then
25002500+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
25012501+ else
25022502+ let body = Requests.Response.text response in
25032503+ let parsed_body =
25042504+ match Jsont_bytesrw.decode_string Jsont.json body with
25052505+ | Ok json -> Some (Openapi.Runtime.Json json)
25062506+ | Error _ -> Some (Openapi.Runtime.Raw body)
25072507+ in
25082508+ raise (Openapi.Runtime.Api_error {
25092509+ operation = op_name;
25102510+ method_ = "GET";
25112511+ url;
25122512+ status = Requests.Response.status_code response;
25132513+ body;
25142514+ parsed_body;
25152515+ })
25162516+25172517+ (** Create a new collection
25182518+25192519+ 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. *)
25202520+ let create_collection ~body client () =
25212521+ let op_name = "create_collection" in
25222522+ let url_path = "/collections" in
25232523+ let query = "" in
25242524+ let url = client.base_url ^ url_path ^ query in
25252525+ let response =
25262526+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CollectionSchema.T.jsont body)) url
25272527+ with Eio.Io _ as ex ->
25282528+ let bt = Printexc.get_raw_backtrace () in
25292529+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
25302530+ in
25312531+ if Requests.Response.ok response then
25322532+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
25332533+ else
25342534+ let body = Requests.Response.text response in
25352535+ let status = Requests.Response.status_code response in
25362536+ let parsed_body = match status with
25372537+ | 400 ->
25382538+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
25392539+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
25402540+ | Error _ -> None)
25412541+ | 409 ->
25422542+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
25432543+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
25442544+ | Error _ -> None)
25452545+ | _ ->
25462546+ (match Jsont_bytesrw.decode_string Jsont.json body with
25472547+ | Ok json -> Some (Openapi.Runtime.Json json)
25482548+ | Error _ -> Some (Openapi.Runtime.Raw body))
25492549+ in
25502550+ raise (Openapi.Runtime.Api_error {
25512551+ operation = op_name;
25522552+ method_ = "POST";
25532553+ url;
25542554+ status;
25552555+ body;
25562556+ parsed_body;
25572557+ })
25582558+25592559+ (** Retrieve a single collection
25602560+25612561+ Retrieve the details of a collection, given its name.
25622562+ @param collection_name The name of the collection to retrieve
25632563+ *)
25642564+ let get_collection ~collection_name client () =
25652565+ let op_name = "get_collection" in
25662566+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in
25672567+ let query = "" in
25682568+ let url = client.base_url ^ url_path ^ query in
25692569+ let response =
25702570+ try Requests.get client.session url
25712571+ with Eio.Io _ as ex ->
25722572+ let bt = Printexc.get_raw_backtrace () in
25732573+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
25742574+ in
25752575+ if Requests.Response.ok response then
25762576+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
25772577+ else
25782578+ let body = Requests.Response.text response in
25792579+ let status = Requests.Response.status_code response in
25802580+ let parsed_body = match status with
25812581+ | 404 ->
25822582+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
25832583+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
25842584+ | Error _ -> None)
25852585+ | _ ->
25862586+ (match Jsont_bytesrw.decode_string Jsont.json body with
25872587+ | Ok json -> Some (Openapi.Runtime.Json json)
25882588+ | Error _ -> Some (Openapi.Runtime.Raw body))
25892589+ in
25902590+ raise (Openapi.Runtime.Api_error {
25912591+ operation = op_name;
25922592+ method_ = "GET";
25932593+ url;
25942594+ status;
25952595+ body;
25962596+ parsed_body;
25972597+ })
25982598+25992599+ (** Delete a collection
26002600+26012601+ Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies.
26022602+ @param collection_name The name of the collection to delete
26032603+ *)
26042604+ let delete_collection ~collection_name client () =
26052605+ let op_name = "delete_collection" in
26062606+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in
26072607+ let query = "" in
26082608+ let url = client.base_url ^ url_path ^ query in
26092609+ let response =
26102610+ try Requests.delete client.session url
26112611+ with Eio.Io _ as ex ->
26122612+ let bt = Printexc.get_raw_backtrace () in
26132613+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
26142614+ in
26152615+ if Requests.Response.ok response then
26162616+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
26172617+ else
26182618+ let body = Requests.Response.text response in
26192619+ let status = Requests.Response.status_code response in
26202620+ let parsed_body = match status with
26212621+ | 404 ->
26222622+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
26232623+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
26242624+ | Error _ -> None)
26252625+ | _ ->
26262626+ (match Jsont_bytesrw.decode_string Jsont.json body with
26272627+ | Ok json -> Some (Openapi.Runtime.Json json)
26282628+ | Error _ -> Some (Openapi.Runtime.Raw body))
26292629+ in
26302630+ raise (Openapi.Runtime.Api_error {
26312631+ operation = op_name;
26322632+ method_ = "DELETE";
26332633+ url;
26342634+ status;
26352635+ body;
26362636+ parsed_body;
26372637+ })
26382638+end
26392639+26402640+module FacetCounts = struct
26412641+ module Types = struct
26422642+ module T = struct
26432643+ type t = {
26442644+ counts : Jsont.json list option;
26452645+ field_name : string option;
26462646+ stats : Jsont.json option;
26472647+ }
26482648+ end
26492649+ end
26502650+26512651+ module T = struct
26522652+ include Types.T
26532653+26542654+ let v ?counts ?field_name ?stats () = { counts; field_name; stats }
26552655+26562656+ let counts t = t.counts
26572657+ let field_name t = t.field_name
26582658+ let stats t = t.stats
26592659+26602660+ let jsont : t Jsont.t =
26612661+ Jsont.Object.map ~kind:"FacetCounts"
26622662+ (fun counts field_name stats -> { counts; field_name; stats })
26632663+ |> Jsont.Object.opt_mem "counts" (Jsont.list Jsont.json) ~enc:(fun r -> r.counts)
26642664+ |> Jsont.Object.opt_mem "field_name" Jsont.string ~enc:(fun r -> r.field_name)
26652665+ |> Jsont.Object.opt_mem "stats" Jsont.json ~enc:(fun r -> r.stats)
26662666+ |> Jsont.Object.skip_unknown
26672667+ |> Jsont.Object.finish
26682668+ end
26692669+end
26702670+26712671+module Search = struct
26722672+ module Types = struct
26732673+ module Result = struct
26742674+ type t = {
26752675+ conversation : SearchResultConversation.T.t option;
26762676+ facet_counts : FacetCounts.T.t list option;
26772677+ found : int option; (** The number of documents found *)
26782678+ found_docs : int option;
26792679+ grouped_hits : SearchGroupedHit.T.t list option;
26802680+ hits : SearchResultHit.T.t list option; (** The documents that matched the search query *)
26812681+ metadata : Jsont.json option; (** Custom JSON object that can be returned in the search response *)
26822682+ out_of : int option; (** The total number of documents in the collection *)
26832683+ page : int option; (** The search result page number *)
26842684+ request_params : SearchRequestParams.T.t option;
26852685+ search_cutoff : bool option; (** Whether the search was cut off *)
26862686+ search_time_ms : int option; (** The number of milliseconds the search took *)
26872687+ union_request_params : SearchRequestParams.T.t list option; (** Returned only for union query response. *)
26882688+ }
26892689+ end
26902690+ end
26912691+26922692+ module Result = struct
26932693+ include Types.Result
26942694+26952695+ let v ?conversation ?facet_counts ?found ?found_docs ?grouped_hits ?hits ?metadata ?out_of ?page ?request_params ?search_cutoff ?search_time_ms ?union_request_params () = { conversation; facet_counts; found; found_docs; grouped_hits; hits; metadata; out_of; page; request_params; search_cutoff; search_time_ms; union_request_params }
26962696+26972697+ let conversation t = t.conversation
26982698+ let facet_counts t = t.facet_counts
26992699+ let found t = t.found
27002700+ let found_docs t = t.found_docs
27012701+ let grouped_hits t = t.grouped_hits
27022702+ let hits t = t.hits
27032703+ let metadata t = t.metadata
27042704+ let out_of t = t.out_of
27052705+ let page t = t.page
27062706+ let request_params t = t.request_params
27072707+ let search_cutoff t = t.search_cutoff
27082708+ let search_time_ms t = t.search_time_ms
27092709+ let union_request_params t = t.union_request_params
27102710+27112711+ let jsont : t Jsont.t =
27122712+ Jsont.Object.map ~kind:"SearchResult"
27132713+ (fun conversation facet_counts found found_docs grouped_hits hits metadata out_of page request_params search_cutoff search_time_ms union_request_params -> { conversation; facet_counts; found; found_docs; grouped_hits; hits; metadata; out_of; page; request_params; search_cutoff; search_time_ms; union_request_params })
27142714+ |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation)
27152715+ |> Jsont.Object.opt_mem "facet_counts" (Jsont.list FacetCounts.T.jsont) ~enc:(fun r -> r.facet_counts)
27162716+ |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found)
27172717+ |> Jsont.Object.opt_mem "found_docs" Jsont.int ~enc:(fun r -> r.found_docs)
27182718+ |> Jsont.Object.opt_mem "grouped_hits" (Jsont.list SearchGroupedHit.T.jsont) ~enc:(fun r -> r.grouped_hits)
27192719+ |> Jsont.Object.opt_mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits)
27202720+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
27212721+ |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of)
27222722+ |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
27232723+ |> Jsont.Object.opt_mem "request_params" SearchRequestParams.T.jsont ~enc:(fun r -> r.request_params)
27242724+ |> Jsont.Object.opt_mem "search_cutoff" Jsont.bool ~enc:(fun r -> r.search_cutoff)
27252725+ |> Jsont.Object.opt_mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms)
27262726+ |> Jsont.Object.opt_mem "union_request_params" (Jsont.list SearchRequestParams.T.jsont) ~enc:(fun r -> r.union_request_params)
27272727+ |> Jsont.Object.skip_unknown
27282728+ |> Jsont.Object.finish
27292729+ end
27302730+27312731+ (** Search for documents in a collection
27322732+27332733+ Search for documents in a collection that match the search criteria.
27342734+ @param collection_name The name of the collection to search for the document under
27352735+ *)
27362736+ let search_collection ~collection_name ~search_parameters client () =
27372737+ let op_name = "search_collection" in
27382738+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/search" in
27392739+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"searchParameters" ~value:search_parameters]) in
27402740+ let url = client.base_url ^ url_path ^ query in
27412741+ let response =
27422742+ try Requests.get client.session url
27432743+ with Eio.Io _ as ex ->
27442744+ let bt = Printexc.get_raw_backtrace () in
27452745+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
27462746+ in
27472747+ if Requests.Response.ok response then
27482748+ Openapi.Runtime.Json.decode_json_exn Result.jsont (Requests.Response.json response)
27492749+ else
27502750+ let body = Requests.Response.text response in
27512751+ let status = Requests.Response.status_code response in
27522752+ let parsed_body = match status with
27532753+ | 400 ->
27542754+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
27552755+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
27562756+ | Error _ -> None)
27572757+ | 404 ->
27582758+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
27592759+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
27602760+ | Error _ -> None)
27612761+ | _ ->
27622762+ (match Jsont_bytesrw.decode_string Jsont.json body with
27632763+ | Ok json -> Some (Openapi.Runtime.Json json)
27642764+ | Error _ -> Some (Openapi.Runtime.Raw body))
27652765+ in
27662766+ raise (Openapi.Runtime.Api_error {
27672767+ operation = op_name;
27682768+ method_ = "GET";
27692769+ url;
27702770+ status;
27712771+ body;
27722772+ parsed_body;
27732773+ })
27742774+end
27752775+27762776+module MultiSearchResult = struct
27772777+ module Types = struct
27782778+ module Item = struct
27792779+ type t = {
27802780+ conversation : SearchResultConversation.T.t option;
27812781+ facet_counts : FacetCounts.T.t list option;
27822782+ found : int option; (** The number of documents found *)
27832783+ found_docs : int option;
27842784+ grouped_hits : SearchGroupedHit.T.t list option;
27852785+ hits : SearchResultHit.T.t list option; (** The documents that matched the search query *)
27862786+ metadata : Jsont.json option; (** Custom JSON object that can be returned in the search response *)
27872787+ out_of : int option; (** The total number of documents in the collection *)
27882788+ page : int option; (** The search result page number *)
27892789+ request_params : SearchRequestParams.T.t option;
27902790+ search_cutoff : bool option; (** Whether the search was cut off *)
27912791+ search_time_ms : int option; (** The number of milliseconds the search took *)
27922792+ union_request_params : SearchRequestParams.T.t list option; (** Returned only for union query response. *)
27932793+ code : int64 option; (** HTTP error code *)
27942794+ error : string option; (** Error description *)
27952795+ }
27962796+ end
27972797+ end
27982798+27992799+ module Item = struct
28002800+ include Types.Item
28012801+28022802+ let v ?conversation ?facet_counts ?found ?found_docs ?grouped_hits ?hits ?metadata ?out_of ?page ?request_params ?search_cutoff ?search_time_ms ?union_request_params ?code ?error () = { conversation; facet_counts; found; found_docs; grouped_hits; hits; metadata; out_of; page; request_params; search_cutoff; search_time_ms; union_request_params; code; error }
28032803+28042804+ let conversation t = t.conversation
28052805+ let facet_counts t = t.facet_counts
28062806+ let found t = t.found
28072807+ let found_docs t = t.found_docs
28082808+ let grouped_hits t = t.grouped_hits
28092809+ let hits t = t.hits
28102810+ let metadata t = t.metadata
28112811+ let out_of t = t.out_of
28122812+ let page t = t.page
28132813+ let request_params t = t.request_params
28142814+ let search_cutoff t = t.search_cutoff
28152815+ let search_time_ms t = t.search_time_ms
28162816+ let union_request_params t = t.union_request_params
28172817+ let code t = t.code
28182818+ let error t = t.error
28192819+28202820+ let jsont : t Jsont.t =
28212821+ Jsont.Object.map ~kind:"MultiSearchResultItem"
28222822+ (fun conversation facet_counts found found_docs grouped_hits hits metadata out_of page request_params search_cutoff search_time_ms union_request_params code error -> { conversation; facet_counts; found; found_docs; grouped_hits; hits; metadata; out_of; page; request_params; search_cutoff; search_time_ms; union_request_params; code; error })
28232823+ |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation)
28242824+ |> Jsont.Object.opt_mem "facet_counts" (Jsont.list FacetCounts.T.jsont) ~enc:(fun r -> r.facet_counts)
28252825+ |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found)
28262826+ |> Jsont.Object.opt_mem "found_docs" Jsont.int ~enc:(fun r -> r.found_docs)
28272827+ |> Jsont.Object.opt_mem "grouped_hits" (Jsont.list SearchGroupedHit.T.jsont) ~enc:(fun r -> r.grouped_hits)
28282828+ |> Jsont.Object.opt_mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits)
28292829+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
28302830+ |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of)
28312831+ |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
28322832+ |> Jsont.Object.opt_mem "request_params" SearchRequestParams.T.jsont ~enc:(fun r -> r.request_params)
28332833+ |> Jsont.Object.opt_mem "search_cutoff" Jsont.bool ~enc:(fun r -> r.search_cutoff)
28342834+ |> Jsont.Object.opt_mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms)
28352835+ |> Jsont.Object.opt_mem "union_request_params" (Jsont.list SearchRequestParams.T.jsont) ~enc:(fun r -> r.union_request_params)
28362836+ |> Jsont.Object.opt_mem "code" Jsont.int64 ~enc:(fun r -> r.code)
28372837+ |> Jsont.Object.opt_mem "error" Jsont.string ~enc:(fun r -> r.error)
28382838+ |> Jsont.Object.skip_unknown
28392839+ |> Jsont.Object.finish
28402840+ end
28412841+end
28422842+28432843+module DropTokensMode = struct
28442844+ module Types = struct
28452845+ module T = struct
28462846+ (** Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left
28472847+ *)
28482848+ type t = [
28492849+ | `Right_to_left
28502850+ | `Left_to_right
28512851+ | `Both_sides3
28522852+ ]
28532853+ end
28542854+ end
28552855+28562856+ module T = struct
28572857+ include Types.T
28582858+28592859+ let jsont : t Jsont.t =
28602860+ Jsont.map Jsont.string ~kind:"DropTokensMode"
28612861+ ~dec:(function
28622862+ | "right_to_left" -> `Right_to_left
28632863+ | "left_to_right" -> `Left_to_right
28642864+ | "both_sides:3" -> `Both_sides3
28652865+ | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s)
28662866+ ~enc:(function
28672867+ | `Right_to_left -> "right_to_left"
28682868+ | `Left_to_right -> "left_to_right"
28692869+ | `Both_sides3 -> "both_sides:3")
28702870+ end
28712871+end
28722872+28732873+module SearchParameters = struct
28742874+ module Types = struct
28752875+ module T = struct
28762876+ type t = {
28772877+ cache_ttl : int option; (** 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.
28782878+ *)
28792879+ conversation : bool option; (** Enable conversational search.
28802880+ *)
28812881+ conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
28822882+ *)
28832883+ conversation_model_id : string option; (** The Id of Conversation Model to be used.
28842884+ *)
28852885+ drop_tokens_mode : DropTokensMode.T.t option;
28862886+ drop_tokens_threshold : int option; (** 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
28872887+ *)
28882888+ enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
28892889+ *)
28902890+ enable_highlight_v1 : bool; (** Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true
28912891+ *)
28922892+ enable_overrides : bool; (** 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
28932893+ *)
28942894+ enable_synonyms : bool option; (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
28952895+ *)
28962896+ enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
28972897+ *)
28982898+ enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens.
28992899+ *)
29002900+ exclude_fields : string option; (** List of fields from the document to exclude in the search result *)
29012901+ exhaustive_search : bool option; (** 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).
29022902+ *)
29032903+ facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
29042904+ facet_query : string option; (** 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". *)
29052905+ facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
29062906+ *)
29072907+ facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
29082908+ *)
29092909+ filter_by : string option; (** Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. *)
29102910+ filter_curated_hits : bool option; (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
29112911+ *)
29122912+ group_by : string option; (** 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. *)
29132913+ group_limit : int option; (** 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
29142914+ *)
29152915+ group_missing_values : bool option; (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
29162916+ *)
29172917+ hidden_hits : string option; (** 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`.
29182918+ 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`.
29192919+ *)
29202920+ highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4
29212921+ *)
29222922+ highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>`
29232923+ *)
29242924+ highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them
29252925+ *)
29262926+ highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *)
29272927+ highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>`
29282928+ *)
29292929+ include_fields : string option; (** List of fields from the document to include in the search result *)
29302930+ infix : string option; (** 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 *)
29312931+ limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
29322932+ *)
29332933+ max_candidates : int option; (** Control the number of words that Typesense considers for typo and prefix searching.
29342934+ *)
29352935+ max_extra_prefix : int option; (** 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. *)
29362936+ max_extra_suffix : int option; (** 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. *)
29372937+ max_facet_values : int option; (** Maximum number of facet values to be returned. *)
29382938+ max_filter_by_candidates : int option; (** Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. *)
29392939+ min_len_1typo : int option; (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
29402940+ *)
29412941+ min_len_2typo : int option; (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
29422942+ *)
29432943+ nl_model_id : string option; (** The ID of the natural language model to use. *)
29442944+ nl_query : bool option; (** Whether to use natural language processing to parse the query. *)
29452945+ num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
29462946+ *)
29472947+ offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
29482948+ override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *)
29492949+ page : int option; (** Results from this specific page number would be fetched. *)
29502950+ per_page : int option; (** Number of results to fetch per page. Default: 10 *)
29512951+ pinned_hits : string option; (** 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`.
29522952+ 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`.
29532953+ *)
29542954+ pre_segmented_query : bool option; (** 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.
29552955+ Set this parameter to true to do the same
29562956+ *)
29572957+ prefix : string option; (** 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. *)
29582958+ preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
29592959+ *)
29602960+ prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others
29612961+ *)
29622962+ prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields.
29632963+ *)
29642964+ prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text.
29652965+ *)
29662966+ q : string option; (** 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. *)
29672967+ query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
29682968+ query_by_weights : string option; (** 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. *)
29692969+ remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings.
29702970+ *)
29712971+ remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings.
29722972+ *)
29732973+ search_cutoff_ms : int option; (** 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.
29742974+ *)
29752975+ snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
29762976+ *)
29772977+ sort_by : string option; (** 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` *)
29782978+ split_join_tokens : string option; (** 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`.
29792979+ *)
29802980+ stopwords : string option; (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
29812981+ *)
29822982+ synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0
29832983+ *)
29842984+ synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false
29852985+ *)
29862986+ synonym_sets : string option; (** List of synonym set names to associate with this search query *)
29872987+ text_match_type : string option; (** 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. *)
29882988+ typo_tokens_threshold : int option; (** 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
29892989+ *)
29902990+ use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled.
29912991+ *)
29922992+ vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector.
29932993+ *)
29942994+ voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format.
29952995+ *)
29962996+ }
29972997+ end
29982998+ end
29992999+30003000+ module T = struct
30013001+ include Types.T
30023002+30033003+ let v ?(enable_analytics=true) ?(enable_highlight_v1=true) ?(enable_overrides=false) ?(enable_typos_for_numerical_tokens=true) ?(prioritize_exact_match=true) ?(prioritize_num_matching_fields=true) ?(prioritize_token_position=false) ?cache_ttl ?conversation ?conversation_id ?conversation_model_id ?drop_tokens_mode ?drop_tokens_threshold ?enable_synonyms ?enable_typos_for_alpha_numerical_tokens ?exclude_fields ?exhaustive_search ?facet_by ?facet_query ?facet_return_parent ?facet_strategy ?filter_by ?filter_curated_hits ?group_by ?group_limit ?group_missing_values ?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 ?max_filter_by_candidates ?min_len_1typo ?min_len_2typo ?nl_model_id ?nl_query ?num_typos ?offset ?override_tags ?page ?per_page ?pinned_hits ?pre_segmented_query ?prefix ?preset ?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 ?synonym_num_typos ?synonym_prefix ?synonym_sets ?text_match_type ?typo_tokens_threshold ?use_cache ?vector_query ?voice_query () = { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_highlight_v1; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; max_filter_by_candidates; min_len_1typo; min_len_2typo; nl_model_id; nl_query; 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; synonym_num_typos; synonym_prefix; synonym_sets; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query }
30043004+30053005+ let cache_ttl t = t.cache_ttl
30063006+ let conversation t = t.conversation
30073007+ let conversation_id t = t.conversation_id
30083008+ let conversation_model_id t = t.conversation_model_id
30093009+ let drop_tokens_mode t = t.drop_tokens_mode
30103010+ let drop_tokens_threshold t = t.drop_tokens_threshold
30113011+ let enable_analytics t = t.enable_analytics
30123012+ let enable_highlight_v1 t = t.enable_highlight_v1
30133013+ let enable_overrides t = t.enable_overrides
30143014+ let enable_synonyms t = t.enable_synonyms
30153015+ let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens
30163016+ let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens
30173017+ let exclude_fields t = t.exclude_fields
30183018+ let exhaustive_search t = t.exhaustive_search
30193019+ let facet_by t = t.facet_by
30203020+ let facet_query t = t.facet_query
30213021+ let facet_return_parent t = t.facet_return_parent
30223022+ let facet_strategy t = t.facet_strategy
30233023+ let filter_by t = t.filter_by
30243024+ let filter_curated_hits t = t.filter_curated_hits
30253025+ let group_by t = t.group_by
30263026+ let group_limit t = t.group_limit
30273027+ let group_missing_values t = t.group_missing_values
30283028+ let hidden_hits t = t.hidden_hits
30293029+ let highlight_affix_num_tokens t = t.highlight_affix_num_tokens
30303030+ let highlight_end_tag t = t.highlight_end_tag
30313031+ let highlight_fields t = t.highlight_fields
30323032+ let highlight_full_fields t = t.highlight_full_fields
30333033+ let highlight_start_tag t = t.highlight_start_tag
30343034+ let include_fields t = t.include_fields
30353035+ let infix t = t.infix
30363036+ let limit t = t.limit
30373037+ let max_candidates t = t.max_candidates
30383038+ let max_extra_prefix t = t.max_extra_prefix
30393039+ let max_extra_suffix t = t.max_extra_suffix
30403040+ let max_facet_values t = t.max_facet_values
30413041+ let max_filter_by_candidates t = t.max_filter_by_candidates
30423042+ let min_len_1typo t = t.min_len_1typo
30433043+ let min_len_2typo t = t.min_len_2typo
30443044+ let nl_model_id t = t.nl_model_id
30453045+ let nl_query t = t.nl_query
30463046+ let num_typos t = t.num_typos
30473047+ let offset t = t.offset
30483048+ let override_tags t = t.override_tags
30493049+ let page t = t.page
30503050+ let per_page t = t.per_page
30513051+ let pinned_hits t = t.pinned_hits
30523052+ let pre_segmented_query t = t.pre_segmented_query
30533053+ let prefix t = t.prefix
30543054+ let preset t = t.preset
30553055+ let prioritize_exact_match t = t.prioritize_exact_match
30563056+ let prioritize_num_matching_fields t = t.prioritize_num_matching_fields
30573057+ let prioritize_token_position t = t.prioritize_token_position
30583058+ let q t = t.q
30593059+ let query_by t = t.query_by
30603060+ let query_by_weights t = t.query_by_weights
30613061+ let remote_embedding_num_tries t = t.remote_embedding_num_tries
30623062+ let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms
30633063+ let search_cutoff_ms t = t.search_cutoff_ms
30643064+ let snippet_threshold t = t.snippet_threshold
30653065+ let sort_by t = t.sort_by
30663066+ let split_join_tokens t = t.split_join_tokens
30673067+ let stopwords t = t.stopwords
30683068+ let synonym_num_typos t = t.synonym_num_typos
30693069+ let synonym_prefix t = t.synonym_prefix
30703070+ let synonym_sets t = t.synonym_sets
30713071+ let text_match_type t = t.text_match_type
30723072+ let typo_tokens_threshold t = t.typo_tokens_threshold
30733073+ let use_cache t = t.use_cache
30743074+ let vector_query t = t.vector_query
30753075+ let voice_query t = t.voice_query
30763076+30773077+ let jsont : t Jsont.t =
30783078+ Jsont.Object.map ~kind:"SearchParameters"
30793079+ (fun cache_ttl conversation conversation_id conversation_model_id drop_tokens_mode drop_tokens_threshold enable_analytics enable_highlight_v1 enable_overrides enable_synonyms enable_typos_for_alpha_numerical_tokens enable_typos_for_numerical_tokens exclude_fields exhaustive_search facet_by facet_query facet_return_parent facet_strategy filter_by filter_curated_hits group_by group_limit group_missing_values 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 max_filter_by_candidates min_len_1typo min_len_2typo nl_model_id nl_query 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 synonym_num_typos synonym_prefix synonym_sets text_match_type typo_tokens_threshold use_cache vector_query voice_query -> { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_highlight_v1; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; max_filter_by_candidates; min_len_1typo; min_len_2typo; nl_model_id; nl_query; 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; synonym_num_typos; synonym_prefix; synonym_sets; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query })
30803080+ |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl)
30813081+ |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation)
30823082+ |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id)
30833083+ |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id)
30843084+ |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode)
30853085+ |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold)
30863086+ |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics)
30873087+ |> Jsont.Object.mem "enable_highlight_v1" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_highlight_v1)
30883088+ |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides)
30893089+ |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms)
30903090+ |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens)
30913091+ |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens)
30923092+ |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields)
30933093+ |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search)
30943094+ |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by)
30953095+ |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query)
30963096+ |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent)
30973097+ |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy)
30983098+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
30993099+ |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits)
31003100+ |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by)
31013101+ |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit)
31023102+ |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values)
31033103+ |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits)
31043104+ |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens)
31053105+ |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag)
31063106+ |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields)
31073107+ |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields)
31083108+ |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag)
31093109+ |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields)
31103110+ |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix)
31113111+ |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit)
31123112+ |> Jsont.Object.opt_mem "max_candidates" Jsont.int ~enc:(fun r -> r.max_candidates)
31133113+ |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix)
31143114+ |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix)
31153115+ |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values)
31163116+ |> Jsont.Object.opt_mem "max_filter_by_candidates" Jsont.int ~enc:(fun r -> r.max_filter_by_candidates)
31173117+ |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo)
31183118+ |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo)
31193119+ |> Jsont.Object.opt_mem "nl_model_id" Jsont.string ~enc:(fun r -> r.nl_model_id)
31203120+ |> Jsont.Object.opt_mem "nl_query" Jsont.bool ~enc:(fun r -> r.nl_query)
31213121+ |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos)
31223122+ |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset)
31233123+ |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags)
31243124+ |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
31253125+ |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page)
31263126+ |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits)
31273127+ |> Jsont.Object.opt_mem "pre_segmented_query" Jsont.bool ~enc:(fun r -> r.pre_segmented_query)
31283128+ |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix)
31293129+ |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset)
31303130+ |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match)
31313131+ |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields)
31323132+ |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position)
31333133+ |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q)
31343134+ |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by)
31353135+ |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights)
31363136+ |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries)
31373137+ |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms)
31383138+ |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms)
31393139+ |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold)
31403140+ |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
31413141+ |> Jsont.Object.opt_mem "split_join_tokens" Jsont.string ~enc:(fun r -> r.split_join_tokens)
31423142+ |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords)
31433143+ |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos)
31443144+ |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix)
31453145+ |> Jsont.Object.opt_mem "synonym_sets" Jsont.string ~enc:(fun r -> r.synonym_sets)
31463146+ |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type)
31473147+ |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold)
31483148+ |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache)
31493149+ |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query)
31503150+ |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query)
31513151+ |> Jsont.Object.skip_unknown
31523152+ |> Jsont.Object.finish
31533153+ end
31543154+end
31553155+31563156+module MultiSearchParameters = struct
31573157+ module Types = struct
31583158+ module T = struct
31593159+ (** Parameters for the multi search API.
31603160+ *)
31613161+ type t = {
31623162+ cache_ttl : int option; (** 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.
31633163+ *)
31643164+ conversation : bool option; (** Enable conversational search.
31653165+ *)
31663166+ conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
31673167+ *)
31683168+ conversation_model_id : string option; (** The Id of Conversation Model to be used.
31693169+ *)
31703170+ drop_tokens_mode : DropTokensMode.T.t option;
31713171+ drop_tokens_threshold : int option; (** 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
31723172+ *)
31733173+ enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
31743174+ *)
31753175+ enable_overrides : bool; (** 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
31763176+ *)
31773177+ enable_synonyms : bool option; (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
31783178+ *)
31793179+ enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
31803180+ *)
31813181+ enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens.
31823182+ *)
31833183+ exclude_fields : string option; (** List of fields from the document to exclude in the search result *)
31843184+ exhaustive_search : bool option; (** 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).
31853185+ *)
31863186+ facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
31873187+ facet_query : string option; (** 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". *)
31883188+ facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
31893189+ *)
31903190+ facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
31913191+ *)
31923192+ filter_by : string option; (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *)
31933193+ filter_curated_hits : bool option; (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
31943194+ *)
31953195+ group_by : string option; (** 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. *)
31963196+ group_limit : int option; (** 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
31973197+ *)
31983198+ group_missing_values : bool option; (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
31993199+ *)
32003200+ hidden_hits : string option; (** 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`.
32013201+ 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`.
32023202+ *)
32033203+ highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4
32043204+ *)
32053205+ highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>`
32063206+ *)
32073207+ highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them
32083208+ *)
32093209+ highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *)
32103210+ highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>`
32113211+ *)
32123212+ include_fields : string option; (** List of fields from the document to include in the search result *)
32133213+ infix : string option; (** 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 *)
32143214+ limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
32153215+ *)
32163216+ max_extra_prefix : int option; (** 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. *)
32173217+ max_extra_suffix : int option; (** 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. *)
32183218+ max_facet_values : int option; (** Maximum number of facet values to be returned. *)
32193219+ min_len_1typo : int option; (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
32203220+ *)
32213221+ min_len_2typo : int option; (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
32223222+ *)
32233223+ num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
32243224+ *)
32253225+ offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
32263226+ override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *)
32273227+ page : int option; (** Results from this specific page number would be fetched. *)
32283228+ per_page : int option; (** Number of results to fetch per page. Default: 10 *)
32293229+ pinned_hits : string option; (** 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`.
32303230+ 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`.
32313231+ *)
32323232+ pre_segmented_query : bool; (** 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.
32333233+ Set this parameter to true to do the same
32343234+ *)
32353235+ prefix : string option; (** 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. *)
32363236+ preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
32373237+ *)
32383238+ prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others
32393239+ *)
32403240+ prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields.
32413241+ *)
32423242+ prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text.
32433243+ *)
32443244+ q : string option; (** 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. *)
32453245+ query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
32463246+ query_by_weights : string option; (** 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. *)
32473247+ remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings.
32483248+ *)
32493249+ remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings.
32503250+ *)
32513251+ search_cutoff_ms : int option; (** 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.
32523252+ *)
32533253+ snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
32543254+ *)
32553255+ sort_by : string option; (** 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` *)
32563256+ stopwords : string option; (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
32573257+ *)
32583258+ synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0
32593259+ *)
32603260+ synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false
32613261+ *)
32623262+ text_match_type : string option; (** 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. *)
32633263+ typo_tokens_threshold : int option; (** 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
32643264+ *)
32653265+ use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled.
32663266+ *)
32673267+ vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector.
32683268+ *)
32693269+ voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format.
32703270+ *)
32713271+ }
32723272+ end
32733273+ end
32743274+32753275+ module T = struct
32763276+ include Types.T
32773277+32783278+ let v ?(enable_analytics=true) ?(enable_overrides=false) ?(enable_typos_for_numerical_tokens=true) ?(pre_segmented_query=false) ?(prioritize_exact_match=true) ?(prioritize_num_matching_fields=true) ?(prioritize_token_position=false) ?cache_ttl ?conversation ?conversation_id ?conversation_model_id ?drop_tokens_mode ?drop_tokens_threshold ?enable_synonyms ?enable_typos_for_alpha_numerical_tokens ?exclude_fields ?exhaustive_search ?facet_by ?facet_query ?facet_return_parent ?facet_strategy ?filter_by ?filter_curated_hits ?group_by ?group_limit ?group_missing_values ?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 ?prefix ?preset ?q ?query_by ?query_by_weights ?remote_embedding_num_tries ?remote_embedding_timeout_ms ?search_cutoff_ms ?snippet_threshold ?sort_by ?stopwords ?synonym_num_typos ?synonym_prefix ?text_match_type ?typo_tokens_threshold ?use_cache ?vector_query ?voice_query () = { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; synonym_num_typos; synonym_prefix; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query }
32793279+32803280+ let cache_ttl t = t.cache_ttl
32813281+ let conversation t = t.conversation
32823282+ let conversation_id t = t.conversation_id
32833283+ let conversation_model_id t = t.conversation_model_id
32843284+ let drop_tokens_mode t = t.drop_tokens_mode
32853285+ let drop_tokens_threshold t = t.drop_tokens_threshold
32863286+ let enable_analytics t = t.enable_analytics
32873287+ let enable_overrides t = t.enable_overrides
32883288+ let enable_synonyms t = t.enable_synonyms
32893289+ let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens
32903290+ let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens
32913291+ let exclude_fields t = t.exclude_fields
32923292+ let exhaustive_search t = t.exhaustive_search
32933293+ let facet_by t = t.facet_by
32943294+ let facet_query t = t.facet_query
32953295+ let facet_return_parent t = t.facet_return_parent
32963296+ let facet_strategy t = t.facet_strategy
32973297+ let filter_by t = t.filter_by
32983298+ let filter_curated_hits t = t.filter_curated_hits
32993299+ let group_by t = t.group_by
33003300+ let group_limit t = t.group_limit
33013301+ let group_missing_values t = t.group_missing_values
33023302+ let hidden_hits t = t.hidden_hits
33033303+ let highlight_affix_num_tokens t = t.highlight_affix_num_tokens
33043304+ let highlight_end_tag t = t.highlight_end_tag
33053305+ let highlight_fields t = t.highlight_fields
33063306+ let highlight_full_fields t = t.highlight_full_fields
33073307+ let highlight_start_tag t = t.highlight_start_tag
33083308+ let include_fields t = t.include_fields
33093309+ let infix t = t.infix
33103310+ let limit t = t.limit
33113311+ let max_extra_prefix t = t.max_extra_prefix
33123312+ let max_extra_suffix t = t.max_extra_suffix
33133313+ let max_facet_values t = t.max_facet_values
33143314+ let min_len_1typo t = t.min_len_1typo
33153315+ let min_len_2typo t = t.min_len_2typo
33163316+ let num_typos t = t.num_typos
33173317+ let offset t = t.offset
33183318+ let override_tags t = t.override_tags
33193319+ let page t = t.page
33203320+ let per_page t = t.per_page
33213321+ let pinned_hits t = t.pinned_hits
33223322+ let pre_segmented_query t = t.pre_segmented_query
33233323+ let prefix t = t.prefix
33243324+ let preset t = t.preset
33253325+ let prioritize_exact_match t = t.prioritize_exact_match
33263326+ let prioritize_num_matching_fields t = t.prioritize_num_matching_fields
33273327+ let prioritize_token_position t = t.prioritize_token_position
33283328+ let q t = t.q
33293329+ let query_by t = t.query_by
33303330+ let query_by_weights t = t.query_by_weights
33313331+ let remote_embedding_num_tries t = t.remote_embedding_num_tries
33323332+ let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms
33333333+ let search_cutoff_ms t = t.search_cutoff_ms
33343334+ let snippet_threshold t = t.snippet_threshold
33353335+ let sort_by t = t.sort_by
33363336+ let stopwords t = t.stopwords
33373337+ let synonym_num_typos t = t.synonym_num_typos
33383338+ let synonym_prefix t = t.synonym_prefix
33393339+ let text_match_type t = t.text_match_type
33403340+ let typo_tokens_threshold t = t.typo_tokens_threshold
33413341+ let use_cache t = t.use_cache
33423342+ let vector_query t = t.vector_query
33433343+ let voice_query t = t.voice_query
33443344+33453345+ let jsont : t Jsont.t =
33463346+ Jsont.Object.map ~kind:"MultiSearchParameters"
33473347+ (fun cache_ttl conversation conversation_id conversation_model_id drop_tokens_mode drop_tokens_threshold enable_analytics enable_overrides enable_synonyms enable_typos_for_alpha_numerical_tokens enable_typos_for_numerical_tokens exclude_fields exhaustive_search facet_by facet_query facet_return_parent facet_strategy filter_by filter_curated_hits group_by group_limit group_missing_values 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 synonym_num_typos synonym_prefix text_match_type typo_tokens_threshold use_cache vector_query voice_query -> { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; synonym_num_typos; synonym_prefix; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query })
33483348+ |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl)
33493349+ |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation)
33503350+ |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id)
33513351+ |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id)
33523352+ |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode)
33533353+ |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold)
33543354+ |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics)
33553355+ |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides)
33563356+ |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms)
33573357+ |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens)
33583358+ |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens)
33593359+ |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields)
33603360+ |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search)
33613361+ |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by)
33623362+ |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query)
33633363+ |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent)
33643364+ |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy)
33653365+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
33663366+ |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits)
33673367+ |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by)
33683368+ |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit)
33693369+ |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values)
33703370+ |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits)
33713371+ |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens)
33723372+ |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag)
33733373+ |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields)
33743374+ |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields)
33753375+ |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag)
33763376+ |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields)
33773377+ |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix)
33783378+ |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit)
33793379+ |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix)
33803380+ |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix)
33813381+ |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values)
33823382+ |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo)
33833383+ |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo)
33843384+ |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos)
33853385+ |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset)
33863386+ |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags)
33873387+ |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
33883388+ |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page)
33893389+ |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits)
33903390+ |> Jsont.Object.mem "pre_segmented_query" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.pre_segmented_query)
33913391+ |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix)
33923392+ |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset)
33933393+ |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match)
33943394+ |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields)
33953395+ |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position)
33963396+ |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q)
33973397+ |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by)
33983398+ |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights)
33993399+ |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries)
34003400+ |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms)
34013401+ |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms)
34023402+ |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold)
34033403+ |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
34043404+ |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords)
34053405+ |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos)
34063406+ |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix)
34073407+ |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type)
34083408+ |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold)
34093409+ |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache)
34103410+ |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query)
34113411+ |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query)
34123412+ |> Jsont.Object.skip_unknown
34133413+ |> Jsont.Object.finish
34143414+ end
34153415+end
34163416+34173417+module MultiSearchCollectionParameters = struct
34183418+ module Types = struct
34193419+ module T = struct
34203420+ type t = {
34213421+ cache_ttl : int option; (** 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.
34223422+ *)
34233423+ conversation : bool option; (** Enable conversational search.
34243424+ *)
34253425+ conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
34263426+ *)
34273427+ conversation_model_id : string option; (** The Id of Conversation Model to be used.
34283428+ *)
34293429+ drop_tokens_mode : DropTokensMode.T.t option;
34303430+ drop_tokens_threshold : int option; (** 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
34313431+ *)
34323432+ enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
34333433+ *)
34343434+ enable_overrides : bool; (** 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
34353435+ *)
34363436+ enable_synonyms : bool option; (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
34373437+ *)
34383438+ enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
34393439+ *)
34403440+ enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens.
34413441+ *)
34423442+ exclude_fields : string option; (** List of fields from the document to exclude in the search result *)
34433443+ exhaustive_search : bool option; (** 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).
34443444+ *)
34453445+ facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
34463446+ facet_query : string option; (** 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". *)
34473447+ facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
34483448+ *)
34493449+ facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
34503450+ *)
34513451+ filter_by : string option; (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *)
34523452+ filter_curated_hits : bool option; (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
34533453+ *)
34543454+ group_by : string option; (** 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. *)
34553455+ group_limit : int option; (** 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
34563456+ *)
34573457+ group_missing_values : bool option; (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
34583458+ *)
34593459+ hidden_hits : string option; (** 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`.
34603460+ 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`.
34613461+ *)
34623462+ highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4
34633463+ *)
34643464+ highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>`
34653465+ *)
34663466+ highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them
34673467+ *)
34683468+ highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *)
34693469+ highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>`
34703470+ *)
34713471+ include_fields : string option; (** List of fields from the document to include in the search result *)
34723472+ infix : string option; (** 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 *)
34733473+ limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
34743474+ *)
34753475+ max_extra_prefix : int option; (** 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. *)
34763476+ max_extra_suffix : int option; (** 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. *)
34773477+ max_facet_values : int option; (** Maximum number of facet values to be returned. *)
34783478+ min_len_1typo : int option; (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
34793479+ *)
34803480+ min_len_2typo : int option; (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
34813481+ *)
34823482+ num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
34833483+ *)
34843484+ offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
34853485+ override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *)
34863486+ page : int option; (** Results from this specific page number would be fetched. *)
34873487+ per_page : int option; (** Number of results to fetch per page. Default: 10 *)
34883488+ pinned_hits : string option; (** 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`.
34893489+ 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`.
34903490+ *)
34913491+ pre_segmented_query : bool; (** 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.
34923492+ Set this parameter to true to do the same
34933493+ *)
34943494+ prefix : string option; (** 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. *)
34953495+ preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
34963496+ *)
34973497+ prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others
34983498+ *)
34993499+ prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields.
35003500+ *)
35013501+ prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text.
35023502+ *)
35033503+ q : string option; (** 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. *)
35043504+ query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
35053505+ query_by_weights : string option; (** 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. *)
35063506+ remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings.
35073507+ *)
35083508+ remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings.
35093509+ *)
35103510+ search_cutoff_ms : int option; (** 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.
35113511+ *)
35123512+ snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
35133513+ *)
35143514+ sort_by : string option; (** 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` *)
35153515+ stopwords : string option; (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
35163516+ *)
35173517+ synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0
35183518+ *)
35193519+ synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false
35203520+ *)
35213521+ text_match_type : string option; (** 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. *)
35223522+ typo_tokens_threshold : int option; (** 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
35233523+ *)
35243524+ use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled.
35253525+ *)
35263526+ vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector.
35273527+ *)
35283528+ voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format.
35293529+ *)
35303530+ collection : string option; (** The collection to search in.
35313531+ *)
35323532+ x_typesense_api_key : string option; (** A separate search API key for each search within a multi_search request *)
35333533+ rerank_hybrid_matches : bool; (** When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score.
35343534+ *)
35353535+ }
35363536+ end
35373537+ end
35383538+35393539+ module T = struct
35403540+ include Types.T
35413541+35423542+ let v ?(enable_analytics=true) ?(enable_overrides=false) ?(enable_typos_for_numerical_tokens=true) ?(pre_segmented_query=false) ?(prioritize_exact_match=true) ?(prioritize_num_matching_fields=true) ?(prioritize_token_position=false) ?(rerank_hybrid_matches=false) ?cache_ttl ?conversation ?conversation_id ?conversation_model_id ?drop_tokens_mode ?drop_tokens_threshold ?enable_synonyms ?enable_typos_for_alpha_numerical_tokens ?exclude_fields ?exhaustive_search ?facet_by ?facet_query ?facet_return_parent ?facet_strategy ?filter_by ?filter_curated_hits ?group_by ?group_limit ?group_missing_values ?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 ?prefix ?preset ?q ?query_by ?query_by_weights ?remote_embedding_num_tries ?remote_embedding_timeout_ms ?search_cutoff_ms ?snippet_threshold ?sort_by ?stopwords ?synonym_num_typos ?synonym_prefix ?text_match_type ?typo_tokens_threshold ?use_cache ?vector_query ?voice_query ?collection ?x_typesense_api_key () = { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; synonym_num_typos; synonym_prefix; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query; collection; x_typesense_api_key; rerank_hybrid_matches }
35433543+35443544+ let cache_ttl t = t.cache_ttl
35453545+ let conversation t = t.conversation
35463546+ let conversation_id t = t.conversation_id
35473547+ let conversation_model_id t = t.conversation_model_id
35483548+ let drop_tokens_mode t = t.drop_tokens_mode
35493549+ let drop_tokens_threshold t = t.drop_tokens_threshold
35503550+ let enable_analytics t = t.enable_analytics
35513551+ let enable_overrides t = t.enable_overrides
35523552+ let enable_synonyms t = t.enable_synonyms
35533553+ let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens
35543554+ let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens
35553555+ let exclude_fields t = t.exclude_fields
35563556+ let exhaustive_search t = t.exhaustive_search
35573557+ let facet_by t = t.facet_by
35583558+ let facet_query t = t.facet_query
35593559+ let facet_return_parent t = t.facet_return_parent
35603560+ let facet_strategy t = t.facet_strategy
35613561+ let filter_by t = t.filter_by
35623562+ let filter_curated_hits t = t.filter_curated_hits
35633563+ let group_by t = t.group_by
35643564+ let group_limit t = t.group_limit
35653565+ let group_missing_values t = t.group_missing_values
35663566+ let hidden_hits t = t.hidden_hits
35673567+ let highlight_affix_num_tokens t = t.highlight_affix_num_tokens
35683568+ let highlight_end_tag t = t.highlight_end_tag
35693569+ let highlight_fields t = t.highlight_fields
35703570+ let highlight_full_fields t = t.highlight_full_fields
35713571+ let highlight_start_tag t = t.highlight_start_tag
35723572+ let include_fields t = t.include_fields
35733573+ let infix t = t.infix
35743574+ let limit t = t.limit
35753575+ let max_extra_prefix t = t.max_extra_prefix
35763576+ let max_extra_suffix t = t.max_extra_suffix
35773577+ let max_facet_values t = t.max_facet_values
35783578+ let min_len_1typo t = t.min_len_1typo
35793579+ let min_len_2typo t = t.min_len_2typo
35803580+ let num_typos t = t.num_typos
35813581+ let offset t = t.offset
35823582+ let override_tags t = t.override_tags
35833583+ let page t = t.page
35843584+ let per_page t = t.per_page
35853585+ let pinned_hits t = t.pinned_hits
35863586+ let pre_segmented_query t = t.pre_segmented_query
35873587+ let prefix t = t.prefix
35883588+ let preset t = t.preset
35893589+ let prioritize_exact_match t = t.prioritize_exact_match
35903590+ let prioritize_num_matching_fields t = t.prioritize_num_matching_fields
35913591+ let prioritize_token_position t = t.prioritize_token_position
35923592+ let q t = t.q
35933593+ let query_by t = t.query_by
35943594+ let query_by_weights t = t.query_by_weights
35953595+ let remote_embedding_num_tries t = t.remote_embedding_num_tries
35963596+ let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms
35973597+ let search_cutoff_ms t = t.search_cutoff_ms
35983598+ let snippet_threshold t = t.snippet_threshold
35993599+ let sort_by t = t.sort_by
36003600+ let stopwords t = t.stopwords
36013601+ let synonym_num_typos t = t.synonym_num_typos
36023602+ let synonym_prefix t = t.synonym_prefix
36033603+ let text_match_type t = t.text_match_type
36043604+ let typo_tokens_threshold t = t.typo_tokens_threshold
36053605+ let use_cache t = t.use_cache
36063606+ let vector_query t = t.vector_query
36073607+ let voice_query t = t.voice_query
36083608+ let collection t = t.collection
36093609+ let x_typesense_api_key t = t.x_typesense_api_key
36103610+ let rerank_hybrid_matches t = t.rerank_hybrid_matches
36113611+36123612+ let jsont : t Jsont.t =
36133613+ Jsont.Object.map ~kind:"MultiSearchCollectionParameters"
36143614+ (fun cache_ttl conversation conversation_id conversation_model_id drop_tokens_mode drop_tokens_threshold enable_analytics enable_overrides enable_synonyms enable_typos_for_alpha_numerical_tokens enable_typos_for_numerical_tokens exclude_fields exhaustive_search facet_by facet_query facet_return_parent facet_strategy filter_by filter_curated_hits group_by group_limit group_missing_values 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 synonym_num_typos synonym_prefix text_match_type typo_tokens_threshold use_cache vector_query voice_query collection x_typesense_api_key rerank_hybrid_matches -> { cache_ttl; conversation; conversation_id; conversation_model_id; drop_tokens_mode; drop_tokens_threshold; enable_analytics; enable_overrides; enable_synonyms; enable_typos_for_alpha_numerical_tokens; enable_typos_for_numerical_tokens; exclude_fields; exhaustive_search; facet_by; facet_query; facet_return_parent; facet_strategy; filter_by; filter_curated_hits; group_by; group_limit; group_missing_values; 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; synonym_num_typos; synonym_prefix; text_match_type; typo_tokens_threshold; use_cache; vector_query; voice_query; collection; x_typesense_api_key; rerank_hybrid_matches })
36153615+ |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl)
36163616+ |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation)
36173617+ |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id)
36183618+ |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id)
36193619+ |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode)
36203620+ |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold)
36213621+ |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics)
36223622+ |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides)
36233623+ |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms)
36243624+ |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens)
36253625+ |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens)
36263626+ |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields)
36273627+ |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search)
36283628+ |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by)
36293629+ |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query)
36303630+ |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent)
36313631+ |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy)
36323632+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
36333633+ |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits)
36343634+ |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by)
36353635+ |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit)
36363636+ |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values)
36373637+ |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits)
36383638+ |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens)
36393639+ |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag)
36403640+ |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields)
36413641+ |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields)
36423642+ |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag)
36433643+ |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields)
36443644+ |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix)
36453645+ |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit)
36463646+ |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix)
36473647+ |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix)
36483648+ |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values)
36493649+ |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo)
36503650+ |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo)
36513651+ |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos)
36523652+ |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset)
36533653+ |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags)
36543654+ |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page)
36553655+ |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page)
36563656+ |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits)
36573657+ |> Jsont.Object.mem "pre_segmented_query" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.pre_segmented_query)
36583658+ |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix)
36593659+ |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset)
36603660+ |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match)
36613661+ |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields)
36623662+ |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position)
36633663+ |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q)
36643664+ |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by)
36653665+ |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights)
36663666+ |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries)
36673667+ |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms)
36683668+ |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms)
36693669+ |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold)
36703670+ |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
36713671+ |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords)
36723672+ |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos)
36733673+ |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix)
36743674+ |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type)
36753675+ |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold)
36763676+ |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache)
36773677+ |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query)
36783678+ |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query)
36793679+ |> Jsont.Object.opt_mem "collection" Jsont.string ~enc:(fun r -> r.collection)
36803680+ |> Jsont.Object.opt_mem "x-typesense-api-key" Jsont.string ~enc:(fun r -> r.x_typesense_api_key)
36813681+ |> Jsont.Object.mem "rerank_hybrid_matches" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.rerank_hybrid_matches)
36823682+ |> Jsont.Object.skip_unknown
36833683+ |> Jsont.Object.finish
36843684+ end
36853685+end
36863686+36873687+module MultiSearchSearchesParameter = struct
36883688+ module Types = struct
36893689+ module T = struct
36903690+ type t = {
36913691+ searches : MultiSearchCollectionParameters.T.t list;
36923692+ union : bool; (** When true, merges the search results from each search query into a single ordered set of hits. *)
36933693+ }
36943694+ end
36953695+ end
36963696+36973697+ module T = struct
36983698+ include Types.T
36993699+37003700+ let v ~searches ?(union=false) () = { searches; union }
37013701+37023702+ let searches t = t.searches
37033703+ let union t = t.union
37043704+37053705+ let jsont : t Jsont.t =
37063706+ Jsont.Object.map ~kind:"MultiSearchSearchesParameter"
37073707+ (fun searches union -> { searches; union })
37083708+ |> Jsont.Object.mem "searches" (Jsont.list MultiSearchCollectionParameters.T.jsont) ~enc:(fun r -> r.searches)
37093709+ |> Jsont.Object.mem "union" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.union)
37103710+ |> Jsont.Object.skip_unknown
37113711+ |> Jsont.Object.finish
37123712+ end
37133713+end
37143714+37153715+module MultiSearch = struct
37163716+ module Types = struct
37173717+ module Result = struct
37183718+ type t = {
37193719+ conversation : SearchResultConversation.T.t option;
37203720+ results : MultiSearchResult.Item.t list;
37213721+ }
37223722+ end
37233723+ end
37243724+37253725+ module Result = struct
37263726+ include Types.Result
37273727+37283728+ let v ~results ?conversation () = { conversation; results }
37293729+37303730+ let conversation t = t.conversation
37313731+ let results t = t.results
37323732+37333733+ let jsont : t Jsont.t =
37343734+ Jsont.Object.map ~kind:"MultiSearchResult"
37353735+ (fun conversation results -> { conversation; results })
37363736+ |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation)
37373737+ |> Jsont.Object.mem "results" (Jsont.list MultiSearchResult.Item.jsont) ~enc:(fun r -> r.results)
37383738+ |> Jsont.Object.skip_unknown
37393739+ |> Jsont.Object.finish
37403740+ end
37413741+37423742+ (** send multiple search requests in a single HTTP request
37433743+37443744+ 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. *)
37453745+ let multi_search ~multi_search_parameters ~body client () =
37463746+ let op_name = "multi_search" in
37473747+ let url_path = "/multi_search" in
37483748+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"multiSearchParameters" ~value:multi_search_parameters]) in
37493749+ let url = client.base_url ^ url_path ^ query in
37503750+ let response =
37513751+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json MultiSearchSearchesParameter.T.jsont body)) url
37523752+ with Eio.Io _ as ex ->
37533753+ let bt = Printexc.get_raw_backtrace () in
37543754+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
37553755+ in
37563756+ if Requests.Response.ok response then
37573757+ Openapi.Runtime.Json.decode_json_exn Result.jsont (Requests.Response.json response)
37583758+ else
37593759+ let body = Requests.Response.text response in
37603760+ let status = Requests.Response.status_code response in
37613761+ let parsed_body = match status with
37623762+ | 400 ->
37633763+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
37643764+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
37653765+ | Error _ -> None)
37663766+ | _ ->
37673767+ (match Jsont_bytesrw.decode_string Jsont.json body with
37683768+ | Ok json -> Some (Openapi.Runtime.Json json)
37693769+ | Error _ -> Some (Openapi.Runtime.Raw body))
37703770+ in
37713771+ raise (Openapi.Runtime.Api_error {
37723772+ operation = op_name;
37733773+ method_ = "POST";
37743774+ url;
37753775+ status;
37763776+ body;
37773777+ parsed_body;
37783778+ })
37793779+end
37803780+37813781+module DirtyValues = struct
37823782+ module Types = struct
37833783+ module T = struct
37843784+ type t = [
37853785+ | `Coerce_or_reject
37863786+ | `Coerce_or_drop
37873787+ | `Drop
37883788+ | `Reject
37893789+ ]
37903790+ end
37913791+ end
37923792+37933793+ module T = struct
37943794+ include Types.T
37953795+37963796+ let jsont : t Jsont.t =
37973797+ Jsont.map Jsont.string ~kind:"DirtyValues"
37983798+ ~dec:(function
37993799+ | "coerce_or_reject" -> `Coerce_or_reject
38003800+ | "coerce_or_drop" -> `Coerce_or_drop
38013801+ | "drop" -> `Drop
38023802+ | "reject" -> `Reject
38033803+ | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s)
38043804+ ~enc:(function
38053805+ | `Coerce_or_reject -> "coerce_or_reject"
38063806+ | `Coerce_or_drop -> "coerce_or_drop"
38073807+ | `Drop -> "drop"
38083808+ | `Reject -> "reject")
38093809+ end
38103810+end
38113811+38123812+module CurationSetDeleteSchema = struct
38133813+ module Types = struct
38143814+ module T = struct
38153815+ type t = {
38163816+ name : string; (** Name of the deleted curation set *)
38173817+ }
38183818+ end
38193819+ end
38203820+38213821+ module T = struct
38223822+ include Types.T
38233823+38243824+ let v ~name () = { name }
38253825+38263826+ let name t = t.name
38273827+38283828+ let jsont : t Jsont.t =
38293829+ Jsont.Object.map ~kind:"CurationSetDeleteSchema"
38303830+ (fun name -> { name })
38313831+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
38323832+ |> Jsont.Object.skip_unknown
38333833+ |> Jsont.Object.finish
38343834+ end
38353835+38363836+ (** Delete a curation set
38373837+38383838+ Delete a specific curation set by its name
38393839+ @param curation_set_name The name of the curation set to delete
38403840+ *)
38413841+ let delete_curation_set ~curation_set_name client () =
38423842+ let op_name = "delete_curation_set" in
38433843+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in
38443844+ let query = "" in
38453845+ let url = client.base_url ^ url_path ^ query in
38463846+ let response =
38473847+ try Requests.delete client.session url
38483848+ with Eio.Io _ as ex ->
38493849+ let bt = Printexc.get_raw_backtrace () in
38503850+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
38513851+ in
38523852+ if Requests.Response.ok response then
38533853+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
38543854+ else
38553855+ let body = Requests.Response.text response in
38563856+ let status = Requests.Response.status_code response in
38573857+ let parsed_body = match status with
38583858+ | 404 ->
38593859+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
38603860+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
38613861+ | Error _ -> None)
38623862+ | _ ->
38633863+ (match Jsont_bytesrw.decode_string Jsont.json body with
38643864+ | Ok json -> Some (Openapi.Runtime.Json json)
38653865+ | Error _ -> Some (Openapi.Runtime.Raw body))
38663866+ in
38673867+ raise (Openapi.Runtime.Api_error {
38683868+ operation = op_name;
38693869+ method_ = "DELETE";
38703870+ url;
38713871+ status;
38723872+ body;
38733873+ parsed_body;
38743874+ })
38753875+end
38763876+38773877+module CurationRule = struct
38783878+ module Types = struct
38793879+ module T = struct
38803880+ type t = {
38813881+ filter_by : string option; (** Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc).
38823882+ *)
38833883+ match_ : string option; (** Indicates whether the match on the query term should be `exact` or `contains`. If we want to match all queries that contained the word `apple`, we will use the `contains` match instead.
38843884+ *)
38853885+ query : string option; (** Indicates what search queries should be curated *)
38863886+ tags : string list option; (** List of tag values to associate with this curation rule. *)
38873887+ }
38883888+ end
38893889+ end
38903890+38913891+ module T = struct
38923892+ include Types.T
38933893+38943894+ let v ?filter_by ?match_ ?query ?tags () = { filter_by; match_; query; tags }
38953895+38963896+ let filter_by t = t.filter_by
38973897+ let match_ t = t.match_
38983898+ let query t = t.query
38993899+ let tags t = t.tags
39003900+39013901+ let jsont : t Jsont.t =
39023902+ Jsont.Object.map ~kind:"CurationRule"
39033903+ (fun filter_by match_ query tags -> { filter_by; match_; query; tags })
39043904+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
39053905+ |> Jsont.Object.opt_mem "match" Jsont.string ~enc:(fun r -> r.match_)
39063906+ |> Jsont.Object.opt_mem "query" Jsont.string ~enc:(fun r -> r.query)
39073907+ |> Jsont.Object.opt_mem "tags" (Jsont.list Jsont.string) ~enc:(fun r -> r.tags)
39083908+ |> Jsont.Object.skip_unknown
39093909+ |> Jsont.Object.finish
39103910+ end
39113911+end
39123912+39133913+module CurationItemDeleteSchema = struct
39143914+ module Types = struct
39153915+ module T = struct
39163916+ type t = {
39173917+ id : string; (** ID of the deleted curation item *)
39183918+ }
39193919+ end
39203920+ end
39213921+39223922+ module T = struct
39233923+ include Types.T
39243924+39253925+ let v ~id () = { id }
39263926+39273927+ let id t = t.id
39283928+39293929+ let jsont : t Jsont.t =
39303930+ Jsont.Object.map ~kind:"CurationItemDeleteSchema"
39313931+ (fun id -> { id })
39323932+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
39333933+ |> Jsont.Object.skip_unknown
39343934+ |> Jsont.Object.finish
39353935+ end
39363936+39373937+ (** Delete a curation set item
39383938+39393939+ Delete a specific curation item by its id
39403940+ @param curation_set_name The name of the curation set
39413941+ @param item_id The id of the curation item to delete
39423942+ *)
39433943+ let delete_curation_set_item ~curation_set_name ~item_id client () =
39443944+ let op_name = "delete_curation_set_item" in
39453945+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in
39463946+ let query = "" in
39473947+ let url = client.base_url ^ url_path ^ query in
39483948+ let response =
39493949+ try Requests.delete client.session url
39503950+ with Eio.Io _ as ex ->
39513951+ let bt = Printexc.get_raw_backtrace () in
39523952+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
39533953+ in
39543954+ if Requests.Response.ok response then
39553955+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
39563956+ else
39573957+ let body = Requests.Response.text response in
39583958+ let status = Requests.Response.status_code response in
39593959+ let parsed_body = match status with
39603960+ | 404 ->
39613961+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
39623962+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
39633963+ | Error _ -> None)
39643964+ | _ ->
39653965+ (match Jsont_bytesrw.decode_string Jsont.json body with
39663966+ | Ok json -> Some (Openapi.Runtime.Json json)
39673967+ | Error _ -> Some (Openapi.Runtime.Raw body))
39683968+ in
39693969+ raise (Openapi.Runtime.Api_error {
39703970+ operation = op_name;
39713971+ method_ = "DELETE";
39723972+ url;
39733973+ status;
39743974+ body;
39753975+ parsed_body;
39763976+ })
39773977+end
39783978+39793979+module CurationInclude = struct
39803980+ module Types = struct
39813981+ module T = struct
39823982+ type t = {
39833983+ id : string; (** document id that should be included *)
39843984+ position : int; (** position number where document should be included in the search results *)
39853985+ }
39863986+ end
39873987+ end
39883988+39893989+ module T = struct
39903990+ include Types.T
39913991+39923992+ let v ~id ~position () = { id; position }
39933993+39943994+ let id t = t.id
39953995+ let position t = t.position
39963996+39973997+ let jsont : t Jsont.t =
39983998+ Jsont.Object.map ~kind:"CurationInclude"
39993999+ (fun id position -> { id; position })
40004000+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
40014001+ |> Jsont.Object.mem "position" Jsont.int ~enc:(fun r -> r.position)
40024002+ |> Jsont.Object.skip_unknown
40034003+ |> Jsont.Object.finish
40044004+ end
40054005+end
40064006+40074007+module CurationExclude = struct
40084008+ module Types = struct
40094009+ module T = struct
40104010+ type t = {
40114011+ id : string; (** document id that should be excluded from the search results. *)
40124012+ }
40134013+ end
40144014+ end
40154015+40164016+ module T = struct
40174017+ include Types.T
40184018+40194019+ let v ~id () = { id }
40204020+40214021+ let id t = t.id
40224022+40234023+ let jsont : t Jsont.t =
40244024+ Jsont.Object.map ~kind:"CurationExclude"
40254025+ (fun id -> { id })
40264026+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
40274027+ |> Jsont.Object.skip_unknown
40284028+ |> Jsont.Object.finish
40294029+ end
40304030+end
40314031+40324032+module CurationItemCreateSchema = struct
40334033+ module Types = struct
40344034+ module T = struct
40354035+ type t = {
40364036+ effective_from_ts : int option; (** A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
40374037+ *)
40384038+ effective_to_ts : int option; (** A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
40394039+ *)
40404040+ excludes : CurationExclude.T.t list option; (** List of document `id`s that should be excluded from the search results. *)
40414041+ filter_by : string option; (** A filter by clause that is applied to any search query that matches the curation rule.
40424042+ *)
40434043+ filter_curated_hits : bool option; (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
40444044+ *)
40454045+ id : string option; (** ID of the curation item *)
40464046+ includes : CurationInclude.T.t list option; (** List of document `id`s that should be included in the search results with their corresponding `position`s. *)
40474047+ metadata : Jsont.json option; (** Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered.
40484048+ *)
40494049+ remove_matched_tokens : bool option; (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
40504050+ *)
40514051+ replace_query : string option; (** Replaces the current search query with this value, when the search query matches the curation rule.
40524052+ *)
40534053+ rule : CurationRule.T.t;
40544054+ sort_by : string option; (** A sort by clause that is applied to any search query that matches the curation rule.
40554055+ *)
40564056+ stop_processing : bool option; (** When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
40574057+ *)
40584058+ }
40594059+ end
40604060+ end
40614061+40624062+ module T = struct
40634063+ include Types.T
40644064+40654065+ let v ~rule ?effective_from_ts ?effective_to_ts ?excludes ?filter_by ?filter_curated_hits ?id ?includes ?metadata ?remove_matched_tokens ?replace_query ?sort_by ?stop_processing () = { 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 }
40664066+40674067+ let effective_from_ts t = t.effective_from_ts
40684068+ let effective_to_ts t = t.effective_to_ts
40694069+ let excludes t = t.excludes
40704070+ let filter_by t = t.filter_by
40714071+ let filter_curated_hits t = t.filter_curated_hits
40724072+ let id t = t.id
40734073+ let includes t = t.includes
40744074+ let metadata t = t.metadata
40754075+ let remove_matched_tokens t = t.remove_matched_tokens
40764076+ let replace_query t = t.replace_query
40774077+ let rule t = t.rule
40784078+ let sort_by t = t.sort_by
40794079+ let stop_processing t = t.stop_processing
40804080+40814081+ let jsont : t Jsont.t =
40824082+ Jsont.Object.map ~kind:"CurationItemCreateSchema"
40834083+ (fun 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 -> { 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 })
40844084+ |> Jsont.Object.opt_mem "effective_from_ts" Jsont.int ~enc:(fun r -> r.effective_from_ts)
40854085+ |> Jsont.Object.opt_mem "effective_to_ts" Jsont.int ~enc:(fun r -> r.effective_to_ts)
40864086+ |> Jsont.Object.opt_mem "excludes" (Jsont.list CurationExclude.T.jsont) ~enc:(fun r -> r.excludes)
40874087+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
40884088+ |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits)
40894089+ |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id)
40904090+ |> Jsont.Object.opt_mem "includes" (Jsont.list CurationInclude.T.jsont) ~enc:(fun r -> r.includes)
40914091+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
40924092+ |> Jsont.Object.opt_mem "remove_matched_tokens" Jsont.bool ~enc:(fun r -> r.remove_matched_tokens)
40934093+ |> Jsont.Object.opt_mem "replace_query" Jsont.string ~enc:(fun r -> r.replace_query)
40944094+ |> Jsont.Object.mem "rule" CurationRule.T.jsont ~enc:(fun r -> r.rule)
40954095+ |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
40964096+ |> Jsont.Object.opt_mem "stop_processing" Jsont.bool ~enc:(fun r -> r.stop_processing)
40974097+ |> Jsont.Object.skip_unknown
40984098+ |> Jsont.Object.finish
40994099+ end
41004100+end
41014101+41024102+module CurationSetCreateSchema = struct
41034103+ module Types = struct
41044104+ module T = struct
41054105+ type t = {
41064106+ description : string option; (** Optional description for the curation set *)
41074107+ items : CurationItemCreateSchema.T.t list; (** Array of curation items *)
41084108+ }
41094109+ end
41104110+ end
41114111+41124112+ module T = struct
41134113+ include Types.T
41144114+41154115+ let v ~items ?description () = { description; items }
41164116+41174117+ let description t = t.description
41184118+ let items t = t.items
41194119+41204120+ let jsont : t Jsont.t =
41214121+ Jsont.Object.map ~kind:"CurationSetCreateSchema"
41224122+ (fun description items -> { description; items })
41234123+ |> Jsont.Object.opt_mem "description" Jsont.string ~enc:(fun r -> r.description)
41244124+ |> Jsont.Object.mem "items" (Jsont.list CurationItemCreateSchema.T.jsont) ~enc:(fun r -> r.items)
41254125+ |> Jsont.Object.skip_unknown
41264126+ |> Jsont.Object.finish
41274127+ end
41284128+end
41294129+41304130+module CurationSetSchema = struct
41314131+ module Types = struct
41324132+ module T = struct
41334133+ type t = {
41344134+ description : string option; (** Optional description for the curation set *)
41354135+ items : CurationItemCreateSchema.T.t list; (** Array of curation items *)
41364136+ name : string;
41374137+ }
41384138+ end
41394139+ end
41404140+41414141+ module T = struct
41424142+ include Types.T
41434143+41444144+ let v ~items ~name ?description () = { description; items; name }
41454145+41464146+ let description t = t.description
41474147+ let items t = t.items
41484148+ let name t = t.name
41494149+41504150+ let jsont : t Jsont.t =
41514151+ Jsont.Object.map ~kind:"CurationSetSchema"
41524152+ (fun description items name -> { description; items; name })
41534153+ |> Jsont.Object.opt_mem "description" Jsont.string ~enc:(fun r -> r.description)
41544154+ |> Jsont.Object.mem "items" (Jsont.list CurationItemCreateSchema.T.jsont) ~enc:(fun r -> r.items)
41554155+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
41564156+ |> Jsont.Object.skip_unknown
41574157+ |> Jsont.Object.finish
41584158+ end
41594159+41604160+ (** List all curation sets
41614161+41624162+ Retrieve all curation sets *)
41634163+ let retrieve_curation_sets client () =
41644164+ let op_name = "retrieve_curation_sets" in
41654165+ let url_path = "/curation_sets" in
41664166+ let query = "" in
41674167+ let url = client.base_url ^ url_path ^ query in
41684168+ let response =
41694169+ try Requests.get client.session url
41704170+ with Eio.Io _ as ex ->
41714171+ let bt = Printexc.get_raw_backtrace () in
41724172+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
41734173+ in
41744174+ if Requests.Response.ok response then
41754175+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
41764176+ else
41774177+ let body = Requests.Response.text response in
41784178+ let parsed_body =
41794179+ match Jsont_bytesrw.decode_string Jsont.json body with
41804180+ | Ok json -> Some (Openapi.Runtime.Json json)
41814181+ | Error _ -> Some (Openapi.Runtime.Raw body)
41824182+ in
41834183+ raise (Openapi.Runtime.Api_error {
41844184+ operation = op_name;
41854185+ method_ = "GET";
41864186+ url;
41874187+ status = Requests.Response.status_code response;
41884188+ body;
41894189+ parsed_body;
41904190+ })
41914191+41924192+ (** Retrieve a curation set
41934193+41944194+ Retrieve a specific curation set by its name
41954195+ @param curation_set_name The name of the curation set to retrieve
41964196+ *)
41974197+ let retrieve_curation_set ~curation_set_name client () =
41984198+ let op_name = "retrieve_curation_set" in
41994199+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in
42004200+ let query = "" in
42014201+ let url = client.base_url ^ url_path ^ query in
42024202+ let response =
42034203+ try Requests.get client.session url
42044204+ with Eio.Io _ as ex ->
42054205+ let bt = Printexc.get_raw_backtrace () in
42064206+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
42074207+ in
42084208+ if Requests.Response.ok response then
42094209+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
42104210+ else
42114211+ let body = Requests.Response.text response in
42124212+ let status = Requests.Response.status_code response in
42134213+ let parsed_body = match status with
42144214+ | 404 ->
42154215+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
42164216+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
42174217+ | Error _ -> None)
42184218+ | _ ->
42194219+ (match Jsont_bytesrw.decode_string Jsont.json body with
42204220+ | Ok json -> Some (Openapi.Runtime.Json json)
42214221+ | Error _ -> Some (Openapi.Runtime.Raw body))
42224222+ in
42234223+ raise (Openapi.Runtime.Api_error {
42244224+ operation = op_name;
42254225+ method_ = "GET";
42264226+ url;
42274227+ status;
42284228+ body;
42294229+ parsed_body;
42304230+ })
42314231+42324232+ (** Create or update a curation set
42334233+42344234+ Create or update a curation set with the given name
42354235+ @param curation_set_name The name of the curation set to create/update
42364236+ *)
42374237+ let upsert_curation_set ~curation_set_name ~body client () =
42384238+ let op_name = "upsert_curation_set" in
42394239+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in
42404240+ let query = "" in
42414241+ let url = client.base_url ^ url_path ^ query in
42424242+ let response =
42434243+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CurationSetCreateSchema.T.jsont body)) url
42444244+ with Eio.Io _ as ex ->
42454245+ let bt = Printexc.get_raw_backtrace () in
42464246+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
42474247+ in
42484248+ if Requests.Response.ok response then
42494249+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
42504250+ else
42514251+ let body = Requests.Response.text response in
42524252+ let status = Requests.Response.status_code response in
42534253+ let parsed_body = match status with
42544254+ | 400 ->
42554255+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
42564256+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
42574257+ | Error _ -> None)
42584258+ | _ ->
42594259+ (match Jsont_bytesrw.decode_string Jsont.json body with
42604260+ | Ok json -> Some (Openapi.Runtime.Json json)
42614261+ | Error _ -> Some (Openapi.Runtime.Raw body))
42624262+ in
42634263+ raise (Openapi.Runtime.Api_error {
42644264+ operation = op_name;
42654265+ method_ = "PUT";
42664266+ url;
42674267+ status;
42684268+ body;
42694269+ parsed_body;
42704270+ })
42714271+end
42724272+42734273+module CurationItemSchema = struct
42744274+ module Types = struct
42754275+ module T = struct
42764276+ type t = {
42774277+ effective_from_ts : int option; (** A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
42784278+ *)
42794279+ effective_to_ts : int option; (** A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
42804280+ *)
42814281+ excludes : CurationExclude.T.t list option; (** List of document `id`s that should be excluded from the search results. *)
42824282+ filter_by : string option; (** A filter by clause that is applied to any search query that matches the curation rule.
42834283+ *)
42844284+ filter_curated_hits : bool option; (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
42854285+ *)
42864286+ includes : CurationInclude.T.t list option; (** List of document `id`s that should be included in the search results with their corresponding `position`s. *)
42874287+ metadata : Jsont.json option; (** Return a custom JSON object in the Search API response, when this rule is triggered. This can can be used to display a pre-defined message (eg: a promotion banner) on the front-end when a particular rule is triggered.
42884288+ *)
42894289+ remove_matched_tokens : bool option; (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
42904290+ *)
42914291+ replace_query : string option; (** Replaces the current search query with this value, when the search query matches the curation rule.
42924292+ *)
42934293+ rule : CurationRule.T.t;
42944294+ sort_by : string option; (** A sort by clause that is applied to any search query that matches the curation rule.
42954295+ *)
42964296+ stop_processing : bool option; (** When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
42974297+ *)
42984298+ id : string;
42994299+ }
43004300+ end
43014301+ end
43024302+43034303+ module T = struct
43044304+ include Types.T
43054305+43064306+ let v ~rule ~id ?effective_from_ts ?effective_to_ts ?excludes ?filter_by ?filter_curated_hits ?includes ?metadata ?remove_matched_tokens ?replace_query ?sort_by ?stop_processing () = { effective_from_ts; effective_to_ts; excludes; filter_by; filter_curated_hits; includes; metadata; remove_matched_tokens; replace_query; rule; sort_by; stop_processing; id }
43074307+43084308+ let effective_from_ts t = t.effective_from_ts
43094309+ let effective_to_ts t = t.effective_to_ts
43104310+ let excludes t = t.excludes
43114311+ let filter_by t = t.filter_by
43124312+ let filter_curated_hits t = t.filter_curated_hits
43134313+ let includes t = t.includes
43144314+ let metadata t = t.metadata
43154315+ let remove_matched_tokens t = t.remove_matched_tokens
43164316+ let replace_query t = t.replace_query
43174317+ let rule t = t.rule
43184318+ let sort_by t = t.sort_by
43194319+ let stop_processing t = t.stop_processing
43204320+ let id t = t.id
43214321+43224322+ let jsont : t Jsont.t =
43234323+ Jsont.Object.map ~kind:"CurationItemSchema"
43244324+ (fun effective_from_ts effective_to_ts excludes filter_by filter_curated_hits includes metadata remove_matched_tokens replace_query rule sort_by stop_processing id -> { effective_from_ts; effective_to_ts; excludes; filter_by; filter_curated_hits; includes; metadata; remove_matched_tokens; replace_query; rule; sort_by; stop_processing; id })
43254325+ |> Jsont.Object.opt_mem "effective_from_ts" Jsont.int ~enc:(fun r -> r.effective_from_ts)
43264326+ |> Jsont.Object.opt_mem "effective_to_ts" Jsont.int ~enc:(fun r -> r.effective_to_ts)
43274327+ |> Jsont.Object.opt_mem "excludes" (Jsont.list CurationExclude.T.jsont) ~enc:(fun r -> r.excludes)
43284328+ |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by)
43294329+ |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits)
43304330+ |> Jsont.Object.opt_mem "includes" (Jsont.list CurationInclude.T.jsont) ~enc:(fun r -> r.includes)
43314331+ |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata)
43324332+ |> Jsont.Object.opt_mem "remove_matched_tokens" Jsont.bool ~enc:(fun r -> r.remove_matched_tokens)
43334333+ |> Jsont.Object.opt_mem "replace_query" Jsont.string ~enc:(fun r -> r.replace_query)
43344334+ |> Jsont.Object.mem "rule" CurationRule.T.jsont ~enc:(fun r -> r.rule)
43354335+ |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by)
43364336+ |> Jsont.Object.opt_mem "stop_processing" Jsont.bool ~enc:(fun r -> r.stop_processing)
43374337+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
43384338+ |> Jsont.Object.skip_unknown
43394339+ |> Jsont.Object.finish
43404340+ end
43414341+43424342+ (** List items in a curation set
43434343+43444344+ Retrieve all curation items in a set
43454345+ @param curation_set_name The name of the curation set to retrieve items for
43464346+ *)
43474347+ let retrieve_curation_set_items ~curation_set_name client () =
43484348+ let op_name = "retrieve_curation_set_items" in
43494349+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}/items" in
43504350+ let query = "" in
43514351+ let url = client.base_url ^ url_path ^ query in
43524352+ let response =
43534353+ try Requests.get client.session url
43544354+ with Eio.Io _ as ex ->
43554355+ let bt = Printexc.get_raw_backtrace () in
43564356+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
43574357+ in
43584358+ if Requests.Response.ok response then
43594359+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
43604360+ else
43614361+ let body = Requests.Response.text response in
43624362+ let status = Requests.Response.status_code response in
43634363+ let parsed_body = match status with
43644364+ | 404 ->
43654365+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
43664366+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
43674367+ | Error _ -> None)
43684368+ | _ ->
43694369+ (match Jsont_bytesrw.decode_string Jsont.json body with
43704370+ | Ok json -> Some (Openapi.Runtime.Json json)
43714371+ | Error _ -> Some (Openapi.Runtime.Raw body))
43724372+ in
43734373+ raise (Openapi.Runtime.Api_error {
43744374+ operation = op_name;
43754375+ method_ = "GET";
43764376+ url;
43774377+ status;
43784378+ body;
43794379+ parsed_body;
43804380+ })
43814381+43824382+ (** Retrieve a curation set item
43834383+43844384+ Retrieve a specific curation item by its id
43854385+ @param curation_set_name The name of the curation set
43864386+ @param item_id The id of the curation item to retrieve
43874387+ *)
43884388+ let retrieve_curation_set_item ~curation_set_name ~item_id client () =
43894389+ let op_name = "retrieve_curation_set_item" in
43904390+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in
43914391+ let query = "" in
43924392+ let url = client.base_url ^ url_path ^ query in
43934393+ let response =
43944394+ try Requests.get client.session url
43954395+ with Eio.Io _ as ex ->
43964396+ let bt = Printexc.get_raw_backtrace () in
43974397+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
43984398+ in
43994399+ if Requests.Response.ok response then
44004400+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
44014401+ else
44024402+ let body = Requests.Response.text response in
44034403+ let status = Requests.Response.status_code response in
44044404+ let parsed_body = match status with
44054405+ | 404 ->
44064406+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
44074407+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
44084408+ | Error _ -> None)
44094409+ | _ ->
44104410+ (match Jsont_bytesrw.decode_string Jsont.json body with
44114411+ | Ok json -> Some (Openapi.Runtime.Json json)
44124412+ | Error _ -> Some (Openapi.Runtime.Raw body))
44134413+ in
44144414+ raise (Openapi.Runtime.Api_error {
44154415+ operation = op_name;
44164416+ method_ = "GET";
44174417+ url;
44184418+ status;
44194419+ body;
44204420+ parsed_body;
44214421+ })
44224422+44234423+ (** Create or update a curation set item
44244424+44254425+ Create or update a curation set item with the given id
44264426+ @param curation_set_name The name of the curation set
44274427+ @param item_id The id of the curation item to upsert
44284428+ *)
44294429+ let upsert_curation_set_item ~curation_set_name ~item_id ~body client () =
44304430+ let op_name = "upsert_curation_set_item" in
44314431+ let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in
44324432+ let query = "" in
44334433+ let url = client.base_url ^ url_path ^ query in
44344434+ let response =
44354435+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CurationItemCreateSchema.T.jsont body)) url
44364436+ with Eio.Io _ as ex ->
44374437+ let bt = Printexc.get_raw_backtrace () in
44384438+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
44394439+ in
44404440+ if Requests.Response.ok response then
44414441+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
44424442+ else
44434443+ let body = Requests.Response.text response in
44444444+ let status = Requests.Response.status_code response in
44454445+ let parsed_body = match status with
44464446+ | 400 ->
44474447+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
44484448+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
44494449+ | Error _ -> None)
44504450+ | _ ->
44514451+ (match Jsont_bytesrw.decode_string Jsont.json body with
44524452+ | Ok json -> Some (Openapi.Runtime.Json json)
44534453+ | Error _ -> Some (Openapi.Runtime.Raw body))
44544454+ in
44554455+ raise (Openapi.Runtime.Api_error {
44564456+ operation = op_name;
44574457+ method_ = "PUT";
44584458+ url;
44594459+ status;
44604460+ body;
44614461+ parsed_body;
44624462+ })
44634463+end
44644464+44654465+module ConversationModelUpdateSchema = struct
44664466+ module Types = struct
44674467+ module T = struct
44684468+ type t = {
44694469+ account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *)
44704470+ api_key : string option; (** The LLM service's API Key *)
44714471+ history_collection : string option; (** Typesense collection that stores the historical conversations *)
44724472+ id : string option; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
44734473+ max_bytes : int option; (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
44744474+ *)
44754475+ model_name : string option; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
44764476+ system_prompt : string option; (** The system prompt that contains special instructions to the LLM *)
44774477+ ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
44784478+ *)
44794479+ vllm_url : string option; (** URL of vLLM service *)
44804480+ }
44814481+ end
44824482+ end
44834483+44844484+ module T = struct
44854485+ include Types.T
44864486+44874487+ let v ?account_id ?api_key ?history_collection ?id ?max_bytes ?model_name ?system_prompt ?ttl ?vllm_url () = { account_id; api_key; history_collection; id; max_bytes; model_name; system_prompt; ttl; vllm_url }
44884488+44894489+ let account_id t = t.account_id
44904490+ let api_key t = t.api_key
44914491+ let history_collection t = t.history_collection
44924492+ let id t = t.id
44934493+ let max_bytes t = t.max_bytes
44944494+ let model_name t = t.model_name
44954495+ let system_prompt t = t.system_prompt
44964496+ let ttl t = t.ttl
44974497+ let vllm_url t = t.vllm_url
44984498+44994499+ let jsont : t Jsont.t =
45004500+ Jsont.Object.map ~kind:"ConversationModelUpdateSchema"
45014501+ (fun account_id api_key history_collection id max_bytes model_name system_prompt ttl vllm_url -> { account_id; api_key; history_collection; id; max_bytes; model_name; system_prompt; ttl; vllm_url })
45024502+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
45034503+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
45044504+ |> Jsont.Object.opt_mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection)
45054505+ |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id)
45064506+ |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
45074507+ |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
45084508+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
45094509+ |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl)
45104510+ |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url)
45114511+ |> Jsont.Object.skip_unknown
45124512+ |> Jsont.Object.finish
45134513+ end
45144514+end
45154515+45164516+module ConversationModelCreateSchema = struct
45174517+ module Types = struct
45184518+ module T = struct
45194519+ type t = {
45204520+ account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *)
45214521+ api_key : string option; (** The LLM service's API Key *)
45224522+ id : string option; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
45234523+ system_prompt : string option; (** The system prompt that contains special instructions to the LLM *)
45244524+ ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
45254525+ *)
45264526+ vllm_url : string option; (** URL of vLLM service *)
45274527+ model_name : string; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
45284528+ max_bytes : int; (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
45294529+ *)
45304530+ history_collection : string; (** Typesense collection that stores the historical conversations *)
45314531+ }
45324532+ end
45334533+ end
45344534+45354535+ module T = struct
45364536+ include Types.T
45374537+45384538+ let v ~model_name ~max_bytes ~history_collection ?account_id ?api_key ?id ?system_prompt ?ttl ?vllm_url () = { account_id; api_key; id; system_prompt; ttl; vllm_url; model_name; max_bytes; history_collection }
45394539+45404540+ let account_id t = t.account_id
45414541+ let api_key t = t.api_key
45424542+ let id t = t.id
45434543+ let system_prompt t = t.system_prompt
45444544+ let ttl t = t.ttl
45454545+ let vllm_url t = t.vllm_url
45464546+ let model_name t = t.model_name
45474547+ let max_bytes t = t.max_bytes
45484548+ let history_collection t = t.history_collection
45494549+45504550+ let jsont : t Jsont.t =
45514551+ Jsont.Object.map ~kind:"ConversationModelCreateSchema"
45524552+ (fun account_id api_key id system_prompt ttl vllm_url model_name max_bytes history_collection -> { account_id; api_key; id; system_prompt; ttl; vllm_url; model_name; max_bytes; history_collection })
45534553+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
45544554+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
45554555+ |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id)
45564556+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
45574557+ |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl)
45584558+ |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url)
45594559+ |> Jsont.Object.mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
45604560+ |> Jsont.Object.mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
45614561+ |> Jsont.Object.mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection)
45624562+ |> Jsont.Object.skip_unknown
45634563+ |> Jsont.Object.finish
45644564+ end
45654565+end
45664566+45674567+module ConversationModelSchema = struct
45684568+ module Types = struct
45694569+ module T = struct
45704570+ type t = {
45714571+ account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *)
45724572+ api_key : string option; (** The LLM service's API Key *)
45734573+ system_prompt : string option; (** The system prompt that contains special instructions to the LLM *)
45744574+ ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
45754575+ *)
45764576+ vllm_url : string option; (** URL of vLLM service *)
45774577+ model_name : string; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
45784578+ max_bytes : int; (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
45794579+ *)
45804580+ history_collection : string; (** Typesense collection that stores the historical conversations *)
45814581+ id : string; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
45824582+ }
45834583+ end
45844584+ end
45854585+45864586+ module T = struct
45874587+ include Types.T
45884588+45894589+ let v ~model_name ~max_bytes ~history_collection ~id ?account_id ?api_key ?system_prompt ?ttl ?vllm_url () = { account_id; api_key; system_prompt; ttl; vllm_url; model_name; max_bytes; history_collection; id }
45904590+45914591+ let account_id t = t.account_id
45924592+ let api_key t = t.api_key
45934593+ let system_prompt t = t.system_prompt
45944594+ let ttl t = t.ttl
45954595+ let vllm_url t = t.vllm_url
45964596+ let model_name t = t.model_name
45974597+ let max_bytes t = t.max_bytes
45984598+ let history_collection t = t.history_collection
45994599+ let id t = t.id
46004600+46014601+ let jsont : t Jsont.t =
46024602+ Jsont.Object.map ~kind:"ConversationModelSchema"
46034603+ (fun account_id api_key system_prompt ttl vllm_url model_name max_bytes history_collection id -> { account_id; api_key; system_prompt; ttl; vllm_url; model_name; max_bytes; history_collection; id })
46044604+ |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id)
46054605+ |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key)
46064606+ |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt)
46074607+ |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl)
46084608+ |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url)
46094609+ |> Jsont.Object.mem "model_name" Jsont.string ~enc:(fun r -> r.model_name)
46104610+ |> Jsont.Object.mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes)
46114611+ |> Jsont.Object.mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection)
46124612+ |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id)
46134613+ |> Jsont.Object.skip_unknown
46144614+ |> Jsont.Object.finish
46154615+ end
46164616+46174617+ (** List all conversation models
46184618+46194619+ Retrieve all conversation models *)
46204620+ let retrieve_all_conversation_models client () =
46214621+ let op_name = "retrieve_all_conversation_models" in
46224622+ let url_path = "/conversations/models" in
46234623+ let query = "" in
46244624+ let url = client.base_url ^ url_path ^ query in
46254625+ let response =
46264626+ try Requests.get client.session url
46274627+ with Eio.Io _ as ex ->
46284628+ let bt = Printexc.get_raw_backtrace () in
46294629+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
46304630+ in
46314631+ if Requests.Response.ok response then
46324632+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
46334633+ else
46344634+ let body = Requests.Response.text response in
46354635+ let parsed_body =
46364636+ match Jsont_bytesrw.decode_string Jsont.json body with
46374637+ | Ok json -> Some (Openapi.Runtime.Json json)
46384638+ | Error _ -> Some (Openapi.Runtime.Raw body)
46394639+ in
46404640+ raise (Openapi.Runtime.Api_error {
46414641+ operation = op_name;
46424642+ method_ = "GET";
46434643+ url;
46444644+ status = Requests.Response.status_code response;
46454645+ body;
46464646+ parsed_body;
46474647+ })
46484648+46494649+ (** Create a conversation model
46504650+46514651+ Create a Conversation Model *)
46524652+ let create_conversation_model ~body client () =
46534653+ let op_name = "create_conversation_model" in
46544654+ let url_path = "/conversations/models" in
46554655+ let query = "" in
46564656+ let url = client.base_url ^ url_path ^ query in
46574657+ let response =
46584658+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ConversationModelCreateSchema.T.jsont body)) url
46594659+ with Eio.Io _ as ex ->
46604660+ let bt = Printexc.get_raw_backtrace () in
46614661+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
46624662+ in
46634663+ if Requests.Response.ok response then
46644664+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
46654665+ else
46664666+ let body = Requests.Response.text response in
46674667+ let status = Requests.Response.status_code response in
46684668+ let parsed_body = match status with
46694669+ | 400 ->
46704670+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
46714671+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
46724672+ | Error _ -> None)
46734673+ | _ ->
46744674+ (match Jsont_bytesrw.decode_string Jsont.json body with
46754675+ | Ok json -> Some (Openapi.Runtime.Json json)
46764676+ | Error _ -> Some (Openapi.Runtime.Raw body))
46774677+ in
46784678+ raise (Openapi.Runtime.Api_error {
46794679+ operation = op_name;
46804680+ method_ = "POST";
46814681+ url;
46824682+ status;
46834683+ body;
46844684+ parsed_body;
46854685+ })
46864686+46874687+ (** Retrieve a conversation model
46884688+46894689+ Retrieve a conversation model
46904690+ @param model_id The id of the conversation model to retrieve
46914691+ *)
46924692+ let retrieve_conversation_model ~model_id client () =
46934693+ let op_name = "retrieve_conversation_model" in
46944694+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in
46954695+ let query = "" in
46964696+ let url = client.base_url ^ url_path ^ query in
46974697+ let response =
46984698+ try Requests.get client.session url
46994699+ with Eio.Io _ as ex ->
47004700+ let bt = Printexc.get_raw_backtrace () in
47014701+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
47024702+ in
47034703+ if Requests.Response.ok response then
47044704+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
47054705+ else
47064706+ let body = Requests.Response.text response in
47074707+ let parsed_body =
47084708+ match Jsont_bytesrw.decode_string Jsont.json body with
47094709+ | Ok json -> Some (Openapi.Runtime.Json json)
47104710+ | Error _ -> Some (Openapi.Runtime.Raw body)
47114711+ in
47124712+ raise (Openapi.Runtime.Api_error {
47134713+ operation = op_name;
47144714+ method_ = "GET";
47154715+ url;
47164716+ status = Requests.Response.status_code response;
47174717+ body;
47184718+ parsed_body;
47194719+ })
47204720+47214721+ (** Update a conversation model
47224722+47234723+ Update a conversation model
47244724+ @param model_id The id of the conversation model to update
47254725+ *)
47264726+ let update_conversation_model ~model_id ~body client () =
47274727+ let op_name = "update_conversation_model" in
47284728+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in
47294729+ let query = "" in
47304730+ let url = client.base_url ^ url_path ^ query in
47314731+ let response =
47324732+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ConversationModelUpdateSchema.T.jsont body)) url
47334733+ with Eio.Io _ as ex ->
47344734+ let bt = Printexc.get_raw_backtrace () in
47354735+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
47364736+ in
47374737+ if Requests.Response.ok response then
47384738+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
47394739+ else
47404740+ let body = Requests.Response.text response in
47414741+ let parsed_body =
47424742+ match Jsont_bytesrw.decode_string Jsont.json body with
47434743+ | Ok json -> Some (Openapi.Runtime.Json json)
47444744+ | Error _ -> Some (Openapi.Runtime.Raw body)
47454745+ in
47464746+ raise (Openapi.Runtime.Api_error {
47474747+ operation = op_name;
47484748+ method_ = "PUT";
47494749+ url;
47504750+ status = Requests.Response.status_code response;
47514751+ body;
47524752+ parsed_body;
47534753+ })
47544754+47554755+ (** Delete a conversation model
47564756+47574757+ Delete a conversation model
47584758+ @param model_id The id of the conversation model to delete
47594759+ *)
47604760+ let delete_conversation_model ~model_id client () =
47614761+ let op_name = "delete_conversation_model" in
47624762+ let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in
47634763+ let query = "" in
47644764+ let url = client.base_url ^ url_path ^ query in
47654765+ let response =
47664766+ try Requests.delete client.session url
47674767+ with Eio.Io _ as ex ->
47684768+ let bt = Printexc.get_raw_backtrace () in
47694769+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
47704770+ in
47714771+ if Requests.Response.ok response then
47724772+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
47734773+ else
47744774+ let body = Requests.Response.text response in
47754775+ let parsed_body =
47764776+ match Jsont_bytesrw.decode_string Jsont.json body with
47774777+ | Ok json -> Some (Openapi.Runtime.Json json)
47784778+ | Error _ -> Some (Openapi.Runtime.Raw body)
47794779+ in
47804780+ raise (Openapi.Runtime.Api_error {
47814781+ operation = op_name;
47824782+ method_ = "DELETE";
47834783+ url;
47844784+ status = Requests.Response.status_code response;
47854785+ body;
47864786+ parsed_body;
47874787+ })
47884788+end
47894789+47904790+module CollectionAliasSchema = struct
47914791+ module Types = struct
47924792+ module T = struct
47934793+ type t = {
47944794+ collection_name : string; (** Name of the collection you wish to map the alias to *)
47954795+ }
47964796+ end
47974797+ end
47984798+47994799+ module T = struct
48004800+ include Types.T
48014801+48024802+ let v ~collection_name () = { collection_name }
48034803+48044804+ let collection_name t = t.collection_name
48054805+48064806+ let jsont : t Jsont.t =
48074807+ Jsont.Object.map ~kind:"CollectionAliasSchema"
48084808+ (fun collection_name -> { collection_name })
48094809+ |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name)
48104810+ |> Jsont.Object.skip_unknown
48114811+ |> Jsont.Object.finish
48124812+ end
48134813+end
48144814+48154815+module CollectionAlias = struct
48164816+ module Types = struct
48174817+ module T = struct
48184818+ type t = {
48194819+ collection_name : string; (** Name of the collection the alias mapped to *)
48204820+ name : string; (** Name of the collection alias *)
48214821+ }
48224822+ end
48234823+ end
48244824+48254825+ module T = struct
48264826+ include Types.T
48274827+48284828+ let v ~collection_name ~name () = { collection_name; name }
48294829+48304830+ let collection_name t = t.collection_name
48314831+ let name t = t.name
48324832+48334833+ let jsont : t Jsont.t =
48344834+ Jsont.Object.map ~kind:"CollectionAlias"
48354835+ (fun collection_name name -> { collection_name; name })
48364836+ |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name)
48374837+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
48384838+ |> Jsont.Object.skip_unknown
48394839+ |> Jsont.Object.finish
48404840+ end
48414841+48424842+ (** Retrieve an alias
48434843+48444844+ Find out which collection an alias points to by fetching it
48454845+ @param alias_name The name of the alias to retrieve
48464846+ *)
48474847+ let get_alias ~alias_name client () =
48484848+ let op_name = "get_alias" in
48494849+ let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in
48504850+ let query = "" in
48514851+ let url = client.base_url ^ url_path ^ query in
48524852+ let response =
48534853+ try Requests.get client.session url
48544854+ with Eio.Io _ as ex ->
48554855+ let bt = Printexc.get_raw_backtrace () in
48564856+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
48574857+ in
48584858+ if Requests.Response.ok response then
48594859+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
48604860+ else
48614861+ let body = Requests.Response.text response in
48624862+ let status = Requests.Response.status_code response in
48634863+ let parsed_body = match status with
48644864+ | 404 ->
48654865+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
48664866+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
48674867+ | Error _ -> None)
48684868+ | _ ->
48694869+ (match Jsont_bytesrw.decode_string Jsont.json body with
48704870+ | Ok json -> Some (Openapi.Runtime.Json json)
48714871+ | Error _ -> Some (Openapi.Runtime.Raw body))
48724872+ in
48734873+ raise (Openapi.Runtime.Api_error {
48744874+ operation = op_name;
48754875+ method_ = "GET";
48764876+ url;
48774877+ status;
48784878+ body;
48794879+ parsed_body;
48804880+ })
48814881+48824882+ (** Create or update a collection alias
48834883+48844884+ 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.
48854885+ @param alias_name The name of the alias to create/update
48864886+ *)
48874887+ let upsert_alias ~alias_name ~body client () =
48884888+ let op_name = "upsert_alias" in
48894889+ let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in
48904890+ let query = "" in
48914891+ let url = client.base_url ^ url_path ^ query in
48924892+ let response =
48934893+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CollectionAliasSchema.T.jsont body)) url
48944894+ with Eio.Io _ as ex ->
48954895+ let bt = Printexc.get_raw_backtrace () in
48964896+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
48974897+ in
48984898+ if Requests.Response.ok response then
48994899+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
49004900+ else
49014901+ let body = Requests.Response.text response in
49024902+ let status = Requests.Response.status_code response in
49034903+ let parsed_body = match status with
49044904+ | 400 ->
49054905+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
49064906+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
49074907+ | Error _ -> None)
49084908+ | 404 ->
49094909+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
49104910+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
49114911+ | Error _ -> None)
49124912+ | _ ->
49134913+ (match Jsont_bytesrw.decode_string Jsont.json body with
49144914+ | Ok json -> Some (Openapi.Runtime.Json json)
49154915+ | Error _ -> Some (Openapi.Runtime.Raw body))
49164916+ in
49174917+ raise (Openapi.Runtime.Api_error {
49184918+ operation = op_name;
49194919+ method_ = "PUT";
49204920+ url;
49214921+ status;
49224922+ body;
49234923+ parsed_body;
49244924+ })
49254925+49264926+ (** Delete an alias
49274927+ @param alias_name The name of the alias to delete
49284928+ *)
49294929+ let delete_alias ~alias_name client () =
49304930+ let op_name = "delete_alias" in
49314931+ let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in
49324932+ let query = "" in
49334933+ let url = client.base_url ^ url_path ^ query in
49344934+ let response =
49354935+ try Requests.delete client.session url
49364936+ with Eio.Io _ as ex ->
49374937+ let bt = Printexc.get_raw_backtrace () in
49384938+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
49394939+ in
49404940+ if Requests.Response.ok response then
49414941+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
49424942+ else
49434943+ let body = Requests.Response.text response in
49444944+ let status = Requests.Response.status_code response in
49454945+ let parsed_body = match status with
49464946+ | 404 ->
49474947+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
49484948+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
49494949+ | Error _ -> None)
49504950+ | _ ->
49514951+ (match Jsont_bytesrw.decode_string Jsont.json body with
49524952+ | Ok json -> Some (Openapi.Runtime.Json json)
49534953+ | Error _ -> Some (Openapi.Runtime.Raw body))
49544954+ in
49554955+ raise (Openapi.Runtime.Api_error {
49564956+ operation = op_name;
49574957+ method_ = "DELETE";
49584958+ url;
49594959+ status;
49604960+ body;
49614961+ parsed_body;
49624962+ })
49634963+end
49644964+49654965+module CollectionAliases = struct
49664966+ module Types = struct
49674967+ module Response = struct
49684968+ type t = {
49694969+ aliases : CollectionAlias.T.t list;
49704970+ }
49714971+ end
49724972+ end
49734973+49744974+ module Response = struct
49754975+ include Types.Response
49764976+49774977+ let v ~aliases () = { aliases }
49784978+49794979+ let aliases t = t.aliases
49804980+49814981+ let jsont : t Jsont.t =
49824982+ Jsont.Object.map ~kind:"CollectionAliasesResponse"
49834983+ (fun aliases -> { aliases })
49844984+ |> Jsont.Object.mem "aliases" (Jsont.list CollectionAlias.T.jsont) ~enc:(fun r -> r.aliases)
49854985+ |> Jsont.Object.skip_unknown
49864986+ |> Jsont.Object.finish
49874987+ end
49884988+49894989+ (** List all aliases
49904990+49914991+ List all aliases and the corresponding collections that they map to. *)
49924992+ let get_aliases client () =
49934993+ let op_name = "get_aliases" in
49944994+ let url_path = "/aliases" in
49954995+ let query = "" in
49964996+ let url = client.base_url ^ url_path ^ query in
49974997+ let response =
49984998+ try Requests.get client.session url
49994999+ with Eio.Io _ as ex ->
50005000+ let bt = Printexc.get_raw_backtrace () in
50015001+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
50025002+ in
50035003+ if Requests.Response.ok response then
50045004+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
50055005+ else
50065006+ let body = Requests.Response.text response in
50075007+ let parsed_body =
50085008+ match Jsont_bytesrw.decode_string Jsont.json body with
50095009+ | Ok json -> Some (Openapi.Runtime.Json json)
50105010+ | Error _ -> Some (Openapi.Runtime.Raw body)
50115011+ in
50125012+ raise (Openapi.Runtime.Api_error {
50135013+ operation = op_name;
50145014+ method_ = "GET";
50155015+ url;
50165016+ status = Requests.Response.status_code response;
50175017+ body;
50185018+ parsed_body;
50195019+ })
50205020+end
50215021+50225022+module Client = struct
50235023+ (** Create analytics rule(s)
50245024+50255025+ Create one or more analytics rules. You can send a single rule object or an array of rule objects. *)
50265026+ let create_analytics_rule client () =
50275027+ let op_name = "create_analytics_rule" in
50285028+ let url_path = "/analytics/rules" in
50295029+ let query = "" in
50305030+ let url = client.base_url ^ url_path ^ query in
50315031+ let response =
50325032+ try Requests.post client.session url
50335033+ with Eio.Io _ as ex ->
50345034+ let bt = Printexc.get_raw_backtrace () in
50355035+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
50365036+ in
50375037+ if Requests.Response.ok response then
50385038+ Requests.Response.json response
50395039+ else
50405040+ let body = Requests.Response.text response in
50415041+ let status = Requests.Response.status_code response in
50425042+ let parsed_body = match status with
50435043+ | 400 ->
50445044+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
50455045+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
50465046+ | Error _ -> None)
50475047+ | _ ->
50485048+ (match Jsont_bytesrw.decode_string Jsont.json body with
50495049+ | Ok json -> Some (Openapi.Runtime.Json json)
50505050+ | Error _ -> Some (Openapi.Runtime.Raw body))
50515051+ in
50525052+ raise (Openapi.Runtime.Api_error {
50535053+ operation = op_name;
50545054+ method_ = "POST";
50555055+ url;
50565056+ status;
50575057+ body;
50585058+ parsed_body;
50595059+ })
50605060+50615061+ (** Index a document
50625062+50635063+ A document to be indexed in a given collection must conform to the schema of the collection.
50645064+ @param collection_name The name of the collection to add the document to
50655065+ @param action Additional action to perform
50665066+ @param dirty_values Dealing with Dirty Data
50675067+ *)
50685068+ let index_document ~collection_name ?action ?dirty_values client () =
50695069+ let op_name = "index_document" in
50705070+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in
50715071+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"action" ~value:action; Openapi.Runtime.Query.optional ~key:"dirty_values" ~value:dirty_values]) in
50725072+ let url = client.base_url ^ url_path ^ query in
50735073+ let response =
50745074+ try Requests.post client.session url
50755075+ with Eio.Io _ as ex ->
50765076+ let bt = Printexc.get_raw_backtrace () in
50775077+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
50785078+ in
50795079+ if Requests.Response.ok response then
50805080+ Requests.Response.json response
50815081+ else
50825082+ let body = Requests.Response.text response in
50835083+ let status = Requests.Response.status_code response in
50845084+ let parsed_body = match status with
50855085+ | 404 ->
50865086+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
50875087+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
50885088+ | Error _ -> None)
50895089+ | _ ->
50905090+ (match Jsont_bytesrw.decode_string Jsont.json body with
50915091+ | Ok json -> Some (Openapi.Runtime.Json json)
50925092+ | Error _ -> Some (Openapi.Runtime.Raw body))
50935093+ in
50945094+ raise (Openapi.Runtime.Api_error {
50955095+ operation = op_name;
50965096+ method_ = "POST";
50975097+ url;
50985098+ status;
50995099+ body;
51005100+ parsed_body;
51015101+ })
51025102+51035103+ (** Delete a bunch of documents
51045104+51055105+ 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.
51065106+ @param collection_name The name of the collection to delete documents from
51075107+ *)
51085108+ let delete_documents ~collection_name ?delete_documents_parameters client () =
51095109+ let op_name = "delete_documents" in
51105110+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in
51115111+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"deleteDocumentsParameters" ~value:delete_documents_parameters]) in
51125112+ let url = client.base_url ^ url_path ^ query in
51135113+ let response =
51145114+ try Requests.delete client.session url
51155115+ with Eio.Io _ as ex ->
51165116+ let bt = Printexc.get_raw_backtrace () in
51175117+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
51185118+ in
51195119+ if Requests.Response.ok response then
51205120+ Requests.Response.json response
51215121+ else
51225122+ let body = Requests.Response.text response in
51235123+ let status = Requests.Response.status_code response in
51245124+ let parsed_body = match status with
51255125+ | 404 ->
51265126+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
51275127+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
51285128+ | Error _ -> None)
51295129+ | _ ->
51305130+ (match Jsont_bytesrw.decode_string Jsont.json body with
51315131+ | Ok json -> Some (Openapi.Runtime.Json json)
51325132+ | Error _ -> Some (Openapi.Runtime.Raw body))
51335133+ in
51345134+ raise (Openapi.Runtime.Api_error {
51355135+ operation = op_name;
51365136+ method_ = "DELETE";
51375137+ url;
51385138+ status;
51395139+ body;
51405140+ parsed_body;
51415141+ })
51425142+51435143+ (** Update documents with conditional query
51445144+51455145+ 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.
51465146+ @param collection_name The name of the collection to update documents in
51475147+ *)
51485148+ let update_documents ~collection_name ?update_documents_parameters client () =
51495149+ let op_name = "update_documents" in
51505150+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in
51515151+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"updateDocumentsParameters" ~value:update_documents_parameters]) in
51525152+ let url = client.base_url ^ url_path ^ query in
51535153+ let response =
51545154+ try Requests.patch client.session url
51555155+ with Eio.Io _ as ex ->
51565156+ let bt = Printexc.get_raw_backtrace () in
51575157+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url
51585158+ in
51595159+ if Requests.Response.ok response then
51605160+ Requests.Response.json response
51615161+ else
51625162+ let body = Requests.Response.text response in
51635163+ let status = Requests.Response.status_code response in
51645164+ let parsed_body = match status with
51655165+ | 400 ->
51665166+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
51675167+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
51685168+ | Error _ -> None)
51695169+ | 404 ->
51705170+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
51715171+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
51725172+ | Error _ -> None)
51735173+ | _ ->
51745174+ (match Jsont_bytesrw.decode_string Jsont.json body with
51755175+ | Ok json -> Some (Openapi.Runtime.Json json)
51765176+ | Error _ -> Some (Openapi.Runtime.Raw body))
51775177+ in
51785178+ raise (Openapi.Runtime.Api_error {
51795179+ operation = op_name;
51805180+ method_ = "PATCH";
51815181+ url;
51825182+ status;
51835183+ body;
51845184+ parsed_body;
51855185+ })
51865186+51875187+ (** Export all documents in a collection
51885188+51895189+ Export all documents in a collection in JSON lines format.
51905190+ @param collection_name The name of the collection
51915191+ *)
51925192+ let export_documents ~collection_name ?export_documents_parameters client () =
51935193+ let op_name = "export_documents" in
51945194+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/export" in
51955195+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"exportDocumentsParameters" ~value:export_documents_parameters]) in
51965196+ let url = client.base_url ^ url_path ^ query in
51975197+ let response =
51985198+ try Requests.get client.session url
51995199+ with Eio.Io _ as ex ->
52005200+ let bt = Printexc.get_raw_backtrace () in
52015201+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
52025202+ in
52035203+ if Requests.Response.ok response then
52045204+ Requests.Response.json response
52055205+ else
52065206+ let body = Requests.Response.text response in
52075207+ let status = Requests.Response.status_code response in
52085208+ let parsed_body = match status with
52095209+ | 404 ->
52105210+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
52115211+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
52125212+ | Error _ -> None)
52135213+ | _ ->
52145214+ (match Jsont_bytesrw.decode_string Jsont.json body with
52155215+ | Ok json -> Some (Openapi.Runtime.Json json)
52165216+ | Error _ -> Some (Openapi.Runtime.Raw body))
52175217+ in
52185218+ raise (Openapi.Runtime.Api_error {
52195219+ operation = op_name;
52205220+ method_ = "GET";
52215221+ url;
52225222+ status;
52235223+ body;
52245224+ parsed_body;
52255225+ })
52265226+52275227+ (** Import documents into a collection
52285228+52295229+ 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.
52305230+ @param collection_name The name of the collection
52315231+ *)
52325232+ let import_documents ~collection_name ?import_documents_parameters client () =
52335233+ let op_name = "import_documents" in
52345234+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/import" in
52355235+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"importDocumentsParameters" ~value:import_documents_parameters]) in
52365236+ let url = client.base_url ^ url_path ^ query in
52375237+ let response =
52385238+ try Requests.post client.session url
52395239+ with Eio.Io _ as ex ->
52405240+ let bt = Printexc.get_raw_backtrace () in
52415241+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
52425242+ in
52435243+ if Requests.Response.ok response then
52445244+ Requests.Response.json response
52455245+ else
52465246+ let body = Requests.Response.text response in
52475247+ let status = Requests.Response.status_code response in
52485248+ let parsed_body = match status with
52495249+ | 400 ->
52505250+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
52515251+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
52525252+ | Error _ -> None)
52535253+ | 404 ->
52545254+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
52555255+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
52565256+ | Error _ -> None)
52575257+ | _ ->
52585258+ (match Jsont_bytesrw.decode_string Jsont.json body with
52595259+ | Ok json -> Some (Openapi.Runtime.Json json)
52605260+ | Error _ -> Some (Openapi.Runtime.Raw body))
52615261+ in
52625262+ raise (Openapi.Runtime.Api_error {
52635263+ operation = op_name;
52645264+ method_ = "POST";
52655265+ url;
52665266+ status;
52675267+ body;
52685268+ parsed_body;
52695269+ })
52705270+52715271+ (** Retrieve a document
52725272+52735273+ Fetch an individual document from a collection by using its ID.
52745274+ @param collection_name The name of the collection to search for the document under
52755275+ @param document_id The Document ID
52765276+ *)
52775277+ let get_document ~collection_name ~document_id client () =
52785278+ let op_name = "get_document" in
52795279+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in
52805280+ let query = "" in
52815281+ let url = client.base_url ^ url_path ^ query in
52825282+ let response =
52835283+ try Requests.get client.session url
52845284+ with Eio.Io _ as ex ->
52855285+ let bt = Printexc.get_raw_backtrace () in
52865286+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
52875287+ in
52885288+ if Requests.Response.ok response then
52895289+ Requests.Response.json response
52905290+ else
52915291+ let body = Requests.Response.text response in
52925292+ let status = Requests.Response.status_code response in
52935293+ let parsed_body = match status with
52945294+ | 404 ->
52955295+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
52965296+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
52975297+ | Error _ -> None)
52985298+ | _ ->
52995299+ (match Jsont_bytesrw.decode_string Jsont.json body with
53005300+ | Ok json -> Some (Openapi.Runtime.Json json)
53015301+ | Error _ -> Some (Openapi.Runtime.Raw body))
53025302+ in
53035303+ raise (Openapi.Runtime.Api_error {
53045304+ operation = op_name;
53055305+ method_ = "GET";
53065306+ url;
53075307+ status;
53085308+ body;
53095309+ parsed_body;
53105310+ })
53115311+53125312+ (** Delete a document
53135313+53145314+ Delete an individual document from a collection by using its ID.
53155315+ @param collection_name The name of the collection to search for the document under
53165316+ @param document_id The Document ID
53175317+ *)
53185318+ let delete_document ~collection_name ~document_id client () =
53195319+ let op_name = "delete_document" in
53205320+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in
53215321+ let query = "" in
53225322+ let url = client.base_url ^ url_path ^ query in
53235323+ let response =
53245324+ try Requests.delete client.session url
53255325+ with Eio.Io _ as ex ->
53265326+ let bt = Printexc.get_raw_backtrace () in
53275327+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
53285328+ in
53295329+ if Requests.Response.ok response then
53305330+ Requests.Response.json response
53315331+ else
53325332+ let body = Requests.Response.text response in
53335333+ let status = Requests.Response.status_code response in
53345334+ let parsed_body = match status with
53355335+ | 404 ->
53365336+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
53375337+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
53385338+ | Error _ -> None)
53395339+ | _ ->
53405340+ (match Jsont_bytesrw.decode_string Jsont.json body with
53415341+ | Ok json -> Some (Openapi.Runtime.Json json)
53425342+ | Error _ -> Some (Openapi.Runtime.Raw body))
53435343+ in
53445344+ raise (Openapi.Runtime.Api_error {
53455345+ operation = op_name;
53465346+ method_ = "DELETE";
53475347+ url;
53485348+ status;
53495349+ body;
53505350+ parsed_body;
53515351+ })
53525352+53535353+ (** Update a document
53545354+53555355+ Update an individual document from a collection by using its ID. The update can be partial.
53565356+ @param collection_name The name of the collection to search for the document under
53575357+ @param document_id The Document ID
53585358+ @param dirty_values Dealing with Dirty Data
53595359+ *)
53605360+ let update_document ~collection_name ~document_id ?dirty_values client () =
53615361+ let op_name = "update_document" in
53625362+ let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in
53635363+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"dirty_values" ~value:dirty_values]) in
53645364+ let url = client.base_url ^ url_path ^ query in
53655365+ let response =
53665366+ try Requests.patch client.session url
53675367+ with Eio.Io _ as ex ->
53685368+ let bt = Printexc.get_raw_backtrace () in
53695369+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url
53705370+ in
53715371+ if Requests.Response.ok response then
53725372+ Requests.Response.json response
53735373+ else
53745374+ let body = Requests.Response.text response in
53755375+ let status = Requests.Response.status_code response in
53765376+ let parsed_body = match status with
53775377+ | 404 ->
53785378+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
53795379+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
53805380+ | Error _ -> None)
53815381+ | _ ->
53825382+ (match Jsont_bytesrw.decode_string Jsont.json body with
53835383+ | Ok json -> Some (Openapi.Runtime.Json json)
53845384+ | Error _ -> Some (Openapi.Runtime.Raw body))
53855385+ in
53865386+ raise (Openapi.Runtime.Api_error {
53875387+ operation = op_name;
53885388+ method_ = "PATCH";
53895389+ url;
53905390+ status;
53915391+ body;
53925392+ parsed_body;
53935393+ })
53945394+53955395+ (** Print debugging information
53965396+53975397+ Print debugging information *)
53985398+ let debug client () =
53995399+ let op_name = "debug" in
54005400+ let url_path = "/debug" in
54015401+ let query = "" in
54025402+ let url = client.base_url ^ url_path ^ query in
54035403+ let response =
54045404+ try Requests.get client.session url
54055405+ with Eio.Io _ as ex ->
54065406+ let bt = Printexc.get_raw_backtrace () in
54075407+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
54085408+ in
54095409+ if Requests.Response.ok response then
54105410+ Requests.Response.json response
54115411+ else
54125412+ let body = Requests.Response.text response in
54135413+ let parsed_body =
54145414+ match Jsont_bytesrw.decode_string Jsont.json body with
54155415+ | Ok json -> Some (Openapi.Runtime.Json json)
54165416+ | Error _ -> Some (Openapi.Runtime.Raw body)
54175417+ in
54185418+ raise (Openapi.Runtime.Api_error {
54195419+ operation = op_name;
54205420+ method_ = "GET";
54215421+ url;
54225422+ status = Requests.Response.status_code response;
54235423+ body;
54245424+ parsed_body;
54255425+ })
54265426+54275427+ (** Get current RAM, CPU, Disk & Network usage metrics.
54285428+54295429+ Retrieve the metrics. *)
54305430+ let retrieve_metrics client () =
54315431+ let op_name = "retrieve_metrics" in
54325432+ let url_path = "/metrics.json" in
54335433+ let query = "" in
54345434+ let url = client.base_url ^ url_path ^ query in
54355435+ let response =
54365436+ try Requests.get client.session url
54375437+ with Eio.Io _ as ex ->
54385438+ let bt = Printexc.get_raw_backtrace () in
54395439+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
54405440+ in
54415441+ if Requests.Response.ok response then
54425442+ Requests.Response.json response
54435443+ else
54445444+ let body = Requests.Response.text response in
54455445+ let parsed_body =
54465446+ match Jsont_bytesrw.decode_string Jsont.json body with
54475447+ | Ok json -> Some (Openapi.Runtime.Json json)
54485448+ | Error _ -> Some (Openapi.Runtime.Raw body)
54495449+ in
54505450+ raise (Openapi.Runtime.Api_error {
54515451+ operation = op_name;
54525452+ method_ = "GET";
54535453+ url;
54545454+ status = Requests.Response.status_code response;
54555455+ body;
54565456+ parsed_body;
54575457+ })
54585458+54595459+ (** List all stemming dictionaries
54605460+54615461+ Retrieve a list of all available stemming dictionaries. *)
54625462+ let list_stemming_dictionaries client () =
54635463+ let op_name = "list_stemming_dictionaries" in
54645464+ let url_path = "/stemming/dictionaries" in
54655465+ let query = "" in
54665466+ let url = client.base_url ^ url_path ^ query in
54675467+ let response =
54685468+ try Requests.get client.session url
54695469+ with Eio.Io _ as ex ->
54705470+ let bt = Printexc.get_raw_backtrace () in
54715471+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
54725472+ in
54735473+ if Requests.Response.ok response then
54745474+ Requests.Response.json response
54755475+ else
54765476+ let body = Requests.Response.text response in
54775477+ let parsed_body =
54785478+ match Jsont_bytesrw.decode_string Jsont.json body with
54795479+ | Ok json -> Some (Openapi.Runtime.Json json)
54805480+ | Error _ -> Some (Openapi.Runtime.Raw body)
54815481+ in
54825482+ raise (Openapi.Runtime.Api_error {
54835483+ operation = op_name;
54845484+ method_ = "GET";
54855485+ url;
54865486+ status = Requests.Response.status_code response;
54875487+ body;
54885488+ parsed_body;
54895489+ })
54905490+54915491+ (** Import a stemming dictionary
54925492+54935493+ Upload a JSONL file containing word mappings to create or update a stemming dictionary.
54945494+ @param id The ID to assign to the dictionary
54955495+ *)
54965496+ let import_stemming_dictionary ~id client () =
54975497+ let op_name = "import_stemming_dictionary" in
54985498+ let url_path = "/stemming/dictionaries/import" in
54995499+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"id" ~value:id]) in
55005500+ let url = client.base_url ^ url_path ^ query in
55015501+ let response =
55025502+ try Requests.post client.session url
55035503+ with Eio.Io _ as ex ->
55045504+ let bt = Printexc.get_raw_backtrace () in
55055505+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
55065506+ in
55075507+ if Requests.Response.ok response then
55085508+ Requests.Response.json response
55095509+ else
55105510+ let body = Requests.Response.text response in
55115511+ let status = Requests.Response.status_code response in
55125512+ let parsed_body = match status with
55135513+ | 400 ->
55145514+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
55155515+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
55165516+ | Error _ -> None)
55175517+ | _ ->
55185518+ (match Jsont_bytesrw.decode_string Jsont.json body with
55195519+ | Ok json -> Some (Openapi.Runtime.Json json)
55205520+ | Error _ -> Some (Openapi.Runtime.Raw body))
55215521+ in
55225522+ raise (Openapi.Runtime.Api_error {
55235523+ operation = op_name;
55245524+ method_ = "POST";
55255525+ url;
55265526+ status;
55275527+ body;
55285528+ parsed_body;
55295529+ })
55305530+55315531+ (** Delete a stopwords set.
55325532+55335533+ Permanently deletes a stopwords set, given it's name.
55345534+ @param set_id The ID of the stopwords set to delete.
55355535+ *)
55365536+ let delete_stopwords_set ~set_id client () =
55375537+ let op_name = "delete_stopwords_set" in
55385538+ let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in
55395539+ let query = "" in
55405540+ let url = client.base_url ^ url_path ^ query in
55415541+ let response =
55425542+ try Requests.delete client.session url
55435543+ with Eio.Io _ as ex ->
55445544+ let bt = Printexc.get_raw_backtrace () in
55455545+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
55465546+ in
55475547+ if Requests.Response.ok response then
55485548+ Requests.Response.json response
55495549+ else
55505550+ let body = Requests.Response.text response in
55515551+ let status = Requests.Response.status_code response in
55525552+ let parsed_body = match status with
55535553+ | 404 ->
55545554+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
55555555+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
55565556+ | Error _ -> None)
55575557+ | _ ->
55585558+ (match Jsont_bytesrw.decode_string Jsont.json body with
55595559+ | Ok json -> Some (Openapi.Runtime.Json json)
55605560+ | Error _ -> Some (Openapi.Runtime.Raw body))
55615561+ in
55625562+ raise (Openapi.Runtime.Api_error {
55635563+ operation = op_name;
55645564+ method_ = "DELETE";
55655565+ url;
55665566+ status;
55675567+ body;
55685568+ parsed_body;
55695569+ })
55705570+end
55715571+55725572+module Apistats = struct
55735573+ module Types = struct
55745574+ module Response = struct
55755575+ type t = {
55765576+ delete_latency_ms : float option;
55775577+ delete_requests_per_second : float option;
55785578+ import_latency_ms : float option;
55795579+ import_requests_per_second : float option;
55805580+ latency_ms : Jsont.json option;
55815581+ overloaded_requests_per_second : float option;
55825582+ pending_write_batches : float option;
55835583+ requests_per_second : Jsont.json option;
55845584+ search_latency_ms : float option;
55855585+ search_requests_per_second : float option;
55865586+ total_requests_per_second : float option;
55875587+ write_latency_ms : float option;
55885588+ write_requests_per_second : float option;
55895589+ }
55905590+ end
55915591+ end
55925592+55935593+ module Response = struct
55945594+ include Types.Response
55955595+55965596+ let v ?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 () = { 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 }
55975597+55985598+ let delete_latency_ms t = t.delete_latency_ms
55995599+ let delete_requests_per_second t = t.delete_requests_per_second
56005600+ let import_latency_ms t = t.import_latency_ms
56015601+ let import_requests_per_second t = t.import_requests_per_second
56025602+ let latency_ms t = t.latency_ms
56035603+ let overloaded_requests_per_second t = t.overloaded_requests_per_second
56045604+ let pending_write_batches t = t.pending_write_batches
56055605+ let requests_per_second t = t.requests_per_second
56065606+ let search_latency_ms t = t.search_latency_ms
56075607+ let search_requests_per_second t = t.search_requests_per_second
56085608+ let total_requests_per_second t = t.total_requests_per_second
56095609+ let write_latency_ms t = t.write_latency_ms
56105610+ let write_requests_per_second t = t.write_requests_per_second
56115611+56125612+ let jsont : t Jsont.t =
56135613+ Jsont.Object.map ~kind:"APIStatsResponse"
56145614+ (fun 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 -> { 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 })
56155615+ |> Jsont.Object.opt_mem "delete_latency_ms" Jsont.number ~enc:(fun r -> r.delete_latency_ms)
56165616+ |> Jsont.Object.opt_mem "delete_requests_per_second" Jsont.number ~enc:(fun r -> r.delete_requests_per_second)
56175617+ |> Jsont.Object.opt_mem "import_latency_ms" Jsont.number ~enc:(fun r -> r.import_latency_ms)
56185618+ |> Jsont.Object.opt_mem "import_requests_per_second" Jsont.number ~enc:(fun r -> r.import_requests_per_second)
56195619+ |> Jsont.Object.opt_mem "latency_ms" Jsont.json ~enc:(fun r -> r.latency_ms)
56205620+ |> Jsont.Object.opt_mem "overloaded_requests_per_second" Jsont.number ~enc:(fun r -> r.overloaded_requests_per_second)
56215621+ |> Jsont.Object.opt_mem "pending_write_batches" Jsont.number ~enc:(fun r -> r.pending_write_batches)
56225622+ |> Jsont.Object.opt_mem "requests_per_second" Jsont.json ~enc:(fun r -> r.requests_per_second)
56235623+ |> Jsont.Object.opt_mem "search_latency_ms" Jsont.number ~enc:(fun r -> r.search_latency_ms)
56245624+ |> Jsont.Object.opt_mem "search_requests_per_second" Jsont.number ~enc:(fun r -> r.search_requests_per_second)
56255625+ |> Jsont.Object.opt_mem "total_requests_per_second" Jsont.number ~enc:(fun r -> r.total_requests_per_second)
56265626+ |> Jsont.Object.opt_mem "write_latency_ms" Jsont.number ~enc:(fun r -> r.write_latency_ms)
56275627+ |> Jsont.Object.opt_mem "write_requests_per_second" Jsont.number ~enc:(fun r -> r.write_requests_per_second)
56285628+ |> Jsont.Object.skip_unknown
56295629+ |> Jsont.Object.finish
56305630+ end
56315631+56325632+ (** Get stats about API endpoints.
56335633+56345634+ Retrieve the stats about API endpoints. *)
56355635+ let retrieve_apistats client () =
56365636+ let op_name = "retrieve_apistats" in
56375637+ let url_path = "/stats.json" in
56385638+ let query = "" in
56395639+ let url = client.base_url ^ url_path ^ query in
56405640+ let response =
56415641+ try Requests.get client.session url
56425642+ with Eio.Io _ as ex ->
56435643+ let bt = Printexc.get_raw_backtrace () in
56445644+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
56455645+ in
56465646+ if Requests.Response.ok response then
56475647+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
56485648+ else
56495649+ let body = Requests.Response.text response in
56505650+ let parsed_body =
56515651+ match Jsont_bytesrw.decode_string Jsont.json body with
56525652+ | Ok json -> Some (Openapi.Runtime.Json json)
56535653+ | Error _ -> Some (Openapi.Runtime.Raw body)
56545654+ in
56555655+ raise (Openapi.Runtime.Api_error {
56565656+ operation = op_name;
56575657+ method_ = "GET";
56585658+ url;
56595659+ status = Requests.Response.status_code response;
56605660+ body;
56615661+ parsed_body;
56625662+ })
56635663+end
56645664+56655665+module ApiKeySchema = struct
56665666+ module Types = struct
56675667+ module T = struct
56685668+ type t = {
56695669+ actions : string list;
56705670+ collections : string list;
56715671+ description : string;
56725672+ expires_at : int64 option;
56735673+ value : string option;
56745674+ }
56755675+ end
56765676+ end
56775677+56785678+ module T = struct
56795679+ include Types.T
56805680+56815681+ let v ~actions ~collections ~description ?expires_at ?value () = { actions; collections; description; expires_at; value }
56825682+56835683+ let actions t = t.actions
56845684+ let collections t = t.collections
56855685+ let description t = t.description
56865686+ let expires_at t = t.expires_at
56875687+ let value t = t.value
56885688+56895689+ let jsont : t Jsont.t =
56905690+ Jsont.Object.map ~kind:"ApiKeySchema"
56915691+ (fun actions collections description expires_at value -> { actions; collections; description; expires_at; value })
56925692+ |> Jsont.Object.mem "actions" (Jsont.list Jsont.string) ~enc:(fun r -> r.actions)
56935693+ |> Jsont.Object.mem "collections" (Jsont.list Jsont.string) ~enc:(fun r -> r.collections)
56945694+ |> Jsont.Object.mem "description" Jsont.string ~enc:(fun r -> r.description)
56955695+ |> Jsont.Object.opt_mem "expires_at" Jsont.int64 ~enc:(fun r -> r.expires_at)
56965696+ |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value)
56975697+ |> Jsont.Object.skip_unknown
56985698+ |> Jsont.Object.finish
56995699+ end
57005700+end
57015701+57025702+module ApiKey = struct
57035703+ module Types = struct
57045704+ module T = struct
57055705+ type t = {
57065706+ actions : string list;
57075707+ collections : string list;
57085708+ description : string;
57095709+ expires_at : int64 option;
57105710+ value : string option;
57115711+ id : int64 option;
57125712+ value_prefix : string option;
57135713+ }
57145714+ end
57155715+ end
57165716+57175717+ module T = struct
57185718+ include Types.T
57195719+57205720+ let v ~actions ~collections ~description ?expires_at ?value ?id ?value_prefix () = { actions; collections; description; expires_at; value; id; value_prefix }
57215721+57225722+ let actions t = t.actions
57235723+ let collections t = t.collections
57245724+ let description t = t.description
57255725+ let expires_at t = t.expires_at
57265726+ let value t = t.value
57275727+ let id t = t.id
57285728+ let value_prefix t = t.value_prefix
57295729+57305730+ let jsont : t Jsont.t =
57315731+ Jsont.Object.map ~kind:"ApiKey"
57325732+ (fun actions collections description expires_at value id value_prefix -> { actions; collections; description; expires_at; value; id; value_prefix })
57335733+ |> Jsont.Object.mem "actions" (Jsont.list Jsont.string) ~enc:(fun r -> r.actions)
57345734+ |> Jsont.Object.mem "collections" (Jsont.list Jsont.string) ~enc:(fun r -> r.collections)
57355735+ |> Jsont.Object.mem "description" Jsont.string ~enc:(fun r -> r.description)
57365736+ |> Jsont.Object.opt_mem "expires_at" Jsont.int64 ~enc:(fun r -> r.expires_at)
57375737+ |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value)
57385738+ |> Jsont.Object.opt_mem "id" Jsont.int64 ~enc:(fun r -> r.id)
57395739+ |> Jsont.Object.opt_mem "value_prefix" Jsont.string ~enc:(fun r -> r.value_prefix)
57405740+ |> Jsont.Object.skip_unknown
57415741+ |> Jsont.Object.finish
57425742+ end
57435743+57445744+ (** Create an API Key
57455745+57465746+ 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. *)
57475747+ let create_key ~body client () =
57485748+ let op_name = "create_key" in
57495749+ let url_path = "/keys" in
57505750+ let query = "" in
57515751+ let url = client.base_url ^ url_path ^ query in
57525752+ let response =
57535753+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ApiKeySchema.T.jsont body)) url
57545754+ with Eio.Io _ as ex ->
57555755+ let bt = Printexc.get_raw_backtrace () in
57565756+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
57575757+ in
57585758+ if Requests.Response.ok response then
57595759+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
57605760+ else
57615761+ let body = Requests.Response.text response in
57625762+ let status = Requests.Response.status_code response in
57635763+ let parsed_body = match status with
57645764+ | 400 ->
57655765+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
57665766+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
57675767+ | Error _ -> None)
57685768+ | 409 ->
57695769+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
57705770+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
57715771+ | Error _ -> None)
57725772+ | _ ->
57735773+ (match Jsont_bytesrw.decode_string Jsont.json body with
57745774+ | Ok json -> Some (Openapi.Runtime.Json json)
57755775+ | Error _ -> Some (Openapi.Runtime.Raw body))
57765776+ in
57775777+ raise (Openapi.Runtime.Api_error {
57785778+ operation = op_name;
57795779+ method_ = "POST";
57805780+ url;
57815781+ status;
57825782+ body;
57835783+ parsed_body;
57845784+ })
57855785+57865786+ (** Retrieve (metadata about) a key
57875787+57885788+ 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.
57895789+ @param key_id The ID of the key to retrieve
57905790+ *)
57915791+ let get_key ~key_id client () =
57925792+ let op_name = "get_key" in
57935793+ let url_path = Openapi.Runtime.Path.render ~params:[("keyId", key_id)] "/keys/{keyId}" in
57945794+ let query = "" in
57955795+ let url = client.base_url ^ url_path ^ query in
57965796+ let response =
57975797+ try Requests.get client.session url
57985798+ with Eio.Io _ as ex ->
57995799+ let bt = Printexc.get_raw_backtrace () in
58005800+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
58015801+ in
58025802+ if Requests.Response.ok response then
58035803+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
58045804+ else
58055805+ let body = Requests.Response.text response in
58065806+ let status = Requests.Response.status_code response in
58075807+ let parsed_body = match status with
58085808+ | 404 ->
58095809+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
58105810+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
58115811+ | Error _ -> None)
58125812+ | _ ->
58135813+ (match Jsont_bytesrw.decode_string Jsont.json body with
58145814+ | Ok json -> Some (Openapi.Runtime.Json json)
58155815+ | Error _ -> Some (Openapi.Runtime.Raw body))
58165816+ in
58175817+ raise (Openapi.Runtime.Api_error {
58185818+ operation = op_name;
58195819+ method_ = "GET";
58205820+ url;
58215821+ status;
58225822+ body;
58235823+ parsed_body;
58245824+ })
58255825+end
58265826+58275827+module ApiKeys = struct
58285828+ module Types = struct
58295829+ module Response = struct
58305830+ type t = {
58315831+ keys : ApiKey.T.t list;
58325832+ }
58335833+ end
58345834+ end
58355835+58365836+ module Response = struct
58375837+ include Types.Response
58385838+58395839+ let v ~keys () = { keys }
58405840+58415841+ let keys t = t.keys
58425842+58435843+ let jsont : t Jsont.t =
58445844+ Jsont.Object.map ~kind:"ApiKeysResponse"
58455845+ (fun keys -> { keys })
58465846+ |> Jsont.Object.mem "keys" (Jsont.list ApiKey.T.jsont) ~enc:(fun r -> r.keys)
58475847+ |> Jsont.Object.skip_unknown
58485848+ |> Jsont.Object.finish
58495849+ end
58505850+58515851+ (** Retrieve (metadata about) all keys. *)
58525852+ let get_keys client () =
58535853+ let op_name = "get_keys" in
58545854+ let url_path = "/keys" in
58555855+ let query = "" in
58565856+ let url = client.base_url ^ url_path ^ query in
58575857+ let response =
58585858+ try Requests.get client.session url
58595859+ with Eio.Io _ as ex ->
58605860+ let bt = Printexc.get_raw_backtrace () in
58615861+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
58625862+ in
58635863+ if Requests.Response.ok response then
58645864+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
58655865+ else
58665866+ let body = Requests.Response.text response in
58675867+ let parsed_body =
58685868+ match Jsont_bytesrw.decode_string Jsont.json body with
58695869+ | Ok json -> Some (Openapi.Runtime.Json json)
58705870+ | Error _ -> Some (Openapi.Runtime.Raw body)
58715871+ in
58725872+ raise (Openapi.Runtime.Api_error {
58735873+ operation = op_name;
58745874+ method_ = "GET";
58755875+ url;
58765876+ status = Requests.Response.status_code response;
58775877+ body;
58785878+ parsed_body;
58795879+ })
58805880+end
58815881+58825882+module ApiKeyDelete = struct
58835883+ module Types = struct
58845884+ module Response = struct
58855885+ type t = {
58865886+ id : int64; (** The id of the API key that was deleted *)
58875887+ }
58885888+ end
58895889+ end
58905890+58915891+ module Response = struct
58925892+ include Types.Response
58935893+58945894+ let v ~id () = { id }
58955895+58965896+ let id t = t.id
58975897+58985898+ let jsont : t Jsont.t =
58995899+ Jsont.Object.map ~kind:"ApiKeyDeleteResponse"
59005900+ (fun id -> { id })
59015901+ |> Jsont.Object.mem "id" Jsont.int64 ~enc:(fun r -> r.id)
59025902+ |> Jsont.Object.skip_unknown
59035903+ |> Jsont.Object.finish
59045904+ end
59055905+59065906+ (** Delete an API key given its ID.
59075907+ @param key_id The ID of the key to delete
59085908+ *)
59095909+ let delete_key ~key_id client () =
59105910+ let op_name = "delete_key" in
59115911+ let url_path = Openapi.Runtime.Path.render ~params:[("keyId", key_id)] "/keys/{keyId}" in
59125912+ let query = "" in
59135913+ let url = client.base_url ^ url_path ^ query in
59145914+ let response =
59155915+ try Requests.delete client.session url
59165916+ with Eio.Io _ as ex ->
59175917+ let bt = Printexc.get_raw_backtrace () in
59185918+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
59195919+ in
59205920+ if Requests.Response.ok response then
59215921+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
59225922+ else
59235923+ let body = Requests.Response.text response in
59245924+ let status = Requests.Response.status_code response in
59255925+ let parsed_body = match status with
59265926+ | 400 ->
59275927+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
59285928+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
59295929+ | Error _ -> None)
59305930+ | 404 ->
59315931+ (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with
59325932+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v))
59335933+ | Error _ -> None)
59345934+ | _ ->
59355935+ (match Jsont_bytesrw.decode_string Jsont.json body with
59365936+ | Ok json -> Some (Openapi.Runtime.Json json)
59375937+ | Error _ -> Some (Openapi.Runtime.Raw body))
59385938+ in
59395939+ raise (Openapi.Runtime.Api_error {
59405940+ operation = op_name;
59415941+ method_ = "DELETE";
59425942+ url;
59435943+ status;
59445944+ body;
59455945+ parsed_body;
59465946+ })
59475947+end
59485948+59495949+module Api = struct
59505950+ module Types = struct
59515951+ module Response = struct
59525952+ type t = {
59535953+ message : string;
59545954+ }
59555955+ end
59565956+ end
59575957+59585958+ module Response = struct
59595959+ include Types.Response
59605960+59615961+ let v ~message () = { message }
59625962+59635963+ let message t = t.message
59645964+59655965+ let jsont : t Jsont.t =
59665966+ Jsont.Object.map ~kind:"ApiResponse"
59675967+ (fun message -> { message })
59685968+ |> Jsont.Object.mem "message" Jsont.string ~enc:(fun r -> r.message)
59695969+ |> Jsont.Object.skip_unknown
59705970+ |> Jsont.Object.finish
59715971+ end
59725972+end
59735973+59745974+module AnalyticsRule = struct
59755975+ module Types = struct
59765976+ module Update = struct
59775977+ (** Fields allowed to update on an analytics rule *)
59785978+ type t = {
59795979+ name : string option;
59805980+ params : Jsont.json option;
59815981+ rule_tag : string option;
59825982+ }
59835983+ end
59845984+59855985+ module Type = struct
59865986+ type t = [
59875987+ | `Popular_queries
59885988+ | `Nohits_queries
59895989+ | `Counter
59905990+ | `Log
59915991+ ]
59925992+ end
59935993+59945994+ module Create = struct
59955995+ type t = {
59965996+ collection : string;
59975997+ event_type : string;
59985998+ name : string;
59995999+ params : Jsont.json option;
60006000+ rule_tag : string option;
60016001+ type_ : Type.t;
60026002+ }
60036003+ end
60046004+60056005+ module T = struct
60066006+ type t = {
60076007+ collection : string;
60086008+ event_type : string;
60096009+ name : string;
60106010+ params : Jsont.json option;
60116011+ rule_tag : string option;
60126012+ type_ : Type.t;
60136013+ }
60146014+ end
60156015+ end
60166016+60176017+ module Update = struct
60186018+ include Types.Update
60196019+60206020+ let v ?name ?params ?rule_tag () = { name; params; rule_tag }
60216021+60226022+ let name t = t.name
60236023+ let params t = t.params
60246024+ let rule_tag t = t.rule_tag
60256025+60266026+ let jsont : t Jsont.t =
60276027+ Jsont.Object.map ~kind:"AnalyticsRuleUpdate"
60286028+ (fun name params rule_tag -> { name; params; rule_tag })
60296029+ |> Jsont.Object.opt_mem "name" Jsont.string ~enc:(fun r -> r.name)
60306030+ |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params)
60316031+ |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag)
60326032+ |> Jsont.Object.skip_unknown
60336033+ |> Jsont.Object.finish
60346034+ end
60356035+60366036+ module Type = struct
60376037+ include Types.Type
60386038+60396039+ let jsont : t Jsont.t =
60406040+ Jsont.map Jsont.string ~kind:"AnalyticsRuleType"
60416041+ ~dec:(function
60426042+ | "popular_queries" -> `Popular_queries
60436043+ | "nohits_queries" -> `Nohits_queries
60446044+ | "counter" -> `Counter
60456045+ | "log" -> `Log
60466046+ | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s)
60476047+ ~enc:(function
60486048+ | `Popular_queries -> "popular_queries"
60496049+ | `Nohits_queries -> "nohits_queries"
60506050+ | `Counter -> "counter"
60516051+ | `Log -> "log")
60526052+ end
60536053+60546054+ module Create = struct
60556055+ include Types.Create
60566056+60576057+ let v ~collection ~event_type ~name ~type_ ?params ?rule_tag () = { collection; event_type; name; params; rule_tag; type_ }
60586058+60596059+ let collection t = t.collection
60606060+ let event_type t = t.event_type
60616061+ let name t = t.name
60626062+ let params t = t.params
60636063+ let rule_tag t = t.rule_tag
60646064+ let type_ t = t.type_
60656065+60666066+ let jsont : t Jsont.t =
60676067+ Jsont.Object.map ~kind:"AnalyticsRuleCreate"
60686068+ (fun collection event_type name params rule_tag type_ -> { collection; event_type; name; params; rule_tag; type_ })
60696069+ |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection)
60706070+ |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type)
60716071+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
60726072+ |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params)
60736073+ |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag)
60746074+ |> Jsont.Object.mem "type" Type.jsont ~enc:(fun r -> r.type_)
60756075+ |> Jsont.Object.skip_unknown
60766076+ |> Jsont.Object.finish
60776077+ end
60786078+60796079+ module T = struct
60806080+ include Types.T
60816081+60826082+ let v ~collection ~event_type ~name ~type_ ?params ?rule_tag () = { collection; event_type; name; params; rule_tag; type_ }
60836083+60846084+ let collection t = t.collection
60856085+ let event_type t = t.event_type
60866086+ let name t = t.name
60876087+ let params t = t.params
60886088+ let rule_tag t = t.rule_tag
60896089+ let type_ t = t.type_
60906090+60916091+ let jsont : t Jsont.t =
60926092+ Jsont.Object.map ~kind:"AnalyticsRule"
60936093+ (fun collection event_type name params rule_tag type_ -> { collection; event_type; name; params; rule_tag; type_ })
60946094+ |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection)
60956095+ |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type)
60966096+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
60976097+ |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params)
60986098+ |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag)
60996099+ |> Jsont.Object.mem "type" Type.jsont ~enc:(fun r -> r.type_)
61006100+ |> Jsont.Object.skip_unknown
61016101+ |> Jsont.Object.finish
61026102+ end
61036103+61046104+ (** Retrieve analytics rules
61056105+61066106+ Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results.
61076107+ @param rule_tag Filter rules by rule_tag
61086108+ *)
61096109+ let retrieve_analytics_rules ?rule_tag client () =
61106110+ let op_name = "retrieve_analytics_rules" in
61116111+ let url_path = "/analytics/rules" in
61126112+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"rule_tag" ~value:rule_tag]) in
61136113+ let url = client.base_url ^ url_path ^ query in
61146114+ let response =
61156115+ try Requests.get client.session url
61166116+ with Eio.Io _ as ex ->
61176117+ let bt = Printexc.get_raw_backtrace () in
61186118+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
61196119+ in
61206120+ if Requests.Response.ok response then
61216121+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
61226122+ else
61236123+ let body = Requests.Response.text response in
61246124+ let parsed_body =
61256125+ match Jsont_bytesrw.decode_string Jsont.json body with
61266126+ | Ok json -> Some (Openapi.Runtime.Json json)
61276127+ | Error _ -> Some (Openapi.Runtime.Raw body)
61286128+ in
61296129+ raise (Openapi.Runtime.Api_error {
61306130+ operation = op_name;
61316131+ method_ = "GET";
61326132+ url;
61336133+ status = Requests.Response.status_code response;
61346134+ body;
61356135+ parsed_body;
61366136+ })
61376137+61386138+ (** Retrieves an analytics rule
61396139+61406140+ Retrieve the details of an analytics rule, given it's name
61416141+ @param rule_name The name of the analytics rule to retrieve
61426142+ *)
61436143+ let retrieve_analytics_rule ~rule_name client () =
61446144+ let op_name = "retrieve_analytics_rule" in
61456145+ let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in
61466146+ let query = "" in
61476147+ let url = client.base_url ^ url_path ^ query in
61486148+ let response =
61496149+ try Requests.get client.session url
61506150+ with Eio.Io _ as ex ->
61516151+ let bt = Printexc.get_raw_backtrace () in
61526152+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
61536153+ in
61546154+ if Requests.Response.ok response then
61556155+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
61566156+ else
61576157+ let body = Requests.Response.text response in
61586158+ let status = Requests.Response.status_code response in
61596159+ let parsed_body = match status with
61606160+ | 404 ->
61616161+ (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with
61626162+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v))
61636163+ | Error _ -> None)
61646164+ | _ ->
61656165+ (match Jsont_bytesrw.decode_string Jsont.json body with
61666166+ | Ok json -> Some (Openapi.Runtime.Json json)
61676167+ | Error _ -> Some (Openapi.Runtime.Raw body))
61686168+ in
61696169+ raise (Openapi.Runtime.Api_error {
61706170+ operation = op_name;
61716171+ method_ = "GET";
61726172+ url;
61736173+ status;
61746174+ body;
61756175+ parsed_body;
61766176+ })
61776177+61786178+ (** Upserts an analytics rule
61796179+61806180+ Upserts an analytics rule with the given name.
61816181+ @param rule_name The name of the analytics rule to upsert
61826182+ *)
61836183+ let upsert_analytics_rule ~rule_name ~body client () =
61846184+ let op_name = "upsert_analytics_rule" in
61856185+ let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in
61866186+ let query = "" in
61876187+ let url = client.base_url ^ url_path ^ query in
61886188+ let response =
61896189+ try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json Update.jsont body)) url
61906190+ with Eio.Io _ as ex ->
61916191+ let bt = Printexc.get_raw_backtrace () in
61926192+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url
61936193+ in
61946194+ if Requests.Response.ok response then
61956195+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
61966196+ else
61976197+ let body = Requests.Response.text response in
61986198+ let status = Requests.Response.status_code response in
61996199+ let parsed_body = match status with
62006200+ | 400 ->
62016201+ (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with
62026202+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v))
62036203+ | Error _ -> None)
62046204+ | _ ->
62056205+ (match Jsont_bytesrw.decode_string Jsont.json body with
62066206+ | Ok json -> Some (Openapi.Runtime.Json json)
62076207+ | Error _ -> Some (Openapi.Runtime.Raw body))
62086208+ in
62096209+ raise (Openapi.Runtime.Api_error {
62106210+ operation = op_name;
62116211+ method_ = "PUT";
62126212+ url;
62136213+ status;
62146214+ body;
62156215+ parsed_body;
62166216+ })
62176217+62186218+ (** Delete an analytics rule
62196219+62206220+ Permanently deletes an analytics rule, given it's name
62216221+ @param rule_name The name of the analytics rule to delete
62226222+ *)
62236223+ let delete_analytics_rule ~rule_name client () =
62246224+ let op_name = "delete_analytics_rule" in
62256225+ let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in
62266226+ let query = "" in
62276227+ let url = client.base_url ^ url_path ^ query in
62286228+ let response =
62296229+ try Requests.delete client.session url
62306230+ with Eio.Io _ as ex ->
62316231+ let bt = Printexc.get_raw_backtrace () in
62326232+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url
62336233+ in
62346234+ if Requests.Response.ok response then
62356235+ Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response)
62366236+ else
62376237+ let body = Requests.Response.text response in
62386238+ let status = Requests.Response.status_code response in
62396239+ let parsed_body = match status with
62406240+ | 404 ->
62416241+ (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with
62426242+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v))
62436243+ | Error _ -> None)
62446244+ | _ ->
62456245+ (match Jsont_bytesrw.decode_string Jsont.json body with
62466246+ | Ok json -> Some (Openapi.Runtime.Json json)
62476247+ | Error _ -> Some (Openapi.Runtime.Raw body))
62486248+ in
62496249+ raise (Openapi.Runtime.Api_error {
62506250+ operation = op_name;
62516251+ method_ = "DELETE";
62526252+ url;
62536253+ status;
62546254+ body;
62556255+ parsed_body;
62566256+ })
62576257+end
62586258+62596259+module AnalyticsEvents = struct
62606260+ module Types = struct
62616261+ module Response = struct
62626262+ type t = {
62636263+ events : Jsont.json list;
62646264+ }
62656265+ end
62666266+ end
62676267+62686268+ module Response = struct
62696269+ include Types.Response
62706270+62716271+ let v ~events () = { events }
62726272+62736273+ let events t = t.events
62746274+62756275+ let jsont : t Jsont.t =
62766276+ Jsont.Object.map ~kind:"AnalyticsEventsResponse"
62776277+ (fun events -> { events })
62786278+ |> Jsont.Object.mem "events" (Jsont.list Jsont.json) ~enc:(fun r -> r.events)
62796279+ |> Jsont.Object.skip_unknown
62806280+ |> Jsont.Object.finish
62816281+ end
62826282+62836283+ (** Retrieve analytics events
62846284+62856285+ Retrieve the most recent events for a user and rule.
62866286+ @param name Analytics rule name
62876287+ @param n Number of events to return (max 1000)
62886288+ *)
62896289+ let get_analytics_events ~user_id ~name ~n client () =
62906290+ let op_name = "get_analytics_events" in
62916291+ let url_path = "/analytics/events" in
62926292+ let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"user_id" ~value:user_id; Openapi.Runtime.Query.singleton ~key:"name" ~value:name; Openapi.Runtime.Query.singleton ~key:"n" ~value:n]) in
62936293+ let url = client.base_url ^ url_path ^ query in
62946294+ let response =
62956295+ try Requests.get client.session url
62966296+ with Eio.Io _ as ex ->
62976297+ let bt = Printexc.get_raw_backtrace () in
62986298+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
62996299+ in
63006300+ if Requests.Response.ok response then
63016301+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
63026302+ else
63036303+ let body = Requests.Response.text response in
63046304+ let status = Requests.Response.status_code response in
63056305+ let parsed_body = match status with
63066306+ | 400 ->
63076307+ (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with
63086308+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v))
63096309+ | Error _ -> None)
63106310+ | _ ->
63116311+ (match Jsont_bytesrw.decode_string Jsont.json body with
63126312+ | Ok json -> Some (Openapi.Runtime.Json json)
63136313+ | Error _ -> Some (Openapi.Runtime.Raw body))
63146314+ in
63156315+ raise (Openapi.Runtime.Api_error {
63166316+ operation = op_name;
63176317+ method_ = "GET";
63186318+ url;
63196319+ status;
63206320+ body;
63216321+ parsed_body;
63226322+ })
63236323+end
63246324+63256325+module AnalyticsEvent = struct
63266326+ module Types = struct
63276327+ module T = struct
63286328+ type t = {
63296329+ data : Jsont.json; (** Event payload *)
63306330+ event_type : string; (** Type of event (e.g., click, conversion, query, visit) *)
63316331+ name : string; (** Name of the analytics rule this event corresponds to *)
63326332+ }
63336333+ end
63346334+ end
63356335+63366336+ module T = struct
63376337+ include Types.T
63386338+63396339+ let v ~data ~event_type ~name () = { data; event_type; name }
63406340+63416341+ let data t = t.data
63426342+ let event_type t = t.event_type
63436343+ let name t = t.name
63446344+63456345+ let jsont : t Jsont.t =
63466346+ Jsont.Object.map ~kind:"AnalyticsEvent"
63476347+ (fun data event_type name -> { data; event_type; name })
63486348+ |> Jsont.Object.mem "data" Jsont.json ~enc:(fun r -> r.data)
63496349+ |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type)
63506350+ |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name)
63516351+ |> Jsont.Object.skip_unknown
63526352+ |> Jsont.Object.finish
63536353+ end
63546354+end
63556355+63566356+module AnalyticsEventCreate = struct
63576357+ module Types = struct
63586358+ module Response = struct
63596359+ type t = {
63606360+ ok : bool;
63616361+ }
63626362+ end
63636363+ end
63646364+63656365+ module Response = struct
63666366+ include Types.Response
63676367+63686368+ let v ~ok () = { ok }
63696369+63706370+ let ok t = t.ok
63716371+63726372+ let jsont : t Jsont.t =
63736373+ Jsont.Object.map ~kind:"AnalyticsEventCreateResponse"
63746374+ (fun ok -> { ok })
63756375+ |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok)
63766376+ |> Jsont.Object.skip_unknown
63776377+ |> Jsont.Object.finish
63786378+ end
63796379+63806380+ (** Create an analytics event
63816381+63826382+ Submit a single analytics event. The event must correspond to an existing analytics rule by name. *)
63836383+ let create_analytics_event ~body client () =
63846384+ let op_name = "create_analytics_event" in
63856385+ let url_path = "/analytics/events" in
63866386+ let query = "" in
63876387+ let url = client.base_url ^ url_path ^ query in
63886388+ let response =
63896389+ try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json AnalyticsEvent.T.jsont body)) url
63906390+ with Eio.Io _ as ex ->
63916391+ let bt = Printexc.get_raw_backtrace () in
63926392+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
63936393+ in
63946394+ if Requests.Response.ok response then
63956395+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
63966396+ else
63976397+ let body = Requests.Response.text response in
63986398+ let status = Requests.Response.status_code response in
63996399+ let parsed_body = match status with
64006400+ | 400 ->
64016401+ (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with
64026402+ | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v))
64036403+ | Error _ -> None)
64046404+ | _ ->
64056405+ (match Jsont_bytesrw.decode_string Jsont.json body with
64066406+ | Ok json -> Some (Openapi.Runtime.Json json)
64076407+ | Error _ -> Some (Openapi.Runtime.Raw body))
64086408+ in
64096409+ raise (Openapi.Runtime.Api_error {
64106410+ operation = op_name;
64116411+ method_ = "POST";
64126412+ url;
64136413+ status;
64146414+ body;
64156415+ parsed_body;
64166416+ })
64176417+64186418+ (** Flush in-memory analytics to disk
64196419+64206420+ Triggers a flush of analytics data to persistent storage. *)
64216421+ let flush_analytics client () =
64226422+ let op_name = "flush_analytics" in
64236423+ let url_path = "/analytics/flush" in
64246424+ let query = "" in
64256425+ let url = client.base_url ^ url_path ^ query in
64266426+ let response =
64276427+ try Requests.post client.session url
64286428+ with Eio.Io _ as ex ->
64296429+ let bt = Printexc.get_raw_backtrace () in
64306430+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url
64316431+ in
64326432+ if Requests.Response.ok response then
64336433+ Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response)
64346434+ else
64356435+ let body = Requests.Response.text response in
64366436+ let parsed_body =
64376437+ match Jsont_bytesrw.decode_string Jsont.json body with
64386438+ | Ok json -> Some (Openapi.Runtime.Json json)
64396439+ | Error _ -> Some (Openapi.Runtime.Raw body)
64406440+ in
64416441+ raise (Openapi.Runtime.Api_error {
64426442+ operation = op_name;
64436443+ method_ = "POST";
64446444+ url;
64456445+ status = Requests.Response.status_code response;
64466446+ body;
64476447+ parsed_body;
64486448+ })
64496449+end
64506450+64516451+module Analytics = struct
64526452+ module Types = struct
64536453+ module Status = struct
64546454+ type t = {
64556455+ doc_counter_events : int option;
64566456+ doc_log_events : int option;
64576457+ log_prefix_queries : int option;
64586458+ nohits_prefix_queries : int option;
64596459+ popular_prefix_queries : int option;
64606460+ query_counter_events : int option;
64616461+ query_log_events : int option;
64626462+ }
64636463+ end
64646464+ end
64656465+64666466+ module Status = struct
64676467+ include Types.Status
64686468+64696469+ let v ?doc_counter_events ?doc_log_events ?log_prefix_queries ?nohits_prefix_queries ?popular_prefix_queries ?query_counter_events ?query_log_events () = { doc_counter_events; doc_log_events; log_prefix_queries; nohits_prefix_queries; popular_prefix_queries; query_counter_events; query_log_events }
64706470+64716471+ let doc_counter_events t = t.doc_counter_events
64726472+ let doc_log_events t = t.doc_log_events
64736473+ let log_prefix_queries t = t.log_prefix_queries
64746474+ let nohits_prefix_queries t = t.nohits_prefix_queries
64756475+ let popular_prefix_queries t = t.popular_prefix_queries
64766476+ let query_counter_events t = t.query_counter_events
64776477+ let query_log_events t = t.query_log_events
64786478+64796479+ let jsont : t Jsont.t =
64806480+ Jsont.Object.map ~kind:"AnalyticsStatus"
64816481+ (fun doc_counter_events doc_log_events log_prefix_queries nohits_prefix_queries popular_prefix_queries query_counter_events query_log_events -> { doc_counter_events; doc_log_events; log_prefix_queries; nohits_prefix_queries; popular_prefix_queries; query_counter_events; query_log_events })
64826482+ |> Jsont.Object.opt_mem "doc_counter_events" Jsont.int ~enc:(fun r -> r.doc_counter_events)
64836483+ |> Jsont.Object.opt_mem "doc_log_events" Jsont.int ~enc:(fun r -> r.doc_log_events)
64846484+ |> Jsont.Object.opt_mem "log_prefix_queries" Jsont.int ~enc:(fun r -> r.log_prefix_queries)
64856485+ |> Jsont.Object.opt_mem "nohits_prefix_queries" Jsont.int ~enc:(fun r -> r.nohits_prefix_queries)
64866486+ |> Jsont.Object.opt_mem "popular_prefix_queries" Jsont.int ~enc:(fun r -> r.popular_prefix_queries)
64876487+ |> Jsont.Object.opt_mem "query_counter_events" Jsont.int ~enc:(fun r -> r.query_counter_events)
64886488+ |> Jsont.Object.opt_mem "query_log_events" Jsont.int ~enc:(fun r -> r.query_log_events)
64896489+ |> Jsont.Object.skip_unknown
64906490+ |> Jsont.Object.finish
64916491+ end
64926492+64936493+ (** Get analytics subsystem status
64946494+64956495+ Returns sizes of internal analytics buffers and queues. *)
64966496+ let get_analytics_status client () =
64976497+ let op_name = "get_analytics_status" in
64986498+ let url_path = "/analytics/status" in
64996499+ let query = "" in
65006500+ let url = client.base_url ^ url_path ^ query in
65016501+ let response =
65026502+ try Requests.get client.session url
65036503+ with Eio.Io _ as ex ->
65046504+ let bt = Printexc.get_raw_backtrace () in
65056505+ Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url
65066506+ in
65076507+ if Requests.Response.ok response then
65086508+ Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response)
65096509+ else
65106510+ let body = Requests.Response.text response in
65116511+ let parsed_body =
65126512+ match Jsont_bytesrw.decode_string Jsont.json body with
65136513+ | Ok json -> Some (Openapi.Runtime.Json json)
65146514+ | Error _ -> Some (Openapi.Runtime.Raw body)
65156515+ in
65166516+ raise (Openapi.Runtime.Api_error {
65176517+ operation = op_name;
65186518+ method_ = "GET";
65196519+ url;
65206520+ status = Requests.Response.status_code response;
65216521+ body;
65226522+ parsed_body;
65236523+ })
65246524+end
+3691
typesense.mli
···11+(** {1 Typesense}
22+33+ An open source search engine for building delightful search experiences.
44+55+ @version 30.0 *)
66+77+type t
88+99+val create :
1010+ ?session:Requests.t ->
1111+ sw:Eio.Switch.t ->
1212+ < net : _ Eio.Net.t ; fs : Eio.Fs.dir_ty Eio.Path.t ; clock : _ Eio.Time.clock ; .. > ->
1313+ base_url:string ->
1414+ t
1515+1616+val base_url : t -> string
1717+val session : t -> Requests.t
1818+1919+module VoiceQueryModelCollection : sig
2020+ module Config : sig
2121+ (** Configuration for the voice query model
2222+ *)
2323+ type t
2424+2525+ (** Construct a value *)
2626+ val v : ?model_name:string -> unit -> t
2727+2828+ val model_name : t -> string option
2929+3030+ val jsont : t Jsont.t
3131+ end
3232+end
3333+3434+module SynonymSetDeleteSchema : sig
3535+ module T : sig
3636+ type t
3737+3838+ (** Construct a value
3939+ @param name Name of the deleted synonym set
4040+ *)
4141+ val v : name:string -> unit -> t
4242+4343+ (** Name of the deleted synonym set *)
4444+ val name : t -> string
4545+4646+ val jsont : t Jsont.t
4747+ end
4848+4949+ (** Delete a synonym set
5050+5151+ Delete a specific synonym set by its name
5252+ @param synonym_set_name The name of the synonym set to delete
5353+ *)
5454+ val delete_synonym_set : synonym_set_name:string -> t -> unit -> T.t
5555+end
5656+5757+module SynonymItemUpsertSchema : sig
5858+ module T : sig
5959+ type t
6060+6161+ (** Construct a value
6262+ @param synonyms Array of words that should be considered as synonyms
6363+ @param locale Locale for the synonym, leave blank to use the standard tokenizer
6464+ @param root For 1-way synonyms, indicates the root word that words in the synonyms parameter map to
6565+ @param symbols_to_index By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is
6666+ *)
6767+ val v : synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t
6868+6969+ (** Locale for the synonym, leave blank to use the standard tokenizer *)
7070+ val locale : t -> string option
7171+7272+ (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *)
7373+ val root : t -> string option
7474+7575+ (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *)
7676+ val symbols_to_index : t -> string list option
7777+7878+ (** Array of words that should be considered as synonyms *)
7979+ val synonyms : t -> string list
8080+8181+ val jsont : t Jsont.t
8282+ end
8383+end
8484+8585+module SynonymItemSchema : sig
8686+ module T : sig
8787+ type t
8888+8989+ (** Construct a value
9090+ @param id Unique identifier for the synonym item
9191+ @param synonyms Array of words that should be considered as synonyms
9292+ @param locale Locale for the synonym, leave blank to use the standard tokenizer
9393+ @param root For 1-way synonyms, indicates the root word that words in the synonyms parameter map to
9494+ @param symbols_to_index By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is
9595+ *)
9696+ val v : id:string -> synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t
9797+9898+ (** Unique identifier for the synonym item *)
9999+ val id : t -> string
100100+101101+ (** Locale for the synonym, leave blank to use the standard tokenizer *)
102102+ val locale : t -> string option
103103+104104+ (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *)
105105+ val root : t -> string option
106106+107107+ (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *)
108108+ val symbols_to_index : t -> string list option
109109+110110+ (** Array of words that should be considered as synonyms *)
111111+ val synonyms : t -> string list
112112+113113+ val jsont : t Jsont.t
114114+ end
115115+116116+ (** List items in a synonym set
117117+118118+ Retrieve all synonym items in a set
119119+ @param synonym_set_name The name of the synonym set to retrieve items for
120120+ *)
121121+ val retrieve_synonym_set_items : synonym_set_name:string -> t -> unit -> T.t
122122+123123+ (** Retrieve a synonym set item
124124+125125+ Retrieve a specific synonym item by its id
126126+ @param synonym_set_name The name of the synonym set
127127+ @param item_id The id of the synonym item to retrieve
128128+ *)
129129+ val retrieve_synonym_set_item : synonym_set_name:string -> item_id:string -> t -> unit -> T.t
130130+131131+ (** Create or update a synonym set item
132132+133133+ Create or update a synonym set item with the given id
134134+ @param synonym_set_name The name of the synonym set
135135+ @param item_id The id of the synonym item to upsert
136136+ *)
137137+ val upsert_synonym_set_item : synonym_set_name:string -> item_id:string -> body:SynonymItemUpsertSchema.T.t -> t -> unit -> T.t
138138+end
139139+140140+module SynonymSetCreateSchema : sig
141141+ module T : sig
142142+ type t
143143+144144+ (** Construct a value
145145+ @param items Array of synonym items
146146+ *)
147147+ val v : items:SynonymItemSchema.T.t list -> unit -> t
148148+149149+ (** Array of synonym items *)
150150+ val items : t -> SynonymItemSchema.T.t list
151151+152152+ val jsont : t Jsont.t
153153+ end
154154+end
155155+156156+module SynonymSetSchema : sig
157157+ module T : sig
158158+ type t
159159+160160+ (** Construct a value
161161+ @param items Array of synonym items
162162+ @param name Name of the synonym set
163163+ *)
164164+ val v : items:SynonymItemSchema.T.t list -> name:string -> unit -> t
165165+166166+ (** Array of synonym items *)
167167+ val items : t -> SynonymItemSchema.T.t list
168168+169169+ (** Name of the synonym set *)
170170+ val name : t -> string
171171+172172+ val jsont : t Jsont.t
173173+ end
174174+175175+ (** List all synonym sets
176176+177177+ Retrieve all synonym sets *)
178178+ val retrieve_synonym_sets : t -> unit -> T.t
179179+180180+ (** Retrieve a synonym set
181181+182182+ Retrieve a specific synonym set by its name
183183+ @param synonym_set_name The name of the synonym set to retrieve
184184+ *)
185185+ val retrieve_synonym_set : synonym_set_name:string -> t -> unit -> T.t
186186+187187+ (** Create or update a synonym set
188188+189189+ Create or update a synonym set with the given name
190190+ @param synonym_set_name The name of the synonym set to create/update
191191+ *)
192192+ val upsert_synonym_set : synonym_set_name:string -> body:SynonymSetCreateSchema.T.t -> t -> unit -> T.t
193193+end
194194+195195+module SynonymSetsRetrieveSchema : sig
196196+ module T : sig
197197+ type t
198198+199199+ (** Construct a value
200200+ @param synonym_sets Array of synonym sets
201201+ *)
202202+ val v : synonym_sets:SynonymSetSchema.T.t list -> unit -> t
203203+204204+ (** Array of synonym sets *)
205205+ val synonym_sets : t -> SynonymSetSchema.T.t list
206206+207207+ val jsont : t Jsont.t
208208+ end
209209+end
210210+211211+module SynonymItemDeleteSchema : sig
212212+ module T : sig
213213+ type t
214214+215215+ (** Construct a value
216216+ @param id ID of the deleted synonym item
217217+ *)
218218+ val v : id:string -> unit -> t
219219+220220+ (** ID of the deleted synonym item *)
221221+ val id : t -> string
222222+223223+ val jsont : t Jsont.t
224224+ end
225225+226226+ (** Delete a synonym set item
227227+228228+ Delete a specific synonym item by its id
229229+ @param synonym_set_name The name of the synonym set
230230+ @param item_id The id of the synonym item to delete
231231+ *)
232232+ val delete_synonym_set_item : synonym_set_name:string -> item_id:string -> t -> unit -> T.t
233233+end
234234+235235+module Success : sig
236236+ module Status : sig
237237+ type t
238238+239239+ (** Construct a value *)
240240+ val v : success:bool -> unit -> t
241241+242242+ val success : t -> bool
243243+244244+ val jsont : t Jsont.t
245245+ end
246246+247247+ (** Toggle Slow Request Log
248248+249249+ Enable logging of requests that take over a defined threshold of time. Default is `-1` which disables slow request logging. Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. *)
250250+ val toggle_slow_request_log : t -> unit -> Status.t
251251+252252+ (** Clear the cached responses of search requests in the LRU cache.
253253+254254+ Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. *)
255255+ val clear_cache : t -> unit -> Status.t
256256+257257+ (** Compacting the on-disk database
258258+259259+ Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours. *)
260260+ val compact_db : t -> unit -> Status.t
261261+262262+ (** Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.
263263+264264+ 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.
265265+ @param snapshot_path The directory on the server where the snapshot should be saved.
266266+ *)
267267+ val take_snapshot : snapshot_path:string -> t -> unit -> Status.t
268268+269269+ (** Triggers a follower node to initiate the raft voting process, which triggers leader re-election.
270270+271271+ 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. *)
272272+ val vote : t -> unit -> Status.t
273273+end
274274+275275+module StopwordsSetUpsertSchema : sig
276276+ module T : sig
277277+ type t
278278+279279+ (** Construct a value *)
280280+ val v : stopwords:string list -> ?locale:string -> unit -> t
281281+282282+ val locale : t -> string option
283283+284284+ val stopwords : t -> string list
285285+286286+ val jsont : t Jsont.t
287287+ end
288288+end
289289+290290+module StopwordsSetSchema : sig
291291+ module T : sig
292292+ type t
293293+294294+ (** Construct a value *)
295295+ val v : id:string -> stopwords:string list -> ?locale:string -> unit -> t
296296+297297+ val id : t -> string
298298+299299+ val locale : t -> string option
300300+301301+ val stopwords : t -> string list
302302+303303+ val jsont : t Jsont.t
304304+ end
305305+306306+ (** Upserts a stopwords set.
307307+308308+ When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection.
309309+ @param set_id The ID of the stopwords set to upsert.
310310+ *)
311311+ val upsert_stopwords_set : set_id:string -> body:StopwordsSetUpsertSchema.T.t -> t -> unit -> T.t
312312+end
313313+314314+module StopwordsSetsRetrieveAllSchema : sig
315315+ module T : sig
316316+ type t
317317+318318+ (** Construct a value *)
319319+ val v : stopwords:StopwordsSetSchema.T.t list -> unit -> t
320320+321321+ val stopwords : t -> StopwordsSetSchema.T.t list
322322+323323+ val jsont : t Jsont.t
324324+ end
325325+326326+ (** Retrieves all stopwords sets.
327327+328328+ Retrieve the details of all stopwords sets *)
329329+ val retrieve_stopwords_sets : t -> unit -> T.t
330330+end
331331+332332+module StopwordsSetRetrieveSchema : sig
333333+ module T : sig
334334+ type t
335335+336336+ (** Construct a value *)
337337+ val v : stopwords:StopwordsSetSchema.T.t -> unit -> t
338338+339339+ val stopwords : t -> StopwordsSetSchema.T.t
340340+341341+ val jsont : t Jsont.t
342342+ end
343343+344344+ (** Retrieves a stopwords set.
345345+346346+ Retrieve the details of a stopwords set, given it's name.
347347+ @param set_id The ID of the stopwords set to retrieve.
348348+ *)
349349+ val retrieve_stopwords_set : set_id:string -> t -> unit -> T.t
350350+end
351351+352352+module StemmingDictionary : sig
353353+ module T : sig
354354+ type t
355355+356356+ (** Construct a value
357357+ @param id Unique identifier for the dictionary
358358+ @param words List of word mappings in the dictionary
359359+ *)
360360+ val v : id:string -> words:Jsont.json list -> unit -> t
361361+362362+ (** Unique identifier for the dictionary *)
363363+ val id : t -> string
364364+365365+ (** List of word mappings in the dictionary *)
366366+ val words : t -> Jsont.json list
367367+368368+ val jsont : t Jsont.t
369369+ end
370370+371371+ (** Retrieve a stemming dictionary
372372+373373+ Fetch details of a specific stemming dictionary.
374374+ @param dictionary_id The ID of the dictionary to retrieve
375375+ *)
376376+ val get_stemming_dictionary : dictionary_id:string -> t -> unit -> T.t
377377+end
378378+379379+module SearchSynonymSchema : sig
380380+ module T : sig
381381+ type t
382382+383383+ (** Construct a value
384384+ @param synonyms Array of words that should be considered as synonyms.
385385+ @param locale Locale for the synonym, leave blank to use the standard tokenizer.
386386+ @param root For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to.
387387+ @param symbols_to_index By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is.
388388+ *)
389389+ val v : synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t
390390+391391+ (** Locale for the synonym, leave blank to use the standard tokenizer. *)
392392+ val locale : t -> string option
393393+394394+ (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *)
395395+ val root : t -> string option
396396+397397+ (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *)
398398+ val symbols_to_index : t -> string list option
399399+400400+ (** Array of words that should be considered as synonyms. *)
401401+ val synonyms : t -> string list
402402+403403+ val jsont : t Jsont.t
404404+ end
405405+end
406406+407407+module SearchSynonymDelete : sig
408408+ module Response : sig
409409+ type t
410410+411411+ (** Construct a value
412412+ @param id The id of the synonym that was deleted
413413+ *)
414414+ val v : id:string -> unit -> t
415415+416416+ (** The id of the synonym that was deleted *)
417417+ val id : t -> string
418418+419419+ val jsont : t Jsont.t
420420+ end
421421+end
422422+423423+module SearchSynonym : sig
424424+ module T : sig
425425+ type t
426426+427427+ (** Construct a value
428428+ @param synonyms Array of words that should be considered as synonyms.
429429+ @param locale Locale for the synonym, leave blank to use the standard tokenizer.
430430+ @param root For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to.
431431+ @param symbols_to_index By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is.
432432+ *)
433433+ val v : synonyms:string list -> id:string -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t
434434+435435+ (** Locale for the synonym, leave blank to use the standard tokenizer. *)
436436+ val locale : t -> string option
437437+438438+ (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *)
439439+ val root : t -> string option
440440+441441+ (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *)
442442+ val symbols_to_index : t -> string list option
443443+444444+ (** Array of words that should be considered as synonyms. *)
445445+ val synonyms : t -> string list
446446+447447+ val id : t -> string
448448+449449+ val jsont : t Jsont.t
450450+ end
451451+end
452452+453453+module SearchSynonyms : sig
454454+ module Response : sig
455455+ type t
456456+457457+ (** Construct a value *)
458458+ val v : synonyms:SearchSynonym.T.t list -> unit -> t
459459+460460+ val synonyms : t -> SearchSynonym.T.t list
461461+462462+ val jsont : t Jsont.t
463463+ end
464464+end
465465+466466+module SearchResultConversation : sig
467467+ module T : sig
468468+ type t
469469+470470+ (** Construct a value *)
471471+ val v : answer:string -> conversation_history:Jsont.json list -> conversation_id:string -> query:string -> unit -> t
472472+473473+ val answer : t -> string
474474+475475+ val conversation_history : t -> Jsont.json list
476476+477477+ val conversation_id : t -> string
478478+479479+ val query : t -> string
480480+481481+ val jsont : t Jsont.t
482482+ end
483483+end
484484+485485+module SearchRequestParams : sig
486486+ module T : sig
487487+ type t
488488+489489+ (** Construct a value *)
490490+ val v : collection_name:string -> per_page:int -> q:string -> ?voice_query:Jsont.json -> unit -> t
491491+492492+ val collection_name : t -> string
493493+494494+ val per_page : t -> int
495495+496496+ val q : t -> string
497497+498498+ val voice_query : t -> Jsont.json option
499499+500500+ val jsont : t Jsont.t
501501+ end
502502+end
503503+504504+module SearchHighlight : sig
505505+ module T : sig
506506+ type t
507507+508508+ (** Construct a value
509509+ @param indices The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field
510510+ @param snippet Present only for (non-array) string fields
511511+ @param snippets Present only for (array) string[] fields
512512+ @param value Full field value with highlighting, present only for (non-array) string fields
513513+ @param values Full field value with highlighting, present only for (array) string[] fields
514514+ *)
515515+ val v : ?field:string -> ?indices:int list -> ?matched_tokens:Jsont.json list -> ?snippet:string -> ?snippets:string list -> ?value:string -> ?values:string list -> unit -> t
516516+517517+ val field : t -> string option
518518+519519+ (** The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field *)
520520+ val indices : t -> int list option
521521+522522+ val matched_tokens : t -> Jsont.json list option
523523+524524+ (** Present only for (non-array) string fields *)
525525+ val snippet : t -> string option
526526+527527+ (** Present only for (array) string[] fields *)
528528+ val snippets : t -> string list option
529529+530530+ (** Full field value with highlighting, present only for (non-array) string fields *)
531531+ val value : t -> string option
532532+533533+ (** Full field value with highlighting, present only for (array) string[] fields *)
534534+ val values : t -> string list option
535535+536536+ val jsont : t Jsont.t
537537+ end
538538+end
539539+540540+module SearchResultHit : sig
541541+ module T : sig
542542+ type t
543543+544544+ (** Construct a value
545545+ @param document Can be any key-value pair
546546+ @param geo_distance_meters Can be any key-value pair
547547+ @param highlight Highlighted version of the matching document
548548+ @param highlights (Deprecated) Contains highlighted portions of the search fields
549549+ @param hybrid_search_info Information about hybrid search scoring
550550+ @param search_index Returned only for union query response. Indicates the index of the query which this document matched to.
551551+ @param vector_distance Distance between the query vector and matching document's vector value
552552+ *)
553553+ val v : ?document:Jsont.json -> ?geo_distance_meters:Jsont.json -> ?highlight:Jsont.json -> ?highlights:SearchHighlight.T.t list -> ?hybrid_search_info:Jsont.json -> ?search_index:int -> ?text_match:int64 -> ?text_match_info:Jsont.json -> ?vector_distance:float -> unit -> t
554554+555555+ (** Can be any key-value pair *)
556556+ val document : t -> Jsont.json option
557557+558558+ (** Can be any key-value pair *)
559559+ val geo_distance_meters : t -> Jsont.json option
560560+561561+ (** Highlighted version of the matching document *)
562562+ val highlight : t -> Jsont.json option
563563+564564+ (** (Deprecated) Contains highlighted portions of the search fields *)
565565+ val highlights : t -> SearchHighlight.T.t list option
566566+567567+ (** Information about hybrid search scoring *)
568568+ val hybrid_search_info : t -> Jsont.json option
569569+570570+ (** Returned only for union query response. Indicates the index of the query which this document matched to. *)
571571+ val search_index : t -> int option
572572+573573+ val text_match : t -> int64 option
574574+575575+ val text_match_info : t -> Jsont.json option
576576+577577+ (** Distance between the query vector and matching document's vector value *)
578578+ val vector_distance : t -> float option
579579+580580+ val jsont : t Jsont.t
581581+ end
582582+end
583583+584584+module SearchGroupedHit : sig
585585+ module T : sig
586586+ type t
587587+588588+ (** Construct a value
589589+ @param hits The documents that matched the search query
590590+ *)
591591+ val v : group_key:Jsont.json list -> hits:SearchResultHit.T.t list -> ?found:int -> unit -> t
592592+593593+ val found : t -> int option
594594+595595+ val group_key : t -> Jsont.json list
596596+597597+ (** The documents that matched the search query *)
598598+ val hits : t -> SearchResultHit.T.t list
599599+600600+ val jsont : t Jsont.t
601601+ end
602602+end
603603+604604+module SchemaChange : sig
605605+ module Status : sig
606606+ type t
607607+608608+ (** Construct a value
609609+ @param altered_docs Number of documents that have been altered
610610+ @param collection Name of the collection being modified
611611+ @param validated_docs Number of documents that have been validated
612612+ *)
613613+ val v : ?altered_docs:int -> ?collection:string -> ?validated_docs:int -> unit -> t
614614+615615+ (** Number of documents that have been altered *)
616616+ val altered_docs : t -> int option
617617+618618+ (** Name of the collection being modified *)
619619+ val collection : t -> string option
620620+621621+ (** Number of documents that have been validated *)
622622+ val validated_docs : t -> int option
623623+624624+ val jsont : t Jsont.t
625625+ end
626626+627627+ (** Get the status of in-progress schema change operations
628628+629629+ Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. *)
630630+ val get_schema_changes : t -> unit -> Status.t
631631+end
632632+633633+module PresetUpsertSchema : sig
634634+ module T : sig
635635+ type t
636636+637637+ (** Construct a value *)
638638+ val v : value:Jsont.json -> unit -> t
639639+640640+ val value : t -> Jsont.json
641641+642642+ val jsont : t Jsont.t
643643+ end
644644+end
645645+646646+module PresetSchema : sig
647647+ module T : sig
648648+ type t
649649+650650+ (** Construct a value *)
651651+ val v : value:Jsont.json -> name:string -> unit -> t
652652+653653+ val value : t -> Jsont.json
654654+655655+ val name : t -> string
656656+657657+ val jsont : t Jsont.t
658658+ end
659659+660660+ (** Retrieves a preset.
661661+662662+ Retrieve the details of a preset, given it's name.
663663+ @param preset_id The ID of the preset to retrieve.
664664+ *)
665665+ val retrieve_preset : preset_id:string -> t -> unit -> T.t
666666+667667+ (** Upserts a preset.
668668+669669+ Create or update an existing preset.
670670+ @param preset_id The name of the preset set to upsert.
671671+ *)
672672+ val upsert_preset : preset_id:string -> body:PresetUpsertSchema.T.t -> t -> unit -> T.t
673673+end
674674+675675+module PresetsRetrieveSchema : sig
676676+ module T : sig
677677+ type t
678678+679679+ (** Construct a value *)
680680+ val v : presets:PresetSchema.T.t list -> unit -> t
681681+682682+ val presets : t -> PresetSchema.T.t list
683683+684684+ val jsont : t Jsont.t
685685+ end
686686+687687+ (** Retrieves all presets.
688688+689689+ Retrieve the details of all presets *)
690690+ val retrieve_all_presets : t -> unit -> T.t
691691+end
692692+693693+module PresetDeleteSchema : sig
694694+ module T : sig
695695+ type t
696696+697697+ (** Construct a value *)
698698+ val v : name:string -> unit -> t
699699+700700+ val name : t -> string
701701+702702+ val jsont : t Jsont.t
703703+ end
704704+705705+ (** Delete a preset.
706706+707707+ Permanently deletes a preset, given it's name.
708708+ @param preset_id The ID of the preset to delete.
709709+ *)
710710+ val delete_preset : preset_id:string -> t -> unit -> T.t
711711+end
712712+713713+module NlsearchModelDeleteSchema : sig
714714+ module T : sig
715715+ type t
716716+717717+ (** Construct a value
718718+ @param id ID of the deleted NL search model
719719+ *)
720720+ val v : id:string -> unit -> t
721721+722722+ (** ID of the deleted NL search model *)
723723+ val id : t -> string
724724+725725+ val jsont : t Jsont.t
726726+ end
727727+728728+ (** Delete a NL search model
729729+730730+ Delete a specific NL search model by its ID.
731731+ @param model_id The ID of the NL search model to delete
732732+ *)
733733+ val delete_nlsearch_model : model_id:string -> t -> unit -> T.t
734734+end
735735+736736+module NlsearchModelCreateSchema : sig
737737+ module T : sig
738738+ type t
739739+740740+ (** Construct a value
741741+ @param access_token Access token for GCP Vertex AI
742742+ @param account_id Account ID for Cloudflare-specific models
743743+ @param api_key API key for the NL model service
744744+ @param api_url Custom API URL for the NL model service
745745+ @param api_version API version for the NL model service
746746+ @param client_id Client ID for GCP Vertex AI
747747+ @param client_secret Client secret for GCP Vertex AI
748748+ @param max_bytes Maximum number of bytes to process
749749+ @param max_output_tokens Maximum output tokens for GCP Vertex AI
750750+ @param model_name Name of the NL model to use
751751+ @param project_id Project ID for GCP Vertex AI
752752+ @param refresh_token Refresh token for GCP Vertex AI
753753+ @param region Region for GCP Vertex AI
754754+ @param stop_sequences Stop sequences for the NL model (Google-specific)
755755+ @param system_prompt System prompt for the NL model
756756+ @param temperature Temperature parameter for the NL model
757757+ @param top_k Top-k parameter for the NL model (Google-specific)
758758+ @param top_p Top-p parameter for the NL model (Google-specific)
759759+ @param id Optional ID for the NL search model
760760+ *)
761761+ val v : ?access_token:string -> ?account_id:string -> ?api_key:string -> ?api_url:string -> ?api_version:string -> ?client_id:string -> ?client_secret:string -> ?max_bytes:int -> ?max_output_tokens:int -> ?model_name:string -> ?project_id:string -> ?refresh_token:string -> ?region:string -> ?stop_sequences:string list -> ?system_prompt:string -> ?temperature:float -> ?top_k:int -> ?top_p:float -> ?id:string -> unit -> t
762762+763763+ (** Access token for GCP Vertex AI *)
764764+ val access_token : t -> string option
765765+766766+ (** Account ID for Cloudflare-specific models *)
767767+ val account_id : t -> string option
768768+769769+ (** API key for the NL model service *)
770770+ val api_key : t -> string option
771771+772772+ (** Custom API URL for the NL model service *)
773773+ val api_url : t -> string option
774774+775775+ (** API version for the NL model service *)
776776+ val api_version : t -> string option
777777+778778+ (** Client ID for GCP Vertex AI *)
779779+ val client_id : t -> string option
780780+781781+ (** Client secret for GCP Vertex AI *)
782782+ val client_secret : t -> string option
783783+784784+ (** Maximum number of bytes to process *)
785785+ val max_bytes : t -> int option
786786+787787+ (** Maximum output tokens for GCP Vertex AI *)
788788+ val max_output_tokens : t -> int option
789789+790790+ (** Name of the NL model to use *)
791791+ val model_name : t -> string option
792792+793793+ (** Project ID for GCP Vertex AI *)
794794+ val project_id : t -> string option
795795+796796+ (** Refresh token for GCP Vertex AI *)
797797+ val refresh_token : t -> string option
798798+799799+ (** Region for GCP Vertex AI *)
800800+ val region : t -> string option
801801+802802+ (** Stop sequences for the NL model (Google-specific) *)
803803+ val stop_sequences : t -> string list option
804804+805805+ (** System prompt for the NL model *)
806806+ val system_prompt : t -> string option
807807+808808+ (** Temperature parameter for the NL model *)
809809+ val temperature : t -> float option
810810+811811+ (** Top-k parameter for the NL model (Google-specific) *)
812812+ val top_k : t -> int option
813813+814814+ (** Top-p parameter for the NL model (Google-specific) *)
815815+ val top_p : t -> float option
816816+817817+ (** Optional ID for the NL search model *)
818818+ val id : t -> string option
819819+820820+ val jsont : t Jsont.t
821821+ end
822822+end
823823+824824+module NlsearchModelSchema : sig
825825+ module T : sig
826826+ type t
827827+828828+ (** Construct a value
829829+ @param id ID of the NL search model
830830+ @param access_token Access token for GCP Vertex AI
831831+ @param account_id Account ID for Cloudflare-specific models
832832+ @param api_key API key for the NL model service
833833+ @param api_url Custom API URL for the NL model service
834834+ @param api_version API version for the NL model service
835835+ @param client_id Client ID for GCP Vertex AI
836836+ @param client_secret Client secret for GCP Vertex AI
837837+ @param max_bytes Maximum number of bytes to process
838838+ @param max_output_tokens Maximum output tokens for GCP Vertex AI
839839+ @param model_name Name of the NL model to use
840840+ @param project_id Project ID for GCP Vertex AI
841841+ @param refresh_token Refresh token for GCP Vertex AI
842842+ @param region Region for GCP Vertex AI
843843+ @param stop_sequences Stop sequences for the NL model (Google-specific)
844844+ @param system_prompt System prompt for the NL model
845845+ @param temperature Temperature parameter for the NL model
846846+ @param top_k Top-k parameter for the NL model (Google-specific)
847847+ @param top_p Top-p parameter for the NL model (Google-specific)
848848+ *)
849849+ val v : id:string -> ?access_token:string -> ?account_id:string -> ?api_key:string -> ?api_url:string -> ?api_version:string -> ?client_id:string -> ?client_secret:string -> ?max_bytes:int -> ?max_output_tokens:int -> ?model_name:string -> ?project_id:string -> ?refresh_token:string -> ?region:string -> ?stop_sequences:string list -> ?system_prompt:string -> ?temperature:float -> ?top_k:int -> ?top_p:float -> unit -> t
850850+851851+ (** Access token for GCP Vertex AI *)
852852+ val access_token : t -> string option
853853+854854+ (** Account ID for Cloudflare-specific models *)
855855+ val account_id : t -> string option
856856+857857+ (** API key for the NL model service *)
858858+ val api_key : t -> string option
859859+860860+ (** Custom API URL for the NL model service *)
861861+ val api_url : t -> string option
862862+863863+ (** API version for the NL model service *)
864864+ val api_version : t -> string option
865865+866866+ (** Client ID for GCP Vertex AI *)
867867+ val client_id : t -> string option
868868+869869+ (** Client secret for GCP Vertex AI *)
870870+ val client_secret : t -> string option
871871+872872+ (** Maximum number of bytes to process *)
873873+ val max_bytes : t -> int option
874874+875875+ (** Maximum output tokens for GCP Vertex AI *)
876876+ val max_output_tokens : t -> int option
877877+878878+ (** Name of the NL model to use *)
879879+ val model_name : t -> string option
880880+881881+ (** Project ID for GCP Vertex AI *)
882882+ val project_id : t -> string option
883883+884884+ (** Refresh token for GCP Vertex AI *)
885885+ val refresh_token : t -> string option
886886+887887+ (** Region for GCP Vertex AI *)
888888+ val region : t -> string option
889889+890890+ (** Stop sequences for the NL model (Google-specific) *)
891891+ val stop_sequences : t -> string list option
892892+893893+ (** System prompt for the NL model *)
894894+ val system_prompt : t -> string option
895895+896896+ (** Temperature parameter for the NL model *)
897897+ val temperature : t -> float option
898898+899899+ (** Top-k parameter for the NL model (Google-specific) *)
900900+ val top_k : t -> int option
901901+902902+ (** Top-p parameter for the NL model (Google-specific) *)
903903+ val top_p : t -> float option
904904+905905+ (** ID of the NL search model *)
906906+ val id : t -> string
907907+908908+ val jsont : t Jsont.t
909909+ end
910910+911911+ (** List all NL search models
912912+913913+ Retrieve all NL search models. *)
914914+ val retrieve_all_nlsearch_models : t -> unit -> T.t
915915+916916+ (** Create a NL search model
917917+918918+ Create a new NL search model. *)
919919+ val create_nlsearch_model : body:NlsearchModelCreateSchema.T.t -> t -> unit -> T.t
920920+921921+ (** Retrieve a NL search model
922922+923923+ Retrieve a specific NL search model by its ID.
924924+ @param model_id The ID of the NL search model to retrieve
925925+ *)
926926+ val retrieve_nlsearch_model : model_id:string -> t -> unit -> T.t
927927+928928+ (** Update a NL search model
929929+930930+ Update an existing NL search model.
931931+ @param model_id The ID of the NL search model to update
932932+ *)
933933+ val update_nlsearch_model : model_id:string -> t -> unit -> T.t
934934+end
935935+936936+module NlsearchModelBase : sig
937937+ module T : sig
938938+ type t
939939+940940+ (** Construct a value
941941+ @param access_token Access token for GCP Vertex AI
942942+ @param account_id Account ID for Cloudflare-specific models
943943+ @param api_key API key for the NL model service
944944+ @param api_url Custom API URL for the NL model service
945945+ @param api_version API version for the NL model service
946946+ @param client_id Client ID for GCP Vertex AI
947947+ @param client_secret Client secret for GCP Vertex AI
948948+ @param max_bytes Maximum number of bytes to process
949949+ @param max_output_tokens Maximum output tokens for GCP Vertex AI
950950+ @param model_name Name of the NL model to use
951951+ @param project_id Project ID for GCP Vertex AI
952952+ @param refresh_token Refresh token for GCP Vertex AI
953953+ @param region Region for GCP Vertex AI
954954+ @param stop_sequences Stop sequences for the NL model (Google-specific)
955955+ @param system_prompt System prompt for the NL model
956956+ @param temperature Temperature parameter for the NL model
957957+ @param top_k Top-k parameter for the NL model (Google-specific)
958958+ @param top_p Top-p parameter for the NL model (Google-specific)
959959+ *)
960960+ val v : ?access_token:string -> ?account_id:string -> ?api_key:string -> ?api_url:string -> ?api_version:string -> ?client_id:string -> ?client_secret:string -> ?max_bytes:int -> ?max_output_tokens:int -> ?model_name:string -> ?project_id:string -> ?refresh_token:string -> ?region:string -> ?stop_sequences:string list -> ?system_prompt:string -> ?temperature:float -> ?top_k:int -> ?top_p:float -> unit -> t
961961+962962+ (** Access token for GCP Vertex AI *)
963963+ val access_token : t -> string option
964964+965965+ (** Account ID for Cloudflare-specific models *)
966966+ val account_id : t -> string option
967967+968968+ (** API key for the NL model service *)
969969+ val api_key : t -> string option
970970+971971+ (** Custom API URL for the NL model service *)
972972+ val api_url : t -> string option
973973+974974+ (** API version for the NL model service *)
975975+ val api_version : t -> string option
976976+977977+ (** Client ID for GCP Vertex AI *)
978978+ val client_id : t -> string option
979979+980980+ (** Client secret for GCP Vertex AI *)
981981+ val client_secret : t -> string option
982982+983983+ (** Maximum number of bytes to process *)
984984+ val max_bytes : t -> int option
985985+986986+ (** Maximum output tokens for GCP Vertex AI *)
987987+ val max_output_tokens : t -> int option
988988+989989+ (** Name of the NL model to use *)
990990+ val model_name : t -> string option
991991+992992+ (** Project ID for GCP Vertex AI *)
993993+ val project_id : t -> string option
994994+995995+ (** Refresh token for GCP Vertex AI *)
996996+ val refresh_token : t -> string option
997997+998998+ (** Region for GCP Vertex AI *)
999999+ val region : t -> string option
10001000+10011001+ (** Stop sequences for the NL model (Google-specific) *)
10021002+ val stop_sequences : t -> string list option
10031003+10041004+ (** System prompt for the NL model *)
10051005+ val system_prompt : t -> string option
10061006+10071007+ (** Temperature parameter for the NL model *)
10081008+ val temperature : t -> float option
10091009+10101010+ (** Top-k parameter for the NL model (Google-specific) *)
10111011+ val top_k : t -> int option
10121012+10131013+ (** Top-p parameter for the NL model (Google-specific) *)
10141014+ val top_p : t -> float option
10151015+10161016+ val jsont : t Jsont.t
10171017+ end
10181018+end
10191019+10201020+module IndexAction : sig
10211021+ module T : sig
10221022+ type t = [
10231023+ | `Create
10241024+ | `Update
10251025+ | `Upsert
10261026+ | `Emplace
10271027+ ]
10281028+10291029+ val jsont : t Jsont.t
10301030+ end
10311031+end
10321032+10331033+module Health : sig
10341034+ module Status : sig
10351035+ type t
10361036+10371037+ (** Construct a value *)
10381038+ val v : ok:bool -> unit -> t
10391039+10401040+ val ok : t -> bool
10411041+10421042+ val jsont : t Jsont.t
10431043+ end
10441044+10451045+ (** Checks if Typesense server is ready to accept requests.
10461046+10471047+ Checks if Typesense server is ready to accept requests. *)
10481048+ val health : t -> unit -> Status.t
10491049+end
10501050+10511051+module Field : sig
10521052+ module T : sig
10531053+ type t
10541054+10551055+ (** Construct a value
10561056+ @param symbols_to_index List of symbols or special characters to be indexed.
10571057+10581058+ @param token_separators List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
10591059+10601060+ @param async_reference Allow documents to be indexed successfully even when the referenced document doesn't exist yet.
10611061+10621062+ @param range_index Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false.
10631063+10641064+ @param reference Name of a field in another collection that should be linked to this collection so that it can be joined during query.
10651065+10661066+ @param stem Values are stemmed before indexing in-memory. Default: false.
10671067+10681068+ @param stem_dictionary Name of the stemming dictionary to use for this field
10691069+ @param store When set to false, the field value will not be stored on disk. Default: true.
10701070+10711071+ @param vec_dist The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product.
10721072+10731073+ *)
10741074+ val v : name:string -> type_:string -> ?index:bool -> ?infix:bool -> ?symbols_to_index:string list -> ?token_separators:string list -> ?async_reference:bool -> ?drop:bool -> ?embed:Jsont.json -> ?facet:bool -> ?locale:string -> ?num_dim:int -> ?optional:bool -> ?range_index:bool -> ?reference:string -> ?sort:bool -> ?stem:bool -> ?stem_dictionary:string -> ?store:bool -> ?vec_dist:string -> unit -> t
10751075+10761076+ (** Allow documents to be indexed successfully even when the referenced document doesn't exist yet.
10771077+ *)
10781078+ val async_reference : t -> bool option
10791079+10801080+ val drop : t -> bool option
10811081+10821082+ val embed : t -> Jsont.json option
10831083+10841084+ val facet : t -> bool option
10851085+10861086+ val index : t -> bool
10871087+10881088+ val infix : t -> bool
10891089+10901090+ val locale : t -> string option
10911091+10921092+ val name : t -> string
10931093+10941094+ val num_dim : t -> int option
10951095+10961096+ val optional : t -> bool option
10971097+10981098+ (** Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false.
10991099+ *)
11001100+ val range_index : t -> bool option
11011101+11021102+ (** Name of a field in another collection that should be linked to this collection so that it can be joined during query.
11031103+ *)
11041104+ val reference : t -> string option
11051105+11061106+ val sort : t -> bool option
11071107+11081108+ (** Values are stemmed before indexing in-memory. Default: false.
11091109+ *)
11101110+ val stem : t -> bool option
11111111+11121112+ (** Name of the stemming dictionary to use for this field *)
11131113+ val stem_dictionary : t -> string option
11141114+11151115+ (** When set to false, the field value will not be stored on disk. Default: true.
11161116+ *)
11171117+ val store : t -> bool option
11181118+11191119+ (** List of symbols or special characters to be indexed.
11201120+ *)
11211121+ val symbols_to_index : t -> string list
11221122+11231123+ (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
11241124+ *)
11251125+ val token_separators : t -> string list
11261126+11271127+ val type_ : t -> string
11281128+11291129+ (** The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product.
11301130+ *)
11311131+ val vec_dist : t -> string option
11321132+11331133+ val jsont : t Jsont.t
11341134+ end
11351135+end
11361136+11371137+module CollectionUpdateSchema : sig
11381138+ module T : sig
11391139+ type t
11401140+11411141+ (** Construct a value
11421142+ @param fields A list of fields for querying, filtering and faceting
11431143+ @param metadata Optional details about the collection, e.g., when it was created, who created it etc.
11441144+11451145+ @param synonym_sets List of synonym set names to associate with this collection
11461146+ *)
11471147+ val v : fields:Field.T.t list -> ?metadata:Jsont.json -> ?synonym_sets:string list -> unit -> t
11481148+11491149+ (** A list of fields for querying, filtering and faceting *)
11501150+ val fields : t -> Field.T.t list
11511151+11521152+ (** Optional details about the collection, e.g., when it was created, who created it etc.
11531153+ *)
11541154+ val metadata : t -> Jsont.json option
11551155+11561156+ (** List of synonym set names to associate with this collection *)
11571157+ val synonym_sets : t -> string list option
11581158+11591159+ val jsont : t Jsont.t
11601160+ end
11611161+11621162+ (** Update a collection
11631163+11641164+ Update a collection's schema to modify the fields and their types.
11651165+ @param collection_name The name of the collection to update
11661166+ *)
11671167+ val update_collection : collection_name:string -> body:T.t -> t -> unit -> T.t
11681168+end
11691169+11701170+module CollectionSchema : sig
11711171+ module T : sig
11721172+ type t
11731173+11741174+ (** Construct a value
11751175+ @param fields A list of fields for querying, filtering and faceting
11761176+ @param name Name of the collection
11771177+ @param default_sorting_field 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.
11781178+ @param enable_nested_fields 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.
11791179+ @param symbols_to_index List of symbols or special characters to be indexed.
11801180+11811181+ @param token_separators List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
11821182+11831183+ @param metadata Optional details about the collection, e.g., when it was created, who created it etc.
11841184+11851185+ @param synonym_sets List of synonym set names to associate with this collection
11861186+ *)
11871187+ val v : fields:Field.T.t list -> name:string -> ?default_sorting_field:string -> ?enable_nested_fields:bool -> ?symbols_to_index:string list -> ?token_separators:string list -> ?metadata:Jsont.json -> ?synonym_sets:string list -> ?voice_query_model:VoiceQueryModelCollection.Config.t -> unit -> t
11881188+11891189+ (** 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. *)
11901190+ val default_sorting_field : t -> string
11911191+11921192+ (** 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. *)
11931193+ val enable_nested_fields : t -> bool
11941194+11951195+ (** A list of fields for querying, filtering and faceting *)
11961196+ val fields : t -> Field.T.t list
11971197+11981198+ (** Optional details about the collection, e.g., when it was created, who created it etc.
11991199+ *)
12001200+ val metadata : t -> Jsont.json option
12011201+12021202+ (** Name of the collection *)
12031203+ val name : t -> string
12041204+12051205+ (** List of symbols or special characters to be indexed.
12061206+ *)
12071207+ val symbols_to_index : t -> string list
12081208+12091209+ (** List of synonym set names to associate with this collection *)
12101210+ val synonym_sets : t -> string list option
12111211+12121212+ (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
12131213+ *)
12141214+ val token_separators : t -> string list
12151215+12161216+ val voice_query_model : t -> VoiceQueryModelCollection.Config.t option
12171217+12181218+ val jsont : t Jsont.t
12191219+ end
12201220+end
12211221+12221222+module Collection : sig
12231223+ module Response : sig
12241224+ type t
12251225+12261226+ (** Construct a value
12271227+ @param fields A list of fields for querying, filtering and faceting
12281228+ @param name Name of the collection
12291229+ @param num_documents Number of documents in the collection
12301230+ @param created_at Timestamp of when the collection was created (Unix epoch in seconds)
12311231+ @param default_sorting_field 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.
12321232+ @param enable_nested_fields 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.
12331233+ @param symbols_to_index List of symbols or special characters to be indexed.
12341234+12351235+ @param token_separators List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
12361236+12371237+ @param metadata Optional details about the collection, e.g., when it was created, who created it etc.
12381238+12391239+ @param synonym_sets List of synonym set names to associate with this collection
12401240+ *)
12411241+ val v : fields:Field.T.t list -> name:string -> num_documents:int64 -> created_at:int64 -> ?default_sorting_field:string -> ?enable_nested_fields:bool -> ?symbols_to_index:string list -> ?token_separators:string list -> ?metadata:Jsont.json -> ?synonym_sets:string list -> ?voice_query_model:VoiceQueryModelCollection.Config.t -> unit -> t
12421242+12431243+ (** 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. *)
12441244+ val default_sorting_field : t -> string
12451245+12461246+ (** 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. *)
12471247+ val enable_nested_fields : t -> bool
12481248+12491249+ (** A list of fields for querying, filtering and faceting *)
12501250+ val fields : t -> Field.T.t list
12511251+12521252+ (** Optional details about the collection, e.g., when it was created, who created it etc.
12531253+ *)
12541254+ val metadata : t -> Jsont.json option
12551255+12561256+ (** Name of the collection *)
12571257+ val name : t -> string
12581258+12591259+ (** List of symbols or special characters to be indexed.
12601260+ *)
12611261+ val symbols_to_index : t -> string list
12621262+12631263+ (** List of synonym set names to associate with this collection *)
12641264+ val synonym_sets : t -> string list option
12651265+12661266+ (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.
12671267+ *)
12681268+ val token_separators : t -> string list
12691269+12701270+ val voice_query_model : t -> VoiceQueryModelCollection.Config.t option
12711271+12721272+ (** Number of documents in the collection *)
12731273+ val num_documents : t -> int64
12741274+12751275+ (** Timestamp of when the collection was created (Unix epoch in seconds) *)
12761276+ val created_at : t -> int64
12771277+12781278+ val jsont : t Jsont.t
12791279+ end
12801280+12811281+ (** List all collections
12821282+12831283+ Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. *)
12841284+ val get_collections : ?get_collections_parameters:string -> t -> unit -> Response.t
12851285+12861286+ (** Create a new collection
12871287+12881288+ 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. *)
12891289+ val create_collection : body:CollectionSchema.T.t -> t -> unit -> Response.t
12901290+12911291+ (** Retrieve a single collection
12921292+12931293+ Retrieve the details of a collection, given its name.
12941294+ @param collection_name The name of the collection to retrieve
12951295+ *)
12961296+ val get_collection : collection_name:string -> t -> unit -> Response.t
12971297+12981298+ (** Delete a collection
12991299+13001300+ Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies.
13011301+ @param collection_name The name of the collection to delete
13021302+ *)
13031303+ val delete_collection : collection_name:string -> t -> unit -> Response.t
13041304+end
13051305+13061306+module FacetCounts : sig
13071307+ module T : sig
13081308+ type t
13091309+13101310+ (** Construct a value *)
13111311+ val v : ?counts:Jsont.json list -> ?field_name:string -> ?stats:Jsont.json -> unit -> t
13121312+13131313+ val counts : t -> Jsont.json list option
13141314+13151315+ val field_name : t -> string option
13161316+13171317+ val stats : t -> Jsont.json option
13181318+13191319+ val jsont : t Jsont.t
13201320+ end
13211321+end
13221322+13231323+module Search : sig
13241324+ module Result : sig
13251325+ type t
13261326+13271327+ (** Construct a value
13281328+ @param found The number of documents found
13291329+ @param hits The documents that matched the search query
13301330+ @param metadata Custom JSON object that can be returned in the search response
13311331+ @param out_of The total number of documents in the collection
13321332+ @param page The search result page number
13331333+ @param search_cutoff Whether the search was cut off
13341334+ @param search_time_ms The number of milliseconds the search took
13351335+ @param union_request_params Returned only for union query response.
13361336+ *)
13371337+ val v : ?conversation:SearchResultConversation.T.t -> ?facet_counts:FacetCounts.T.t list -> ?found:int -> ?found_docs:int -> ?grouped_hits:SearchGroupedHit.T.t list -> ?hits:SearchResultHit.T.t list -> ?metadata:Jsont.json -> ?out_of:int -> ?page:int -> ?request_params:SearchRequestParams.T.t -> ?search_cutoff:bool -> ?search_time_ms:int -> ?union_request_params:SearchRequestParams.T.t list -> unit -> t
13381338+13391339+ val conversation : t -> SearchResultConversation.T.t option
13401340+13411341+ val facet_counts : t -> FacetCounts.T.t list option
13421342+13431343+ (** The number of documents found *)
13441344+ val found : t -> int option
13451345+13461346+ val found_docs : t -> int option
13471347+13481348+ val grouped_hits : t -> SearchGroupedHit.T.t list option
13491349+13501350+ (** The documents that matched the search query *)
13511351+ val hits : t -> SearchResultHit.T.t list option
13521352+13531353+ (** Custom JSON object that can be returned in the search response *)
13541354+ val metadata : t -> Jsont.json option
13551355+13561356+ (** The total number of documents in the collection *)
13571357+ val out_of : t -> int option
13581358+13591359+ (** The search result page number *)
13601360+ val page : t -> int option
13611361+13621362+ val request_params : t -> SearchRequestParams.T.t option
13631363+13641364+ (** Whether the search was cut off *)
13651365+ val search_cutoff : t -> bool option
13661366+13671367+ (** The number of milliseconds the search took *)
13681368+ val search_time_ms : t -> int option
13691369+13701370+ (** Returned only for union query response. *)
13711371+ val union_request_params : t -> SearchRequestParams.T.t list option
13721372+13731373+ val jsont : t Jsont.t
13741374+ end
13751375+13761376+ (** Search for documents in a collection
13771377+13781378+ Search for documents in a collection that match the search criteria.
13791379+ @param collection_name The name of the collection to search for the document under
13801380+ *)
13811381+ val search_collection : collection_name:string -> search_parameters:string -> t -> unit -> Result.t
13821382+end
13831383+13841384+module MultiSearchResult : sig
13851385+ module Item : sig
13861386+ type t
13871387+13881388+ (** Construct a value
13891389+ @param found The number of documents found
13901390+ @param hits The documents that matched the search query
13911391+ @param metadata Custom JSON object that can be returned in the search response
13921392+ @param out_of The total number of documents in the collection
13931393+ @param page The search result page number
13941394+ @param search_cutoff Whether the search was cut off
13951395+ @param search_time_ms The number of milliseconds the search took
13961396+ @param union_request_params Returned only for union query response.
13971397+ @param code HTTP error code
13981398+ @param error Error description
13991399+ *)
14001400+ val v : ?conversation:SearchResultConversation.T.t -> ?facet_counts:FacetCounts.T.t list -> ?found:int -> ?found_docs:int -> ?grouped_hits:SearchGroupedHit.T.t list -> ?hits:SearchResultHit.T.t list -> ?metadata:Jsont.json -> ?out_of:int -> ?page:int -> ?request_params:SearchRequestParams.T.t -> ?search_cutoff:bool -> ?search_time_ms:int -> ?union_request_params:SearchRequestParams.T.t list -> ?code:int64 -> ?error:string -> unit -> t
14011401+14021402+ val conversation : t -> SearchResultConversation.T.t option
14031403+14041404+ val facet_counts : t -> FacetCounts.T.t list option
14051405+14061406+ (** The number of documents found *)
14071407+ val found : t -> int option
14081408+14091409+ val found_docs : t -> int option
14101410+14111411+ val grouped_hits : t -> SearchGroupedHit.T.t list option
14121412+14131413+ (** The documents that matched the search query *)
14141414+ val hits : t -> SearchResultHit.T.t list option
14151415+14161416+ (** Custom JSON object that can be returned in the search response *)
14171417+ val metadata : t -> Jsont.json option
14181418+14191419+ (** The total number of documents in the collection *)
14201420+ val out_of : t -> int option
14211421+14221422+ (** The search result page number *)
14231423+ val page : t -> int option
14241424+14251425+ val request_params : t -> SearchRequestParams.T.t option
14261426+14271427+ (** Whether the search was cut off *)
14281428+ val search_cutoff : t -> bool option
14291429+14301430+ (** The number of milliseconds the search took *)
14311431+ val search_time_ms : t -> int option
14321432+14331433+ (** Returned only for union query response. *)
14341434+ val union_request_params : t -> SearchRequestParams.T.t list option
14351435+14361436+ (** HTTP error code *)
14371437+ val code : t -> int64 option
14381438+14391439+ (** Error description *)
14401440+ val error : t -> string option
14411441+14421442+ val jsont : t Jsont.t
14431443+ end
14441444+end
14451445+14461446+module DropTokensMode : sig
14471447+ module T : sig
14481448+ (** Dictates the direction in which the words in the query must be dropped when the original words in the query do not appear in any document. Values: right_to_left (default), left_to_right, both_sides:3 A note on both_sides:3 - for queries up to 3 tokens (words) in length, this mode will drop tokens from both sides and exhaustively rank all matching results. If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left
14491449+ *)
14501450+ type t = [
14511451+ | `Right_to_left
14521452+ | `Left_to_right
14531453+ | `Both_sides3
14541454+ ]
14551455+14561456+ val jsont : t Jsont.t
14571457+ end
14581458+end
14591459+14601460+module SearchParameters : sig
14611461+ module T : sig
14621462+ type t
14631463+14641464+ (** Construct a value
14651465+ @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
14661466+14671467+ @param enable_highlight_v1 Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true
14681468+14691469+ @param enable_overrides 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
14701470+14711471+ @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens.
14721472+14731473+ @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others
14741474+14751475+ @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields.
14761476+14771477+ @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text.
14781478+14791479+ @param cache_ttl 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.
14801480+14811481+ @param conversation Enable conversational search.
14821482+14831483+ @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
14841484+14851485+ @param conversation_model_id The Id of Conversation Model to be used.
14861486+14871487+ @param drop_tokens_threshold 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
14881488+14891489+ @param enable_synonyms If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
14901490+14911491+ @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
14921492+14931493+ @param exclude_fields List of fields from the document to exclude in the search result
14941494+ @param exhaustive_search 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).
14951495+14961496+ @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma.
14971497+ @param facet_query 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".
14981498+ @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response.
14991499+15001500+ @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
15011501+15021502+ @param filter_by Filter conditions for refining your open api validator search results. Separate multiple conditions with &&.
15031503+ @param filter_curated_hits Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
15041504+15051505+ @param group_by 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.
15061506+ @param group_limit 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
15071507+15081508+ @param group_missing_values Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
15091509+15101510+ @param hidden_hits 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`.
15111511+ 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`.
15121512+15131513+ @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4
15141514+15151515+ @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>`
15161516+15171517+ @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them
15181518+15191519+ @param highlight_full_fields List of fields which should be highlighted fully without snippeting
15201520+ @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>`
15211521+15221522+ @param include_fields List of fields from the document to include in the search result
15231523+ @param infix 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
15241524+ @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
15251525+15261526+ @param max_candidates Control the number of words that Typesense considers for typo and prefix searching.
15271527+15281528+ @param max_extra_prefix 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.
15291529+ @param max_extra_suffix 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.
15301530+ @param max_facet_values Maximum number of facet values to be returned.
15311531+ @param max_filter_by_candidates Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*.
15321532+ @param min_len_1typo Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
15331533+15341534+ @param min_len_2typo Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
15351535+15361536+ @param nl_model_id The ID of the natural language model to use.
15371537+ @param nl_query Whether to use natural language processing to parse the query.
15381538+ @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2
15391539+15401540+ @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter.
15411541+ @param override_tags Comma separated list of tags to trigger the curations rules that match the tags.
15421542+ @param page Results from this specific page number would be fetched.
15431543+ @param per_page Number of results to fetch per page. Default: 10
15441544+ @param pinned_hits 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`.
15451545+ 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`.
15461546+15471547+ @param pre_segmented_query 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.
15481548+ Set this parameter to true to do the same
15491549+15501550+ @param prefix 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.
15511551+ @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
15521552+15531553+ @param q 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.
15541554+ @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma.
15551555+ @param query_by_weights 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.
15561556+ @param remote_embedding_num_tries Number of times to retry fetching remote embeddings.
15571557+15581558+ @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings.
15591559+15601560+ @param search_cutoff_ms 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.
15611561+15621562+ @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
15631563+15641564+ @param sort_by 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`
15651565+ @param split_join_tokens 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`.
15661566+15671567+ @param stopwords Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
15681568+15691569+ @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0
15701570+15711571+ @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false
15721572+15731573+ @param synonym_sets List of synonym set names to associate with this search query
15741574+ @param text_match_type 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.
15751575+ @param typo_tokens_threshold 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
15761576+15771577+ @param use_cache Enable server side caching of search query results. By default, caching is disabled.
15781578+15791579+ @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector.
15801580+15811581+ @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format.
15821582+15831583+ *)
15841584+ val v : ?enable_analytics:bool -> ?enable_highlight_v1:bool -> ?enable_overrides:bool -> ?enable_typos_for_numerical_tokens:bool -> ?prioritize_exact_match:bool -> ?prioritize_num_matching_fields:bool -> ?prioritize_token_position:bool -> ?cache_ttl:int -> ?conversation:bool -> ?conversation_id:string -> ?conversation_model_id:string -> ?drop_tokens_mode:DropTokensMode.T.t -> ?drop_tokens_threshold:int -> ?enable_synonyms:bool -> ?enable_typos_for_alpha_numerical_tokens:bool -> ?exclude_fields:string -> ?exhaustive_search:bool -> ?facet_by:string -> ?facet_query:string -> ?facet_return_parent:string -> ?facet_strategy:string -> ?filter_by:string -> ?filter_curated_hits:bool -> ?group_by:string -> ?group_limit:int -> ?group_missing_values:bool -> ?hidden_hits:string -> ?highlight_affix_num_tokens:int -> ?highlight_end_tag:string -> ?highlight_fields:string -> ?highlight_full_fields:string -> ?highlight_start_tag:string -> ?include_fields:string -> ?infix:string -> ?limit:int -> ?max_candidates:int -> ?max_extra_prefix:int -> ?max_extra_suffix:int -> ?max_facet_values:int -> ?max_filter_by_candidates:int -> ?min_len_1typo:int -> ?min_len_2typo:int -> ?nl_model_id:string -> ?nl_query:bool -> ?num_typos:string -> ?offset:int -> ?override_tags:string -> ?page:int -> ?per_page:int -> ?pinned_hits:string -> ?pre_segmented_query:bool -> ?prefix:string -> ?preset:string -> ?q:string -> ?query_by:string -> ?query_by_weights:string -> ?remote_embedding_num_tries:int -> ?remote_embedding_timeout_ms:int -> ?search_cutoff_ms:int -> ?snippet_threshold:int -> ?sort_by:string -> ?split_join_tokens:string -> ?stopwords:string -> ?synonym_num_typos:int -> ?synonym_prefix:bool -> ?synonym_sets:string -> ?text_match_type:string -> ?typo_tokens_threshold:int -> ?use_cache:bool -> ?vector_query:string -> ?voice_query:string -> unit -> t
15851585+15861586+ (** 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.
15871587+ *)
15881588+ val cache_ttl : t -> int option
15891589+15901590+ (** Enable conversational search.
15911591+ *)
15921592+ val conversation : t -> bool option
15931593+15941594+ (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
15951595+ *)
15961596+ val conversation_id : t -> string option
15971597+15981598+ (** The Id of Conversation Model to be used.
15991599+ *)
16001600+ val conversation_model_id : t -> string option
16011601+16021602+ val drop_tokens_mode : t -> DropTokensMode.T.t option
16031603+16041604+ (** 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
16051605+ *)
16061606+ val drop_tokens_threshold : t -> int option
16071607+16081608+ (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
16091609+ *)
16101610+ val enable_analytics : t -> bool
16111611+16121612+ (** Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true
16131613+ *)
16141614+ val enable_highlight_v1 : t -> bool
16151615+16161616+ (** 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
16171617+ *)
16181618+ val enable_overrides : t -> bool
16191619+16201620+ (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
16211621+ *)
16221622+ val enable_synonyms : t -> bool option
16231623+16241624+ (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
16251625+ *)
16261626+ val enable_typos_for_alpha_numerical_tokens : t -> bool option
16271627+16281628+ (** Make Typesense disable typos for numerical tokens.
16291629+ *)
16301630+ val enable_typos_for_numerical_tokens : t -> bool
16311631+16321632+ (** List of fields from the document to exclude in the search result *)
16331633+ val exclude_fields : t -> string option
16341634+16351635+ (** 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).
16361636+ *)
16371637+ val exhaustive_search : t -> bool option
16381638+16391639+ (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
16401640+ val facet_by : t -> string option
16411641+16421642+ (** 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". *)
16431643+ val facet_query : t -> string option
16441644+16451645+ (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
16461646+ *)
16471647+ val facet_return_parent : t -> string option
16481648+16491649+ (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
16501650+ *)
16511651+ val facet_strategy : t -> string option
16521652+16531653+ (** Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. *)
16541654+ val filter_by : t -> string option
16551655+16561656+ (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
16571657+ *)
16581658+ val filter_curated_hits : t -> bool option
16591659+16601660+ (** 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. *)
16611661+ val group_by : t -> string option
16621662+16631663+ (** 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
16641664+ *)
16651665+ val group_limit : t -> int option
16661666+16671667+ (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
16681668+ *)
16691669+ val group_missing_values : t -> bool option
16701670+16711671+ (** 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`.
16721672+ 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`.
16731673+ *)
16741674+ val hidden_hits : t -> string option
16751675+16761676+ (** The number of tokens that should surround the highlighted text on each side. Default: 4
16771677+ *)
16781678+ val highlight_affix_num_tokens : t -> int option
16791679+16801680+ (** The end tag used for the highlighted snippets. Default: `</mark>`
16811681+ *)
16821682+ val highlight_end_tag : t -> string option
16831683+16841684+ (** A list of custom fields that must be highlighted even if you don't query for them
16851685+ *)
16861686+ val highlight_fields : t -> string option
16871687+16881688+ (** List of fields which should be highlighted fully without snippeting *)
16891689+ val highlight_full_fields : t -> string option
16901690+16911691+ (** The start tag used for the highlighted snippets. Default: `<mark>`
16921692+ *)
16931693+ val highlight_start_tag : t -> string option
16941694+16951695+ (** List of fields from the document to include in the search result *)
16961696+ val include_fields : t -> string option
16971697+16981698+ (** 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 *)
16991699+ val infix : t -> string option
17001700+17011701+ (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
17021702+ *)
17031703+ val limit : t -> int option
17041704+17051705+ (** Control the number of words that Typesense considers for typo and prefix searching.
17061706+ *)
17071707+ val max_candidates : t -> int option
17081708+17091709+ (** 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. *)
17101710+ val max_extra_prefix : t -> int option
17111711+17121712+ (** 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. *)
17131713+ val max_extra_suffix : t -> int option
17141714+17151715+ (** Maximum number of facet values to be returned. *)
17161716+ val max_facet_values : t -> int option
17171717+17181718+ (** Controls the number of similar words that Typesense considers during fuzzy search on filter_by values. Useful for controlling prefix matches like company_name:Acm*. *)
17191719+ val max_filter_by_candidates : t -> int option
17201720+17211721+ (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
17221722+ *)
17231723+ val min_len_1typo : t -> int option
17241724+17251725+ (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
17261726+ *)
17271727+ val min_len_2typo : t -> int option
17281728+17291729+ (** The ID of the natural language model to use. *)
17301730+ val nl_model_id : t -> string option
17311731+17321732+ (** Whether to use natural language processing to parse the query. *)
17331733+ val nl_query : t -> bool option
17341734+17351735+ (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
17361736+ *)
17371737+ val num_typos : t -> string option
17381738+17391739+ (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
17401740+ val offset : t -> int option
17411741+17421742+ (** Comma separated list of tags to trigger the curations rules that match the tags. *)
17431743+ val override_tags : t -> string option
17441744+17451745+ (** Results from this specific page number would be fetched. *)
17461746+ val page : t -> int option
17471747+17481748+ (** Number of results to fetch per page. Default: 10 *)
17491749+ val per_page : t -> int option
17501750+17511751+ (** 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`.
17521752+ 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`.
17531753+ *)
17541754+ val pinned_hits : t -> string option
17551755+17561756+ (** 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.
17571757+ Set this parameter to true to do the same
17581758+ *)
17591759+ val pre_segmented_query : t -> bool option
17601760+17611761+ (** 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. *)
17621762+ val prefix : t -> string option
17631763+17641764+ (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
17651765+ *)
17661766+ val preset : t -> string option
17671767+17681768+ (** Set this parameter to true to ensure that an exact match is ranked above the others
17691769+ *)
17701770+ val prioritize_exact_match : t -> bool
17711771+17721772+ (** Make Typesense prioritize documents where the query words appear in more number of fields.
17731773+ *)
17741774+ val prioritize_num_matching_fields : t -> bool
17751775+17761776+ (** Make Typesense prioritize documents where the query words appear earlier in the text.
17771777+ *)
17781778+ val prioritize_token_position : t -> bool
17791779+17801780+ (** 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. *)
17811781+ val q : t -> string option
17821782+17831783+ (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
17841784+ val query_by : t -> string option
17851785+17861786+ (** 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. *)
17871787+ val query_by_weights : t -> string option
17881788+17891789+ (** Number of times to retry fetching remote embeddings.
17901790+ *)
17911791+ val remote_embedding_num_tries : t -> int option
17921792+17931793+ (** Timeout (in milliseconds) for fetching remote embeddings.
17941794+ *)
17951795+ val remote_embedding_timeout_ms : t -> int option
17961796+17971797+ (** 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.
17981798+ *)
17991799+ val search_cutoff_ms : t -> int option
18001800+18011801+ (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
18021802+ *)
18031803+ val snippet_threshold : t -> int option
18041804+18051805+ (** 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` *)
18061806+ val sort_by : t -> string option
18071807+18081808+ (** 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`.
18091809+ *)
18101810+ val split_join_tokens : t -> string option
18111811+18121812+ (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
18131813+ *)
18141814+ val stopwords : t -> string option
18151815+18161816+ (** Allow synonym resolution on typo-corrected words in the query. Default: 0
18171817+ *)
18181818+ val synonym_num_typos : t -> int option
18191819+18201820+ (** Allow synonym resolution on word prefixes in the query. Default: false
18211821+ *)
18221822+ val synonym_prefix : t -> bool option
18231823+18241824+ (** List of synonym set names to associate with this search query *)
18251825+ val synonym_sets : t -> string option
18261826+18271827+ (** 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. *)
18281828+ val text_match_type : t -> string option
18291829+18301830+ (** 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
18311831+ *)
18321832+ val typo_tokens_threshold : t -> int option
18331833+18341834+ (** Enable server side caching of search query results. By default, caching is disabled.
18351835+ *)
18361836+ val use_cache : t -> bool option
18371837+18381838+ (** Vector query expression for fetching documents "closest" to a given query/document vector.
18391839+ *)
18401840+ val vector_query : t -> string option
18411841+18421842+ (** The base64 encoded audio file in 16 khz 16-bit WAV format.
18431843+ *)
18441844+ val voice_query : t -> string option
18451845+18461846+ val jsont : t Jsont.t
18471847+ end
18481848+end
18491849+18501850+module MultiSearchParameters : sig
18511851+ module T : sig
18521852+ (** Parameters for the multi search API.
18531853+ *)
18541854+ type t
18551855+18561856+ (** Construct a value
18571857+ @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
18581858+18591859+ @param enable_overrides 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
18601860+18611861+ @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens.
18621862+18631863+ @param pre_segmented_query 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.
18641864+ Set this parameter to true to do the same
18651865+18661866+ @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others
18671867+18681868+ @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields.
18691869+18701870+ @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text.
18711871+18721872+ @param cache_ttl 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.
18731873+18741874+ @param conversation Enable conversational search.
18751875+18761876+ @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
18771877+18781878+ @param conversation_model_id The Id of Conversation Model to be used.
18791879+18801880+ @param drop_tokens_threshold 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
18811881+18821882+ @param enable_synonyms If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
18831883+18841884+ @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
18851885+18861886+ @param exclude_fields List of fields from the document to exclude in the search result
18871887+ @param exhaustive_search 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).
18881888+18891889+ @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma.
18901890+ @param facet_query 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".
18911891+ @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response.
18921892+18931893+ @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
18941894+18951895+ @param filter_by Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&.
18961896+ @param filter_curated_hits Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
18971897+18981898+ @param group_by 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.
18991899+ @param group_limit 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
19001900+19011901+ @param group_missing_values Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
19021902+19031903+ @param hidden_hits 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`.
19041904+ 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`.
19051905+19061906+ @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4
19071907+19081908+ @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>`
19091909+19101910+ @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them
19111911+19121912+ @param highlight_full_fields List of fields which should be highlighted fully without snippeting
19131913+ @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>`
19141914+19151915+ @param include_fields List of fields from the document to include in the search result
19161916+ @param infix 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
19171917+ @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
19181918+19191919+ @param max_extra_prefix 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.
19201920+ @param max_extra_suffix 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.
19211921+ @param max_facet_values Maximum number of facet values to be returned.
19221922+ @param min_len_1typo Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
19231923+19241924+ @param min_len_2typo Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
19251925+19261926+ @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2
19271927+19281928+ @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter.
19291929+ @param override_tags Comma separated list of tags to trigger the curations rules that match the tags.
19301930+ @param page Results from this specific page number would be fetched.
19311931+ @param per_page Number of results to fetch per page. Default: 10
19321932+ @param pinned_hits 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`.
19331933+ 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`.
19341934+19351935+ @param prefix 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.
19361936+ @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
19371937+19381938+ @param q 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.
19391939+ @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma.
19401940+ @param query_by_weights 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.
19411941+ @param remote_embedding_num_tries Number of times to retry fetching remote embeddings.
19421942+19431943+ @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings.
19441944+19451945+ @param search_cutoff_ms 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.
19461946+19471947+ @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
19481948+19491949+ @param sort_by 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`
19501950+ @param stopwords Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
19511951+19521952+ @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0
19531953+19541954+ @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false
19551955+19561956+ @param text_match_type 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.
19571957+ @param typo_tokens_threshold 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
19581958+19591959+ @param use_cache Enable server side caching of search query results. By default, caching is disabled.
19601960+19611961+ @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector.
19621962+19631963+ @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format.
19641964+19651965+ *)
19661966+ val v : ?enable_analytics:bool -> ?enable_overrides:bool -> ?enable_typos_for_numerical_tokens:bool -> ?pre_segmented_query:bool -> ?prioritize_exact_match:bool -> ?prioritize_num_matching_fields:bool -> ?prioritize_token_position:bool -> ?cache_ttl:int -> ?conversation:bool -> ?conversation_id:string -> ?conversation_model_id:string -> ?drop_tokens_mode:DropTokensMode.T.t -> ?drop_tokens_threshold:int -> ?enable_synonyms:bool -> ?enable_typos_for_alpha_numerical_tokens:bool -> ?exclude_fields:string -> ?exhaustive_search:bool -> ?facet_by:string -> ?facet_query:string -> ?facet_return_parent:string -> ?facet_strategy:string -> ?filter_by:string -> ?filter_curated_hits:bool -> ?group_by:string -> ?group_limit:int -> ?group_missing_values:bool -> ?hidden_hits:string -> ?highlight_affix_num_tokens:int -> ?highlight_end_tag:string -> ?highlight_fields:string -> ?highlight_full_fields:string -> ?highlight_start_tag:string -> ?include_fields:string -> ?infix:string -> ?limit:int -> ?max_extra_prefix:int -> ?max_extra_suffix:int -> ?max_facet_values:int -> ?min_len_1typo:int -> ?min_len_2typo:int -> ?num_typos:string -> ?offset:int -> ?override_tags:string -> ?page:int -> ?per_page:int -> ?pinned_hits:string -> ?prefix:string -> ?preset:string -> ?q:string -> ?query_by:string -> ?query_by_weights:string -> ?remote_embedding_num_tries:int -> ?remote_embedding_timeout_ms:int -> ?search_cutoff_ms:int -> ?snippet_threshold:int -> ?sort_by:string -> ?stopwords:string -> ?synonym_num_typos:int -> ?synonym_prefix:bool -> ?text_match_type:string -> ?typo_tokens_threshold:int -> ?use_cache:bool -> ?vector_query:string -> ?voice_query:string -> unit -> t
19671967+19681968+ (** 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.
19691969+ *)
19701970+ val cache_ttl : t -> int option
19711971+19721972+ (** Enable conversational search.
19731973+ *)
19741974+ val conversation : t -> bool option
19751975+19761976+ (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
19771977+ *)
19781978+ val conversation_id : t -> string option
19791979+19801980+ (** The Id of Conversation Model to be used.
19811981+ *)
19821982+ val conversation_model_id : t -> string option
19831983+19841984+ val drop_tokens_mode : t -> DropTokensMode.T.t option
19851985+19861986+ (** 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
19871987+ *)
19881988+ val drop_tokens_threshold : t -> int option
19891989+19901990+ (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
19911991+ *)
19921992+ val enable_analytics : t -> bool
19931993+19941994+ (** 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
19951995+ *)
19961996+ val enable_overrides : t -> bool
19971997+19981998+ (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
19991999+ *)
20002000+ val enable_synonyms : t -> bool option
20012001+20022002+ (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
20032003+ *)
20042004+ val enable_typos_for_alpha_numerical_tokens : t -> bool option
20052005+20062006+ (** Make Typesense disable typos for numerical tokens.
20072007+ *)
20082008+ val enable_typos_for_numerical_tokens : t -> bool
20092009+20102010+ (** List of fields from the document to exclude in the search result *)
20112011+ val exclude_fields : t -> string option
20122012+20132013+ (** 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).
20142014+ *)
20152015+ val exhaustive_search : t -> bool option
20162016+20172017+ (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
20182018+ val facet_by : t -> string option
20192019+20202020+ (** 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". *)
20212021+ val facet_query : t -> string option
20222022+20232023+ (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
20242024+ *)
20252025+ val facet_return_parent : t -> string option
20262026+20272027+ (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
20282028+ *)
20292029+ val facet_strategy : t -> string option
20302030+20312031+ (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *)
20322032+ val filter_by : t -> string option
20332033+20342034+ (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
20352035+ *)
20362036+ val filter_curated_hits : t -> bool option
20372037+20382038+ (** 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. *)
20392039+ val group_by : t -> string option
20402040+20412041+ (** 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
20422042+ *)
20432043+ val group_limit : t -> int option
20442044+20452045+ (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
20462046+ *)
20472047+ val group_missing_values : t -> bool option
20482048+20492049+ (** 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`.
20502050+ 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`.
20512051+ *)
20522052+ val hidden_hits : t -> string option
20532053+20542054+ (** The number of tokens that should surround the highlighted text on each side. Default: 4
20552055+ *)
20562056+ val highlight_affix_num_tokens : t -> int option
20572057+20582058+ (** The end tag used for the highlighted snippets. Default: `</mark>`
20592059+ *)
20602060+ val highlight_end_tag : t -> string option
20612061+20622062+ (** A list of custom fields that must be highlighted even if you don't query for them
20632063+ *)
20642064+ val highlight_fields : t -> string option
20652065+20662066+ (** List of fields which should be highlighted fully without snippeting *)
20672067+ val highlight_full_fields : t -> string option
20682068+20692069+ (** The start tag used for the highlighted snippets. Default: `<mark>`
20702070+ *)
20712071+ val highlight_start_tag : t -> string option
20722072+20732073+ (** List of fields from the document to include in the search result *)
20742074+ val include_fields : t -> string option
20752075+20762076+ (** 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 *)
20772077+ val infix : t -> string option
20782078+20792079+ (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
20802080+ *)
20812081+ val limit : t -> int option
20822082+20832083+ (** 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. *)
20842084+ val max_extra_prefix : t -> int option
20852085+20862086+ (** 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. *)
20872087+ val max_extra_suffix : t -> int option
20882088+20892089+ (** Maximum number of facet values to be returned. *)
20902090+ val max_facet_values : t -> int option
20912091+20922092+ (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
20932093+ *)
20942094+ val min_len_1typo : t -> int option
20952095+20962096+ (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
20972097+ *)
20982098+ val min_len_2typo : t -> int option
20992099+21002100+ (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
21012101+ *)
21022102+ val num_typos : t -> string option
21032103+21042104+ (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
21052105+ val offset : t -> int option
21062106+21072107+ (** Comma separated list of tags to trigger the curations rules that match the tags. *)
21082108+ val override_tags : t -> string option
21092109+21102110+ (** Results from this specific page number would be fetched. *)
21112111+ val page : t -> int option
21122112+21132113+ (** Number of results to fetch per page. Default: 10 *)
21142114+ val per_page : t -> int option
21152115+21162116+ (** 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`.
21172117+ 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`.
21182118+ *)
21192119+ val pinned_hits : t -> string option
21202120+21212121+ (** 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.
21222122+ Set this parameter to true to do the same
21232123+ *)
21242124+ val pre_segmented_query : t -> bool
21252125+21262126+ (** 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. *)
21272127+ val prefix : t -> string option
21282128+21292129+ (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
21302130+ *)
21312131+ val preset : t -> string option
21322132+21332133+ (** Set this parameter to true to ensure that an exact match is ranked above the others
21342134+ *)
21352135+ val prioritize_exact_match : t -> bool
21362136+21372137+ (** Make Typesense prioritize documents where the query words appear in more number of fields.
21382138+ *)
21392139+ val prioritize_num_matching_fields : t -> bool
21402140+21412141+ (** Make Typesense prioritize documents where the query words appear earlier in the text.
21422142+ *)
21432143+ val prioritize_token_position : t -> bool
21442144+21452145+ (** 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. *)
21462146+ val q : t -> string option
21472147+21482148+ (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
21492149+ val query_by : t -> string option
21502150+21512151+ (** 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. *)
21522152+ val query_by_weights : t -> string option
21532153+21542154+ (** Number of times to retry fetching remote embeddings.
21552155+ *)
21562156+ val remote_embedding_num_tries : t -> int option
21572157+21582158+ (** Timeout (in milliseconds) for fetching remote embeddings.
21592159+ *)
21602160+ val remote_embedding_timeout_ms : t -> int option
21612161+21622162+ (** 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.
21632163+ *)
21642164+ val search_cutoff_ms : t -> int option
21652165+21662166+ (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
21672167+ *)
21682168+ val snippet_threshold : t -> int option
21692169+21702170+ (** 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` *)
21712171+ val sort_by : t -> string option
21722172+21732173+ (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
21742174+ *)
21752175+ val stopwords : t -> string option
21762176+21772177+ (** Allow synonym resolution on typo-corrected words in the query. Default: 0
21782178+ *)
21792179+ val synonym_num_typos : t -> int option
21802180+21812181+ (** Allow synonym resolution on word prefixes in the query. Default: false
21822182+ *)
21832183+ val synonym_prefix : t -> bool option
21842184+21852185+ (** 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. *)
21862186+ val text_match_type : t -> string option
21872187+21882188+ (** 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
21892189+ *)
21902190+ val typo_tokens_threshold : t -> int option
21912191+21922192+ (** Enable server side caching of search query results. By default, caching is disabled.
21932193+ *)
21942194+ val use_cache : t -> bool option
21952195+21962196+ (** Vector query expression for fetching documents "closest" to a given query/document vector.
21972197+ *)
21982198+ val vector_query : t -> string option
21992199+22002200+ (** The base64 encoded audio file in 16 khz 16-bit WAV format.
22012201+ *)
22022202+ val voice_query : t -> string option
22032203+22042204+ val jsont : t Jsont.t
22052205+ end
22062206+end
22072207+22082208+module MultiSearchCollectionParameters : sig
22092209+ module T : sig
22102210+ type t
22112211+22122212+ (** Construct a value
22132213+ @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
22142214+22152215+ @param enable_overrides 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
22162216+22172217+ @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens.
22182218+22192219+ @param pre_segmented_query 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.
22202220+ Set this parameter to true to do the same
22212221+22222222+ @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others
22232223+22242224+ @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields.
22252225+22262226+ @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text.
22272227+22282228+ @param rerank_hybrid_matches When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score.
22292229+22302230+ @param cache_ttl 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.
22312231+22322232+ @param conversation Enable conversational search.
22332233+22342234+ @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
22352235+22362236+ @param conversation_model_id The Id of Conversation Model to be used.
22372237+22382238+ @param drop_tokens_threshold 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
22392239+22402240+ @param enable_synonyms If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
22412241+22422242+ @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
22432243+22442244+ @param exclude_fields List of fields from the document to exclude in the search result
22452245+ @param exhaustive_search 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).
22462246+22472247+ @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma.
22482248+ @param facet_query 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".
22492249+ @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response.
22502250+22512251+ @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
22522252+22532253+ @param filter_by Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&.
22542254+ @param filter_curated_hits Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
22552255+22562256+ @param group_by 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.
22572257+ @param group_limit 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
22582258+22592259+ @param group_missing_values Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
22602260+22612261+ @param hidden_hits 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`.
22622262+ 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`.
22632263+22642264+ @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4
22652265+22662266+ @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>`
22672267+22682268+ @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them
22692269+22702270+ @param highlight_full_fields List of fields which should be highlighted fully without snippeting
22712271+ @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>`
22722272+22732273+ @param include_fields List of fields from the document to include in the search result
22742274+ @param infix 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
22752275+ @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
22762276+22772277+ @param max_extra_prefix 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.
22782278+ @param max_extra_suffix 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.
22792279+ @param max_facet_values Maximum number of facet values to be returned.
22802280+ @param min_len_1typo Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
22812281+22822282+ @param min_len_2typo Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
22832283+22842284+ @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2
22852285+22862286+ @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter.
22872287+ @param override_tags Comma separated list of tags to trigger the curations rules that match the tags.
22882288+ @param page Results from this specific page number would be fetched.
22892289+ @param per_page Number of results to fetch per page. Default: 10
22902290+ @param pinned_hits 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`.
22912291+ 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`.
22922292+22932293+ @param prefix 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.
22942294+ @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
22952295+22962296+ @param q 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.
22972297+ @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma.
22982298+ @param query_by_weights 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.
22992299+ @param remote_embedding_num_tries Number of times to retry fetching remote embeddings.
23002300+23012301+ @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings.
23022302+23032303+ @param search_cutoff_ms 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.
23042304+23052305+ @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
23062306+23072307+ @param sort_by 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`
23082308+ @param stopwords Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
23092309+23102310+ @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0
23112311+23122312+ @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false
23132313+23142314+ @param text_match_type 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.
23152315+ @param typo_tokens_threshold 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
23162316+23172317+ @param use_cache Enable server side caching of search query results. By default, caching is disabled.
23182318+23192319+ @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector.
23202320+23212321+ @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format.
23222322+23232323+ @param collection The collection to search in.
23242324+23252325+ @param x_typesense_api_key A separate search API key for each search within a multi_search request
23262326+ *)
23272327+ val v : ?enable_analytics:bool -> ?enable_overrides:bool -> ?enable_typos_for_numerical_tokens:bool -> ?pre_segmented_query:bool -> ?prioritize_exact_match:bool -> ?prioritize_num_matching_fields:bool -> ?prioritize_token_position:bool -> ?rerank_hybrid_matches:bool -> ?cache_ttl:int -> ?conversation:bool -> ?conversation_id:string -> ?conversation_model_id:string -> ?drop_tokens_mode:DropTokensMode.T.t -> ?drop_tokens_threshold:int -> ?enable_synonyms:bool -> ?enable_typos_for_alpha_numerical_tokens:bool -> ?exclude_fields:string -> ?exhaustive_search:bool -> ?facet_by:string -> ?facet_query:string -> ?facet_return_parent:string -> ?facet_strategy:string -> ?filter_by:string -> ?filter_curated_hits:bool -> ?group_by:string -> ?group_limit:int -> ?group_missing_values:bool -> ?hidden_hits:string -> ?highlight_affix_num_tokens:int -> ?highlight_end_tag:string -> ?highlight_fields:string -> ?highlight_full_fields:string -> ?highlight_start_tag:string -> ?include_fields:string -> ?infix:string -> ?limit:int -> ?max_extra_prefix:int -> ?max_extra_suffix:int -> ?max_facet_values:int -> ?min_len_1typo:int -> ?min_len_2typo:int -> ?num_typos:string -> ?offset:int -> ?override_tags:string -> ?page:int -> ?per_page:int -> ?pinned_hits:string -> ?prefix:string -> ?preset:string -> ?q:string -> ?query_by:string -> ?query_by_weights:string -> ?remote_embedding_num_tries:int -> ?remote_embedding_timeout_ms:int -> ?search_cutoff_ms:int -> ?snippet_threshold:int -> ?sort_by:string -> ?stopwords:string -> ?synonym_num_typos:int -> ?synonym_prefix:bool -> ?text_match_type:string -> ?typo_tokens_threshold:int -> ?use_cache:bool -> ?vector_query:string -> ?voice_query:string -> ?collection:string -> ?x_typesense_api_key:string -> unit -> t
23282328+23292329+ (** 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.
23302330+ *)
23312331+ val cache_ttl : t -> int option
23322332+23332333+ (** Enable conversational search.
23342334+ *)
23352335+ val conversation : t -> bool option
23362336+23372337+ (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM.
23382338+ *)
23392339+ val conversation_id : t -> string option
23402340+23412341+ (** The Id of Conversation Model to be used.
23422342+ *)
23432343+ val conversation_model_id : t -> string option
23442344+23452345+ val drop_tokens_mode : t -> DropTokensMode.T.t option
23462346+23472347+ (** 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
23482348+ *)
23492349+ val drop_tokens_threshold : t -> int option
23502350+23512351+ (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script).
23522352+ *)
23532353+ val enable_analytics : t -> bool
23542354+23552355+ (** 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
23562356+ *)
23572357+ val enable_overrides : t -> bool
23582358+23592359+ (** If you have some synonyms defined but want to disable all of them for a particular search query, set enable_synonyms to false. Default: true
23602360+ *)
23612361+ val enable_synonyms : t -> bool option
23622362+23632363+ (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true.
23642364+ *)
23652365+ val enable_typos_for_alpha_numerical_tokens : t -> bool option
23662366+23672367+ (** Make Typesense disable typos for numerical tokens.
23682368+ *)
23692369+ val enable_typos_for_numerical_tokens : t -> bool
23702370+23712371+ (** List of fields from the document to exclude in the search result *)
23722372+ val exclude_fields : t -> string option
23732373+23742374+ (** 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).
23752375+ *)
23762376+ val exhaustive_search : t -> bool option
23772377+23782378+ (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *)
23792379+ val facet_by : t -> string option
23802380+23812381+ (** 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". *)
23822382+ val facet_query : t -> string option
23832383+23842384+ (** Comma separated string of nested facet fields whose parent object should be returned in facet response.
23852385+ *)
23862386+ val facet_return_parent : t -> string option
23872387+23882388+ (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default).
23892389+ *)
23902390+ val facet_strategy : t -> string option
23912391+23922392+ (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *)
23932393+ val filter_by : t -> string option
23942394+23952395+ (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false
23962396+ *)
23972397+ val filter_curated_hits : t -> bool option
23982398+23992399+ (** 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. *)
24002400+ val group_by : t -> string option
24012401+24022402+ (** 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
24032403+ *)
24042404+ val group_limit : t -> int option
24052405+24062406+ (** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true
24072407+ *)
24082408+ val group_missing_values : t -> bool option
24092409+24102410+ (** 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`.
24112411+ 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`.
24122412+ *)
24132413+ val hidden_hits : t -> string option
24142414+24152415+ (** The number of tokens that should surround the highlighted text on each side. Default: 4
24162416+ *)
24172417+ val highlight_affix_num_tokens : t -> int option
24182418+24192419+ (** The end tag used for the highlighted snippets. Default: `</mark>`
24202420+ *)
24212421+ val highlight_end_tag : t -> string option
24222422+24232423+ (** A list of custom fields that must be highlighted even if you don't query for them
24242424+ *)
24252425+ val highlight_fields : t -> string option
24262426+24272427+ (** List of fields which should be highlighted fully without snippeting *)
24282428+ val highlight_full_fields : t -> string option
24292429+24302430+ (** The start tag used for the highlighted snippets. Default: `<mark>`
24312431+ *)
24322432+ val highlight_start_tag : t -> string option
24332433+24342434+ (** List of fields from the document to include in the search result *)
24352435+ val include_fields : t -> string option
24362436+24372437+ (** 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 *)
24382438+ val infix : t -> string option
24392439+24402440+ (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10.
24412441+ *)
24422442+ val limit : t -> int option
24432443+24442444+ (** 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. *)
24452445+ val max_extra_prefix : t -> int option
24462446+24472447+ (** 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. *)
24482448+ val max_extra_suffix : t -> int option
24492449+24502450+ (** Maximum number of facet values to be returned. *)
24512451+ val max_facet_values : t -> int option
24522452+24532453+ (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
24542454+ *)
24552455+ val min_len_1typo : t -> int option
24562456+24572457+ (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos.
24582458+ *)
24592459+ val min_len_2typo : t -> int option
24602460+24612461+ (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2
24622462+ *)
24632463+ val num_typos : t -> string option
24642464+24652465+ (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *)
24662466+ val offset : t -> int option
24672467+24682468+ (** Comma separated list of tags to trigger the curations rules that match the tags. *)
24692469+ val override_tags : t -> string option
24702470+24712471+ (** Results from this specific page number would be fetched. *)
24722472+ val page : t -> int option
24732473+24742474+ (** Number of results to fetch per page. Default: 10 *)
24752475+ val per_page : t -> int option
24762476+24772477+ (** 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`.
24782478+ 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`.
24792479+ *)
24802480+ val pinned_hits : t -> string option
24812481+24822482+ (** 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.
24832483+ Set this parameter to true to do the same
24842484+ *)
24852485+ val pre_segmented_query : t -> bool
24862486+24872487+ (** 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. *)
24882488+ val prefix : t -> string option
24892489+24902490+ (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset.
24912491+ *)
24922492+ val preset : t -> string option
24932493+24942494+ (** Set this parameter to true to ensure that an exact match is ranked above the others
24952495+ *)
24962496+ val prioritize_exact_match : t -> bool
24972497+24982498+ (** Make Typesense prioritize documents where the query words appear in more number of fields.
24992499+ *)
25002500+ val prioritize_num_matching_fields : t -> bool
25012501+25022502+ (** Make Typesense prioritize documents where the query words appear earlier in the text.
25032503+ *)
25042504+ val prioritize_token_position : t -> bool
25052505+25062506+ (** 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. *)
25072507+ val q : t -> string option
25082508+25092509+ (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *)
25102510+ val query_by : t -> string option
25112511+25122512+ (** 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. *)
25132513+ val query_by_weights : t -> string option
25142514+25152515+ (** Number of times to retry fetching remote embeddings.
25162516+ *)
25172517+ val remote_embedding_num_tries : t -> int option
25182518+25192519+ (** Timeout (in milliseconds) for fetching remote embeddings.
25202520+ *)
25212521+ val remote_embedding_timeout_ms : t -> int option
25222522+25232523+ (** 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.
25242524+ *)
25252525+ val search_cutoff_ms : t -> int option
25262526+25272527+ (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30
25282528+ *)
25292529+ val snippet_threshold : t -> int option
25302530+25312531+ (** 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` *)
25322532+ val sort_by : t -> string option
25332533+25342534+ (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query.
25352535+ *)
25362536+ val stopwords : t -> string option
25372537+25382538+ (** Allow synonym resolution on typo-corrected words in the query. Default: 0
25392539+ *)
25402540+ val synonym_num_typos : t -> int option
25412541+25422542+ (** Allow synonym resolution on word prefixes in the query. Default: false
25432543+ *)
25442544+ val synonym_prefix : t -> bool option
25452545+25462546+ (** 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. *)
25472547+ val text_match_type : t -> string option
25482548+25492549+ (** 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
25502550+ *)
25512551+ val typo_tokens_threshold : t -> int option
25522552+25532553+ (** Enable server side caching of search query results. By default, caching is disabled.
25542554+ *)
25552555+ val use_cache : t -> bool option
25562556+25572557+ (** Vector query expression for fetching documents "closest" to a given query/document vector.
25582558+ *)
25592559+ val vector_query : t -> string option
25602560+25612561+ (** The base64 encoded audio file in 16 khz 16-bit WAV format.
25622562+ *)
25632563+ val voice_query : t -> string option
25642564+25652565+ (** The collection to search in.
25662566+ *)
25672567+ val collection : t -> string option
25682568+25692569+ (** A separate search API key for each search within a multi_search request *)
25702570+ val x_typesense_api_key : t -> string option
25712571+25722572+ (** When true, computes both text match and vector distance scores for all matches in hybrid search. Documents found only through keyword search will get a vector distance score, and documents found only through vector search will get a text match score.
25732573+ *)
25742574+ val rerank_hybrid_matches : t -> bool
25752575+25762576+ val jsont : t Jsont.t
25772577+ end
25782578+end
25792579+25802580+module MultiSearchSearchesParameter : sig
25812581+ module T : sig
25822582+ type t
25832583+25842584+ (** Construct a value
25852585+ @param union When true, merges the search results from each search query into a single ordered set of hits.
25862586+ *)
25872587+ val v : searches:MultiSearchCollectionParameters.T.t list -> ?union:bool -> unit -> t
25882588+25892589+ val searches : t -> MultiSearchCollectionParameters.T.t list
25902590+25912591+ (** When true, merges the search results from each search query into a single ordered set of hits. *)
25922592+ val union : t -> bool
25932593+25942594+ val jsont : t Jsont.t
25952595+ end
25962596+end
25972597+25982598+module MultiSearch : sig
25992599+ module Result : sig
26002600+ type t
26012601+26022602+ (** Construct a value *)
26032603+ val v : results:MultiSearchResult.Item.t list -> ?conversation:SearchResultConversation.T.t -> unit -> t
26042604+26052605+ val conversation : t -> SearchResultConversation.T.t option
26062606+26072607+ val results : t -> MultiSearchResult.Item.t list
26082608+26092609+ val jsont : t Jsont.t
26102610+ end
26112611+26122612+ (** send multiple search requests in a single HTTP request
26132613+26142614+ 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. *)
26152615+ val multi_search : multi_search_parameters:string -> body:MultiSearchSearchesParameter.T.t -> t -> unit -> Result.t
26162616+end
26172617+26182618+module DirtyValues : sig
26192619+ module T : sig
26202620+ type t = [
26212621+ | `Coerce_or_reject
26222622+ | `Coerce_or_drop
26232623+ | `Drop
26242624+ | `Reject
26252625+ ]
26262626+26272627+ val jsont : t Jsont.t
26282628+ end
26292629+end
26302630+26312631+module CurationSetDeleteSchema : sig
26322632+ module T : sig
26332633+ type t
26342634+26352635+ (** Construct a value
26362636+ @param name Name of the deleted curation set
26372637+ *)
26382638+ val v : name:string -> unit -> t
26392639+26402640+ (** Name of the deleted curation set *)
26412641+ val name : t -> string
26422642+26432643+ val jsont : t Jsont.t
26442644+ end
26452645+26462646+ (** Delete a curation set
26472647+26482648+ Delete a specific curation set by its name
26492649+ @param curation_set_name The name of the curation set to delete
26502650+ *)
26512651+ val delete_curation_set : curation_set_name:string -> t -> unit -> T.t
26522652+end
26532653+26542654+module CurationRule : sig
26552655+ module T : sig
26562656+ type t
26572657+26582658+ (** Construct a value
26592659+ @param filter_by Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc).
26602660+26612661+ @param match_ 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.
26622662+26632663+ @param query Indicates what search queries should be curated
26642664+ @param tags List of tag values to associate with this curation rule.
26652665+ *)
26662666+ val v : ?filter_by:string -> ?match_:string -> ?query:string -> ?tags:string list -> unit -> t
26672667+26682668+ (** Indicates that the curation should apply when the filter_by parameter in a search query exactly matches the string specified here (including backticks, spaces, brackets, etc).
26692669+ *)
26702670+ val filter_by : t -> string option
26712671+26722672+ (** 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.
26732673+ *)
26742674+ val match_ : t -> string option
26752675+26762676+ (** Indicates what search queries should be curated *)
26772677+ val query : t -> string option
26782678+26792679+ (** List of tag values to associate with this curation rule. *)
26802680+ val tags : t -> string list option
26812681+26822682+ val jsont : t Jsont.t
26832683+ end
26842684+end
26852685+26862686+module CurationItemDeleteSchema : sig
26872687+ module T : sig
26882688+ type t
26892689+26902690+ (** Construct a value
26912691+ @param id ID of the deleted curation item
26922692+ *)
26932693+ val v : id:string -> unit -> t
26942694+26952695+ (** ID of the deleted curation item *)
26962696+ val id : t -> string
26972697+26982698+ val jsont : t Jsont.t
26992699+ end
27002700+27012701+ (** Delete a curation set item
27022702+27032703+ Delete a specific curation item by its id
27042704+ @param curation_set_name The name of the curation set
27052705+ @param item_id The id of the curation item to delete
27062706+ *)
27072707+ val delete_curation_set_item : curation_set_name:string -> item_id:string -> t -> unit -> T.t
27082708+end
27092709+27102710+module CurationInclude : sig
27112711+ module T : sig
27122712+ type t
27132713+27142714+ (** Construct a value
27152715+ @param id document id that should be included
27162716+ @param position position number where document should be included in the search results
27172717+ *)
27182718+ val v : id:string -> position:int -> unit -> t
27192719+27202720+ (** document id that should be included *)
27212721+ val id : t -> string
27222722+27232723+ (** position number where document should be included in the search results *)
27242724+ val position : t -> int
27252725+27262726+ val jsont : t Jsont.t
27272727+ end
27282728+end
27292729+27302730+module CurationExclude : sig
27312731+ module T : sig
27322732+ type t
27332733+27342734+ (** Construct a value
27352735+ @param id document id that should be excluded from the search results.
27362736+ *)
27372737+ val v : id:string -> unit -> t
27382738+27392739+ (** document id that should be excluded from the search results. *)
27402740+ val id : t -> string
27412741+27422742+ val jsont : t Jsont.t
27432743+ end
27442744+end
27452745+27462746+module CurationItemCreateSchema : sig
27472747+ module T : sig
27482748+ type t
27492749+27502750+ (** Construct a value
27512751+ @param effective_from_ts A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
27522752+27532753+ @param effective_to_ts A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
27542754+27552755+ @param excludes List of document `id`s that should be excluded from the search results.
27562756+ @param filter_by A filter by clause that is applied to any search query that matches the curation rule.
27572757+27582758+ @param filter_curated_hits When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
27592759+27602760+ @param id ID of the curation item
27612761+ @param includes List of document `id`s that should be included in the search results with their corresponding `position`s.
27622762+ @param metadata 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.
27632763+27642764+ @param remove_matched_tokens Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
27652765+27662766+ @param replace_query Replaces the current search query with this value, when the search query matches the curation rule.
27672767+27682768+ @param sort_by A sort by clause that is applied to any search query that matches the curation rule.
27692769+27702770+ @param stop_processing When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
27712771+27722772+ *)
27732773+ val v : rule:CurationRule.T.t -> ?effective_from_ts:int -> ?effective_to_ts:int -> ?excludes:CurationExclude.T.t list -> ?filter_by:string -> ?filter_curated_hits:bool -> ?id:string -> ?includes:CurationInclude.T.t list -> ?metadata:Jsont.json -> ?remove_matched_tokens:bool -> ?replace_query:string -> ?sort_by:string -> ?stop_processing:bool -> unit -> t
27742774+27752775+ (** A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
27762776+ *)
27772777+ val effective_from_ts : t -> int option
27782778+27792779+ (** A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
27802780+ *)
27812781+ val effective_to_ts : t -> int option
27822782+27832783+ (** List of document `id`s that should be excluded from the search results. *)
27842784+ val excludes : t -> CurationExclude.T.t list option
27852785+27862786+ (** A filter by clause that is applied to any search query that matches the curation rule.
27872787+ *)
27882788+ val filter_by : t -> string option
27892789+27902790+ (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
27912791+ *)
27922792+ val filter_curated_hits : t -> bool option
27932793+27942794+ (** ID of the curation item *)
27952795+ val id : t -> string option
27962796+27972797+ (** List of document `id`s that should be included in the search results with their corresponding `position`s. *)
27982798+ val includes : t -> CurationInclude.T.t list option
27992799+28002800+ (** 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.
28012801+ *)
28022802+ val metadata : t -> Jsont.json option
28032803+28042804+ (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
28052805+ *)
28062806+ val remove_matched_tokens : t -> bool option
28072807+28082808+ (** Replaces the current search query with this value, when the search query matches the curation rule.
28092809+ *)
28102810+ val replace_query : t -> string option
28112811+28122812+ val rule : t -> CurationRule.T.t
28132813+28142814+ (** A sort by clause that is applied to any search query that matches the curation rule.
28152815+ *)
28162816+ val sort_by : t -> string option
28172817+28182818+ (** When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
28192819+ *)
28202820+ val stop_processing : t -> bool option
28212821+28222822+ val jsont : t Jsont.t
28232823+ end
28242824+end
28252825+28262826+module CurationSetCreateSchema : sig
28272827+ module T : sig
28282828+ type t
28292829+28302830+ (** Construct a value
28312831+ @param items Array of curation items
28322832+ @param description Optional description for the curation set
28332833+ *)
28342834+ val v : items:CurationItemCreateSchema.T.t list -> ?description:string -> unit -> t
28352835+28362836+ (** Optional description for the curation set *)
28372837+ val description : t -> string option
28382838+28392839+ (** Array of curation items *)
28402840+ val items : t -> CurationItemCreateSchema.T.t list
28412841+28422842+ val jsont : t Jsont.t
28432843+ end
28442844+end
28452845+28462846+module CurationSetSchema : sig
28472847+ module T : sig
28482848+ type t
28492849+28502850+ (** Construct a value
28512851+ @param items Array of curation items
28522852+ @param description Optional description for the curation set
28532853+ *)
28542854+ val v : items:CurationItemCreateSchema.T.t list -> name:string -> ?description:string -> unit -> t
28552855+28562856+ (** Optional description for the curation set *)
28572857+ val description : t -> string option
28582858+28592859+ (** Array of curation items *)
28602860+ val items : t -> CurationItemCreateSchema.T.t list
28612861+28622862+ val name : t -> string
28632863+28642864+ val jsont : t Jsont.t
28652865+ end
28662866+28672867+ (** List all curation sets
28682868+28692869+ Retrieve all curation sets *)
28702870+ val retrieve_curation_sets : t -> unit -> T.t
28712871+28722872+ (** Retrieve a curation set
28732873+28742874+ Retrieve a specific curation set by its name
28752875+ @param curation_set_name The name of the curation set to retrieve
28762876+ *)
28772877+ val retrieve_curation_set : curation_set_name:string -> t -> unit -> T.t
28782878+28792879+ (** Create or update a curation set
28802880+28812881+ Create or update a curation set with the given name
28822882+ @param curation_set_name The name of the curation set to create/update
28832883+ *)
28842884+ val upsert_curation_set : curation_set_name:string -> body:CurationSetCreateSchema.T.t -> t -> unit -> T.t
28852885+end
28862886+28872887+module CurationItemSchema : sig
28882888+ module T : sig
28892889+ type t
28902890+28912891+ (** Construct a value
28922892+ @param effective_from_ts A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
28932893+28942894+ @param effective_to_ts A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
28952895+28962896+ @param excludes List of document `id`s that should be excluded from the search results.
28972897+ @param filter_by A filter by clause that is applied to any search query that matches the curation rule.
28982898+28992899+ @param filter_curated_hits When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
29002900+29012901+ @param includes List of document `id`s that should be included in the search results with their corresponding `position`s.
29022902+ @param metadata 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.
29032903+29042904+ @param remove_matched_tokens Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
29052905+29062906+ @param replace_query Replaces the current search query with this value, when the search query matches the curation rule.
29072907+29082908+ @param sort_by A sort by clause that is applied to any search query that matches the curation rule.
29092909+29102910+ @param stop_processing When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
29112911+29122912+ *)
29132913+ val v : rule:CurationRule.T.t -> id:string -> ?effective_from_ts:int -> ?effective_to_ts:int -> ?excludes:CurationExclude.T.t list -> ?filter_by:string -> ?filter_curated_hits:bool -> ?includes:CurationInclude.T.t list -> ?metadata:Jsont.json -> ?remove_matched_tokens:bool -> ?replace_query:string -> ?sort_by:string -> ?stop_processing:bool -> unit -> t
29142914+29152915+ (** A Unix timestamp that indicates the date/time from which the curation will be active. You can use this to create rules that start applying from a future point in time.
29162916+ *)
29172917+ val effective_from_ts : t -> int option
29182918+29192919+ (** A Unix timestamp that indicates the date/time until which the curation will be active. You can use this to create rules that stop applying after a period of time.
29202920+ *)
29212921+ val effective_to_ts : t -> int option
29222922+29232923+ (** List of document `id`s that should be excluded from the search results. *)
29242924+ val excludes : t -> CurationExclude.T.t list option
29252925+29262926+ (** A filter by clause that is applied to any search query that matches the curation rule.
29272927+ *)
29282928+ val filter_by : t -> string option
29292929+29302930+ (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false.
29312931+ *)
29322932+ val filter_curated_hits : t -> bool option
29332933+29342934+ (** List of document `id`s that should be included in the search results with their corresponding `position`s. *)
29352935+ val includes : t -> CurationInclude.T.t list option
29362936+29372937+ (** 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.
29382938+ *)
29392939+ val metadata : t -> Jsont.json option
29402940+29412941+ (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query.
29422942+ *)
29432943+ val remove_matched_tokens : t -> bool option
29442944+29452945+ (** Replaces the current search query with this value, when the search query matches the curation rule.
29462946+ *)
29472947+ val replace_query : t -> string option
29482948+29492949+ val rule : t -> CurationRule.T.t
29502950+29512951+ (** A sort by clause that is applied to any search query that matches the curation rule.
29522952+ *)
29532953+ val sort_by : t -> string option
29542954+29552955+ (** When set to true, curation processing will stop at the first matching rule. When set to false curation processing will continue and multiple curation actions will be triggered in sequence. Curations are processed in the lexical sort order of their id field.
29562956+ *)
29572957+ val stop_processing : t -> bool option
29582958+29592959+ val id : t -> string
29602960+29612961+ val jsont : t Jsont.t
29622962+ end
29632963+29642964+ (** List items in a curation set
29652965+29662966+ Retrieve all curation items in a set
29672967+ @param curation_set_name The name of the curation set to retrieve items for
29682968+ *)
29692969+ val retrieve_curation_set_items : curation_set_name:string -> t -> unit -> T.t
29702970+29712971+ (** Retrieve a curation set item
29722972+29732973+ Retrieve a specific curation item by its id
29742974+ @param curation_set_name The name of the curation set
29752975+ @param item_id The id of the curation item to retrieve
29762976+ *)
29772977+ val retrieve_curation_set_item : curation_set_name:string -> item_id:string -> t -> unit -> T.t
29782978+29792979+ (** Create or update a curation set item
29802980+29812981+ Create or update a curation set item with the given id
29822982+ @param curation_set_name The name of the curation set
29832983+ @param item_id The id of the curation item to upsert
29842984+ *)
29852985+ val upsert_curation_set_item : curation_set_name:string -> item_id:string -> body:CurationItemCreateSchema.T.t -> t -> unit -> T.t
29862986+end
29872987+29882988+module ConversationModelUpdateSchema : sig
29892989+ module T : sig
29902990+ type t
29912991+29922992+ (** Construct a value
29932993+ @param account_id LLM service's account ID (only applicable for Cloudflare)
29942994+ @param api_key The LLM service's API Key
29952995+ @param history_collection Typesense collection that stores the historical conversations
29962996+ @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id.
29972997+ @param max_bytes The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
29982998+29992999+ @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM
30003000+ @param system_prompt The system prompt that contains special instructions to the LLM
30013001+ @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
30023002+30033003+ @param vllm_url URL of vLLM service
30043004+ *)
30053005+ val v : ?account_id:string -> ?api_key:string -> ?history_collection:string -> ?id:string -> ?max_bytes:int -> ?model_name:string -> ?system_prompt:string -> ?ttl:int -> ?vllm_url:string -> unit -> t
30063006+30073007+ (** LLM service's account ID (only applicable for Cloudflare) *)
30083008+ val account_id : t -> string option
30093009+30103010+ (** The LLM service's API Key *)
30113011+ val api_key : t -> string option
30123012+30133013+ (** Typesense collection that stores the historical conversations *)
30143014+ val history_collection : t -> string option
30153015+30163016+ (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
30173017+ val id : t -> string option
30183018+30193019+ (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
30203020+ *)
30213021+ val max_bytes : t -> int option
30223022+30233023+ (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
30243024+ val model_name : t -> string option
30253025+30263026+ (** The system prompt that contains special instructions to the LLM *)
30273027+ val system_prompt : t -> string option
30283028+30293029+ (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
30303030+ *)
30313031+ val ttl : t -> int option
30323032+30333033+ (** URL of vLLM service *)
30343034+ val vllm_url : t -> string option
30353035+30363036+ val jsont : t Jsont.t
30373037+ end
30383038+end
30393039+30403040+module ConversationModelCreateSchema : sig
30413041+ module T : sig
30423042+ type t
30433043+30443044+ (** Construct a value
30453045+ @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM
30463046+ @param max_bytes The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
30473047+30483048+ @param history_collection Typesense collection that stores the historical conversations
30493049+ @param account_id LLM service's account ID (only applicable for Cloudflare)
30503050+ @param api_key The LLM service's API Key
30513051+ @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id.
30523052+ @param system_prompt The system prompt that contains special instructions to the LLM
30533053+ @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
30543054+30553055+ @param vllm_url URL of vLLM service
30563056+ *)
30573057+ val v : model_name:string -> max_bytes:int -> history_collection:string -> ?account_id:string -> ?api_key:string -> ?id:string -> ?system_prompt:string -> ?ttl:int -> ?vllm_url:string -> unit -> t
30583058+30593059+ (** LLM service's account ID (only applicable for Cloudflare) *)
30603060+ val account_id : t -> string option
30613061+30623062+ (** The LLM service's API Key *)
30633063+ val api_key : t -> string option
30643064+30653065+ (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
30663066+ val id : t -> string option
30673067+30683068+ (** The system prompt that contains special instructions to the LLM *)
30693069+ val system_prompt : t -> string option
30703070+30713071+ (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
30723072+ *)
30733073+ val ttl : t -> int option
30743074+30753075+ (** URL of vLLM service *)
30763076+ val vllm_url : t -> string option
30773077+30783078+ (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
30793079+ val model_name : t -> string
30803080+30813081+ (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
30823082+ *)
30833083+ val max_bytes : t -> int
30843084+30853085+ (** Typesense collection that stores the historical conversations *)
30863086+ val history_collection : t -> string
30873087+30883088+ val jsont : t Jsont.t
30893089+ end
30903090+end
30913091+30923092+module ConversationModelSchema : sig
30933093+ module T : sig
30943094+ type t
30953095+30963096+ (** Construct a value
30973097+ @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM
30983098+ @param max_bytes The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
30993099+31003100+ @param history_collection Typesense collection that stores the historical conversations
31013101+ @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id.
31023102+ @param account_id LLM service's account ID (only applicable for Cloudflare)
31033103+ @param api_key The LLM service's API Key
31043104+ @param system_prompt The system prompt that contains special instructions to the LLM
31053105+ @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
31063106+31073107+ @param vllm_url URL of vLLM service
31083108+ *)
31093109+ val v : model_name:string -> max_bytes:int -> history_collection:string -> id:string -> ?account_id:string -> ?api_key:string -> ?system_prompt:string -> ?ttl:int -> ?vllm_url:string -> unit -> t
31103110+31113111+ (** LLM service's account ID (only applicable for Cloudflare) *)
31123112+ val account_id : t -> string option
31133113+31143114+ (** The LLM service's API Key *)
31153115+ val api_key : t -> string option
31163116+31173117+ (** The system prompt that contains special instructions to the LLM *)
31183118+ val system_prompt : t -> string option
31193119+31203120+ (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours)
31213121+ *)
31223122+ val ttl : t -> int option
31233123+31243124+ (** URL of vLLM service *)
31253125+ val vllm_url : t -> string option
31263126+31273127+ (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *)
31283128+ val model_name : t -> string
31293129+31303130+ (** The maximum number of bytes to send to the LLM in every API call. Consult the LLM's documentation on the number of bytes supported in the context window.
31313131+ *)
31323132+ val max_bytes : t -> int
31333133+31343134+ (** Typesense collection that stores the historical conversations *)
31353135+ val history_collection : t -> string
31363136+31373137+ (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *)
31383138+ val id : t -> string
31393139+31403140+ val jsont : t Jsont.t
31413141+ end
31423142+31433143+ (** List all conversation models
31443144+31453145+ Retrieve all conversation models *)
31463146+ val retrieve_all_conversation_models : t -> unit -> T.t
31473147+31483148+ (** Create a conversation model
31493149+31503150+ Create a Conversation Model *)
31513151+ val create_conversation_model : body:ConversationModelCreateSchema.T.t -> t -> unit -> T.t
31523152+31533153+ (** Retrieve a conversation model
31543154+31553155+ Retrieve a conversation model
31563156+ @param model_id The id of the conversation model to retrieve
31573157+ *)
31583158+ val retrieve_conversation_model : model_id:string -> t -> unit -> T.t
31593159+31603160+ (** Update a conversation model
31613161+31623162+ Update a conversation model
31633163+ @param model_id The id of the conversation model to update
31643164+ *)
31653165+ val update_conversation_model : model_id:string -> body:ConversationModelUpdateSchema.T.t -> t -> unit -> T.t
31663166+31673167+ (** Delete a conversation model
31683168+31693169+ Delete a conversation model
31703170+ @param model_id The id of the conversation model to delete
31713171+ *)
31723172+ val delete_conversation_model : model_id:string -> t -> unit -> T.t
31733173+end
31743174+31753175+module CollectionAliasSchema : sig
31763176+ module T : sig
31773177+ type t
31783178+31793179+ (** Construct a value
31803180+ @param collection_name Name of the collection you wish to map the alias to
31813181+ *)
31823182+ val v : collection_name:string -> unit -> t
31833183+31843184+ (** Name of the collection you wish to map the alias to *)
31853185+ val collection_name : t -> string
31863186+31873187+ val jsont : t Jsont.t
31883188+ end
31893189+end
31903190+31913191+module CollectionAlias : sig
31923192+ module T : sig
31933193+ type t
31943194+31953195+ (** Construct a value
31963196+ @param collection_name Name of the collection the alias mapped to
31973197+ @param name Name of the collection alias
31983198+ *)
31993199+ val v : collection_name:string -> name:string -> unit -> t
32003200+32013201+ (** Name of the collection the alias mapped to *)
32023202+ val collection_name : t -> string
32033203+32043204+ (** Name of the collection alias *)
32053205+ val name : t -> string
32063206+32073207+ val jsont : t Jsont.t
32083208+ end
32093209+32103210+ (** Retrieve an alias
32113211+32123212+ Find out which collection an alias points to by fetching it
32133213+ @param alias_name The name of the alias to retrieve
32143214+ *)
32153215+ val get_alias : alias_name:string -> t -> unit -> T.t
32163216+32173217+ (** Create or update a collection alias
32183218+32193219+ 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.
32203220+ @param alias_name The name of the alias to create/update
32213221+ *)
32223222+ val upsert_alias : alias_name:string -> body:CollectionAliasSchema.T.t -> t -> unit -> T.t
32233223+32243224+ (** Delete an alias
32253225+ @param alias_name The name of the alias to delete
32263226+ *)
32273227+ val delete_alias : alias_name:string -> t -> unit -> T.t
32283228+end
32293229+32303230+module CollectionAliases : sig
32313231+ module Response : sig
32323232+ type t
32333233+32343234+ (** Construct a value *)
32353235+ val v : aliases:CollectionAlias.T.t list -> unit -> t
32363236+32373237+ val aliases : t -> CollectionAlias.T.t list
32383238+32393239+ val jsont : t Jsont.t
32403240+ end
32413241+32423242+ (** List all aliases
32433243+32443244+ List all aliases and the corresponding collections that they map to. *)
32453245+ val get_aliases : t -> unit -> Response.t
32463246+end
32473247+32483248+module Client : sig
32493249+ (** Create analytics rule(s)
32503250+32513251+ Create one or more analytics rules. You can send a single rule object or an array of rule objects. *)
32523252+ val create_analytics_rule : t -> unit -> Jsont.json
32533253+32543254+ (** Index a document
32553255+32563256+ A document to be indexed in a given collection must conform to the schema of the collection.
32573257+ @param collection_name The name of the collection to add the document to
32583258+ @param action Additional action to perform
32593259+ @param dirty_values Dealing with Dirty Data
32603260+ *)
32613261+ val index_document : collection_name:string -> ?action:string -> ?dirty_values:string -> t -> unit -> Jsont.json
32623262+32633263+ (** Delete a bunch of documents
32643264+32653265+ 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.
32663266+ @param collection_name The name of the collection to delete documents from
32673267+ *)
32683268+ val delete_documents : collection_name:string -> ?delete_documents_parameters:string -> t -> unit -> Jsont.json
32693269+32703270+ (** Update documents with conditional query
32713271+32723272+ 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.
32733273+ @param collection_name The name of the collection to update documents in
32743274+ *)
32753275+ val update_documents : collection_name:string -> ?update_documents_parameters:string -> t -> unit -> Jsont.json
32763276+32773277+ (** Export all documents in a collection
32783278+32793279+ Export all documents in a collection in JSON lines format.
32803280+ @param collection_name The name of the collection
32813281+ *)
32823282+ val export_documents : collection_name:string -> ?export_documents_parameters:string -> t -> unit -> Jsont.json
32833283+32843284+ (** Import documents into a collection
32853285+32863286+ 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.
32873287+ @param collection_name The name of the collection
32883288+ *)
32893289+ val import_documents : collection_name:string -> ?import_documents_parameters:string -> t -> unit -> Jsont.json
32903290+32913291+ (** Retrieve a document
32923292+32933293+ Fetch an individual document from a collection by using its ID.
32943294+ @param collection_name The name of the collection to search for the document under
32953295+ @param document_id The Document ID
32963296+ *)
32973297+ val get_document : collection_name:string -> document_id:string -> t -> unit -> Jsont.json
32983298+32993299+ (** Delete a document
33003300+33013301+ Delete an individual document from a collection by using its ID.
33023302+ @param collection_name The name of the collection to search for the document under
33033303+ @param document_id The Document ID
33043304+ *)
33053305+ val delete_document : collection_name:string -> document_id:string -> t -> unit -> Jsont.json
33063306+33073307+ (** Update a document
33083308+33093309+ Update an individual document from a collection by using its ID. The update can be partial.
33103310+ @param collection_name The name of the collection to search for the document under
33113311+ @param document_id The Document ID
33123312+ @param dirty_values Dealing with Dirty Data
33133313+ *)
33143314+ val update_document : collection_name:string -> document_id:string -> ?dirty_values:string -> t -> unit -> Jsont.json
33153315+33163316+ (** Print debugging information
33173317+33183318+ Print debugging information *)
33193319+ val debug : t -> unit -> Jsont.json
33203320+33213321+ (** Get current RAM, CPU, Disk & Network usage metrics.
33223322+33233323+ Retrieve the metrics. *)
33243324+ val retrieve_metrics : t -> unit -> Jsont.json
33253325+33263326+ (** List all stemming dictionaries
33273327+33283328+ Retrieve a list of all available stemming dictionaries. *)
33293329+ val list_stemming_dictionaries : t -> unit -> Jsont.json
33303330+33313331+ (** Import a stemming dictionary
33323332+33333333+ Upload a JSONL file containing word mappings to create or update a stemming dictionary.
33343334+ @param id The ID to assign to the dictionary
33353335+ *)
33363336+ val import_stemming_dictionary : id:string -> t -> unit -> Jsont.json
33373337+33383338+ (** Delete a stopwords set.
33393339+33403340+ Permanently deletes a stopwords set, given it's name.
33413341+ @param set_id The ID of the stopwords set to delete.
33423342+ *)
33433343+ val delete_stopwords_set : set_id:string -> t -> unit -> Jsont.json
33443344+end
33453345+33463346+module Apistats : sig
33473347+ module Response : sig
33483348+ type t
33493349+33503350+ (** Construct a value *)
33513351+ val v : ?delete_latency_ms:float -> ?delete_requests_per_second:float -> ?import_latency_ms:float -> ?import_requests_per_second:float -> ?latency_ms:Jsont.json -> ?overloaded_requests_per_second:float -> ?pending_write_batches:float -> ?requests_per_second:Jsont.json -> ?search_latency_ms:float -> ?search_requests_per_second:float -> ?total_requests_per_second:float -> ?write_latency_ms:float -> ?write_requests_per_second:float -> unit -> t
33523352+33533353+ val delete_latency_ms : t -> float option
33543354+33553355+ val delete_requests_per_second : t -> float option
33563356+33573357+ val import_latency_ms : t -> float option
33583358+33593359+ val import_requests_per_second : t -> float option
33603360+33613361+ val latency_ms : t -> Jsont.json option
33623362+33633363+ val overloaded_requests_per_second : t -> float option
33643364+33653365+ val pending_write_batches : t -> float option
33663366+33673367+ val requests_per_second : t -> Jsont.json option
33683368+33693369+ val search_latency_ms : t -> float option
33703370+33713371+ val search_requests_per_second : t -> float option
33723372+33733373+ val total_requests_per_second : t -> float option
33743374+33753375+ val write_latency_ms : t -> float option
33763376+33773377+ val write_requests_per_second : t -> float option
33783378+33793379+ val jsont : t Jsont.t
33803380+ end
33813381+33823382+ (** Get stats about API endpoints.
33833383+33843384+ Retrieve the stats about API endpoints. *)
33853385+ val retrieve_apistats : t -> unit -> Response.t
33863386+end
33873387+33883388+module ApiKeySchema : sig
33893389+ module T : sig
33903390+ type t
33913391+33923392+ (** Construct a value *)
33933393+ val v : actions:string list -> collections:string list -> description:string -> ?expires_at:int64 -> ?value:string -> unit -> t
33943394+33953395+ val actions : t -> string list
33963396+33973397+ val collections : t -> string list
33983398+33993399+ val description : t -> string
34003400+34013401+ val expires_at : t -> int64 option
34023402+34033403+ val value : t -> string option
34043404+34053405+ val jsont : t Jsont.t
34063406+ end
34073407+end
34083408+34093409+module ApiKey : sig
34103410+ module T : sig
34113411+ type t
34123412+34133413+ (** Construct a value *)
34143414+ val v : actions:string list -> collections:string list -> description:string -> ?expires_at:int64 -> ?value:string -> ?id:int64 -> ?value_prefix:string -> unit -> t
34153415+34163416+ val actions : t -> string list
34173417+34183418+ val collections : t -> string list
34193419+34203420+ val description : t -> string
34213421+34223422+ val expires_at : t -> int64 option
34233423+34243424+ val value : t -> string option
34253425+34263426+ val id : t -> int64 option
34273427+34283428+ val value_prefix : t -> string option
34293429+34303430+ val jsont : t Jsont.t
34313431+ end
34323432+34333433+ (** Create an API Key
34343434+34353435+ 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. *)
34363436+ val create_key : body:ApiKeySchema.T.t -> t -> unit -> T.t
34373437+34383438+ (** Retrieve (metadata about) a key
34393439+34403440+ 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.
34413441+ @param key_id The ID of the key to retrieve
34423442+ *)
34433443+ val get_key : key_id:string -> t -> unit -> T.t
34443444+end
34453445+34463446+module ApiKeys : sig
34473447+ module Response : sig
34483448+ type t
34493449+34503450+ (** Construct a value *)
34513451+ val v : keys:ApiKey.T.t list -> unit -> t
34523452+34533453+ val keys : t -> ApiKey.T.t list
34543454+34553455+ val jsont : t Jsont.t
34563456+ end
34573457+34583458+ (** Retrieve (metadata about) all keys. *)
34593459+ val get_keys : t -> unit -> Response.t
34603460+end
34613461+34623462+module ApiKeyDelete : sig
34633463+ module Response : sig
34643464+ type t
34653465+34663466+ (** Construct a value
34673467+ @param id The id of the API key that was deleted
34683468+ *)
34693469+ val v : id:int64 -> unit -> t
34703470+34713471+ (** The id of the API key that was deleted *)
34723472+ val id : t -> int64
34733473+34743474+ val jsont : t Jsont.t
34753475+ end
34763476+34773477+ (** Delete an API key given its ID.
34783478+ @param key_id The ID of the key to delete
34793479+ *)
34803480+ val delete_key : key_id:string -> t -> unit -> Response.t
34813481+end
34823482+34833483+module Api : sig
34843484+ module Response : sig
34853485+ type t
34863486+34873487+ (** Construct a value *)
34883488+ val v : message:string -> unit -> t
34893489+34903490+ val message : t -> string
34913491+34923492+ val jsont : t Jsont.t
34933493+ end
34943494+end
34953495+34963496+module AnalyticsRule : sig
34973497+ module Update : sig
34983498+ (** Fields allowed to update on an analytics rule *)
34993499+ type t
35003500+35013501+ (** Construct a value *)
35023502+ val v : ?name:string -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t
35033503+35043504+ val name : t -> string option
35053505+35063506+ val params : t -> Jsont.json option
35073507+35083508+ val rule_tag : t -> string option
35093509+35103510+ val jsont : t Jsont.t
35113511+ end
35123512+35133513+ module Type : sig
35143514+ type t = [
35153515+ | `Popular_queries
35163516+ | `Nohits_queries
35173517+ | `Counter
35183518+ | `Log
35193519+ ]
35203520+35213521+ val jsont : t Jsont.t
35223522+ end
35233523+35243524+ module Create : sig
35253525+ type t
35263526+35273527+ (** Construct a value *)
35283528+ val v : collection:string -> event_type:string -> name:string -> type_:Type.t -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t
35293529+35303530+ val collection : t -> string
35313531+35323532+ val event_type : t -> string
35333533+35343534+ val name : t -> string
35353535+35363536+ val params : t -> Jsont.json option
35373537+35383538+ val rule_tag : t -> string option
35393539+35403540+ val type_ : t -> Type.t
35413541+35423542+ val jsont : t Jsont.t
35433543+ end
35443544+35453545+ module T : sig
35463546+ type t
35473547+35483548+ (** Construct a value *)
35493549+ val v : collection:string -> event_type:string -> name:string -> type_:Type.t -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t
35503550+35513551+ val collection : t -> string
35523552+35533553+ val event_type : t -> string
35543554+35553555+ val name : t -> string
35563556+35573557+ val params : t -> Jsont.json option
35583558+35593559+ val rule_tag : t -> string option
35603560+35613561+ val type_ : t -> Type.t
35623562+35633563+ val jsont : t Jsont.t
35643564+ end
35653565+35663566+ (** Retrieve analytics rules
35673567+35683568+ Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results.
35693569+ @param rule_tag Filter rules by rule_tag
35703570+ *)
35713571+ val retrieve_analytics_rules : ?rule_tag:string -> t -> unit -> T.t
35723572+35733573+ (** Retrieves an analytics rule
35743574+35753575+ Retrieve the details of an analytics rule, given it's name
35763576+ @param rule_name The name of the analytics rule to retrieve
35773577+ *)
35783578+ val retrieve_analytics_rule : rule_name:string -> t -> unit -> T.t
35793579+35803580+ (** Upserts an analytics rule
35813581+35823582+ Upserts an analytics rule with the given name.
35833583+ @param rule_name The name of the analytics rule to upsert
35843584+ *)
35853585+ val upsert_analytics_rule : rule_name:string -> body:Update.t -> t -> unit -> T.t
35863586+35873587+ (** Delete an analytics rule
35883588+35893589+ Permanently deletes an analytics rule, given it's name
35903590+ @param rule_name The name of the analytics rule to delete
35913591+ *)
35923592+ val delete_analytics_rule : rule_name:string -> t -> unit -> T.t
35933593+end
35943594+35953595+module AnalyticsEvents : sig
35963596+ module Response : sig
35973597+ type t
35983598+35993599+ (** Construct a value *)
36003600+ val v : events:Jsont.json list -> unit -> t
36013601+36023602+ val events : t -> Jsont.json list
36033603+36043604+ val jsont : t Jsont.t
36053605+ end
36063606+36073607+ (** Retrieve analytics events
36083608+36093609+ Retrieve the most recent events for a user and rule.
36103610+ @param name Analytics rule name
36113611+ @param n Number of events to return (max 1000)
36123612+ *)
36133613+ val get_analytics_events : user_id:string -> name:string -> n:string -> t -> unit -> Response.t
36143614+end
36153615+36163616+module AnalyticsEvent : sig
36173617+ module T : sig
36183618+ type t
36193619+36203620+ (** Construct a value
36213621+ @param data Event payload
36223622+ @param event_type Type of event (e.g., click, conversion, query, visit)
36233623+ @param name Name of the analytics rule this event corresponds to
36243624+ *)
36253625+ val v : data:Jsont.json -> event_type:string -> name:string -> unit -> t
36263626+36273627+ (** Event payload *)
36283628+ val data : t -> Jsont.json
36293629+36303630+ (** Type of event (e.g., click, conversion, query, visit) *)
36313631+ val event_type : t -> string
36323632+36333633+ (** Name of the analytics rule this event corresponds to *)
36343634+ val name : t -> string
36353635+36363636+ val jsont : t Jsont.t
36373637+ end
36383638+end
36393639+36403640+module AnalyticsEventCreate : sig
36413641+ module Response : sig
36423642+ type t
36433643+36443644+ (** Construct a value *)
36453645+ val v : ok:bool -> unit -> t
36463646+36473647+ val ok : t -> bool
36483648+36493649+ val jsont : t Jsont.t
36503650+ end
36513651+36523652+ (** Create an analytics event
36533653+36543654+ Submit a single analytics event. The event must correspond to an existing analytics rule by name. *)
36553655+ val create_analytics_event : body:AnalyticsEvent.T.t -> t -> unit -> Response.t
36563656+36573657+ (** Flush in-memory analytics to disk
36583658+36593659+ Triggers a flush of analytics data to persistent storage. *)
36603660+ val flush_analytics : t -> unit -> Response.t
36613661+end
36623662+36633663+module Analytics : sig
36643664+ module Status : sig
36653665+ type t
36663666+36673667+ (** Construct a value *)
36683668+ val v : ?doc_counter_events:int -> ?doc_log_events:int -> ?log_prefix_queries:int -> ?nohits_prefix_queries:int -> ?popular_prefix_queries:int -> ?query_counter_events:int -> ?query_log_events:int -> unit -> t
36693669+36703670+ val doc_counter_events : t -> int option
36713671+36723672+ val doc_log_events : t -> int option
36733673+36743674+ val log_prefix_queries : t -> int option
36753675+36763676+ val nohits_prefix_queries : t -> int option
36773677+36783678+ val popular_prefix_queries : t -> int option
36793679+36803680+ val query_counter_events : t -> int option
36813681+36823682+ val query_log_events : t -> int option
36833683+36843684+ val jsont : t Jsont.t
36853685+ end
36863686+36873687+ (** Get analytics subsystem status
36883688+36893689+ Returns sizes of internal analytics buffers and queues. *)
36903690+ val get_analytics_status : t -> unit -> Status.t
36913691+end