OCaml bindings to the Typesense embeddings search API

Migrate ocaml-typesense to OpenAPI-generated library

Replace the handwritten Typesense bindings with an OpenAPI-generated
library following the pattern established in ocaml-immich and
ocaml-peertube. This provides full Typesense API v30.0 coverage.

Changes:
- Add typesense-openapi.yaml spec from upstream
- Generate typesense.ml/mli using openapi-gen
- Create typesense.auth library with:
- session.ml: Profile-based API key storage
- client.ml: Wrapper with JSONL batch import/export
- error.ml: Typesense error handling
- cmd.ml: Cmdliner integration for auth commands
- Create typesense-cli with commands for:
- auth: login, logout, status, profile management
- collections: list, get, delete
- documents: get, delete, import, export
- search: full-text search with filters
- health: server health check
- Delete old handwritten library (lib/typesense/)
- Update dune-project with new dependencies

The bushel consumer does not depend on the old typesense library,
so there are no backwards compatibility concerns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+16507 -1909
+16
bin/dune
··· 1 + (executable 2 + (name main) 3 + (public_name typesense-cli) 4 + (libraries 5 + typesense 6 + typesense.auth 7 + openapi 8 + requests 9 + jsont 10 + jsont.bytesrw 11 + uri 12 + eio 13 + eio_main 14 + fmt 15 + fmt.tty 16 + cmdliner))
+374
bin/main.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + open Cmdliner 7 + 8 + let version = "0.1.0" 9 + 10 + (* Styled output helpers *) 11 + let header_style = Fmt.(styled `Bold string) 12 + let label_style = Fmt.(styled `Faint string) 13 + let value_style = Fmt.(styled (`Fg `Cyan) string) 14 + let success_style = Fmt.(styled (`Fg `Green) string) 15 + let warning_style = Fmt.(styled (`Fg `Yellow) string) 16 + let error_style = Fmt.(styled (`Fg `Red) string) 17 + 18 + (* Common arguments *) 19 + let collection_arg = 20 + let doc = "Collection name." in 21 + Arg.(required & pos 0 (some string) None & info [] ~docv:"COLLECTION" ~doc) 22 + 23 + let id_arg = 24 + let doc = "Document ID." in 25 + Arg.(required & pos 1 (some string) None & info [] ~docv:"ID" ~doc) 26 + 27 + let file_arg = 28 + let doc = "Path to file." in 29 + Arg.(value & opt (some string) None & info ["file"; "f"] ~docv:"FILE" ~doc) 30 + 31 + let output_arg = 32 + let doc = "Output file path." in 33 + Arg.(value & opt (some string) None & info ["output"; "o"] ~docv:"FILE" ~doc) 34 + 35 + (* Collections commands *) 36 + 37 + let collections_list_cmd env fs = 38 + let doc = "List all collections." in 39 + let info = Cmd.info "list" ~doc in 40 + let action (style_renderer, level) requests_config profile = 41 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 42 + Typesense_auth.Error.wrap (fun () -> 43 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 44 + let api = Typesense_auth.Client.client client in 45 + (* Use raw request since get_collections returns wrong type *) 46 + let session = Typesense.session api in 47 + let base_url = Typesense.base_url api in 48 + let response = Requests.get session (base_url ^ "/collections") in 49 + if not (Requests.Response.ok response) then 50 + failwith ("Failed to list collections: " ^ string_of_int (Requests.Response.status_code response)); 51 + let json = Requests.Response.json response in 52 + match json with 53 + | Jsont.Array (items, _) -> 54 + if items = [] then 55 + Fmt.pr "%a No collections found.@." warning_style "Note:" 56 + else begin 57 + Fmt.pr "%a@." header_style "Collections:"; 58 + List.iter (fun item -> 59 + match Jsont_bytesrw.decode_string Typesense.Collection.Response.jsont 60 + (match Jsont_bytesrw.encode_string Jsont.json item with Ok s -> s | Error _ -> "{}") with 61 + | Ok c -> 62 + let name = Typesense.Collection.Response.name c in 63 + let num_docs = Typesense.Collection.Response.num_documents c in 64 + Fmt.pr " %a (%Ld documents)@." value_style name num_docs 65 + | Error _ -> () 66 + ) items 67 + end 68 + | _ -> failwith "Unexpected response format" 69 + ) env) 70 + in 71 + Cmd.v info 72 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg) 73 + 74 + let collections_get_cmd env fs = 75 + let doc = "Get a collection by name." in 76 + let info = Cmd.info "get" ~doc in 77 + let name_arg = 78 + let doc = "Collection name." in 79 + Arg.(required & pos 0 (some string) None & info [] ~docv:"NAME" ~doc) 80 + in 81 + let action (style_renderer, level) requests_config profile name = 82 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 83 + Typesense_auth.Error.wrap (fun () -> 84 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 85 + let api = Typesense_auth.Client.client client in 86 + let collection = Typesense.Collection.get_collection api ~collection_name:name () in 87 + Fmt.pr "%a %a@." label_style "Name:" value_style (Typesense.Collection.Response.name collection); 88 + Fmt.pr "%a %Ld@." label_style "Documents:" (Typesense.Collection.Response.num_documents collection); 89 + Fmt.pr "%a %a@." label_style "Created:" value_style (Int64.to_string (Typesense.Collection.Response.created_at collection)); 90 + let fields = Typesense.Collection.Response.fields collection in 91 + Fmt.pr "%a@." header_style "Fields:"; 92 + List.iter (fun field -> 93 + let name = Typesense.Field.T.name field in 94 + let type_ = Typesense.Field.T.type_ field in 95 + Fmt.pr " - %a: %s@." value_style name type_ 96 + ) fields 97 + ) env) 98 + in 99 + Cmd.v info 100 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ name_arg) 101 + 102 + let collections_delete_cmd env fs = 103 + let doc = "Delete a collection." in 104 + let info = Cmd.info "delete" ~doc in 105 + let name_arg = 106 + let doc = "Collection name." in 107 + Arg.(required & pos 0 (some string) None & info [] ~docv:"NAME" ~doc) 108 + in 109 + let action (style_renderer, level) requests_config profile name = 110 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 111 + Typesense_auth.Error.wrap (fun () -> 112 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 113 + let api = Typesense_auth.Client.client client in 114 + ignore (Typesense.Collection.delete_collection api ~collection_name:name ()); 115 + Fmt.pr "%a Deleted collection: %a@." success_style "Success:" value_style name 116 + ) env) 117 + in 118 + Cmd.v info 119 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ name_arg) 120 + 121 + let collections_cmd env fs = 122 + let doc = "Collection management commands." in 123 + let info = Cmd.info "collections" ~doc in 124 + Cmd.group info 125 + [ collections_list_cmd env fs 126 + ; collections_get_cmd env fs 127 + ; collections_delete_cmd env fs 128 + ] 129 + 130 + (* Documents commands *) 131 + 132 + let documents_get_cmd env fs = 133 + let doc = "Get a document by ID." in 134 + let info = Cmd.info "get" ~doc in 135 + let action (style_renderer, level) requests_config profile collection id = 136 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 137 + Typesense_auth.Error.wrap (fun () -> 138 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 139 + let api = Typesense_auth.Client.client client in 140 + let doc = Typesense.Client.get_document api ~collection_name:collection ~document_id:id () in 141 + let json_str = match Jsont_bytesrw.encode_string ~format:Jsont.Indent Jsont.json doc with 142 + | Ok s -> s 143 + | Error e -> failwith ("Failed to encode: " ^ e) 144 + in 145 + print_endline json_str 146 + ) env) 147 + in 148 + Cmd.v info 149 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ collection_arg $ id_arg) 150 + 151 + let documents_delete_cmd env fs = 152 + let doc = "Delete a document by ID." in 153 + let info = Cmd.info "delete" ~doc in 154 + let action (style_renderer, level) requests_config profile collection id = 155 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 156 + Typesense_auth.Error.wrap (fun () -> 157 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 158 + let api = Typesense_auth.Client.client client in 159 + ignore (Typesense.Client.delete_document api ~collection_name:collection ~document_id:id ()); 160 + Fmt.pr "%a Deleted document %a from %a@." success_style "Success:" value_style id value_style collection 161 + ) env) 162 + in 163 + Cmd.v info 164 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ collection_arg $ id_arg) 165 + 166 + let documents_import_cmd env fs = 167 + let doc = "Import documents from JSONL file." in 168 + let info = Cmd.info "import" ~doc in 169 + let action_arg = 170 + let doc = "Import action: create, upsert, update, or emplace." in 171 + let actions = ["create", Typesense_auth.Client.Create; "upsert", Typesense_auth.Client.Upsert; "update", Typesense_auth.Client.Update; "emplace", Typesense_auth.Client.Emplace] in 172 + Arg.(value & opt (enum actions) Typesense_auth.Client.Upsert & info ["action"; "a"] ~docv:"ACTION" ~doc) 173 + in 174 + let action (style_renderer, level) requests_config profile collection file action_type = 175 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 176 + Typesense_auth.Error.wrap (fun () -> 177 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 178 + let file = match file with 179 + | Some f -> f 180 + | None -> failwith "Please specify --file" 181 + in 182 + let content = In_channel.with_open_text file In_channel.input_all in 183 + let docs = String.split_on_char '\n' content 184 + |> List.filter (fun line -> String.trim line <> "") 185 + |> List.map (fun line -> 186 + match Jsont_bytesrw.decode_string Jsont.json line with 187 + | Ok doc -> doc 188 + | Error e -> failwith ("Invalid JSON on line: " ^ e)) 189 + in 190 + let results = Typesense_auth.Client.import client ~collection ~action:action_type docs in 191 + let success_count = List.length (List.filter (fun r -> r.Typesense_auth.Client.success) results) in 192 + let error_count = List.length results - success_count in 193 + Fmt.pr "%a Imported %d documents (%d successful, %d errors)@." 194 + success_style "Done:" (List.length results) success_count error_count; 195 + if error_count > 0 then begin 196 + Fmt.pr "%a@." warning_style "Errors:"; 197 + List.iteri (fun i r -> 198 + if not r.Typesense_auth.Client.success then 199 + match r.Typesense_auth.Client.error with 200 + | Some e -> Fmt.pr " Line %d: %s@." (i + 1) e 201 + | None -> Fmt.pr " Line %d: Unknown error@." (i + 1) 202 + ) results 203 + end 204 + ) env) 205 + in 206 + Cmd.v info 207 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ collection_arg $ file_arg $ action_arg) 208 + 209 + let documents_export_cmd env fs = 210 + let doc = "Export documents to JSONL." in 211 + let info = Cmd.info "export" ~doc in 212 + let filter_arg = 213 + let doc = "Filter expression." in 214 + Arg.(value & opt (some string) None & info ["filter"] ~docv:"FILTER" ~doc) 215 + in 216 + let action (style_renderer, level) requests_config profile collection output filter = 217 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 218 + Typesense_auth.Error.wrap (fun () -> 219 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 220 + let params = Typesense_auth.Client.export_params ?filter_by:filter () in 221 + let docs = Typesense_auth.Client.export client ~collection ~params () in 222 + let output_fn = match output with 223 + | Some path -> 224 + let oc = open_out path in 225 + (fun line -> output_string oc (line ^ "\n")), 226 + (fun () -> close_out oc) 227 + | None -> 228 + (fun line -> print_endline line), 229 + (fun () -> ()) 230 + in 231 + let (output_line, close) = output_fn in 232 + List.iter (fun doc -> 233 + match Jsont_bytesrw.encode_string Jsont.json doc with 234 + | Ok s -> output_line s 235 + | Error _ -> () 236 + ) docs; 237 + close (); 238 + Fmt.epr "%a Exported %d documents@." success_style "Done:" (List.length docs) 239 + ) env) 240 + in 241 + Cmd.v info 242 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ collection_arg $ output_arg $ filter_arg) 243 + 244 + let documents_cmd env fs = 245 + let doc = "Document operations." in 246 + let info = Cmd.info "documents" ~doc in 247 + Cmd.group info 248 + [ documents_get_cmd env fs 249 + ; documents_delete_cmd env fs 250 + ; documents_import_cmd env fs 251 + ; documents_export_cmd env fs 252 + ] 253 + 254 + (* Search command *) 255 + 256 + let search_cmd env fs = 257 + let doc = "Search documents in a collection." in 258 + let info = Cmd.info "search" ~doc in 259 + let query_arg = 260 + let doc = "Search query." in 261 + Arg.(required & opt (some string) None & info ["query"; "q"] ~docv:"QUERY" ~doc) 262 + in 263 + let query_by_arg = 264 + let doc = "Fields to search in (comma-separated)." in 265 + Arg.(required & opt (some string) None & info ["query-by"] ~docv:"FIELDS" ~doc) 266 + in 267 + let filter_arg = 268 + let doc = "Filter expression." in 269 + Arg.(value & opt (some string) None & info ["filter-by"] ~docv:"FILTER" ~doc) 270 + in 271 + let limit_arg = 272 + let doc = "Maximum number of results." in 273 + Arg.(value & opt int 10 & info ["limit"; "n"] ~docv:"NUM" ~doc) 274 + in 275 + let action (style_renderer, level) requests_config profile collection query query_by filter limit = 276 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 277 + Typesense_auth.Error.wrap (fun () -> 278 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 279 + let api = Typesense_auth.Client.client client in 280 + (* Build search_parameters query string *) 281 + let params = [ 282 + ("q", query); 283 + ("query_by", query_by); 284 + ("per_page", string_of_int limit); 285 + ] @ (match filter with Some f -> [("filter_by", f)] | None -> []) in 286 + let search_parameters = 287 + params 288 + |> List.map (fun (k, v) -> Uri.pct_encode k ^ "=" ^ Uri.pct_encode v) 289 + |> String.concat "&" 290 + in 291 + let result = Typesense.Search.search_collection api ~collection_name:collection ~search_parameters () in 292 + let found = Option.value ~default:0 (Typesense.Search.Result.found result) in 293 + let hits = Typesense.Search.Result.hits result in 294 + Fmt.pr "%a %d results (showing %d)@." header_style "Found:" found (List.length (Option.value ~default:[] hits)); 295 + match hits with 296 + | None | Some [] -> () 297 + | Some hits -> 298 + List.iter (fun hit -> 299 + match Typesense.SearchResultHit.T.document hit with 300 + | Some doc -> 301 + (match Jsont_bytesrw.encode_string Jsont.json doc with 302 + | Ok s -> print_endline s 303 + | Error _ -> ()) 304 + | None -> () 305 + ) hits 306 + ) env) 307 + in 308 + Cmd.v info 309 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg $ collection_arg $ query_arg $ query_by_arg $ filter_arg $ limit_arg) 310 + 311 + (* Health command *) 312 + 313 + let health_cmd env fs = 314 + let doc = "Check server health." in 315 + let info = Cmd.info "health" ~doc in 316 + let action (style_renderer, level) requests_config profile = 317 + Typesense_auth.Cmd.setup_logging_with_config style_renderer level requests_config; 318 + Typesense_auth.Error.wrap (fun () -> 319 + Typesense_auth.Cmd.with_client ~requests_config ?profile (fun _fs client -> 320 + let api = Typesense_auth.Client.client client in 321 + let health = Typesense.Health.health api () in 322 + if Typesense.Health.Status.ok health then 323 + Fmt.pr "%a Server is healthy@." success_style "OK:" 324 + else 325 + Fmt.pr "%a Server is not healthy@." error_style "Error:" 326 + ) env) 327 + in 328 + Cmd.v info 329 + Term.(const action $ Typesense_auth.Cmd.setup_logging $ Typesense_auth.Cmd.requests_config_term fs $ Typesense_auth.Cmd.profile_arg) 330 + 331 + (* Main *) 332 + 333 + let () = 334 + let exit_code = 335 + try 336 + Eio_main.run @@ fun env -> 337 + let fs = env#fs in 338 + let doc = "Typesense CLI - A command-line interface for Typesense search server" in 339 + let man = [ 340 + `S Manpage.s_description; 341 + `P "A command-line interface for interacting with Typesense search servers."; 342 + `P "Use $(b,typesense-cli auth login) to authenticate with your server."; 343 + `S Manpage.s_commands; 344 + `S Manpage.s_bugs; 345 + `P "Report bugs at https://tangled.org/@anil.recoil.org/ocaml-typesense/issues"; 346 + ] in 347 + let info = Cmd.info "typesense-cli" ~version ~doc ~man in 348 + let cmds = 349 + [ Typesense_auth.Cmd.auth_cmd env fs 350 + ; collections_cmd env fs 351 + ; documents_cmd env fs 352 + ; search_cmd env fs 353 + ; health_cmd env fs 354 + ] 355 + in 356 + Cmd.eval (Cmd.group info cmds) 357 + with 358 + | Eio.Cancel.Cancelled Stdlib.Exit -> 359 + (* Eio wraps Exit in Cancelled when a fiber is cancelled *) 360 + 0 361 + | Typesense_auth.Error.Exit_code code -> 362 + (* Exit code from Error.wrap - already printed error message *) 363 + code 364 + | Openapi.Runtime.Api_error _ as exn -> 365 + (* Handle Typesense API errors with nice formatting *) 366 + Typesense_auth.Error.handle_exn exn 367 + | Failure msg -> 368 + Fmt.epr "Error: %s@." msg; 369 + 1 370 + | exn -> 371 + Fmt.epr "Unexpected error: %s@." (Printexc.to_string exn); 372 + 125 373 + in 374 + exit exit_code
+7
dune
··· 1 + (library 2 + (name typesense) 3 + (public_name typesense) 4 + (libraries openapi jsont jsont.bytesrw requests ptime eio) 5 + (wrapped true)) 6 + 7 + (include dune.inc)
+6
dune-project
··· 26 26 "High-quality OCaml bindings to the Typesense search API using Eio for async operations. Provides collection management, document operations, search, multi-search, and analytics.") 27 27 (depends 28 28 (ocaml (>= 5.1.0)) 29 + (openapi (>= 0.4.0)) 29 30 (eio (>= 1.2)) 31 + (eio_main (>= 1.2)) 30 32 (requests (>= 0.3.1)) 31 33 (uri (>= 4.4.0)) 32 34 (jsont (>= 0.2.0)) 33 35 bytesrw 36 + (ptime (>= 1.0.0)) 37 + ptime-clock-os 38 + (cmdliner (>= 1.3.0)) 39 + (fmt (>= 0.9.0)) 34 40 (logs (>= 0.7.0)) 35 41 (odoc :with-doc) 36 42 (alcotest :with-test)))
+7
dune.inc
··· 1 + (rule 2 + (alias gen) 3 + (mode (promote (until-clean))) 4 + (targets typesense.ml typesense.mli) 5 + (deps typesense-openapi.yaml) 6 + (action 7 + (run openapi-gen generate -o . -n typesense %{deps})))
+172
lib/client.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + type t = { 7 + client : Typesense.t; 8 + session : Session.t; 9 + fs : Eio.Fs.dir_ty Eio.Path.t; 10 + profile : string option; 11 + } 12 + 13 + let create_with_session ~sw ~env ?requests_config ?profile ~session () = 14 + let fs = env#fs in 15 + let server_url = Session.server_url session in 16 + let api_key = Session.api_key session in 17 + (* Create a Requests session, optionally from cmdliner config *) 18 + let requests_session = match requests_config with 19 + | Some config -> Requests.Cmd.create config env sw 20 + | None -> Requests.create ~sw env 21 + in 22 + (* Set the X-TYPESENSE-API-KEY header *) 23 + let requests_session = 24 + Requests.set_default_header requests_session "X-TYPESENSE-API-KEY" api_key 25 + in 26 + let client = Typesense.create ~session:requests_session ~sw env ~base_url:server_url in 27 + { client; session; fs; profile } 28 + 29 + let login ~sw ~env ?requests_config ?profile ~server_url ~api_key () = 30 + let fs = env#fs in 31 + (* Create session with API key header *) 32 + let requests_session = match requests_config with 33 + | Some config -> Requests.Cmd.create config env sw 34 + | None -> Requests.create ~sw env 35 + in 36 + let requests_session = 37 + Requests.set_default_header requests_session "X-TYPESENSE-API-KEY" api_key 38 + in 39 + let client = Typesense.create ~session:requests_session ~sw env ~base_url:server_url in 40 + (* Validate by calling the health endpoint *) 41 + let health = Typesense.Health.health client () in 42 + if not (Typesense.Health.Status.ok health) then 43 + failwith "Health check failed - server not OK"; 44 + (* Create and save session *) 45 + let session = Session.create ~server_url ~api_key () in 46 + Session.save fs ?profile session; 47 + (* Set as current profile if first login or explicitly requested *) 48 + let profiles = Session.list_profiles fs in 49 + let profile_name = Option.value ~default:Session.default_profile profile in 50 + if profiles = [] || Option.is_some profile then 51 + Session.set_current_profile fs profile_name; 52 + { client; session; fs; profile } 53 + 54 + let resume ~sw ~env ?requests_config ?profile ~session () = 55 + create_with_session ~sw ~env ?requests_config ?profile ~session () 56 + 57 + let logout t = 58 + Session.clear t.fs ?profile:t.profile () 59 + 60 + let client t = t.client 61 + let session t = t.session 62 + let profile t = t.profile 63 + let fs t = t.fs 64 + 65 + (** {1 JSONL Helpers} *) 66 + 67 + let parse_jsonl codec response = 68 + String.split_on_char '\n' response 69 + |> List.filter_map (fun line -> 70 + let line = String.trim line in 71 + if line = "" then None 72 + else 73 + match Jsont_bytesrw.decode_string codec line with 74 + | Ok result -> Some result 75 + | Error _ -> None) 76 + 77 + let to_json_string codec value = 78 + match Jsont_bytesrw.encode_string' codec value with 79 + | Ok s -> s 80 + | Error e -> failwith ("JSON encoding error: " ^ Jsont.Error.to_string e) 81 + 82 + (** {1 JSONL Import/Export} *) 83 + 84 + type import_action = Create | Upsert | Update | Emplace 85 + 86 + let action_to_string = function 87 + | Create -> "create" 88 + | Upsert -> "upsert" 89 + | Update -> "update" 90 + | Emplace -> "emplace" 91 + 92 + type import_result = { 93 + success : bool; 94 + error : string option; 95 + document : string option; 96 + } 97 + 98 + let import_result_jsont = 99 + let make success error document = { success; error; document } in 100 + Jsont.Object.map ~kind:"ImportResult" make 101 + |> Jsont.Object.mem "success" Jsont.bool ~enc:(fun r -> r.success) 102 + |> Jsont.Object.opt_mem "error" Jsont.string ~enc:(fun r -> r.error) 103 + |> Jsont.Object.opt_mem "document" Jsont.string ~enc:(fun r -> r.document) 104 + |> Jsont.Object.skip_unknown 105 + |> Jsont.Object.finish 106 + 107 + let import t ~collection ?(action = Upsert) ?(batch_size = 40) 108 + ?(return_doc = false) ?(return_id = false) documents = 109 + let base_url = Typesense.base_url t.client in 110 + let session = Typesense.session t.client in 111 + (* Build URL with query params *) 112 + let params = 113 + [ 114 + ("action", action_to_string action); 115 + ("batch_size", string_of_int batch_size); 116 + ("return_doc", string_of_bool return_doc); 117 + ("return_id", string_of_bool return_id); 118 + ] 119 + in 120 + let query_string = 121 + params 122 + |> List.map (fun (k, v) -> Uri.pct_encode k ^ "=" ^ Uri.pct_encode v) 123 + |> String.concat "&" 124 + in 125 + let url = 126 + base_url ^ "/collections/" ^ Uri.pct_encode collection ^ "/documents/import?" ^ query_string 127 + in 128 + (* Convert documents to JSONL format *) 129 + let body = 130 + documents 131 + |> List.map (fun doc -> to_json_string Jsont.json doc) 132 + |> String.concat "\n" 133 + in 134 + let response = Requests.post session ~body:(Requests.Body.text body) url in 135 + if not (Requests.Response.ok response) then 136 + failwith ("Import failed: " ^ string_of_int (Requests.Response.status_code response)); 137 + parse_jsonl import_result_jsont (Requests.Response.text response) 138 + 139 + type export_params = { 140 + filter_by : string option; 141 + include_fields : string list option; 142 + exclude_fields : string list option; 143 + } 144 + 145 + let export_params ?filter_by ?include_fields ?exclude_fields () = 146 + { filter_by; include_fields; exclude_fields } 147 + 148 + let export t ~collection ?params () = 149 + let base_url = Typesense.base_url t.client in 150 + let session = Typesense.session t.client in 151 + let query_params = 152 + match params with 153 + | None -> [] 154 + | Some p -> 155 + List.filter_map Fun.id 156 + [ 157 + Option.map (fun v -> ("filter_by", v)) p.filter_by; 158 + Option.map 159 + (fun v -> ("include_fields", String.concat "," v)) 160 + p.include_fields; 161 + Option.map 162 + (fun v -> ("exclude_fields", String.concat "," v)) 163 + p.exclude_fields; 164 + ] 165 + in 166 + let url = 167 + base_url ^ "/collections/" ^ Uri.pct_encode collection ^ "/documents/export" 168 + in 169 + let response = Requests.get session ~params:query_params url in 170 + if not (Requests.Response.ok response) then 171 + failwith ("Export failed: " ^ string_of_int (Requests.Response.status_code response)); 172 + parse_jsonl Jsont.json (Requests.Response.text response)
+141
lib/client.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Authenticated Typesense client with session persistence and profile support. 7 + 8 + This module provides a high-level client that wraps the generated 9 + {!Typesense} module with authentication support. Sessions are stored in 10 + profile-specific directories. 11 + 12 + {2 Usage} 13 + 14 + {[ 15 + let t = Client.login ~sw ~env 16 + ~server_url:"http://localhost:8108" 17 + ~api_key:"xyz123" 18 + () in 19 + let collections = Typesense.Collections.list_collections (Client.client t) () 20 + ]} 21 + 22 + {2 Resuming Sessions} 23 + 24 + {[ 25 + match Session.load fs () with 26 + | Some session -> 27 + let t = Client.resume ~sw ~env ~session () in 28 + ... 29 + | None -> 30 + Fmt.epr "Not logged in@." 31 + ]} *) 32 + 33 + type t 34 + (** Authenticated client state. *) 35 + 36 + (** {1 Authentication} *) 37 + 38 + val login : 39 + sw:Eio.Switch.t -> 40 + env:< clock : _ Eio.Time.clock 41 + ; net : _ Eio.Net.t 42 + ; fs : Eio.Fs.dir_ty Eio.Path.t 43 + ; .. > -> 44 + ?requests_config:Requests.Cmd.config -> 45 + ?profile:string -> 46 + server_url:string -> 47 + api_key:string -> 48 + unit -> 49 + t 50 + (** [login ~sw ~env ?requests_config ?profile ~server_url ~api_key ()] 51 + authenticates using an API key. The API key is sent in the 52 + [X-TYPESENSE-API-KEY] header for all requests. 53 + 54 + @param requests_config Optional Requests.Cmd.config for HTTP settings 55 + @param profile Profile name (default: "default") *) 56 + 57 + val resume : 58 + sw:Eio.Switch.t -> 59 + env:< clock : _ Eio.Time.clock 60 + ; net : _ Eio.Net.t 61 + ; fs : Eio.Fs.dir_ty Eio.Path.t 62 + ; .. > -> 63 + ?requests_config:Requests.Cmd.config -> 64 + ?profile:string -> 65 + session:Session.t -> 66 + unit -> 67 + t 68 + (** [resume ~sw ~env ?requests_config ?profile ~session ()] resumes from a saved session. 69 + 70 + @param requests_config Optional Requests.Cmd.config for HTTP settings *) 71 + 72 + val logout : t -> unit 73 + (** [logout t] clears the session from disk. *) 74 + 75 + (** {1 Client Access} *) 76 + 77 + val client : t -> Typesense.t 78 + (** [client t] returns the underlying Typesense client for API calls. *) 79 + 80 + val session : t -> Session.t 81 + (** [session t] returns the current session. *) 82 + 83 + val profile : t -> string option 84 + (** [profile t] returns the current profile name, if set. *) 85 + 86 + val fs : t -> Eio.Fs.dir_ty Eio.Path.t 87 + (** [fs t] returns the filesystem capability. *) 88 + 89 + (** {1 JSONL Import/Export} 90 + 91 + These functions provide bulk document operations using JSONL format, 92 + which is more efficient than individual API calls for large batches. *) 93 + 94 + type import_action = Create | Upsert | Update | Emplace 95 + (** The action to perform for each imported document. *) 96 + 97 + type import_result = { 98 + success : bool; 99 + error : string option; 100 + document : string option; 101 + } 102 + (** Result of importing a single document. *) 103 + 104 + val import : 105 + t -> 106 + collection:string -> 107 + ?action:import_action -> 108 + ?batch_size:int -> 109 + ?return_doc:bool -> 110 + ?return_id:bool -> 111 + Jsont.json list -> 112 + import_result list 113 + (** [import t ~collection documents] imports documents using JSONL format. 114 + 115 + @param action Import action (default: Upsert) 116 + @param batch_size Documents per batch (default: 40) 117 + @param return_doc Include document in result (default: false) 118 + @param return_id Include ID in result (default: false) *) 119 + 120 + type export_params = { 121 + filter_by : string option; 122 + include_fields : string list option; 123 + exclude_fields : string list option; 124 + } 125 + (** Parameters for document export. *) 126 + 127 + val export_params : 128 + ?filter_by:string -> 129 + ?include_fields:string list -> 130 + ?exclude_fields:string list -> 131 + unit -> 132 + export_params 133 + (** Create export parameters. *) 134 + 135 + val export : 136 + t -> 137 + collection:string -> 138 + ?params:export_params -> 139 + unit -> 140 + Jsont.json list 141 + (** [export t ~collection ?params ()] exports documents as JSONL. *)
+317
lib/cmd.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + open Cmdliner 7 + 8 + let app_name = "typesense" 9 + 10 + (* Styled output helpers *) 11 + let header_style = Fmt.(styled `Bold string) 12 + let label_style = Fmt.(styled `Faint string) 13 + let value_style = Fmt.(styled (`Fg `Cyan) string) 14 + let success_style = Fmt.(styled (`Fg `Green) string) 15 + let warning_style = Fmt.(styled (`Fg `Yellow) string) 16 + let error_style = Fmt.(styled (`Fg `Red) string) 17 + let profile_style = Fmt.(styled (`Fg `Magenta) string) 18 + let current_style = Fmt.(styled (`Fg `Green) (styled `Bold string)) 19 + 20 + (* Common Arguments *) 21 + 22 + let server_arg = 23 + let doc = "Typesense server URL." in 24 + let env = Cmd.Env.info "TYPESENSE_SERVER" ~doc in 25 + Arg.(required & pos 0 (some string) None & info [] ~env ~docv:"SERVER" ~doc) 26 + 27 + let server_opt = 28 + let doc = "Typesense server URL." in 29 + let env = Cmd.Env.info "TYPESENSE_SERVER" ~doc in 30 + Arg.(value & opt (some string) None & info ["server"; "s"] ~env ~docv:"URL" ~doc) 31 + 32 + let api_key_arg = 33 + let doc = "API key (will prompt if not provided)." in 34 + let env = Cmd.Env.info "TYPESENSE_API_KEY" ~doc in 35 + Arg.(value & opt (some string) None & info ["api-key"; "k"] ~env ~docv:"KEY" ~doc) 36 + 37 + let profile_arg = 38 + let doc = "Profile name (default: current profile)." in 39 + Arg.(value & opt (some string) None & info ["profile"; "P"] ~docv:"PROFILE" ~doc) 40 + 41 + (* Logging setup - takes requests_config to extract verbose_http *) 42 + 43 + let setup_logging_with_config style_renderer level (requests_config : Requests.Cmd.config) = 44 + Fmt_tty.setup_std_outputs ?style_renderer (); 45 + Logs.set_level level; 46 + Logs.set_reporter (Logs_fmt.reporter ()); 47 + Requests.Cmd.setup_log_sources ~verbose_http:requests_config.verbose_http.value level 48 + 49 + let setup_logging_simple style_renderer level = 50 + Fmt_tty.setup_std_outputs ?style_renderer (); 51 + Logs.set_level level; 52 + Logs.set_reporter (Logs_fmt.reporter ()) 53 + 54 + let setup_logging = 55 + Term.(const (fun style_renderer level -> (style_renderer, level)) 56 + $ Fmt_cli.style_renderer () 57 + $ Logs_cli.level ()) 58 + 59 + (* Requests config term *) 60 + 61 + let requests_config_term fs = 62 + Requests.Cmd.config_term app_name fs 63 + 64 + (* Session helper *) 65 + 66 + let with_session ?profile f env = 67 + let fs = env#fs in 68 + match Session.load fs ?profile () with 69 + | None -> 70 + let profile_name = 71 + match profile with 72 + | Some p -> p 73 + | None -> Session.get_current_profile fs 74 + in 75 + Fmt.epr "%a Not logged in (profile: %a). Use '%a' first.@." 76 + error_style "Error:" 77 + profile_style profile_name 78 + Fmt.(styled `Bold string) "typesense-cli auth login"; 79 + raise (Error.Exit_code 1) 80 + | Some session -> f fs session 81 + 82 + let with_client ?requests_config ?profile f env = 83 + with_session ?profile (fun fs session -> 84 + Eio.Switch.run @@ fun sw -> 85 + let client = Client.resume ~sw ~env ?requests_config ?profile ~session () in 86 + f fs client 87 + ) env 88 + 89 + (* Profile configuration for external programs *) 90 + 91 + module Profile_config = struct 92 + type t = { 93 + style_renderer : Fmt.style_renderer option; 94 + log_level : Logs.level option; 95 + requests_config : Requests.Cmd.config; 96 + profile : string option; 97 + } 98 + 99 + let style_renderer t = t.style_renderer 100 + let log_level t = t.log_level 101 + let requests_config t = t.requests_config 102 + let profile t = t.profile 103 + 104 + let setup_logging t = 105 + setup_logging_with_config t.style_renderer t.log_level t.requests_config 106 + end 107 + 108 + let profile_config_term fs = 109 + let make (sr, ll) rc p = 110 + Profile_config.{ style_renderer = sr; log_level = ll; requests_config = rc; profile = p } 111 + in 112 + Term.(const make $ setup_logging $ requests_config_term fs $ profile_arg) 113 + 114 + (* Login command *) 115 + 116 + let login_action ~requests_config ~server ~api_key ~profile env = 117 + let api_key = match api_key with 118 + | Some k -> k 119 + | None -> 120 + Fmt.pr "%a @?" label_style "API Key:"; 121 + read_line () 122 + in 123 + Eio.Switch.run @@ fun sw -> 124 + let client = Client.login ~sw ~env ~requests_config ?profile ~server_url:server ~api_key () in 125 + let profile_name = Option.value ~default:Session.default_profile profile in 126 + Fmt.pr "%a Logged in to %a (profile: %a)@." 127 + success_style "Success:" value_style server profile_style profile_name; 128 + ignore client 129 + 130 + let login_cmd env fs = 131 + let doc = "Login to a Typesense server." in 132 + let info = Cmd.info "login" ~doc in 133 + let login' (style_renderer, level) requests_config server api_key profile = 134 + setup_logging_with_config style_renderer level requests_config; 135 + Error.wrap (fun () -> 136 + login_action ~requests_config ~server ~api_key ~profile env) 137 + in 138 + Cmd.v info 139 + Term.(const login' $ setup_logging $ requests_config_term fs $ server_arg $ api_key_arg $ profile_arg) 140 + 141 + (* Logout command *) 142 + 143 + let logout_action ~profile env = 144 + let fs = env#fs in 145 + match Session.load fs ?profile () with 146 + | None -> Fmt.pr "%a Not logged in.@." warning_style "Note:" 147 + | Some session -> 148 + Session.clear fs ?profile (); 149 + let profile_name = 150 + match profile with 151 + | Some p -> p 152 + | None -> Session.get_current_profile fs 153 + in 154 + Fmt.pr "%a Logged out from %a (profile: %a).@." 155 + success_style "Success:" 156 + value_style (Session.server_url session) 157 + profile_style profile_name 158 + 159 + let logout_cmd env = 160 + let doc = "Logout and clear saved session." in 161 + let info = Cmd.info "logout" ~doc in 162 + let logout' (style_renderer, level) profile = 163 + setup_logging_simple style_renderer level; 164 + logout_action ~profile env 165 + in 166 + Cmd.v info Term.(const logout' $ setup_logging $ profile_arg) 167 + 168 + (* Status command *) 169 + 170 + let status_action ~profile env = 171 + let fs = env#fs in 172 + let home = Sys.getenv "HOME" in 173 + Fmt.pr "%a %a@." label_style "Config directory:" value_style (home ^ "/.config/typesense"); 174 + let current = Session.get_current_profile fs in 175 + Fmt.pr "%a %a@." label_style "Current profile:" current_style current; 176 + let profiles = Session.list_profiles fs in 177 + if profiles <> [] then begin 178 + Fmt.pr "%a %a@." label_style "Available profiles:" 179 + Fmt.(list ~sep:(any ", ") profile_style) profiles 180 + end; 181 + Fmt.pr "@."; 182 + let profile = Option.value ~default:current profile in 183 + match Session.load fs ~profile () with 184 + | None -> 185 + Fmt.pr "%a %a: %a@." 186 + header_style "Profile" 187 + profile_style profile 188 + warning_style "Not logged in" 189 + | Some session -> 190 + Fmt.pr "%a %a:@." header_style "Profile" profile_style profile; 191 + Fmt.pr " %a@." Session.pp session 192 + 193 + let auth_status_cmd env = 194 + let doc = "Show authentication status." in 195 + let info = Cmd.info "status" ~doc in 196 + let status' (style_renderer, level) profile = 197 + setup_logging_simple style_renderer level; 198 + status_action ~profile env 199 + in 200 + Cmd.v info Term.(const status' $ setup_logging $ profile_arg) 201 + 202 + (* Profile list command *) 203 + 204 + let profile_list_action env = 205 + let fs = env#fs in 206 + let current = Session.get_current_profile fs in 207 + let profiles = Session.list_profiles fs in 208 + if profiles = [] then 209 + Fmt.pr "%a No profiles found. Use '%a' to create one.@." 210 + warning_style "Note:" 211 + Fmt.(styled `Bold string) "typesense-cli auth login" 212 + else begin 213 + Fmt.pr "%a@." header_style "Profiles:"; 214 + List.iter 215 + (fun p -> 216 + let is_current = p = current in 217 + match Session.load fs ~profile:p () with 218 + | Some session -> 219 + if is_current then 220 + Fmt.pr " %a %a - %a@." 221 + current_style p 222 + success_style "(current)" 223 + value_style (Session.server_url session) 224 + else 225 + Fmt.pr " %a - %a@." 226 + profile_style p 227 + value_style (Session.server_url session) 228 + | None -> 229 + if is_current then 230 + Fmt.pr " %a %a@." current_style p success_style "(current)" 231 + else 232 + Fmt.pr " %a@." profile_style p) 233 + profiles 234 + end 235 + 236 + let profile_list_cmd env = 237 + let doc = "List available profiles." in 238 + let info = Cmd.info "list" ~doc in 239 + let list' (style_renderer, level) () = 240 + setup_logging_simple style_renderer level; 241 + profile_list_action env 242 + in 243 + Cmd.v info Term.(const list' $ setup_logging $ const ()) 244 + 245 + (* Profile switch command *) 246 + 247 + let profile_name_arg = 248 + let doc = "Profile name to switch to." in 249 + Arg.(required & pos 0 (some string) None & info [] ~docv:"PROFILE" ~doc) 250 + 251 + let profile_switch_action ~profile env = 252 + let fs = env#fs in 253 + let profiles = Session.list_profiles fs in 254 + if List.mem profile profiles then begin 255 + Session.set_current_profile fs profile; 256 + Fmt.pr "%a Switched to profile: %a@." 257 + success_style "Success:" 258 + profile_style profile 259 + end 260 + else begin 261 + Fmt.epr "%a Profile '%a' not found.@." 262 + error_style "Error:" 263 + profile_style profile; 264 + if profiles <> [] then 265 + Fmt.epr "%a %a@." 266 + label_style "Available profiles:" 267 + Fmt.(list ~sep:(any ", ") profile_style) profiles; 268 + raise (Error.Exit_code 1) 269 + end 270 + 271 + let profile_switch_cmd env = 272 + let doc = "Switch to a different profile." in 273 + let info = Cmd.info "switch" ~doc in 274 + let switch' (style_renderer, level) profile = 275 + setup_logging_simple style_renderer level; 276 + profile_switch_action ~profile env 277 + in 278 + Cmd.v info Term.(const switch' $ setup_logging $ profile_name_arg) 279 + 280 + (* Profile current command *) 281 + 282 + let profile_current_action env = 283 + let fs = env#fs in 284 + let current = Session.get_current_profile fs in 285 + Fmt.pr "%a@." current_style current 286 + 287 + let profile_current_cmd env = 288 + let doc = "Show current profile name." in 289 + let info = Cmd.info "current" ~doc in 290 + let current' (style_renderer, level) () = 291 + setup_logging_simple style_renderer level; 292 + profile_current_action env 293 + in 294 + Cmd.v info Term.(const current' $ setup_logging $ const ()) 295 + 296 + (* Profile command group *) 297 + 298 + let profile_cmd env = 299 + let doc = "Profile management commands." in 300 + let info = Cmd.info "profile" ~doc in 301 + Cmd.group info 302 + [ profile_list_cmd env 303 + ; profile_switch_cmd env 304 + ; profile_current_cmd env 305 + ] 306 + 307 + (* Auth command group *) 308 + 309 + let auth_cmd env fs = 310 + let doc = "Authentication commands." in 311 + let info = Cmd.info "auth" ~doc in 312 + Cmd.group info 313 + [ login_cmd env fs 314 + ; logout_cmd env 315 + ; auth_status_cmd env 316 + ; profile_cmd env 317 + ]
+145
lib/cmd.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Cmdliner helpers for Typesense CLI authentication. 7 + 8 + This module provides reusable command-line argument definitions and command 9 + builders for authentication workflows. It supports multiple profiles for 10 + managing multiple server connections. 11 + 12 + {2 Usage} 13 + 14 + {[ 15 + (* In your main.ml *) 16 + Eio_main.run @@ fun env -> 17 + let fs = env#fs in 18 + Cmd.group (Cmd.info "typesense-cli") 19 + [ Typesense_auth.Cmd.auth_cmd env fs 20 + ; (* other commands *) 21 + ] 22 + |> Cmd.eval_exn 23 + ]} 24 + 25 + {2 Environment Variables} 26 + 27 + - [TYPESENSE_SERVER]: Default server URL 28 + - [TYPESENSE_API_KEY]: Default API key 29 + 30 + {2 Logging} 31 + 32 + Uses Logs_cli for verbosity control: 33 + - [-v] or [--verbose]: Info level logging 34 + - [-v -v] or [--verbosity=debug]: Debug level logging 35 + - [--verbose-http]: Enable verbose HTTP protocol logging *) 36 + 37 + open Cmdliner 38 + 39 + (** {1 Common Arguments} *) 40 + 41 + val server_arg : string Term.t 42 + (** Required positional argument for server URL (also reads [TYPESENSE_SERVER]). *) 43 + 44 + val server_opt : string option Term.t 45 + (** Optional [--server] argument (also reads [TYPESENSE_SERVER]). *) 46 + 47 + val api_key_arg : string option Term.t 48 + (** Optional [--api-key] argument (also reads [TYPESENSE_API_KEY]). *) 49 + 50 + val profile_arg : string option Term.t 51 + (** Optional [--profile] argument for selecting a specific profile. *) 52 + 53 + (** {1 Logging and Configuration} *) 54 + 55 + val setup_logging : (Fmt.style_renderer option * Logs.level option) Term.t 56 + (** Term that collects logging options ([-v], [--color], etc.). 57 + Use with [setup_logging_with_config] to apply logging after parsing. *) 58 + 59 + val setup_logging_with_config : 60 + Fmt.style_renderer option -> 61 + Logs.level option -> 62 + Requests.Cmd.config -> 63 + unit 64 + (** [setup_logging_with_config style_renderer level config] sets up logging 65 + with the given options. Extracts [--verbose-http] from the requests config. 66 + Call this at the start of command execution. *) 67 + 68 + val requests_config_term : Eio.Fs.dir_ty Eio.Path.t -> Requests.Cmd.config Term.t 69 + (** Term for HTTP request configuration (timeouts, retries, proxy, etc.). *) 70 + 71 + (** {1 Commands} 72 + 73 + Commands take an [env] parameter from the outer [Eio_main.run] context, 74 + and an [fs] path for building cmdliner terms. *) 75 + 76 + val auth_cmd : 77 + < fs : Eio.Fs.dir_ty Eio.Path.t 78 + ; clock : _ Eio.Time.clock 79 + ; net : _ Eio.Net.t 80 + ; .. > -> 81 + Eio.Fs.dir_ty Eio.Path.t -> 82 + unit Cmd.t 83 + (** Complete auth command group combining login, logout, status, and profile. *) 84 + 85 + (** {1 Helper Functions} *) 86 + 87 + val with_session : 88 + ?profile:string -> 89 + (Eio.Fs.dir_ty Eio.Path.t -> Session.t -> 'a) -> 90 + < fs : Eio.Fs.dir_ty Eio.Path.t ; .. > -> 91 + 'a 92 + (** [with_session ?profile f env] loads the session and calls 93 + [f fs session]. Prints an error and exits if not logged in. 94 + @param profile Profile to load (default: current profile) *) 95 + 96 + val with_client : 97 + ?requests_config:Requests.Cmd.config -> 98 + ?profile:string -> 99 + (Eio.Fs.dir_ty Eio.Path.t -> Client.t -> 'a) -> 100 + < fs : Eio.Fs.dir_ty Eio.Path.t 101 + ; clock : _ Eio.Time.clock 102 + ; net : _ Eio.Net.t 103 + ; .. > -> 104 + 'a 105 + (** [with_client ?requests_config ?profile f env] loads the session, creates a client, and calls 106 + [f fs client]. Prints an error and exits if not logged in. 107 + @param requests_config HTTP request configuration 108 + @param profile Profile to load (default: current profile) *) 109 + 110 + (** {1 Profile Configuration for External Programs} 111 + 112 + These types and functions allow other programs to easily use Typesense profiles 113 + that were set up with the typesense CLI. *) 114 + 115 + (** Configuration for using a Typesense profile. *) 116 + module Profile_config : sig 117 + type t 118 + (** Bundled configuration for Typesense profile access. *) 119 + 120 + val style_renderer : t -> Fmt.style_renderer option 121 + (** Terminal style renderer setting. *) 122 + 123 + val log_level : t -> Logs.level option 124 + (** Logging level. *) 125 + 126 + val requests_config : t -> Requests.Cmd.config 127 + (** HTTP request configuration. *) 128 + 129 + val profile : t -> string option 130 + (** Selected profile name, if any. *) 131 + 132 + val setup_logging : t -> unit 133 + (** [setup_logging config] initializes logging with the bundled settings. 134 + Call this at the start of your command execution. *) 135 + end 136 + 137 + val profile_config_term : Eio.Fs.dir_ty Eio.Path.t -> Profile_config.t Term.t 138 + (** Cmdliner term that collects all configuration needed to use a Typesense profile. 139 + 140 + Combines: 141 + - Logging options ([-v], [--color], etc.) 142 + - HTTP configuration (timeouts, retries, proxy, [--verbose-http]) 143 + - Profile selection ([--profile]) 144 + 145 + Use with {!with_client} to create an authenticated client. *)
+20
lib/dune
··· 1 + (library 2 + (name typesense_auth) 3 + (public_name typesense.auth) 4 + (libraries 5 + typesense 6 + openapi 7 + requests 8 + jsont 9 + jsont.bytesrw 10 + eio 11 + eio_main 12 + ptime 13 + ptime.clock.os 14 + fmt 15 + fmt.tty 16 + fmt.cli 17 + logs 18 + logs.fmt 19 + logs.cli 20 + cmdliner))
+107
lib/error.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Typesense API error handling. 7 + 8 + Typesense returns errors in a simple format: {"message": "..."} *) 9 + 10 + (** Typesense error response *) 11 + type t = { 12 + message : string; 13 + status_code : int; 14 + } 15 + 16 + let error_jsont = 17 + Jsont.Object.map ~kind:"TypesenseError" 18 + (fun message -> message) 19 + |> Jsont.Object.mem "message" Jsont.string ~enc:Fun.id 20 + |> Jsont.Object.skip_unknown 21 + |> Jsont.Object.finish 22 + 23 + (** Parse an API error into a structured Typesense error. *) 24 + let of_api_error (e : Openapi.Runtime.api_error) : t option = 25 + match Jsont_bytesrw.decode_string error_jsont e.body with 26 + | Ok message -> Some { message; status_code = e.status } 27 + | Error _ -> None 28 + 29 + (** {1 Styled Output Helpers} *) 30 + 31 + (** Style for error labels (red, bold) *) 32 + let error_style = Fmt.(styled (`Fg `Red) (styled `Bold string)) 33 + 34 + (** Style for status codes *) 35 + let status_style status = 36 + if status >= 500 then Fmt.(styled (`Fg `Red) int) 37 + else if status >= 400 then Fmt.(styled (`Fg `Yellow) int) 38 + else Fmt.(styled (`Fg `Green) int) 39 + 40 + (** Pretty-print a Typesense API error with colors. *) 41 + let pp ppf (e : t) = 42 + Fmt.pf ppf "%s [%a]" e.message (status_style e.status_code) e.status_code 43 + 44 + (** Convert to a human-readable string (without colors). *) 45 + let to_string (e : t) : string = 46 + Printf.sprintf "%s [%d]" e.message e.status_code 47 + 48 + (** Check if this is an authentication/authorization error. *) 49 + let is_auth_error (e : t) = 50 + e.status_code = 401 || e.status_code = 403 51 + 52 + (** Check if this is a "not found" error. *) 53 + let is_not_found (e : t) = 54 + e.status_code = 404 55 + 56 + (** Handle an exception, printing a nice error message if it's an API error. 57 + 58 + Returns an exit code: 59 + - 1 for most API errors 60 + - 77 for authentication errors (permission denied) 61 + - 69 for not found errors *) 62 + let handle_exn exn = 63 + match exn with 64 + | Openapi.Runtime.Api_error e -> 65 + (match of_api_error e with 66 + | Some err -> 67 + Fmt.epr "%a %a@." error_style "Error:" pp err; 68 + if is_auth_error err then 77 69 + else if is_not_found err then 69 70 + else 1 71 + | None -> 72 + (* Not a Typesense error, show raw response *) 73 + Fmt.epr "%a %s %s returned %a@.%s@." 74 + error_style "API Error:" 75 + e.method_ e.url 76 + (status_style e.status) e.status 77 + e.body; 78 + 1) 79 + | Failure msg -> 80 + Fmt.epr "%a %s@." error_style "Error:" msg; 81 + 1 82 + | exn -> 83 + (* Re-raise unknown exceptions *) 84 + raise exn 85 + 86 + (** Wrap a function to handle API errors gracefully. *) 87 + let run f = 88 + try f (); 0 89 + with exn -> handle_exn exn 90 + 91 + (** Exception to signal desired exit code without calling [exit] directly. 92 + This avoids issues when running inside Eio's event loop. *) 93 + exception Exit_code of int 94 + 95 + (** Wrap a command action to handle API errors gracefully. *) 96 + let wrap f = 97 + try f () 98 + with 99 + | Stdlib.Exit -> 100 + (* exit() was called somewhere - treat as success *) 101 + () 102 + | Eio.Cancel.Cancelled Stdlib.Exit -> 103 + (* Eio wraps Exit in Cancelled - treat as success *) 104 + () 105 + | exn -> 106 + let code = handle_exn exn in 107 + raise (Exit_code code)
+76
lib/error.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Typesense API error handling. 7 + 8 + The Typesense API returns errors in a simple format: 9 + {[ 10 + { 11 + "message": "Collection not found" 12 + } 13 + ]} 14 + 15 + This module provides utilities for parsing and displaying these errors. *) 16 + 17 + (** {1 Error Type} *) 18 + 19 + type t = { 20 + message : string; 21 + status_code : int; 22 + } 23 + (** A structured Typesense API error. *) 24 + 25 + (** {1 Parsing} *) 26 + 27 + val of_api_error : Openapi.Runtime.api_error -> t option 28 + (** Parse an API error into a structured Typesense error. 29 + Returns [None] if the error body is not valid JSON. *) 30 + 31 + (** {1 Pretty Printing} *) 32 + 33 + val pp : Format.formatter -> t -> unit 34 + (** Pretty-print a Typesense API error. 35 + 36 + Format: "Collection not found [404]" *) 37 + 38 + val to_string : t -> string 39 + (** Convert to a human-readable string. *) 40 + 41 + (** {1 Error Classification} *) 42 + 43 + val is_auth_error : t -> bool 44 + (** Check if this is an authentication/authorization error (401 or 403). *) 45 + 46 + val is_not_found : t -> bool 47 + (** Check if this is a "not found" error (404). *) 48 + 49 + (** {1 Exception Handling} *) 50 + 51 + exception Exit_code of int 52 + (** Exception raised to signal a desired exit code. 53 + This is used instead of calling [exit] directly to avoid issues 54 + when running inside Eio's event loop. Catch this exception in 55 + the main program outside the Eio context. *) 56 + 57 + val handle_exn : exn -> int 58 + (** Handle an exception, printing a nice error message if it's an API error. 59 + 60 + Returns an exit code: 61 + - 1 for most API errors 62 + - 77 for authentication errors (permission denied) 63 + - 69 for not found errors 64 + 65 + @raise exn if the exception is not an API error or Failure *) 66 + 67 + val run : (unit -> unit) -> int 68 + (** Wrap a function to handle API errors gracefully. 69 + 70 + Returns 0 on success, or an appropriate exit code on error. *) 71 + 72 + val wrap : (unit -> unit) -> unit 73 + (** Wrap a command action to handle API errors gracefully. 74 + 75 + Catches API errors, prints a nice message, and raises {!Exit_code} 76 + with an appropriate code. *)
+159
lib/session.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Session data for Typesense authentication. *) 7 + type t = { 8 + server_url : string; 9 + api_key : string; 10 + created_at : string; 11 + } 12 + 13 + let jsont = 14 + Jsont.Object.map ~kind:"Session" 15 + (fun server_url api_key created_at -> { server_url; api_key; created_at }) 16 + |> Jsont.Object.mem "server_url" Jsont.string ~enc:(fun s -> s.server_url) 17 + |> Jsont.Object.mem "api_key" Jsont.string ~enc:(fun s -> s.api_key) 18 + |> Jsont.Object.mem "created_at" Jsont.string ~enc:(fun s -> s.created_at) 19 + |> Jsont.Object.finish 20 + 21 + (* App config stores the current profile *) 22 + type app_config = { current_profile : string } 23 + 24 + let app_config_jsont = 25 + Jsont.Object.map ~kind:"AppConfig" (fun current_profile -> 26 + { current_profile }) 27 + |> Jsont.Object.mem "current_profile" Jsont.string ~enc:(fun c -> 28 + c.current_profile) 29 + |> Jsont.Object.finish 30 + 31 + let default_profile = "default" 32 + let app_name = "typesense" 33 + 34 + (* Base config directory for the app *) 35 + let base_config_dir fs = 36 + let home = Sys.getenv "HOME" in 37 + let config_path = Eio.Path.(fs / home / ".config" / app_name) in 38 + (try Eio.Path.mkdir ~perm:0o700 config_path 39 + with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ()); 40 + config_path 41 + 42 + (* Profiles directory *) 43 + let profiles_dir fs = 44 + let base = base_config_dir fs in 45 + let profiles = Eio.Path.(base / "profiles") in 46 + (try Eio.Path.mkdir ~perm:0o700 profiles 47 + with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ()); 48 + profiles 49 + 50 + (* Config directory for a specific profile *) 51 + let config_dir fs ?profile () = 52 + let profile_name = Option.value ~default:default_profile profile in 53 + let profiles = profiles_dir fs in 54 + let profile_dir = Eio.Path.(profiles / profile_name) in 55 + (try Eio.Path.mkdir ~perm:0o700 profile_dir 56 + with Eio.Io (Eio.Fs.E (Eio.Fs.Already_exists _), _) -> ()); 57 + profile_dir 58 + 59 + (* App config file (stores current profile) *) 60 + let app_config_file fs = 61 + Eio.Path.(base_config_dir fs / "config.json") 62 + 63 + let load_app_config fs = 64 + let path = app_config_file fs in 65 + try 66 + Eio.Path.load path 67 + |> Jsont_bytesrw.decode_string app_config_jsont 68 + |> Result.to_option 69 + with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> None 70 + 71 + let save_app_config fs config = 72 + let path = app_config_file fs in 73 + match 74 + Jsont_bytesrw.encode_string ~format:Jsont.Indent app_config_jsont config 75 + with 76 + | Ok content -> Eio.Path.save ~create:(`Or_truncate 0o600) path content 77 + | Error e -> failwith ("Failed to encode app config: " ^ e) 78 + 79 + (* Get the current profile name *) 80 + let get_current_profile fs = 81 + match load_app_config fs with 82 + | Some config -> config.current_profile 83 + | None -> default_profile 84 + 85 + (* Set the current profile *) 86 + let set_current_profile fs profile = 87 + save_app_config fs { current_profile = profile } 88 + 89 + (* List all available profiles *) 90 + let list_profiles fs = 91 + let profiles = profiles_dir fs in 92 + try 93 + Eio.Path.read_dir profiles 94 + |> List.filter (fun name -> 95 + (* Check if it's a directory with a session.json *) 96 + let dir = Eio.Path.(profiles / name) in 97 + let session = Eio.Path.(dir / "session.json") in 98 + try 99 + ignore (Eio.Path.load session); 100 + true 101 + with _ -> false) 102 + |> List.sort String.compare 103 + with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> [] 104 + 105 + (* Session file within a profile directory *) 106 + let session_file fs ?profile () = 107 + Eio.Path.(config_dir fs ?profile () / "session.json") 108 + 109 + let load fs ?profile () = 110 + let profile = 111 + match profile with 112 + | Some p -> Some p 113 + | None -> 114 + (* Use current profile if none specified *) 115 + let current = get_current_profile fs in 116 + Some current 117 + in 118 + let path = session_file fs ?profile () in 119 + try 120 + Eio.Path.load path |> Jsont_bytesrw.decode_string jsont |> Result.to_option 121 + with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> None 122 + 123 + let save fs ?profile session = 124 + let profile = 125 + match profile with 126 + | Some p -> Some p 127 + | None -> Some (get_current_profile fs) 128 + in 129 + let path = session_file fs ?profile () in 130 + match Jsont_bytesrw.encode_string ~format:Jsont.Indent jsont session with 131 + | Ok content -> Eio.Path.save ~create:(`Or_truncate 0o600) path content 132 + | Error e -> failwith ("Failed to encode session: " ^ e) 133 + 134 + let clear fs ?profile () = 135 + let profile = 136 + match profile with 137 + | Some p -> Some p 138 + | None -> Some (get_current_profile fs) 139 + in 140 + let path = session_file fs ?profile () in 141 + try Eio.Path.unlink path 142 + with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> () 143 + 144 + (* Styled output helpers *) 145 + let label_style = Fmt.(styled `Faint string) 146 + let value_style = Fmt.(styled (`Fg `Cyan) string) 147 + 148 + let pp ppf session = 149 + Fmt.pf ppf "@[<v>%a %a@,%a %a@,%a %a@]" 150 + label_style "Server:" value_style session.server_url 151 + label_style "API Key:" value_style (String.sub session.api_key 0 (min 8 (String.length session.api_key)) ^ "...") 152 + label_style "Created:" value_style session.created_at 153 + 154 + let server_url t = t.server_url 155 + let api_key t = t.api_key 156 + let created_at t = t.created_at 157 + 158 + let create ~server_url ~api_key () = 159 + { server_url; api_key; created_at = Ptime.to_rfc3339 (Ptime_clock.now ()) }
+105
lib/session.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Session management for Typesense CLI with profile support. 7 + 8 + This module provides session persistence for Typesense authentication 9 + using API keys. Sessions are stored in profile-specific directories 10 + under [~/.config/typesense/profiles/<profile>/session.json]. 11 + 12 + {2 Directory Structure} 13 + 14 + {v 15 + ~/.config/typesense/ 16 + config.json # Stores current_profile setting 17 + profiles/ 18 + default/ 19 + session.json # Session for "default" profile 20 + prod/ 21 + session.json # Session for "prod" profile 22 + v} 23 + 24 + {[ 25 + (* Login with API key *) 26 + let session = Session.create 27 + ~server_url:"http://localhost:8108" 28 + ~api_key:"xyz" 29 + () in 30 + Session.save fs ~profile:"default" session 31 + ]} *) 32 + 33 + (** {1 Types} *) 34 + 35 + type t 36 + (** Session data. *) 37 + 38 + val jsont : t Jsont.t 39 + (** JSON codec for sessions. *) 40 + 41 + (** {1 Session Construction} *) 42 + 43 + val create : server_url:string -> api_key:string -> unit -> t 44 + (** [create ~server_url ~api_key ()] creates a new session with the current timestamp. *) 45 + 46 + (** {1 Session Accessors} *) 47 + 48 + val server_url : t -> string 49 + (** [server_url t] returns the server URL. *) 50 + 51 + val api_key : t -> string 52 + (** [api_key t] returns the API key. *) 53 + 54 + val created_at : t -> string 55 + (** [created_at t] returns the creation timestamp (RFC 3339). *) 56 + 57 + (** {1 Profile Management} *) 58 + 59 + val default_profile : string 60 + (** The default profile name (["default"]). *) 61 + 62 + val get_current_profile : Eio.Fs.dir_ty Eio.Path.t -> string 63 + (** [get_current_profile fs] returns the current profile name. Returns 64 + {!default_profile} if no profile has been set. *) 65 + 66 + val set_current_profile : Eio.Fs.dir_ty Eio.Path.t -> string -> unit 67 + (** [set_current_profile fs profile] sets the current profile. *) 68 + 69 + val list_profiles : Eio.Fs.dir_ty Eio.Path.t -> string list 70 + (** [list_profiles fs] returns all profiles that have sessions. 71 + Returns profile names sorted alphabetically. *) 72 + 73 + (** {1 Directory Paths} *) 74 + 75 + val base_config_dir : Eio.Fs.dir_ty Eio.Path.t -> Eio.Fs.dir_ty Eio.Path.t 76 + (** [base_config_dir fs] returns the base config directory 77 + ([~/.config/typesense]), creating it if needed. *) 78 + 79 + val config_dir : 80 + Eio.Fs.dir_ty Eio.Path.t -> 81 + ?profile:string -> 82 + unit -> 83 + Eio.Fs.dir_ty Eio.Path.t 84 + (** [config_dir fs ?profile ()] returns the config directory for a 85 + profile, creating it if needed. 86 + @param profile Profile name (default: current profile) *) 87 + 88 + (** {1 Session Persistence} *) 89 + 90 + val save : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> t -> unit 91 + (** [save fs ?profile session] saves the session. 92 + @param profile Profile name (default: current profile) *) 93 + 94 + val load : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> t option 95 + (** [load fs ?profile ()] loads a saved session. 96 + @param profile Profile name (default: current profile) *) 97 + 98 + val clear : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> unit 99 + (** [clear fs ?profile ()] removes the saved session. 100 + @param profile Profile name (default: current profile) *) 101 + 102 + (** {1 Session Utilities} *) 103 + 104 + val pp : t Fmt.t 105 + (** Pretty-print a session. *)
-181
lib/typesense/analytics.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type rule_type = Popular_queries | Nohits_queries | Counter 7 - 8 - let rule_type_to_string = function 9 - | Popular_queries -> "popular_queries" 10 - | Nohits_queries -> "nohits_queries" 11 - | Counter -> "counter" 12 - 13 - let rule_type_of_string = function 14 - | "popular_queries" -> Popular_queries 15 - | "nohits_queries" -> Nohits_queries 16 - | "counter" -> Counter 17 - | s -> failwith ("Unknown rule type: " ^ s) 18 - 19 - let rule_type_jsont = 20 - Jsont.of_of_string ~kind:"RuleType" (fun s -> Ok (rule_type_of_string s)) 21 - ~enc:rule_type_to_string 22 - 23 - type destination = { collection : string } 24 - 25 - let destination_jsont = 26 - Jsont.Object.map ~kind:"Destination" (fun collection -> { collection }) 27 - |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun d -> d.collection) 28 - |> Jsont.Object.skip_unknown 29 - |> Jsont.Object.finish 30 - 31 - type source = { 32 - collections : string list; 33 - events : Jsont.json option; 34 - } 35 - 36 - let source_jsont = 37 - let make collections events = { collections; events } in 38 - Jsont.Object.map ~kind:"Source" make 39 - |> Jsont.Object.mem "collections" (Jsont.list Jsont.string) 40 - ~enc:(fun s -> s.collections) 41 - |> Jsont.Object.opt_mem "events" Jsont.json ~enc:(fun s -> s.events) 42 - |> Jsont.Object.skip_unknown 43 - |> Jsont.Object.finish 44 - 45 - type rule_params = { 46 - source : source; 47 - destination : destination; 48 - limit : int option; 49 - expand_query : bool option; 50 - } 51 - 52 - let rule_params_jsont = 53 - let make source destination limit expand_query = 54 - { source; destination; limit; expand_query } 55 - in 56 - Jsont.Object.map ~kind:"RuleParams" make 57 - |> Jsont.Object.mem "source" source_jsont ~enc:(fun p -> p.source) 58 - |> Jsont.Object.mem "destination" destination_jsont ~enc:(fun p -> p.destination) 59 - |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun p -> p.limit) 60 - |> Jsont.Object.opt_mem "expand_query" Jsont.bool ~enc:(fun p -> p.expand_query) 61 - |> Jsont.Object.skip_unknown 62 - |> Jsont.Object.finish 63 - 64 - type rule = { 65 - name : string; 66 - type_ : rule_type; 67 - params : rule_params; 68 - } 69 - 70 - let rule_jsont = 71 - let make name type_ params = { name; type_; params } in 72 - Jsont.Object.map ~kind:"Rule" make 73 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 74 - |> Jsont.Object.mem "type" rule_type_jsont ~enc:(fun r -> r.type_) 75 - |> Jsont.Object.mem "params" rule_params_jsont ~enc:(fun r -> r.params) 76 - |> Jsont.Object.skip_unknown 77 - |> Jsont.Object.finish 78 - 79 - let rule ~name ~type_ ~params = { name; type_; params } 80 - 81 - let rule_params ~source_collections ~destination_collection ?limit 82 - ?expand_query ?events () = 83 - { 84 - source = { collections = source_collections; events }; 85 - destination = { collection = destination_collection }; 86 - limit; 87 - expand_query; 88 - } 89 - 90 - type rules_response = { rules : rule list } 91 - 92 - let rules_response_jsont = 93 - Jsont.Object.map ~kind:"RulesResponse" (fun rules -> { rules }) 94 - |> Jsont.Object.mem "rules" (Jsont.list rule_jsont) ~enc:(fun r -> r.rules) 95 - |> Jsont.Object.skip_unknown 96 - |> Jsont.Object.finish 97 - 98 - let list_rules client = 99 - let json = Client.request client ~method_:`GET ~path:"/analytics/rules" () in 100 - let response = Encode.decode_or_raise rules_response_jsont json "list rules" in 101 - response.rules 102 - 103 - let get_rule client ~name = 104 - let path = "/analytics/rules/" ^ Uri.pct_encode name in 105 - let json = Client.request client ~method_:`GET ~path () in 106 - Encode.decode_or_raise rule_jsont json ("get rule " ^ name) 107 - 108 - let create_rule client rule = 109 - let body = Encode.to_json_string rule_jsont rule in 110 - let json = Client.request client ~method_:`POST ~path:"/analytics/rules" ~body () in 111 - Encode.decode_or_raise rule_jsont json ("create rule " ^ rule.name) 112 - 113 - let upsert_rule client rule = 114 - let path = "/analytics/rules/" ^ Uri.pct_encode rule.name in 115 - let body = Encode.to_json_string rule_jsont rule in 116 - let json = Client.request client ~method_:`PUT ~path ~body () in 117 - Encode.decode_or_raise rule_jsont json ("upsert rule " ^ rule.name) 118 - 119 - type delete_result = { name : string } 120 - 121 - let delete_result_jsont = 122 - Jsont.Object.map ~kind:"DeleteResult" (fun name -> { name }) 123 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 124 - |> Jsont.Object.skip_unknown 125 - |> Jsont.Object.finish 126 - 127 - let delete_rule client ~name = 128 - let path = "/analytics/rules/" ^ Uri.pct_encode name in 129 - let json = Client.request client ~method_:`DELETE ~path () in 130 - let _ = Encode.decode_or_raise delete_result_jsont json ("delete rule " ^ name) in 131 - () 132 - 133 - type event_type = Search | Click | Conversion | Visit | Custom of string 134 - 135 - let event_type_to_string = function 136 - | Search -> "search" 137 - | Click -> "click" 138 - | Conversion -> "conversion" 139 - | Visit -> "visit" 140 - | Custom s -> s 141 - 142 - let event_type_of_string = function 143 - | "search" -> Search 144 - | "click" -> Click 145 - | "conversion" -> Conversion 146 - | "visit" -> Visit 147 - | s -> Custom s 148 - 149 - let event_type_jsont = 150 - Jsont.of_of_string ~kind:"EventType" (fun s -> Ok (event_type_of_string s)) 151 - ~enc:event_type_to_string 152 - 153 - type event = { 154 - type_ : event_type; 155 - name : string; 156 - data : Jsont.json; 157 - } 158 - 159 - let event_jsont = 160 - let make type_ name data = { type_; name; data } in 161 - Jsont.Object.map ~kind:"Event" make 162 - |> Jsont.Object.mem "type" event_type_jsont ~enc:(fun e -> e.type_) 163 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun e -> e.name) 164 - |> Jsont.Object.mem "data" Jsont.json ~enc:(fun e -> e.data) 165 - |> Jsont.Object.finish 166 - 167 - let event ~type_ ~name ~data = { type_; name; data } 168 - 169 - type event_response = { ok : bool } 170 - 171 - let event_response_jsont = 172 - Jsont.Object.map ~kind:"EventResponse" (fun ok -> { ok }) 173 - |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok) 174 - |> Jsont.Object.skip_unknown 175 - |> Jsont.Object.finish 176 - 177 - let create_event client event = 178 - let body = Encode.to_json_string event_jsont event in 179 - let json = Client.request client ~method_:`POST ~path:"/analytics/events" ~body () in 180 - let _ = Encode.decode_or_raise event_response_jsont json "create event" in 181 - ()
-113
lib/typesense/analytics.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense analytics rules and events. 7 - 8 - This module provides support for creating and managing analytics rules 9 - and tracking events. Analytics rules automatically aggregate search queries 10 - into collections for analysis. *) 11 - 12 - (** {1 Rule Types} *) 13 - 14 - type rule_type = 15 - | Popular_queries (** Track popular search queries *) 16 - | Nohits_queries (** Track queries with no results *) 17 - | Counter (** Generic counter for events *) 18 - (** Type of analytics rule. *) 19 - 20 - val rule_type_jsont : rule_type Jsont.t 21 - 22 - type destination = { collection : string } 23 - (** Destination collection for aggregated data. *) 24 - 25 - type source = { 26 - collections : string list; (** Source collections to track *) 27 - events : Jsont.json option; (** Event configuration *) 28 - } 29 - (** Source configuration for analytics. *) 30 - 31 - type rule_params = { 32 - source : source; 33 - destination : destination; 34 - limit : int option; (** Max entries to store *) 35 - expand_query : bool option; (** Expand queries before storing *) 36 - } 37 - (** Parameters for analytics rules. *) 38 - 39 - val rule_params : 40 - source_collections:string list -> 41 - destination_collection:string -> 42 - ?limit:int -> 43 - ?expand_query:bool -> 44 - ?events:Jsont.json -> 45 - unit -> 46 - rule_params 47 - (** [rule_params ~source_collections ~destination_collection ...] creates rule 48 - parameters. *) 49 - 50 - type rule = { 51 - name : string; (** Unique rule name *) 52 - type_ : rule_type; (** Rule type *) 53 - params : rule_params; (** Rule parameters *) 54 - } 55 - (** An analytics rule. *) 56 - 57 - val rule : name:string -> type_:rule_type -> params:rule_params -> rule 58 - (** [rule ~name ~type_ ~params] creates an analytics rule. *) 59 - 60 - val rule_jsont : rule Jsont.t 61 - (** JSON codec for rules. *) 62 - 63 - (** {1 Rule Operations} *) 64 - 65 - val list_rules : Client.t -> rule list 66 - (** [list_rules client] returns all analytics rules. 67 - @raise Eio.Io with [Error.E] on API errors *) 68 - 69 - val get_rule : Client.t -> name:string -> rule 70 - (** [get_rule client ~name] retrieves a rule by name. 71 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 72 - 73 - val create_rule : Client.t -> rule -> rule 74 - (** [create_rule client rule] creates a new analytics rule. 75 - @raise Eio.Io with [Error.E { code = Conflict; _ }] if already exists *) 76 - 77 - val upsert_rule : Client.t -> rule -> rule 78 - (** [upsert_rule client rule] creates or updates an analytics rule. *) 79 - 80 - val delete_rule : Client.t -> name:string -> unit 81 - (** [delete_rule client ~name] deletes an analytics rule. 82 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 83 - 84 - (** {1 Event Types} *) 85 - 86 - type event_type = 87 - | Search (** Search event *) 88 - | Click (** Click event *) 89 - | Conversion (** Conversion event *) 90 - | Visit (** Visit event *) 91 - | Custom of string (** Custom event type *) 92 - (** Type of analytics event. *) 93 - 94 - val event_type_jsont : event_type Jsont.t 95 - 96 - type event = { 97 - type_ : event_type; (** Event type *) 98 - name : string; (** Event name (rule name to track) *) 99 - data : Jsont.json; (** Event data *) 100 - } 101 - (** An analytics event. *) 102 - 103 - val event : type_:event_type -> name:string -> data:Jsont.json -> event 104 - (** [event ~type_ ~name ~data] creates an analytics event. *) 105 - 106 - val event_jsont : event Jsont.t 107 - (** JSON codec for events. *) 108 - 109 - (** {1 Event Operations} *) 110 - 111 - val create_event : Client.t -> event -> unit 112 - (** [create_event client event] records an analytics event. 113 - @raise Eio.Io with [Error.E] on API errors *)
-28
lib/typesense/auth.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type t = { endpoint : string; api_key : string } 7 - 8 - let create ~endpoint ~api_key = { endpoint; api_key } 9 - 10 - let from_env ?endpoint_var ?api_key_var () = 11 - let endpoint_var = Option.value ~default:"TYPESENSE_API_ENDPOINT" endpoint_var in 12 - let api_key_var = Option.value ~default:"TYPESENSE_API_KEY" api_key_var in 13 - match (Sys.getenv_opt endpoint_var, Sys.getenv_opt api_key_var) with 14 - | Some endpoint, Some api_key -> Some { endpoint; api_key } 15 - | _ -> None 16 - 17 - let endpoint t = t.endpoint 18 - let api_key t = t.api_key 19 - 20 - let default_headers t = 21 - [ 22 - ("X-TYPESENSE-API-KEY", t.api_key); 23 - ("Content-Type", "application/json"); 24 - ("User-Agent", "OCaml-Typesense/1.0"); 25 - ] 26 - 27 - let pp fmt t = 28 - Format.fprintf fmt "Auth{endpoint=%s}" t.endpoint
-38
lib/typesense/auth.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Authentication for the Typesense API. 7 - 8 - This module handles authentication credentials for connecting to a Typesense 9 - server. Typesense uses API key authentication via the [X-TYPESENSE-API-KEY] 10 - header. *) 11 - 12 - type t 13 - (** Authentication credentials. *) 14 - 15 - val create : endpoint:string -> api_key:string -> t 16 - (** [create ~endpoint ~api_key] creates authentication credentials directly. 17 - @param endpoint The Typesense server URL (e.g., "http://localhost:8108") 18 - @param api_key The Typesense API key *) 19 - 20 - val from_env : ?endpoint_var:string -> ?api_key_var:string -> unit -> t option 21 - (** [from_env ?endpoint_var ?api_key_var ()] loads credentials from environment 22 - variables. 23 - @param endpoint_var Environment variable for endpoint (default: TYPESENSE_API_ENDPOINT) 24 - @param api_key_var Environment variable for API key (default: TYPESENSE_API_KEY) 25 - @return [Some t] if both variables are set, [None] otherwise *) 26 - 27 - val endpoint : t -> string 28 - (** [endpoint t] returns the Typesense server endpoint. *) 29 - 30 - val api_key : t -> string 31 - (** [api_key t] returns the API key. *) 32 - 33 - val default_headers : t -> (string * string) list 34 - (** [default_headers t] returns the default HTTP headers for authentication. 35 - Includes the API key header, Content-Type, and User-Agent. *) 36 - 37 - val pp : Format.formatter -> t -> unit 38 - (** Pretty printer for authentication (shows endpoint only, not credentials). *)
-101
lib/typesense/client.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - let src = Logs.Src.create "typesense.client" ~doc:"Typesense API client" 7 - 8 - module Log = (val Logs.src_log src : Logs.LOG) 9 - 10 - type t = { auth : Auth.t; session : Requests.t } 11 - 12 - let create ?session ~sw env auth = 13 - Log.info (fun m -> m "Creating Typesense client for %s" (Auth.endpoint auth)); 14 - let session = match session with 15 - | Some s -> s 16 - | None -> Requests.create ~sw ~follow_redirects:true ~verify_tls:true env 17 - in 18 - { auth; session } 19 - 20 - let with_client ?session env auth f = 21 - Eio.Switch.run @@ fun sw -> 22 - let client = create ?session ~sw env auth in 23 - f client 24 - 25 - let auth_headers t = 26 - Requests.Headers.of_list (Auth.default_headers t.auth) 27 - 28 - let method_to_string = function 29 - | `GET -> "GET" 30 - | `POST -> "POST" 31 - | `PUT -> "PUT" 32 - | `DELETE -> "DELETE" 33 - | `PATCH -> "PATCH" 34 - 35 - let build_url base_url params = 36 - match params with 37 - | None -> base_url 38 - | Some p -> 39 - Uri.of_string base_url 40 - |> Fun.flip 41 - (List.fold_left (fun u (k, v) -> Uri.add_query_param' u (k, v))) 42 - p 43 - |> Uri.to_string 44 - 45 - let make_request t ~method_ ~url ~body_opt = 46 - let headers = auth_headers t in 47 - match method_ with 48 - | `GET -> Requests.get t.session ~headers url 49 - | `POST -> Requests.post t.session ~headers ?body:body_opt url 50 - | `PUT -> Requests.put t.session ~headers ?body:body_opt url 51 - | `DELETE -> Requests.delete t.session ~headers url 52 - | `PATCH -> Requests.patch t.session ~headers ?body:body_opt url 53 - 54 - let request t ~method_ ~path ?params ?body () = 55 - let url = build_url (Auth.endpoint t.auth ^ path) params in 56 - Log.debug (fun m -> m "Request: %s %s" (method_to_string method_) path); 57 - let body_opt = 58 - Option.map (fun s -> Requests.Body.of_string Requests.Mime.json s) body 59 - in 60 - let response = make_request t ~method_ ~url ~body_opt in 61 - let status = Requests.Response.status_code response in 62 - Log.debug (fun m -> m "Response status: %d" status); 63 - let json = Requests.Response.json response in 64 - if status >= 400 then begin 65 - let message = 66 - match json with 67 - | Jsont.Object (fields, _) -> ( 68 - let assoc = List.map (fun ((k, _), v) -> (k, v)) fields in 69 - match List.assoc_opt "message" assoc with 70 - | Some (Jsont.String (s, _)) -> s 71 - | _ -> "Unknown error") 72 - | _ -> "Unknown error" 73 - in 74 - Error.raise_with_context 75 - (Error.make ~code:(Error.code_of_status status) ~message) 76 - "%s" path 77 - end; 78 - json 79 - 80 - let request_raw t ~method_ ~path ?params ?body () = 81 - let url = build_url (Auth.endpoint t.auth ^ path) params in 82 - Log.debug (fun m -> m "Request (raw): %s %s" (method_to_string method_) path); 83 - let body_opt = 84 - Option.map 85 - (fun s -> 86 - Requests.Body.of_string 87 - (Requests.Mime.of_string "application/x-ndjson") 88 - s) 89 - body 90 - in 91 - let response = make_request t ~method_ ~url ~body_opt in 92 - let status = Requests.Response.status_code response in 93 - Log.debug (fun m -> m "Response status: %d" status); 94 - let body_str = Requests.Response.text response in 95 - if status >= 400 then 96 - Error.raise_with_context 97 - (Error.make ~code:(Error.code_of_status status) ~message:body_str) 98 - "%s" path; 99 - body_str 100 - 101 - let pp fmt t = Format.fprintf fmt "Client(endpoint=%s)" (Auth.endpoint t.auth)
-71
lib/typesense/client.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** HTTP client for making requests to the Typesense API. 7 - 8 - This module provides the low-level HTTP client for communicating with the 9 - Typesense API. All API errors are raised as [Eio.Io] exceptions with 10 - [Error.E] error codes, following the Eio error pattern. 11 - 12 - @raise Eio.Io with [Error.E error] for API errors *) 13 - 14 - type t 15 - (** Type representing a Typesense HTTP client *) 16 - 17 - val create : 18 - ?session:Requests.t -> 19 - sw:Eio.Switch.t -> 20 - < clock : float Eio.Time.clock_ty Eio.Resource.t 21 - ; net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t 22 - ; fs : Eio.Fs.dir_ty Eio.Path.t 23 - ; .. > -> 24 - Auth.t -> 25 - t 26 - (** [create ?session ~sw env auth] creates a new client with the given switch, 27 - environment and authentication. If [session] is provided, it is reused; 28 - otherwise a new session is created. The environment must have clock, net, 29 - and fs capabilities. *) 30 - 31 - val with_client : 32 - ?session:Requests.t -> 33 - < clock : float Eio.Time.clock_ty Eio.Resource.t 34 - ; net : [ `Generic | `Unix ] Eio.Net.ty Eio.Resource.t 35 - ; fs : Eio.Fs.dir_ty Eio.Path.t 36 - ; .. > -> 37 - Auth.t -> 38 - (t -> 'a) -> 39 - 'a 40 - (** [with_client ?session env auth f] runs [f] with a client that is 41 - automatically cleaned up. If [session] is provided, it is reused. The 42 - environment must have clock, net, and fs capabilities. *) 43 - 44 - val request : 45 - t -> 46 - method_:[ `GET | `POST | `PUT | `DELETE | `PATCH ] -> 47 - path:string -> 48 - ?params:(string * string) list -> 49 - ?body:string -> 50 - unit -> 51 - Jsont.json 52 - (** [request t ~method_ ~path ?params ?body ()] makes an HTTP request to the 53 - Typesense API and returns the JSON response. 54 - @param params Optional query parameters 55 - @param body Optional JSON request body 56 - @raise Eio.Io with [Error.E error] on API errors *) 57 - 58 - val request_raw : 59 - t -> 60 - method_:[ `GET | `POST | `PUT | `DELETE | `PATCH ] -> 61 - path:string -> 62 - ?params:(string * string) list -> 63 - ?body:string -> 64 - unit -> 65 - string 66 - (** [request_raw t ~method_ ~path ?params ?body ()] makes an HTTP request and 67 - returns the raw response body as a string. Used for JSONL import responses. 68 - @raise Eio.Io with [Error.E error] on API errors *) 69 - 70 - val pp : Format.formatter -> t -> unit 71 - (** Pretty printer for client (shows endpoint only, not credentials) *)
-144
lib/typesense/collection.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type field = { 7 - name : string; 8 - type_ : string; 9 - facet : bool option; 10 - optional : bool option; 11 - index : bool option; 12 - sort : bool option; 13 - infix : bool option; 14 - locale : string option; 15 - num_dim : int option; 16 - } 17 - 18 - let field_jsont = 19 - let make name type_ facet optional index sort infix locale num_dim = 20 - { name; type_; facet; optional; index; sort; infix; locale; num_dim } 21 - in 22 - Jsont.Object.map ~kind:"Field" make 23 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun f -> f.name) 24 - |> Jsont.Object.mem "type" Jsont.string ~enc:(fun f -> f.type_) 25 - |> Jsont.Object.opt_mem "facet" Jsont.bool ~enc:(fun f -> f.facet) 26 - |> Jsont.Object.opt_mem "optional" Jsont.bool ~enc:(fun f -> f.optional) 27 - |> Jsont.Object.opt_mem "index" Jsont.bool ~enc:(fun f -> f.index) 28 - |> Jsont.Object.opt_mem "sort" Jsont.bool ~enc:(fun f -> f.sort) 29 - |> Jsont.Object.opt_mem "infix" Jsont.bool ~enc:(fun f -> f.infix) 30 - |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun f -> f.locale) 31 - |> Jsont.Object.opt_mem "num_dim" Jsont.int ~enc:(fun f -> f.num_dim) 32 - |> Jsont.Object.skip_unknown 33 - |> Jsont.Object.finish 34 - 35 - let field ~name ~type_ ?facet ?optional ?index ?sort ?infix ?locale ?num_dim () = 36 - { name; type_; facet; optional; index; sort; infix; locale; num_dim } 37 - 38 - type schema = { 39 - name : string; 40 - fields : field list; 41 - default_sorting_field : string option; 42 - token_separators : string list option; 43 - symbols_to_index : string list option; 44 - enable_nested_fields : bool option; 45 - } 46 - 47 - let schema_jsont = 48 - let make name fields default_sorting_field token_separators symbols_to_index 49 - enable_nested_fields = 50 - { 51 - name; 52 - fields; 53 - default_sorting_field; 54 - token_separators; 55 - symbols_to_index; 56 - enable_nested_fields; 57 - } 58 - in 59 - Jsont.Object.map ~kind:"Schema" make 60 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun s -> s.name) 61 - |> Jsont.Object.mem "fields" (Jsont.list field_jsont) ~enc:(fun s -> s.fields) 62 - |> Jsont.Object.opt_mem "default_sorting_field" Jsont.string 63 - ~enc:(fun s -> s.default_sorting_field) 64 - |> Jsont.Object.opt_mem "token_separators" (Jsont.list Jsont.string) 65 - ~enc:(fun s -> s.token_separators) 66 - |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) 67 - ~enc:(fun s -> s.symbols_to_index) 68 - |> Jsont.Object.opt_mem "enable_nested_fields" Jsont.bool 69 - ~enc:(fun s -> s.enable_nested_fields) 70 - |> Jsont.Object.skip_unknown 71 - |> Jsont.Object.finish 72 - 73 - let schema ~name ~fields ?default_sorting_field ?token_separators 74 - ?symbols_to_index ?enable_nested_fields () = 75 - { 76 - name; 77 - fields; 78 - default_sorting_field; 79 - token_separators; 80 - symbols_to_index; 81 - enable_nested_fields; 82 - } 83 - 84 - type t = { 85 - name : string; 86 - num_documents : int; 87 - fields : field list; 88 - default_sorting_field : string option; 89 - enable_nested_fields : bool option; 90 - } 91 - 92 - let jsont = 93 - let make name num_documents fields default_sorting_field enable_nested_fields = 94 - { name; num_documents; fields; default_sorting_field; enable_nested_fields } 95 - in 96 - Jsont.Object.map ~kind:"Collection" make 97 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun c -> c.name) 98 - |> Jsont.Object.mem "num_documents" Jsont.int ~enc:(fun c -> c.num_documents) 99 - |> Jsont.Object.mem "fields" (Jsont.list field_jsont) ~enc:(fun c -> c.fields) 100 - |> Jsont.Object.opt_mem "default_sorting_field" Jsont.string 101 - ~enc:(fun c -> c.default_sorting_field) 102 - |> Jsont.Object.opt_mem "enable_nested_fields" Jsont.bool 103 - ~enc:(fun c -> c.enable_nested_fields) 104 - |> Jsont.Object.skip_unknown 105 - |> Jsont.Object.finish 106 - 107 - let name t = t.name 108 - let num_documents t = t.num_documents 109 - let fields t = t.fields 110 - let default_sorting_field t = t.default_sorting_field 111 - 112 - let list client = 113 - let json = Client.request client ~method_:`GET ~path:"/collections" () in 114 - Encode.decode_or_raise (Jsont.list jsont) json "listing collections" 115 - 116 - let get client ~name = 117 - let path = "/collections/" ^ Uri.pct_encode name in 118 - let json = Client.request client ~method_:`GET ~path () in 119 - Encode.decode_or_raise jsont json ("getting collection " ^ name) 120 - 121 - let create client schema = 122 - let body = Encode.to_json_string schema_jsont schema in 123 - let json = Client.request client ~method_:`POST ~path:"/collections" ~body () in 124 - Encode.decode_or_raise jsont json ("creating collection " ^ schema.name) 125 - 126 - type delete_result = { name : string } 127 - 128 - let delete_result_jsont = 129 - Jsont.Object.map ~kind:"DeleteResult" (fun name -> { name }) 130 - |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 131 - |> Jsont.Object.skip_unknown 132 - |> Jsont.Object.finish 133 - 134 - let delete client ~name = 135 - let path = "/collections/" ^ Uri.pct_encode name in 136 - let json = Client.request client ~method_:`DELETE ~path () in 137 - let _ = Encode.decode_or_raise delete_result_jsont json ("deleting collection " ^ name) in 138 - () 139 - 140 - let exists client ~name = 141 - try 142 - let _ = get client ~name in 143 - true 144 - with Eio.Io (Error.E { code = Not_found; _ }, _) -> false
-114
lib/typesense/collection.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense collection management. 7 - 8 - This module provides types and operations for managing Typesense collections. 9 - A collection is a group of related documents with a defined schema. *) 10 - 11 - (** {1 Field Types} *) 12 - 13 - type field = { 14 - name : string; (** Field name *) 15 - type_ : string; (** Field type (string, int32, float, bool, etc.) *) 16 - facet : bool option; (** Whether field is facetable *) 17 - optional : bool option; (** Whether field is optional *) 18 - index : bool option; (** Whether to index this field *) 19 - sort : bool option; (** Whether field is sortable *) 20 - infix : bool option; (** Enable infix search *) 21 - locale : string option; (** Locale for string fields *) 22 - num_dim : int option; (** Number of dimensions for vector fields *) 23 - } 24 - (** A field definition in a collection schema. *) 25 - 26 - val field : 27 - name:string -> 28 - type_:string -> 29 - ?facet:bool -> 30 - ?optional:bool -> 31 - ?index:bool -> 32 - ?sort:bool -> 33 - ?infix:bool -> 34 - ?locale:string -> 35 - ?num_dim:int -> 36 - unit -> 37 - field 38 - (** [field ~name ~type_ ...] creates a field definition. Common types: 39 - - ["string"], ["string[]] - Text fields 40 - - ["int32"], ["int64"], ["float"] - Numeric fields 41 - - ["bool"] - Boolean field 42 - - ["auto"] - Auto-detect type 43 - - ["float[]] - Vector field (requires [num_dim]) *) 44 - 45 - val field_jsont : field Jsont.t 46 - (** JSON codec for fields. *) 47 - 48 - (** {1 Schema Types} *) 49 - 50 - type schema = { 51 - name : string; (** Collection name *) 52 - fields : field list; (** Field definitions *) 53 - default_sorting_field : string option; (** Default field for sorting *) 54 - token_separators : string list option; (** Custom token separators *) 55 - symbols_to_index : string list option; (** Symbols to index *) 56 - enable_nested_fields : bool option; (** Enable nested object fields *) 57 - } 58 - (** A collection schema for creating new collections. *) 59 - 60 - val schema : 61 - name:string -> 62 - fields:field list -> 63 - ?default_sorting_field:string -> 64 - ?token_separators:string list -> 65 - ?symbols_to_index:string list -> 66 - ?enable_nested_fields:bool -> 67 - unit -> 68 - schema 69 - (** [schema ~name ~fields ...] creates a collection schema. *) 70 - 71 - val schema_jsont : schema Jsont.t 72 - (** JSON codec for schemas. *) 73 - 74 - (** {1 Collection Type} *) 75 - 76 - type t = { 77 - name : string; (** Collection name *) 78 - num_documents : int; (** Number of documents in collection *) 79 - fields : field list; (** Field definitions *) 80 - default_sorting_field : string option; (** Default sorting field *) 81 - enable_nested_fields : bool option; (** Whether nested fields are enabled *) 82 - } 83 - (** A collection as returned by the API. *) 84 - 85 - val jsont : t Jsont.t 86 - (** JSON codec for collections. *) 87 - 88 - (** {1 Accessors} *) 89 - 90 - val name : t -> string 91 - val num_documents : t -> int 92 - val fields : t -> field list 93 - val default_sorting_field : t -> string option 94 - 95 - (** {1 Operations} *) 96 - 97 - val list : Client.t -> t list 98 - (** [list client] returns all collections. 99 - @raise Eio.Io with [Error.E] on API errors *) 100 - 101 - val get : Client.t -> name:string -> t 102 - (** [get client ~name] retrieves a collection by name. 103 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 104 - 105 - val create : Client.t -> schema -> t 106 - (** [create client schema] creates a new collection. 107 - @raise Eio.Io with [Error.E { code = Conflict; _ }] if already exists *) 108 - 109 - val delete : Client.t -> name:string -> unit 110 - (** [delete client ~name] deletes a collection. 111 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 112 - 113 - val exists : Client.t -> name:string -> bool 114 - (** [exists client ~name] returns [true] if the collection exists. *)
-128
lib/typesense/document.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type action = Create | Upsert | Update | Emplace 7 - 8 - let action_to_string = function 9 - | Create -> "create" 10 - | Upsert -> "upsert" 11 - | Update -> "update" 12 - | Emplace -> "emplace" 13 - 14 - type import_result = { 15 - success : bool; 16 - error : string option; 17 - document : string option; 18 - } 19 - 20 - let import_result_jsont = 21 - let make success error document = { success; error; document } in 22 - Jsont.Object.map ~kind:"ImportResult" make 23 - |> Jsont.Object.mem "success" Jsont.bool ~enc:(fun r -> r.success) 24 - |> Jsont.Object.opt_mem "error" Jsont.string ~enc:(fun r -> r.error) 25 - |> Jsont.Object.opt_mem "document" Jsont.string ~enc:(fun r -> r.document) 26 - |> Jsont.Object.skip_unknown 27 - |> Jsont.Object.finish 28 - 29 - let import client ~collection ?(action = Upsert) ?(batch_size = 40) 30 - ?(return_doc = false) ?(return_id = false) documents = 31 - let path = 32 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/import" 33 - in 34 - let params = 35 - [ 36 - ("action", action_to_string action); 37 - ("batch_size", string_of_int batch_size); 38 - ("return_doc", string_of_bool return_doc); 39 - ("return_id", string_of_bool return_id); 40 - ] 41 - in 42 - (* Convert documents to JSONL format *) 43 - let body = 44 - documents 45 - |> List.map (fun doc -> Encode.to_json_string Jsont.json doc) 46 - |> String.concat "\n" 47 - in 48 - let response = Client.request_raw client ~method_:`POST ~path ~params ~body () in 49 - Encode.parse_jsonl import_result_jsont response 50 - 51 - let get client ~collection ~id = 52 - let path = 53 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/" 54 - ^ Uri.pct_encode id 55 - in 56 - Client.request client ~method_:`GET ~path () 57 - 58 - let delete client ~collection ~id = 59 - let path = 60 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/" 61 - ^ Uri.pct_encode id 62 - in 63 - Client.request client ~method_:`DELETE ~path () 64 - 65 - let update client ~collection ~id document = 66 - let path = 67 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/" 68 - ^ Uri.pct_encode id 69 - in 70 - let body = Encode.to_json_string Jsont.json document in 71 - Client.request client ~method_:`PATCH ~path ~body () 72 - 73 - let create client ~collection document = 74 - let path = "/collections/" ^ Uri.pct_encode collection ^ "/documents" in 75 - let body = Encode.to_json_string Jsont.json document in 76 - Client.request client ~method_:`POST ~path ~body () 77 - 78 - type delete_by_query_result = { num_deleted : int } 79 - 80 - let delete_by_query_result_jsont = 81 - Jsont.Object.map ~kind:"DeleteByQueryResult" (fun num_deleted -> 82 - { num_deleted }) 83 - |> Jsont.Object.mem "num_deleted" Jsont.int ~enc:(fun r -> r.num_deleted) 84 - |> Jsont.Object.skip_unknown 85 - |> Jsont.Object.finish 86 - 87 - let delete_by_query client ~collection ~filter_by = 88 - let path = 89 - "/collections/" ^ Uri.pct_encode collection ^ "/documents" 90 - in 91 - let params = [ ("filter_by", filter_by) ] in 92 - let json = Client.request client ~method_:`DELETE ~path ~params () in 93 - let result = 94 - Encode.decode_or_raise delete_by_query_result_jsont json "delete by query" 95 - in 96 - result.num_deleted 97 - 98 - type export_params = { 99 - filter_by : string option; 100 - include_fields : string list option; 101 - exclude_fields : string list option; 102 - } 103 - 104 - let export_params ?filter_by ?include_fields ?exclude_fields () = 105 - { filter_by; include_fields; exclude_fields } 106 - 107 - let export client ~collection ?params () = 108 - let path = 109 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/export" 110 - in 111 - let query_params = 112 - match params with 113 - | None -> [] 114 - | Some p -> 115 - List.filter_map Fun.id 116 - [ 117 - Option.map (fun v -> ("filter_by", v)) p.filter_by; 118 - Option.map 119 - (fun v -> ("include_fields", String.concat "," v)) 120 - p.include_fields; 121 - Option.map 122 - (fun v -> ("exclude_fields", String.concat "," v)) 123 - p.exclude_fields; 124 - ] 125 - in 126 - let params = if query_params = [] then None else Some query_params in 127 - let response = Client.request_raw client ~method_:`GET ~path ?params () in 128 - Encode.parse_jsonl Jsont.json response
-97
lib/typesense/document.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense document operations. 7 - 8 - This module provides operations for managing documents in Typesense 9 - collections. Documents are JSON objects stored in collections. *) 10 - 11 - (** {1 Import Actions} *) 12 - 13 - type action = 14 - | Create (** Only create new documents (fail if exists) *) 15 - | Upsert (** Create or replace documents *) 16 - | Update (** Only update existing documents *) 17 - | Emplace (** Create or update (merge) documents *) 18 - (** Action to take during document import. *) 19 - 20 - (** {1 Import Results} *) 21 - 22 - type import_result = { 23 - success : bool; (** Whether the import succeeded *) 24 - error : string option; (** Error message if failed *) 25 - document : string option; (** Document JSON if return_doc was true *) 26 - } 27 - (** Result for a single document in a batch import. *) 28 - 29 - val import_result_jsont : import_result Jsont.t 30 - (** JSON codec for import results. *) 31 - 32 - (** {1 Document Operations} *) 33 - 34 - val import : 35 - Client.t -> 36 - collection:string -> 37 - ?action:action -> 38 - ?batch_size:int -> 39 - ?return_doc:bool -> 40 - ?return_id:bool -> 41 - Jsont.json list -> 42 - import_result list 43 - (** [import client ~collection ?action ?batch_size documents] imports documents 44 - in batch. 45 - @param action Import action (default: Upsert) 46 - @param batch_size Number of documents per batch (default: 40) 47 - @param return_doc Return the document in the result 48 - @param return_id Return the document ID in the result 49 - @return List of import results, one per document *) 50 - 51 - val get : Client.t -> collection:string -> id:string -> Jsont.json 52 - (** [get client ~collection ~id] retrieves a document by ID. 53 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 54 - 55 - val delete : Client.t -> collection:string -> id:string -> Jsont.json 56 - (** [delete client ~collection ~id] deletes a document by ID. 57 - @return The deleted document 58 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 59 - 60 - val update : Client.t -> collection:string -> id:string -> Jsont.json -> Jsont.json 61 - (** [update client ~collection ~id document] updates a document by ID. Only the 62 - fields present in [document] are updated. 63 - @return The updated document 64 - @raise Eio.Io with [Error.E { code = Not_found; _ }] if not found *) 65 - 66 - val create : Client.t -> collection:string -> Jsont.json -> Jsont.json 67 - (** [create client ~collection document] creates a new document. 68 - @return The created document with auto-generated ID if not specified 69 - @raise Eio.Io with [Error.E { code = Conflict; _ }] if ID already exists *) 70 - 71 - val delete_by_query : Client.t -> collection:string -> filter_by:string -> int 72 - (** [delete_by_query client ~collection ~filter_by] deletes all documents 73 - matching the filter. 74 - @return Number of documents deleted *) 75 - 76 - (** {1 Export Operations} *) 77 - 78 - type export_params = { 79 - filter_by : string option; 80 - include_fields : string list option; 81 - exclude_fields : string list option; 82 - } 83 - (** Parameters for exporting documents. *) 84 - 85 - val export_params : 86 - ?filter_by:string -> 87 - ?include_fields:string list -> 88 - ?exclude_fields:string list -> 89 - unit -> 90 - export_params 91 - (** [export_params ...] creates export parameters. *) 92 - 93 - val export : 94 - Client.t -> collection:string -> ?params:export_params -> unit -> Jsont.json list 95 - (** [export client ~collection ?params ()] exports all documents from a 96 - collection. 97 - @return List of documents as JSON *)
-10
lib/typesense/dune
··· 1 - (library 2 - (public_name typesense) 3 - (name typesense) 4 - (libraries 5 - eio 6 - requests 7 - jsont 8 - jsont.bytesrw 9 - uri 10 - logs))
-55
lib/typesense/encode.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Encoding utilities for Typesense API requests *) 7 - 8 - let to_json_string : 'a Jsont.t -> 'a -> string = 9 - fun codec value -> 10 - match Jsont_bytesrw.encode_string' codec value with 11 - | Ok s -> s 12 - | Error e -> failwith ("JSON encoding error: " ^ Jsont.Error.to_string e) 13 - 14 - let from_json_string : 'a Jsont.t -> string -> ('a, string) result = 15 - fun codec json_str -> 16 - match Jsont_bytesrw.decode_string' codec json_str with 17 - | Ok v -> Ok v 18 - | Error e -> Error (Jsont.Error.to_string e) 19 - 20 - let from_json : 'a Jsont.t -> Jsont.json -> ('a, string) result = 21 - fun codec json -> 22 - let json_str = 23 - match Jsont_bytesrw.encode_string' Jsont.json json with 24 - | Ok s -> s 25 - | Error e -> 26 - failwith ("Failed to re-encode json: " ^ Jsont.Error.to_string e) 27 - in 28 - from_json_string codec json_str 29 - 30 - let to_json : 'a Jsont.t -> 'a -> (Jsont.json, string) result = 31 - fun codec value -> 32 - let json_str = to_json_string codec value in 33 - match Jsont_bytesrw.decode_string' Jsont.json json_str with 34 - | Ok json -> Ok json 35 - | Error e -> Error (Jsont.Error.to_string e) 36 - 37 - let decode_or_raise : 'a Jsont.t -> Jsont.json -> string -> 'a = 38 - fun codec json context -> 39 - match from_json codec json with 40 - | Ok v -> v 41 - | Error msg -> 42 - Error.raise_with_context 43 - (Error.make ~code:(Other 0) ~message:msg) 44 - "%s" context 45 - 46 - let parse_jsonl : 'a Jsont.t -> string -> 'a list = 47 - fun codec response -> 48 - String.split_on_char '\n' response 49 - |> List.filter_map (fun line -> 50 - let line = String.trim line in 51 - if line = "" then None 52 - else 53 - match from_json_string codec line with 54 - | Ok result -> Some result 55 - | Error _ -> None)
-28
lib/typesense/encode.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Encoding utilities for Typesense API requests *) 7 - 8 - val to_json_string : 'a Jsont.t -> 'a -> string 9 - (** [to_json_string codec value] converts a value to JSON string using its 10 - jsont codec. *) 11 - 12 - val from_json_string : 'a Jsont.t -> string -> ('a, string) result 13 - (** [from_json_string codec str] parses a JSON string using a jsont codec. *) 14 - 15 - val from_json : 'a Jsont.t -> Jsont.json -> ('a, string) result 16 - (** [from_json codec json] parses a Jsont.json value using a codec. *) 17 - 18 - val to_json : 'a Jsont.t -> 'a -> (Jsont.json, string) result 19 - (** [to_json codec value] converts a value to Jsont.json using a codec. *) 20 - 21 - val decode_or_raise : 'a Jsont.t -> Jsont.json -> string -> 'a 22 - (** [decode_or_raise codec json context] decodes JSON using the codec, or 23 - raises a Typesense error with the given context if decoding fails. *) 24 - 25 - val parse_jsonl : 'a Jsont.t -> string -> 'a list 26 - (** [parse_jsonl codec response] parses a JSONL (newline-delimited JSON) 27 - response string into a list of values. Empty lines are skipped and 28 - parse errors are silently dropped. *)
-54
lib/typesense/error.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type code = 7 - | Bad_request 8 - | Unauthorized 9 - | Not_found 10 - | Conflict 11 - | Unprocessable_entity 12 - | Service_unavailable 13 - | Other of int 14 - 15 - type t = { code : code; message : string } 16 - type Eio.Exn.err += E of t 17 - 18 - let pp_code fmt = function 19 - | Bad_request -> Format.fprintf fmt "Bad_request" 20 - | Unauthorized -> Format.fprintf fmt "Unauthorized" 21 - | Not_found -> Format.fprintf fmt "Not_found" 22 - | Conflict -> Format.fprintf fmt "Conflict" 23 - | Unprocessable_entity -> Format.fprintf fmt "Unprocessable_entity" 24 - | Service_unavailable -> Format.fprintf fmt "Service_unavailable" 25 - | Other n -> Format.fprintf fmt "Other(%d)" n 26 - 27 - let pp fmt t = Format.fprintf fmt "%a: %s" pp_code t.code t.message 28 - 29 - let () = 30 - Eio.Exn.register_pp (fun f -> function 31 - | E e -> 32 - Format.fprintf f "Typesense %a" pp e; 33 - true 34 - | _ -> false) 35 - 36 - let code_of_status = function 37 - | 400 -> Bad_request 38 - | 401 -> Unauthorized 39 - | 404 -> Not_found 40 - | 409 -> Conflict 41 - | 422 -> Unprocessable_entity 42 - | 503 -> Service_unavailable 43 - | n -> Other n 44 - 45 - let make ~code ~message = { code; message } 46 - let code t = t.code 47 - let message t = t.message 48 - let raise e = Stdlib.raise (Eio.Exn.create (E e)) 49 - 50 - let raise_with_context e fmt = 51 - Format.kasprintf 52 - (fun context -> 53 - Stdlib.raise (Eio.Exn.add_context (Eio.Exn.create (E e)) "%s" context)) 54 - fmt
-71
lib/typesense/error.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense API error handling. 7 - 8 - This module defines protocol-level errors for the Typesense API, following 9 - the Eio error pattern for context-aware error handling. 10 - 11 - Errors are raised as [Eio.Io] exceptions: 12 - {[ 13 - try Typesense.Collection.create client schema with 14 - | Eio.Io (Typesense.Error.E { code = Unauthorized; message; _ }, _) -> 15 - Printf.eprintf "Authentication failed: %s\n" message 16 - | Eio.Io (Typesense.Error.E err, _) -> 17 - Printf.eprintf "API error: %a\n" Typesense.Error.pp err 18 - ]} *) 19 - 20 - (** {1 Error Codes} 21 - 22 - These error codes correspond to HTTP status codes returned by Typesense. *) 23 - 24 - type code = 25 - | Bad_request (** 400 - Malformed request *) 26 - | Unauthorized (** 401 - Invalid API key *) 27 - | Not_found (** 404 - Resource not found *) 28 - | Conflict (** 409 - Resource already exists *) 29 - | Unprocessable_entity (** 422 - Invalid data *) 30 - | Service_unavailable (** 503 - Server temporarily unavailable *) 31 - | Other of int (** Other HTTP status code *) 32 - 33 - (** {1 Error Type} *) 34 - 35 - type t = { 36 - code : code; (** The error code *) 37 - message : string; (** Human-readable error message *) 38 - } 39 - (** The protocol-level error type. *) 40 - 41 - (** {1 Eio Integration} *) 42 - 43 - type Eio.Exn.err += 44 - | E of t (** Extend [Eio.Exn.err] with Typesense protocol errors. *) 45 - 46 - val raise : t -> 'a 47 - (** [raise e] raises an [Eio.Io] exception for error [e]. Equivalent to 48 - [Stdlib.raise (Eio.Exn.create (E e))]. *) 49 - 50 - val raise_with_context : t -> ('a, Format.formatter, unit, 'b) format4 -> 'a 51 - (** [raise_with_context e fmt ...] raises an [Eio.Io] exception with context. 52 - Equivalent to 53 - [Stdlib.raise (Eio.Exn.add_context (Eio.Exn.create (E e)) fmt ...)]. *) 54 - 55 - (** {1 Error Construction} *) 56 - 57 - val make : code:code -> message:string -> t 58 - (** [make ~code ~message] creates an error value. *) 59 - 60 - val code_of_status : int -> code 61 - (** [code_of_status status] converts an HTTP status code to an error code. *) 62 - 63 - (** {1 Accessors} *) 64 - 65 - val code : t -> code 66 - val message : t -> string 67 - 68 - (** {1 Pretty Printing} *) 69 - 70 - val pp_code : Format.formatter -> code -> unit 71 - val pp : Format.formatter -> t -> unit
-97
lib/typesense/multi_search.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type search_request = { 7 - collection : string; 8 - q : string; 9 - query_by : string list; 10 - filter_by : string option; 11 - sort_by : string option; 12 - facet_by : string list option; 13 - per_page : int option; 14 - page : int option; 15 - prefix : bool option; 16 - include_fields : string list option; 17 - exclude_fields : string list option; 18 - } 19 - 20 - let search_request ~collection ~q ~query_by ?filter_by ?sort_by ?facet_by 21 - ?per_page ?page ?prefix ?include_fields ?exclude_fields () = 22 - { 23 - collection; 24 - q; 25 - query_by; 26 - filter_by; 27 - sort_by; 28 - facet_by; 29 - per_page; 30 - page; 31 - prefix; 32 - include_fields; 33 - exclude_fields; 34 - } 35 - 36 - (* Helper codec for comma-separated string lists *) 37 - let comma_list_jsont = 38 - let of_string s = Ok (String.split_on_char ',' s |> List.map String.trim) in 39 - let to_string l = String.concat "," l in 40 - Jsont.of_of_string ~kind:"comma_list" of_string ~enc:to_string 41 - 42 - let search_request_jsont = 43 - let make collection q query_by filter_by sort_by facet_by per_page page prefix 44 - include_fields exclude_fields = 45 - { 46 - collection; 47 - q; 48 - query_by; 49 - filter_by; 50 - sort_by; 51 - facet_by; 52 - per_page; 53 - page; 54 - prefix; 55 - include_fields; 56 - exclude_fields; 57 - } 58 - in 59 - Jsont.Object.map ~kind:"SearchRequest" make 60 - |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection) 61 - |> Jsont.Object.mem "q" Jsont.string ~enc:(fun r -> r.q) 62 - |> Jsont.Object.mem "query_by" comma_list_jsont ~enc:(fun r -> r.query_by) 63 - |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 64 - |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 65 - |> Jsont.Object.opt_mem "facet_by" comma_list_jsont ~enc:(fun r -> r.facet_by) 66 - |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page) 67 - |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 68 - |> Jsont.Object.opt_mem "prefix" Jsont.bool ~enc:(fun r -> r.prefix) 69 - |> Jsont.Object.opt_mem "include_fields" comma_list_jsont 70 - ~enc:(fun r -> r.include_fields) 71 - |> Jsont.Object.opt_mem "exclude_fields" comma_list_jsont 72 - ~enc:(fun r -> r.exclude_fields) 73 - |> Jsont.Object.skip_unknown 74 - |> Jsont.Object.finish 75 - 76 - type request = { searches : search_request list } 77 - 78 - let request_jsont = 79 - Jsont.Object.map ~kind:"MultiSearchRequest" (fun searches -> { searches }) 80 - |> Jsont.Object.mem "searches" (Jsont.list search_request_jsont) 81 - ~enc:(fun r -> r.searches) 82 - |> Jsont.Object.finish 83 - 84 - type result = { results : Search.result list } 85 - 86 - let result_jsont = 87 - Jsont.Object.map ~kind:"MultiSearchResult" (fun results -> { results }) 88 - |> Jsont.Object.mem "results" (Jsont.list Search.result_jsont) 89 - ~enc:(fun r -> r.results) 90 - |> Jsont.Object.skip_unknown 91 - |> Jsont.Object.finish 92 - 93 - let search client requests = 94 - let req = { searches = requests } in 95 - let body = Encode.to_json_string request_jsont req in 96 - let json = Client.request client ~method_:`POST ~path:"/multi_search" ~body () in 97 - Encode.decode_or_raise result_jsont json "multi_search"
-61
lib/typesense/multi_search.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense multi-search operations. 7 - 8 - This module provides support for executing multiple searches across different 9 - collections in a single request. This is more efficient than making separate 10 - search requests. *) 11 - 12 - (** {1 Search Request Type} *) 13 - 14 - type search_request = { 15 - collection : string; (** Collection to search *) 16 - q : string; (** Query string *) 17 - query_by : string list; (** Fields to search in *) 18 - filter_by : string option; (** Filter expression *) 19 - sort_by : string option; (** Sort expression *) 20 - facet_by : string list option; (** Fields to facet on *) 21 - per_page : int option; (** Results per page *) 22 - page : int option; (** Page number *) 23 - prefix : bool option; (** Enable prefix search *) 24 - include_fields : string list option; (** Fields to include *) 25 - exclude_fields : string list option; (** Fields to exclude *) 26 - } 27 - (** A single search request within a multi-search operation. *) 28 - 29 - val search_request : 30 - collection:string -> 31 - q:string -> 32 - query_by:string list -> 33 - ?filter_by:string -> 34 - ?sort_by:string -> 35 - ?facet_by:string list -> 36 - ?per_page:int -> 37 - ?page:int -> 38 - ?prefix:bool -> 39 - ?include_fields:string list -> 40 - ?exclude_fields:string list -> 41 - unit -> 42 - search_request 43 - (** [search_request ~collection ~q ~query_by ...] creates a search request. *) 44 - 45 - val search_request_jsont : search_request Jsont.t 46 - (** JSON codec for search requests. *) 47 - 48 - (** {1 Multi-Search Result} *) 49 - 50 - type result = { results : Search.result list } 51 - (** Multi-search result containing results for each search request. *) 52 - 53 - val result_jsont : result Jsont.t 54 - (** JSON codec for multi-search results. *) 55 - 56 - (** {1 Multi-Search Operation} *) 57 - 58 - val search : Client.t -> search_request list -> result 59 - (** [search client requests] executes multiple searches in a single request. 60 - The results are returned in the same order as the requests. 61 - @raise Eio.Io with [Error.E] on API errors *)
-261
lib/typesense/search.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - type highlight = { 7 - field : string; 8 - snippet : string option; 9 - snippets : string list option; 10 - matched_tokens : string list option; 11 - indices : int list option; 12 - } 13 - 14 - let highlight_jsont = 15 - let make field snippet snippets matched_tokens indices = 16 - { field; snippet; snippets; matched_tokens; indices } 17 - in 18 - Jsont.Object.map ~kind:"Highlight" make 19 - |> Jsont.Object.mem "field" Jsont.string ~enc:(fun h -> h.field) 20 - |> Jsont.Object.opt_mem "snippet" Jsont.string ~enc:(fun h -> h.snippet) 21 - |> Jsont.Object.opt_mem "snippets" (Jsont.list Jsont.string) 22 - ~enc:(fun h -> h.snippets) 23 - |> Jsont.Object.opt_mem "matched_tokens" (Jsont.list Jsont.string) 24 - ~enc:(fun h -> h.matched_tokens) 25 - |> Jsont.Object.opt_mem "indices" (Jsont.list Jsont.int) 26 - ~enc:(fun h -> h.indices) 27 - |> Jsont.Object.skip_unknown 28 - |> Jsont.Object.finish 29 - 30 - type hit = { 31 - document : Jsont.json; 32 - highlights : highlight list option; 33 - text_match : int64 option; 34 - text_match_info : Jsont.json option; 35 - } 36 - 37 - let hit_jsont = 38 - let make document highlights text_match text_match_info = 39 - { document; highlights; text_match; text_match_info } 40 - in 41 - Jsont.Object.map ~kind:"Hit" make 42 - |> Jsont.Object.mem "document" Jsont.json ~enc:(fun h -> h.document) 43 - |> Jsont.Object.opt_mem "highlights" (Jsont.list highlight_jsont) 44 - ~enc:(fun h -> h.highlights) 45 - |> Jsont.Object.opt_mem "text_match" Jsont.int64 ~enc:(fun h -> h.text_match) 46 - |> Jsont.Object.opt_mem "text_match_info" Jsont.json 47 - ~enc:(fun h -> h.text_match_info) 48 - |> Jsont.Object.skip_unknown 49 - |> Jsont.Object.finish 50 - 51 - type facet_count = { 52 - value : string; 53 - count : int; 54 - highlighted : string option; 55 - } 56 - 57 - let facet_count_jsont = 58 - let make value count highlighted = { value; count; highlighted } in 59 - Jsont.Object.map ~kind:"FacetCount" make 60 - |> Jsont.Object.mem "value" Jsont.string ~enc:(fun f -> f.value) 61 - |> Jsont.Object.mem "count" Jsont.int ~enc:(fun f -> f.count) 62 - |> Jsont.Object.opt_mem "highlighted" Jsont.string ~enc:(fun f -> f.highlighted) 63 - |> Jsont.Object.skip_unknown 64 - |> Jsont.Object.finish 65 - 66 - type facet_stats = { 67 - min : float option; 68 - max : float option; 69 - sum : float option; 70 - avg : float option; 71 - total_values : int option; 72 - } 73 - 74 - let facet_stats_jsont = 75 - let make min max sum avg total_values = 76 - { min; max; sum; avg; total_values } 77 - in 78 - Jsont.Object.map ~kind:"FacetStats" make 79 - |> Jsont.Object.opt_mem "min" Jsont.number ~enc:(fun f -> f.min) 80 - |> Jsont.Object.opt_mem "max" Jsont.number ~enc:(fun f -> f.max) 81 - |> Jsont.Object.opt_mem "sum" Jsont.number ~enc:(fun f -> f.sum) 82 - |> Jsont.Object.opt_mem "avg" Jsont.number ~enc:(fun f -> f.avg) 83 - |> Jsont.Object.opt_mem "total_values" Jsont.int ~enc:(fun f -> f.total_values) 84 - |> Jsont.Object.skip_unknown 85 - |> Jsont.Object.finish 86 - 87 - type facet = { 88 - field_name : string; 89 - counts : facet_count list; 90 - stats : facet_stats option; 91 - } 92 - 93 - let facet_jsont = 94 - let make field_name counts stats = { field_name; counts; stats } in 95 - Jsont.Object.map ~kind:"Facet" make 96 - |> Jsont.Object.mem "field_name" Jsont.string ~enc:(fun f -> f.field_name) 97 - |> Jsont.Object.mem "counts" (Jsont.list facet_count_jsont) ~enc:(fun f -> f.counts) 98 - |> Jsont.Object.opt_mem "stats" facet_stats_jsont ~enc:(fun f -> f.stats) 99 - |> Jsont.Object.skip_unknown 100 - |> Jsont.Object.finish 101 - 102 - type result = { 103 - hits : hit list; 104 - found : int; 105 - search_time_ms : int; 106 - page : int option; 107 - out_of : int option; 108 - facet_counts : facet list option; 109 - request_params : Jsont.json option; 110 - } 111 - 112 - let result_jsont = 113 - let make hits found search_time_ms page out_of facet_counts request_params = 114 - { hits; found; search_time_ms; page; out_of; facet_counts; request_params } 115 - in 116 - Jsont.Object.map ~kind:"SearchResult" make 117 - |> Jsont.Object.mem "hits" (Jsont.list hit_jsont) ~enc:(fun r -> r.hits) 118 - |> Jsont.Object.mem "found" Jsont.int ~enc:(fun r -> r.found) 119 - |> Jsont.Object.mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms) 120 - |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 121 - |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of) 122 - |> Jsont.Object.opt_mem "facet_counts" (Jsont.list facet_jsont) 123 - ~enc:(fun r -> r.facet_counts) 124 - |> Jsont.Object.opt_mem "request_params" Jsont.json 125 - ~enc:(fun r -> r.request_params) 126 - |> Jsont.Object.skip_unknown 127 - |> Jsont.Object.finish 128 - 129 - type params = { 130 - q : string; 131 - query_by : string list; 132 - filter_by : string option; 133 - sort_by : string option; 134 - facet_by : string list option; 135 - max_facet_values : int option; 136 - per_page : int option; 137 - page : int option; 138 - prefix : bool option; 139 - infix : string option; 140 - highlight_fields : string list option; 141 - highlight_full_fields : string list option; 142 - highlight_affix_num_tokens : int option; 143 - highlight_start_tag : string option; 144 - highlight_end_tag : string option; 145 - snippet_threshold : int option; 146 - num_typos : int option; 147 - typo_tokens_threshold : int option; 148 - drop_tokens_threshold : int option; 149 - include_fields : string list option; 150 - exclude_fields : string list option; 151 - group_by : string list option; 152 - group_limit : int option; 153 - limit_hits : int option; 154 - prioritize_exact_match : bool option; 155 - prioritize_token_position : bool option; 156 - exhaustive_search : bool option; 157 - search_cutoff_ms : int option; 158 - use_cache : bool option; 159 - cache_ttl : int option; 160 - enable_highlight_v1 : bool option; 161 - } 162 - 163 - let params ~q ~query_by ?filter_by ?sort_by ?facet_by ?max_facet_values ?per_page 164 - ?page ?prefix ?infix ?highlight_fields ?highlight_full_fields 165 - ?highlight_affix_num_tokens ?highlight_start_tag ?highlight_end_tag 166 - ?snippet_threshold ?num_typos ?typo_tokens_threshold ?drop_tokens_threshold 167 - ?include_fields ?exclude_fields ?group_by ?group_limit ?limit_hits 168 - ?prioritize_exact_match ?prioritize_token_position ?exhaustive_search 169 - ?search_cutoff_ms ?use_cache ?cache_ttl ?enable_highlight_v1 () = 170 - { 171 - q; 172 - query_by; 173 - filter_by; 174 - sort_by; 175 - facet_by; 176 - max_facet_values; 177 - per_page; 178 - page; 179 - prefix; 180 - infix; 181 - highlight_fields; 182 - highlight_full_fields; 183 - highlight_affix_num_tokens; 184 - highlight_start_tag; 185 - highlight_end_tag; 186 - snippet_threshold; 187 - num_typos; 188 - typo_tokens_threshold; 189 - drop_tokens_threshold; 190 - include_fields; 191 - exclude_fields; 192 - group_by; 193 - group_limit; 194 - limit_hits; 195 - prioritize_exact_match; 196 - prioritize_token_position; 197 - exhaustive_search; 198 - search_cutoff_ms; 199 - use_cache; 200 - cache_ttl; 201 - enable_highlight_v1; 202 - } 203 - 204 - let params_to_query_params p = 205 - let add_opt name opt acc = 206 - match opt with Some v -> (name, v) :: acc | None -> acc 207 - in 208 - let add_opt_bool name opt acc = 209 - match opt with 210 - | Some v -> (name, string_of_bool v) :: acc 211 - | None -> acc 212 - in 213 - let add_opt_int name opt acc = 214 - match opt with Some v -> (name, string_of_int v) :: acc | None -> acc 215 - in 216 - let add_opt_list name opt acc = 217 - match opt with 218 - | Some v when v <> [] -> (name, String.concat "," v) :: acc 219 - | _ -> acc 220 - in 221 - [] 222 - |> add_opt "q" (Some p.q) 223 - |> add_opt "query_by" (Some (String.concat "," p.query_by)) 224 - |> add_opt "filter_by" p.filter_by 225 - |> add_opt "sort_by" p.sort_by 226 - |> add_opt_list "facet_by" p.facet_by 227 - |> add_opt_int "max_facet_values" p.max_facet_values 228 - |> add_opt_int "per_page" p.per_page 229 - |> add_opt_int "page" p.page 230 - |> add_opt_bool "prefix" p.prefix 231 - |> add_opt "infix" p.infix 232 - |> add_opt_list "highlight_fields" p.highlight_fields 233 - |> add_opt_list "highlight_full_fields" p.highlight_full_fields 234 - |> add_opt_int "highlight_affix_num_tokens" p.highlight_affix_num_tokens 235 - |> add_opt "highlight_start_tag" p.highlight_start_tag 236 - |> add_opt "highlight_end_tag" p.highlight_end_tag 237 - |> add_opt_int "snippet_threshold" p.snippet_threshold 238 - |> add_opt_int "num_typos" p.num_typos 239 - |> add_opt_int "typo_tokens_threshold" p.typo_tokens_threshold 240 - |> add_opt_int "drop_tokens_threshold" p.drop_tokens_threshold 241 - |> add_opt_list "include_fields" p.include_fields 242 - |> add_opt_list "exclude_fields" p.exclude_fields 243 - |> add_opt_list "group_by" p.group_by 244 - |> add_opt_int "group_limit" p.group_limit 245 - |> add_opt_int "limit_hits" p.limit_hits 246 - |> add_opt_bool "prioritize_exact_match" p.prioritize_exact_match 247 - |> add_opt_bool "prioritize_token_position" p.prioritize_token_position 248 - |> add_opt_bool "exhaustive_search" p.exhaustive_search 249 - |> add_opt_int "search_cutoff_ms" p.search_cutoff_ms 250 - |> add_opt_bool "use_cache" p.use_cache 251 - |> add_opt_int "cache_ttl" p.cache_ttl 252 - |> add_opt_bool "enable_highlight_v1" p.enable_highlight_v1 253 - |> List.rev 254 - 255 - let search client ~collection p = 256 - let path = 257 - "/collections/" ^ Uri.pct_encode collection ^ "/documents/search" 258 - in 259 - let params = params_to_query_params p in 260 - let json = Client.request client ~method_:`GET ~path ~params () in 261 - Encode.decode_or_raise result_jsont json "search"
-153
lib/typesense/search.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** Typesense search operations. 7 - 8 - This module provides types and functions for searching documents in 9 - Typesense collections. *) 10 - 11 - (** {1 Search Result Types} *) 12 - 13 - type highlight = { 14 - field : string; (** Field name that was highlighted *) 15 - snippet : string option; (** Highlighted snippet (single value) *) 16 - snippets : string list option; (** Highlighted snippets (array fields) *) 17 - matched_tokens : string list option; (** Tokens that matched *) 18 - indices : int list option; (** Indices of matched values in array *) 19 - } 20 - (** Highlighting information for a matched field. *) 21 - 22 - val highlight_jsont : highlight Jsont.t 23 - 24 - type hit = { 25 - document : Jsont.json; (** The matched document *) 26 - highlights : highlight list option; (** Highlighting information *) 27 - text_match : int64 option; (** Text match score *) 28 - text_match_info : Jsont.json option; (** Detailed match info *) 29 - } 30 - (** A single search hit. *) 31 - 32 - val hit_jsont : hit Jsont.t 33 - 34 - type facet_count = { 35 - value : string; (** Facet value *) 36 - count : int; (** Number of documents with this value *) 37 - highlighted : string option; (** Highlighted value for facet search *) 38 - } 39 - (** Count for a single facet value. *) 40 - 41 - val facet_count_jsont : facet_count Jsont.t 42 - 43 - type facet_stats = { 44 - min : float option; 45 - max : float option; 46 - sum : float option; 47 - avg : float option; 48 - total_values : int option; 49 - } 50 - (** Statistics for numeric facets. *) 51 - 52 - val facet_stats_jsont : facet_stats Jsont.t 53 - 54 - type facet = { 55 - field_name : string; (** Faceted field name *) 56 - counts : facet_count list; (** Value counts *) 57 - stats : facet_stats option; (** Numeric statistics *) 58 - } 59 - (** Facet results for a field. *) 60 - 61 - val facet_jsont : facet Jsont.t 62 - 63 - type result = { 64 - hits : hit list; (** Matched documents *) 65 - found : int; (** Total documents matching query *) 66 - search_time_ms : int; (** Search time in milliseconds *) 67 - page : int option; (** Current page number *) 68 - out_of : int option; (** Total documents in collection *) 69 - facet_counts : facet list option; (** Facet results *) 70 - request_params : Jsont.json option; (** Echo of request parameters *) 71 - } 72 - (** Search result containing hits and metadata. *) 73 - 74 - val result_jsont : result Jsont.t 75 - 76 - (** {1 Search Parameters} *) 77 - 78 - type params = { 79 - q : string; (** Query string (use "*" for all documents) *) 80 - query_by : string list; (** Fields to search in *) 81 - filter_by : string option; (** Filter expression *) 82 - sort_by : string option; (** Sort expression *) 83 - facet_by : string list option; (** Fields to facet on *) 84 - max_facet_values : int option; (** Max facet values to return *) 85 - per_page : int option; (** Results per page (default: 10) *) 86 - page : int option; (** Page number (default: 1) *) 87 - prefix : bool option; (** Enable prefix search *) 88 - infix : string option; (** Infix search mode *) 89 - highlight_fields : string list option; (** Fields to highlight *) 90 - highlight_full_fields : string list option; (** Fields for full highlight *) 91 - highlight_affix_num_tokens : int option; (** Tokens around highlight *) 92 - highlight_start_tag : string option; (** Start tag for highlighting *) 93 - highlight_end_tag : string option; (** End tag for highlighting *) 94 - snippet_threshold : int option; (** Threshold for snippets *) 95 - num_typos : int option; (** Max typos allowed *) 96 - typo_tokens_threshold : int option; (** Typo token threshold *) 97 - drop_tokens_threshold : int option; (** Token dropping threshold *) 98 - include_fields : string list option; (** Fields to include in results *) 99 - exclude_fields : string list option; (** Fields to exclude from results *) 100 - group_by : string list option; (** Fields to group by *) 101 - group_limit : int option; (** Max documents per group *) 102 - limit_hits : int option; (** Max total hits *) 103 - prioritize_exact_match : bool option; (** Prioritize exact matches *) 104 - prioritize_token_position : bool option; (** Prioritize token position *) 105 - exhaustive_search : bool option; (** Exhaustive search mode *) 106 - search_cutoff_ms : int option; (** Search timeout *) 107 - use_cache : bool option; (** Use search cache *) 108 - cache_ttl : int option; (** Cache TTL in seconds *) 109 - enable_highlight_v1 : bool option; (** Use v1 highlighting *) 110 - } 111 - (** Search parameters. *) 112 - 113 - val params : 114 - q:string -> 115 - query_by:string list -> 116 - ?filter_by:string -> 117 - ?sort_by:string -> 118 - ?facet_by:string list -> 119 - ?max_facet_values:int -> 120 - ?per_page:int -> 121 - ?page:int -> 122 - ?prefix:bool -> 123 - ?infix:string -> 124 - ?highlight_fields:string list -> 125 - ?highlight_full_fields:string list -> 126 - ?highlight_affix_num_tokens:int -> 127 - ?highlight_start_tag:string -> 128 - ?highlight_end_tag:string -> 129 - ?snippet_threshold:int -> 130 - ?num_typos:int -> 131 - ?typo_tokens_threshold:int -> 132 - ?drop_tokens_threshold:int -> 133 - ?include_fields:string list -> 134 - ?exclude_fields:string list -> 135 - ?group_by:string list -> 136 - ?group_limit:int -> 137 - ?limit_hits:int -> 138 - ?prioritize_exact_match:bool -> 139 - ?prioritize_token_position:bool -> 140 - ?exhaustive_search:bool -> 141 - ?search_cutoff_ms:int -> 142 - ?use_cache:bool -> 143 - ?cache_ttl:int -> 144 - ?enable_highlight_v1:bool -> 145 - unit -> 146 - params 147 - (** [params ~q ~query_by ...] creates search parameters. *) 148 - 149 - (** {1 Search Operation} *) 150 - 151 - val search : Client.t -> collection:string -> params -> result 152 - (** [search client ~collection params] searches for documents. 153 - @raise Eio.Io with [Error.E] on API errors *)
-15
lib/typesense/typesense.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** OCaml bindings for the Typesense search API. *) 7 - 8 - module Auth = Auth 9 - module Error = Error 10 - module Client = Client 11 - module Collection = Collection 12 - module Document = Document 13 - module Search = Search 14 - module Multi_search = Multi_search 15 - module Analytics = Analytics
-89
lib/typesense/typesense.mli
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (** OCaml bindings for the Typesense search API. 7 - 8 - Typesense is a fast, typo-tolerant search engine. This library provides 9 - high-quality OCaml bindings using Eio for async operations. 10 - 11 - {2 Quick Start} 12 - 13 - {[ 14 - open Typesense 15 - 16 - let () = 17 - Eio_main.run @@ fun env -> 18 - let auth = Auth.create ~endpoint:"http://localhost:8108" ~api_key:"xyz" in 19 - Client.with_client env auth @@ fun client -> 20 - 21 - (* Create a collection *) 22 - let schema = 23 - Collection.schema ~name:"books" 24 - ~fields: 25 - [ 26 - Collection.field ~name:"title" ~type_:"string" (); 27 - Collection.field ~name:"author" ~type_:"string" ~facet:true (); 28 - Collection.field ~name:"year" ~type_:"int32" (); 29 - ] 30 - ~default_sorting_field:"year" () 31 - in 32 - let _ = Collection.create client schema in 33 - 34 - (* Search *) 35 - let params = Search.params ~q:"harry" ~query_by:["title"; "author"] () in 36 - let result = Search.search client ~collection:"books" params in 37 - Printf.printf "Found %d books\n" result.found 38 - ]} 39 - 40 - {2 Error Handling} 41 - 42 - All API operations raise [Eio.Io] exceptions with [Error.E] error codes: 43 - 44 - {[ 45 - try Collection.get client ~name:"nonexistent" with 46 - | Eio.Io (Error.E { code = Not_found; message; _ }, _) -> 47 - Printf.eprintf "Collection not found: %s\n" message 48 - ]} 49 - *) 50 - 51 - (** {1 Authentication} *) 52 - 53 - module Auth = Auth 54 - (** API key authentication for Typesense. *) 55 - 56 - (** {1 Error Handling} *) 57 - 58 - module Error = Error 59 - (** Protocol-level errors with Eio integration. *) 60 - 61 - (** {1 HTTP Client} *) 62 - 63 - module Client = Client 64 - (** Low-level HTTP client for the Typesense API. *) 65 - 66 - (** {1 Collections} *) 67 - 68 - module Collection = Collection 69 - (** Collection schema and CRUD operations. *) 70 - 71 - (** {1 Documents} *) 72 - 73 - module Document = Document 74 - (** Document import, export, and CRUD operations. *) 75 - 76 - (** {1 Search} *) 77 - 78 - module Search = Search 79 - (** Search parameters and results. *) 80 - 81 - (** {1 Multi-Search} *) 82 - 83 - module Multi_search = Multi_search 84 - (** Search multiple collections in one request. *) 85 - 86 - (** {1 Analytics} *) 87 - 88 - module Analytics = Analytics 89 - (** Analytics rules and event tracking. *)
+14
lib/typesense_auth.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (** Typesense authentication library. 7 + 8 + This library provides authentication support for the Typesense API client, 9 + with profile-based session management. *) 10 + 11 + module Session = Session 12 + module Client = Client 13 + module Cmd = Cmd 14 + module Error = Error
+4620
typesense-openapi.yaml
··· 1 + openapi: 3.0.3 2 + info: 3 + title: Typesense API 4 + description: "An open source search engine for building delightful search experiences." 5 + version: '30.0' 6 + license: 7 + name: GPL-3.0 8 + url: https://opensource.org/licenses/GPL-3.0 9 + servers: 10 + - url: "{protocol}://{hostname}:{port}" 11 + description: Typesense Server 12 + variables: 13 + protocol: 14 + default: http 15 + description: The protocol of your Typesense server 16 + hostname: 17 + default: localhost 18 + description: The hostname of your Typesense server 19 + port: 20 + default: "8108" 21 + description: The port of your Typesense server 22 + externalDocs: 23 + description: Find out more about Typsesense 24 + url: https://typesense.org 25 + security: 26 + - api_key_header: [] 27 + tags: 28 + - name: collections 29 + description: A collection is defined by a schema 30 + externalDocs: 31 + description: Find out more 32 + url: https://typesense.org/api/#create-collection 33 + - name: documents 34 + description: A document is an individual record to be indexed and belongs to a collection 35 + externalDocs: 36 + description: Find out more 37 + url: https://typesense.org/api/#index-document 38 + - name: analytics 39 + description: Typesense can aggregate search queries for both analytics purposes and for query suggestions. 40 + externalDocs: 41 + description: Find out more 42 + url: https://typesense.org/docs/28.0/api/analytics-query-suggestions.html 43 + - name: keys 44 + description: Manage API Keys with fine-grain access control 45 + externalDocs: 46 + description: Find out more 47 + url: https://typesense.org/docs/0.23.0/api/#api-keys 48 + - name: debug 49 + description: Debugging information 50 + - name: operations 51 + description: Manage Typesense cluster 52 + externalDocs: 53 + description: Find out more 54 + url: https://typesense.org/docs/28.0/api/cluster-operations.html 55 + - name: stopwords 56 + description: Manage stopwords sets 57 + externalDocs: 58 + description: Find out more 59 + url: https://typesense.org/docs/28.0/api/stopwords.html 60 + - name: presets 61 + description: Store and reference search parameters 62 + externalDocs: 63 + description: Find out more 64 + url: https://typesense.org/docs/28.0/api/search.html#presets 65 + - name: conversations 66 + description: Conversational Search (RAG) 67 + externalDocs: 68 + description: Find out more 69 + url: https://typesense.org/docs/28.0/api/conversational-search-rag.html 70 + - name: synonyms 71 + description: Manage synonyms 72 + externalDocs: 73 + description: Find out more 74 + url: https://typesense.org/docs/28.0/api/synonyms.html 75 + - name: curation_sets 76 + description: Manage curation sets 77 + - name: stemming 78 + description: Manage stemming dictionaries 79 + externalDocs: 80 + description: Find out more 81 + url: https://typesense.org/docs/28.0/api/stemming.html 82 + - name: nl_search_models 83 + description: Manage NL search models 84 + externalDocs: 85 + description: Find out more 86 + url: https://typesense.org/docs/29.0/api/natural-language-search.html 87 + 88 + paths: 89 + /collections: 90 + get: 91 + tags: 92 + - collections 93 + summary: List all collections 94 + description: 95 + Returns a summary of all your collections. The collections are 96 + returned sorted by creation date, with the most recent collections appearing 97 + first. 98 + operationId: getCollections 99 + parameters: 100 + - name: getCollectionsParameters 101 + in: query 102 + schema: 103 + type: object 104 + properties: 105 + exclude_fields: 106 + description: Comma-separated list of fields from the collection to exclude from the response 107 + type: string 108 + limit: 109 + description: > 110 + Number of collections to fetch. 111 + Default: returns all collections. 112 + type: integer 113 + offset: 114 + description: Identifies the starting point to return collections when paginating. 115 + type: integer 116 + responses: 117 + '200': 118 + description: List of all collections 119 + content: 120 + application/json: 121 + schema: 122 + type: array 123 + x-go-type: "[]*CollectionResponse" 124 + items: 125 + $ref: "#/components/schemas/CollectionResponse" 126 + post: 127 + tags: 128 + - collections 129 + summary: Create a new collection 130 + description: 131 + When a collection is created, we give it a name and describe the 132 + fields that will be indexed from the documents added to the collection. 133 + operationId: createCollection 134 + requestBody: 135 + description: The collection object to be created 136 + content: 137 + application/json: 138 + schema: 139 + $ref: "#/components/schemas/CollectionSchema" 140 + required: true 141 + responses: 142 + '201': 143 + description: Collection successfully created 144 + content: 145 + application/json: 146 + schema: 147 + $ref: "#/components/schemas/CollectionResponse" 148 + '400': 149 + description: Bad request, see error message for details 150 + content: 151 + application/json: 152 + schema: 153 + $ref: "#/components/schemas/ApiResponse" 154 + '409': 155 + description: Collection already exists 156 + content: 157 + application/json: 158 + schema: 159 + $ref: "#/components/schemas/ApiResponse" 160 + /collections/{collectionName}: 161 + get: 162 + tags: 163 + - collections 164 + summary: Retrieve a single collection 165 + description: Retrieve the details of a collection, given its name. 166 + operationId: getCollection 167 + parameters: 168 + - name: collectionName 169 + in: path 170 + description: The name of the collection to retrieve 171 + required: true 172 + schema: 173 + type: string 174 + responses: 175 + '200': 176 + description: Collection fetched 177 + content: 178 + application/json: 179 + schema: 180 + $ref: "#/components/schemas/CollectionResponse" 181 + '404': 182 + description: Collection not found 183 + content: 184 + application/json: 185 + schema: 186 + $ref: "#/components/schemas/ApiResponse" 187 + patch: 188 + tags: 189 + - collections 190 + summary: Update a collection 191 + description: 192 + Update a collection's schema to modify the fields and their types. 193 + operationId: updateCollection 194 + parameters: 195 + - name: collectionName 196 + in: path 197 + description: The name of the collection to update 198 + required: true 199 + schema: 200 + type: string 201 + requestBody: 202 + description: The document object with fields to be updated 203 + content: 204 + application/json: 205 + schema: 206 + $ref: "#/components/schemas/CollectionUpdateSchema" 207 + required: true 208 + responses: 209 + '200': 210 + description: The updated partial collection schema 211 + content: 212 + application/json: 213 + schema: 214 + $ref: "#/components/schemas/CollectionUpdateSchema" 215 + '400': 216 + description: Bad request, see error message for details 217 + content: 218 + application/json: 219 + schema: 220 + $ref: "#/components/schemas/ApiResponse" 221 + '404': 222 + description: The collection was not found 223 + content: 224 + application/json: 225 + schema: 226 + $ref: "#/components/schemas/ApiResponse" 227 + delete: 228 + tags: 229 + - collections 230 + summary: Delete a collection 231 + description: 232 + Permanently drops a collection. This action cannot be undone. For 233 + large collections, this might have an impact on read latencies. 234 + operationId: deleteCollection 235 + parameters: 236 + - name: collectionName 237 + in: path 238 + description: The name of the collection to delete 239 + required: true 240 + schema: 241 + type: string 242 + responses: 243 + '200': 244 + description: Collection deleted 245 + content: 246 + application/json: 247 + schema: 248 + $ref: "#/components/schemas/CollectionResponse" 249 + '404': 250 + description: Collection not found 251 + content: 252 + application/json: 253 + schema: 254 + $ref: "#/components/schemas/ApiResponse" 255 + /collections/{collectionName}/documents: 256 + post: 257 + tags: 258 + - documents 259 + summary: Index a document 260 + description: 261 + A document to be indexed in a given collection must conform to 262 + the schema of the collection. 263 + operationId: indexDocument 264 + parameters: 265 + - name: collectionName 266 + in: path 267 + description: The name of the collection to add the document to 268 + required: true 269 + schema: 270 + type: string 271 + - name: action 272 + in: query 273 + description: Additional action to perform 274 + schema: 275 + type: string 276 + example: upsert 277 + $ref: "#/components/schemas/IndexAction" 278 + - name: dirty_values 279 + in: query 280 + description: Dealing with Dirty Data 281 + schema: 282 + $ref: "#/components/schemas/DirtyValues" 283 + requestBody: 284 + description: The document object to be indexed 285 + content: 286 + application/json: 287 + schema: 288 + type: object 289 + description: Can be any key-value pair 290 + x-go-type: "interface{}" 291 + required: true 292 + responses: 293 + '201': 294 + description: Document successfully created/indexed 295 + content: 296 + application/json: 297 + schema: 298 + type: object 299 + description: Can be any key-value pair 300 + '404': 301 + description: Collection not found 302 + content: 303 + application/json: 304 + schema: 305 + $ref: "#/components/schemas/ApiResponse" 306 + patch: 307 + tags: 308 + - documents 309 + summary: Update documents with conditional query 310 + description: 311 + The filter_by query parameter is used to filter to specify a condition against which the documents are matched. 312 + The request body contains the fields that should be updated for any documents that match the filter condition. 313 + This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later. 314 + operationId: updateDocuments 315 + parameters: 316 + - name: collectionName 317 + in: path 318 + description: The name of the collection to update documents in 319 + required: true 320 + schema: 321 + type: string 322 + - name: updateDocumentsParameters 323 + in: query 324 + schema: 325 + type: object 326 + properties: 327 + filter_by: 328 + type: string 329 + example: "num_employees:>100 && country: [USA, UK]" 330 + responses: 331 + '200': 332 + description: 333 + The response contains a single field, `num_updated`, indicating the number of documents affected. 334 + content: 335 + application/json: 336 + schema: 337 + type: object 338 + required: 339 + - num_updated 340 + properties: 341 + num_updated: 342 + type: integer 343 + description: The number of documents that have been updated 344 + example: 1 345 + '400': 346 + description: 'Bad request, see error message for details' 347 + content: 348 + application/json: 349 + schema: 350 + $ref: '#/components/schemas/ApiResponse' 351 + '404': 352 + description: The collection was not found 353 + content: 354 + application/json: 355 + schema: 356 + $ref: '#/components/schemas/ApiResponse' 357 + requestBody: 358 + description: The document fields to be updated 359 + content: 360 + application/json: 361 + schema: 362 + type: object 363 + description: Can be any key-value pair 364 + x-go-type: "interface{}" 365 + required: true 366 + delete: 367 + tags: 368 + - documents 369 + summary: Delete a bunch of documents 370 + description: 371 + Delete a bunch of documents that match a specific filter condition. 372 + Use the `batch_size` parameter to control the number of documents that 373 + should deleted at a time. A larger value will speed up deletions, but will 374 + impact performance of other operations running on the server. 375 + operationId: deleteDocuments 376 + parameters: 377 + - name: collectionName 378 + in: path 379 + description: The name of the collection to delete documents from 380 + required: true 381 + schema: 382 + type: string 383 + - name: deleteDocumentsParameters 384 + in: query 385 + schema: 386 + type: object 387 + required: 388 + - filter_by 389 + properties: 390 + filter_by: 391 + type: string 392 + example: "num_employees:>100 && country: [USA, UK]" 393 + batch_size: 394 + description: 395 + Batch size parameter controls the number of documents that should be deleted 396 + at a time. A larger value will speed up deletions, but will impact performance 397 + of other operations running on the server. 398 + type: integer 399 + ignore_not_found: 400 + type: boolean 401 + truncate: 402 + description: When true, removes all documents from the collection while preserving the collection and its schema. 403 + type: boolean 404 + responses: 405 + '200': 406 + description: Documents successfully deleted 407 + content: 408 + application/json: 409 + schema: 410 + type: object 411 + required: 412 + - num_deleted 413 + properties: 414 + num_deleted: 415 + type: integer 416 + '404': 417 + description: Collection not found 418 + content: 419 + application/json: 420 + schema: 421 + $ref: "#/components/schemas/ApiResponse" 422 + /collections/{collectionName}/documents/search: 423 + get: 424 + tags: 425 + - documents 426 + summary: Search for documents in a collection 427 + description: Search for documents in a collection that match the search criteria. 428 + operationId: searchCollection 429 + parameters: 430 + - name: collectionName 431 + in: path 432 + description: The name of the collection to search for the document under 433 + required: true 434 + schema: 435 + type: string 436 + - name: searchParameters 437 + required: true 438 + in: query 439 + schema: 440 + $ref: "#/components/schemas/SearchParameters" 441 + responses: 442 + '200': 443 + description: Search results 444 + content: 445 + application/json: 446 + schema: 447 + $ref: "#/components/schemas/SearchResult" 448 + '400': 449 + description: Bad request, see error message for details 450 + content: 451 + application/json: 452 + schema: 453 + $ref: "#/components/schemas/ApiResponse" 454 + '404': 455 + description: The collection or field was not found 456 + content: 457 + application/json: 458 + schema: 459 + $ref: "#/components/schemas/ApiResponse" 460 + 461 + /synonym_sets: 462 + get: 463 + tags: 464 + - synonyms 465 + summary: List all synonym sets 466 + description: Retrieve all synonym sets 467 + operationId: retrieveSynonymSets 468 + responses: 469 + "200": 470 + description: List of all synonym sets 471 + content: 472 + application/json: 473 + schema: 474 + type: array 475 + items: 476 + $ref: "#/components/schemas/SynonymSetSchema" 477 + 478 + /synonym_sets/{synonymSetName}: 479 + get: 480 + tags: 481 + - synonyms 482 + summary: Retrieve a synonym set 483 + description: Retrieve a specific synonym set by its name 484 + operationId: retrieveSynonymSet 485 + parameters: 486 + - name: synonymSetName 487 + in: path 488 + description: The name of the synonym set to retrieve 489 + required: true 490 + schema: 491 + type: string 492 + responses: 493 + "200": 494 + description: Synonym set fetched 495 + content: 496 + application/json: 497 + schema: 498 + $ref: "#/components/schemas/SynonymSetSchema" 499 + "404": 500 + description: Synonym set not found 501 + content: 502 + application/json: 503 + schema: 504 + $ref: "#/components/schemas/ApiResponse" 505 + 506 + put: 507 + tags: 508 + - synonyms 509 + summary: Create or update a synonym set 510 + description: Create or update a synonym set with the given name 511 + operationId: upsertSynonymSet 512 + parameters: 513 + - name: synonymSetName 514 + in: path 515 + description: The name of the synonym set to create/update 516 + required: true 517 + schema: 518 + type: string 519 + requestBody: 520 + description: The synonym set to be created/updated 521 + content: 522 + application/json: 523 + schema: 524 + $ref: "#/components/schemas/SynonymSetCreateSchema" 525 + required: true 526 + responses: 527 + "200": 528 + description: Synonym set successfully created/updated 529 + content: 530 + application/json: 531 + schema: 532 + $ref: "#/components/schemas/SynonymSetSchema" 533 + "400": 534 + description: Bad request, see error message for details 535 + content: 536 + application/json: 537 + schema: 538 + $ref: "#/components/schemas/ApiResponse" 539 + delete: 540 + tags: 541 + - synonyms 542 + summary: Delete a synonym set 543 + description: Delete a specific synonym set by its name 544 + operationId: deleteSynonymSet 545 + parameters: 546 + - name: synonymSetName 547 + in: path 548 + description: The name of the synonym set to delete 549 + required: true 550 + schema: 551 + type: string 552 + responses: 553 + "200": 554 + description: Synonym set successfully deleted 555 + content: 556 + application/json: 557 + schema: 558 + $ref: "#/components/schemas/SynonymSetDeleteSchema" 559 + "404": 560 + description: Synonym set not found 561 + content: 562 + application/json: 563 + schema: 564 + $ref: "#/components/schemas/ApiResponse" 565 + 566 + /synonym_sets/{synonymSetName}/items: 567 + get: 568 + tags: 569 + - synonyms 570 + summary: List items in a synonym set 571 + description: Retrieve all synonym items in a set 572 + operationId: retrieveSynonymSetItems 573 + parameters: 574 + - name: synonymSetName 575 + in: path 576 + description: The name of the synonym set to retrieve items for 577 + required: true 578 + schema: 579 + type: string 580 + responses: 581 + "200": 582 + description: List of synonym items 583 + content: 584 + application/json: 585 + schema: 586 + type: array 587 + items: 588 + $ref: "#/components/schemas/SynonymItemSchema" 589 + "404": 590 + description: Synonym set not found 591 + content: 592 + application/json: 593 + schema: 594 + $ref: "#/components/schemas/ApiResponse" 595 + 596 + /synonym_sets/{synonymSetName}/items/{itemId}: 597 + get: 598 + tags: 599 + - synonyms 600 + summary: Retrieve a synonym set item 601 + description: Retrieve a specific synonym item by its id 602 + operationId: retrieveSynonymSetItem 603 + parameters: 604 + - name: synonymSetName 605 + in: path 606 + description: The name of the synonym set 607 + required: true 608 + schema: 609 + type: string 610 + - name: itemId 611 + in: path 612 + description: The id of the synonym item to retrieve 613 + required: true 614 + schema: 615 + type: string 616 + responses: 617 + "200": 618 + description: Synonym item fetched 619 + content: 620 + application/json: 621 + schema: 622 + $ref: "#/components/schemas/SynonymItemSchema" 623 + "404": 624 + description: Synonym item not found 625 + content: 626 + application/json: 627 + schema: 628 + $ref: "#/components/schemas/ApiResponse" 629 + put: 630 + tags: 631 + - synonyms 632 + summary: Create or update a synonym set item 633 + description: Create or update a synonym set item with the given id 634 + operationId: upsertSynonymSetItem 635 + parameters: 636 + - name: synonymSetName 637 + in: path 638 + description: The name of the synonym set 639 + required: true 640 + schema: 641 + type: string 642 + - name: itemId 643 + in: path 644 + description: The id of the synonym item to upsert 645 + required: true 646 + schema: 647 + type: string 648 + requestBody: 649 + description: The synonym item to be created/updated 650 + content: 651 + application/json: 652 + schema: 653 + $ref: "#/components/schemas/SynonymItemUpsertSchema" 654 + required: true 655 + responses: 656 + "200": 657 + description: Synonym item successfully created/updated 658 + content: 659 + application/json: 660 + schema: 661 + $ref: "#/components/schemas/SynonymItemSchema" 662 + "400": 663 + description: Bad request, see error message for details 664 + content: 665 + application/json: 666 + schema: 667 + $ref: "#/components/schemas/ApiResponse" 668 + delete: 669 + tags: 670 + - synonyms 671 + summary: Delete a synonym set item 672 + description: Delete a specific synonym item by its id 673 + operationId: deleteSynonymSetItem 674 + parameters: 675 + - name: synonymSetName 676 + in: path 677 + description: The name of the synonym set 678 + required: true 679 + schema: 680 + type: string 681 + - name: itemId 682 + in: path 683 + description: The id of the synonym item to delete 684 + required: true 685 + schema: 686 + type: string 687 + responses: 688 + "200": 689 + description: Synonym item successfully deleted 690 + content: 691 + application/json: 692 + schema: 693 + $ref: "#/components/schemas/SynonymItemDeleteSchema" 694 + "404": 695 + description: Synonym item not found 696 + content: 697 + application/json: 698 + schema: 699 + $ref: "#/components/schemas/ApiResponse" 700 + 701 + /curation_sets: 702 + get: 703 + tags: 704 + - curation_sets 705 + summary: List all curation sets 706 + description: Retrieve all curation sets 707 + operationId: retrieveCurationSets 708 + responses: 709 + "200": 710 + description: List of all curation sets 711 + content: 712 + application/json: 713 + schema: 714 + type: array 715 + items: 716 + $ref: "#/components/schemas/CurationSetSchema" 717 + 718 + /curation_sets/{curationSetName}: 719 + get: 720 + tags: 721 + - curation_sets 722 + summary: Retrieve a curation set 723 + description: Retrieve a specific curation set by its name 724 + operationId: retrieveCurationSet 725 + parameters: 726 + - name: curationSetName 727 + in: path 728 + description: The name of the curation set to retrieve 729 + required: true 730 + schema: 731 + type: string 732 + responses: 733 + "200": 734 + description: Curation set fetched 735 + content: 736 + application/json: 737 + schema: 738 + $ref: "#/components/schemas/CurationSetSchema" 739 + "404": 740 + description: Curation set not found 741 + content: 742 + application/json: 743 + schema: 744 + $ref: "#/components/schemas/ApiResponse" 745 + put: 746 + tags: 747 + - curation_sets 748 + summary: Create or update a curation set 749 + description: Create or update a curation set with the given name 750 + operationId: upsertCurationSet 751 + parameters: 752 + - name: curationSetName 753 + in: path 754 + description: The name of the curation set to create/update 755 + required: true 756 + schema: 757 + type: string 758 + requestBody: 759 + description: The curation set to be created/updated 760 + content: 761 + application/json: 762 + schema: 763 + $ref: "#/components/schemas/CurationSetCreateSchema" 764 + required: true 765 + responses: 766 + "200": 767 + description: Curation set successfully created/updated 768 + content: 769 + application/json: 770 + schema: 771 + $ref: "#/components/schemas/CurationSetSchema" 772 + "400": 773 + description: Bad request, see error message for details 774 + content: 775 + application/json: 776 + schema: 777 + $ref: "#/components/schemas/ApiResponse" 778 + delete: 779 + tags: 780 + - curation_sets 781 + summary: Delete a curation set 782 + description: Delete a specific curation set by its name 783 + operationId: deleteCurationSet 784 + parameters: 785 + - name: curationSetName 786 + in: path 787 + description: The name of the curation set to delete 788 + required: true 789 + schema: 790 + type: string 791 + responses: 792 + "200": 793 + description: Curation set successfully deleted 794 + content: 795 + application/json: 796 + schema: 797 + $ref: "#/components/schemas/CurationSetDeleteSchema" 798 + "404": 799 + description: Curation set not found 800 + content: 801 + application/json: 802 + schema: 803 + $ref: "#/components/schemas/ApiResponse" 804 + 805 + /curation_sets/{curationSetName}/items: 806 + get: 807 + tags: 808 + - curation_sets 809 + summary: List items in a curation set 810 + description: Retrieve all curation items in a set 811 + operationId: retrieveCurationSetItems 812 + parameters: 813 + - name: curationSetName 814 + in: path 815 + description: The name of the curation set to retrieve items for 816 + required: true 817 + schema: 818 + type: string 819 + responses: 820 + "200": 821 + description: List of curation items 822 + content: 823 + application/json: 824 + schema: 825 + type: array 826 + items: 827 + $ref: "#/components/schemas/CurationItemSchema" 828 + "404": 829 + description: Curation set not found 830 + content: 831 + application/json: 832 + schema: 833 + $ref: "#/components/schemas/ApiResponse" 834 + 835 + /curation_sets/{curationSetName}/items/{itemId}: 836 + get: 837 + tags: 838 + - curation_sets 839 + summary: Retrieve a curation set item 840 + description: Retrieve a specific curation item by its id 841 + operationId: retrieveCurationSetItem 842 + parameters: 843 + - name: curationSetName 844 + in: path 845 + description: The name of the curation set 846 + required: true 847 + schema: 848 + type: string 849 + - name: itemId 850 + in: path 851 + description: The id of the curation item to retrieve 852 + required: true 853 + schema: 854 + type: string 855 + responses: 856 + "200": 857 + description: Curation item fetched 858 + content: 859 + application/json: 860 + schema: 861 + $ref: "#/components/schemas/CurationItemSchema" 862 + "404": 863 + description: Curation item not found 864 + content: 865 + application/json: 866 + schema: 867 + $ref: "#/components/schemas/ApiResponse" 868 + put: 869 + tags: 870 + - curation_sets 871 + summary: Create or update a curation set item 872 + description: Create or update a curation set item with the given id 873 + operationId: upsertCurationSetItem 874 + parameters: 875 + - name: curationSetName 876 + in: path 877 + description: The name of the curation set 878 + required: true 879 + schema: 880 + type: string 881 + - name: itemId 882 + in: path 883 + description: The id of the curation item to upsert 884 + required: true 885 + schema: 886 + type: string 887 + requestBody: 888 + description: The curation item to be created/updated 889 + content: 890 + application/json: 891 + schema: 892 + $ref: "#/components/schemas/CurationItemCreateSchema" 893 + required: true 894 + responses: 895 + "200": 896 + description: Curation item successfully created/updated 897 + content: 898 + application/json: 899 + schema: 900 + $ref: "#/components/schemas/CurationItemSchema" 901 + "400": 902 + description: Bad request, see error message for details 903 + content: 904 + application/json: 905 + schema: 906 + $ref: "#/components/schemas/ApiResponse" 907 + delete: 908 + tags: 909 + - curation_sets 910 + summary: Delete a curation set item 911 + description: Delete a specific curation item by its id 912 + operationId: deleteCurationSetItem 913 + parameters: 914 + - name: curationSetName 915 + in: path 916 + description: The name of the curation set 917 + required: true 918 + schema: 919 + type: string 920 + - name: itemId 921 + in: path 922 + description: The id of the curation item to delete 923 + required: true 924 + schema: 925 + type: string 926 + responses: 927 + "200": 928 + description: Curation item successfully deleted 929 + content: 930 + application/json: 931 + schema: 932 + $ref: "#/components/schemas/CurationItemDeleteSchema" 933 + "404": 934 + description: Curation item not found 935 + content: 936 + application/json: 937 + schema: 938 + $ref: "#/components/schemas/ApiResponse" 939 + 940 + /collections/{collectionName}/documents/export: 941 + get: 942 + tags: 943 + - documents 944 + summary: Export all documents in a collection 945 + description: Export all documents in a collection in JSON lines format. 946 + operationId: exportDocuments 947 + parameters: 948 + - name: collectionName 949 + in: path 950 + description: The name of the collection 951 + required: true 952 + schema: 953 + type: string 954 + - name: exportDocumentsParameters 955 + in: query 956 + schema: 957 + type: object 958 + properties: 959 + filter_by: 960 + description: 961 + Filter conditions for refining your search results. Separate 962 + multiple conditions with &&. 963 + type: string 964 + include_fields: 965 + description: List of fields from the document to include in the search result 966 + type: string 967 + exclude_fields: 968 + description: List of fields from the document to exclude in the search result 969 + type: string 970 + 971 + responses: 972 + '200': 973 + description: Exports all the documents in a given collection. 974 + content: 975 + application/octet-stream: 976 + schema: 977 + type: string 978 + example: | 979 + {"id": "124", "company_name": "Stark Industries", "num_employees": 5215, "country": "US"} 980 + {"id": "125", "company_name": "Future Technology", "num_employees": 1232,"country": "UK"} 981 + {"id": "126", "company_name": "Random Corp.", "num_employees": 531,"country": "AU"} 982 + '404': 983 + description: The collection was not found 984 + content: 985 + application/json: 986 + schema: 987 + $ref: "#/components/schemas/ApiResponse" 988 + /collections/{collectionName}/documents/import: 989 + post: 990 + tags: 991 + - documents 992 + summary: Import documents into a collection 993 + description: 994 + The documents to be imported must be formatted in a newline delimited 995 + JSON structure. You can feed the output file from a Typesense export operation 996 + directly as import. 997 + operationId: importDocuments 998 + parameters: 999 + - name: collectionName 1000 + in: path 1001 + description: The name of the collection 1002 + required: true 1003 + schema: 1004 + type: string 1005 + # Do not change the index position of this param 1006 + - name: importDocumentsParameters 1007 + in: query 1008 + schema: 1009 + type: object 1010 + properties: 1011 + batch_size: 1012 + type: integer 1013 + return_id: 1014 + type: boolean 1015 + description: 1016 + Returning the id of the imported documents. If you want the 1017 + import response to return the ingested document's id in the 1018 + response, you can use the return_id parameter. 1019 + remote_embedding_batch_size: 1020 + type: integer 1021 + return_doc: 1022 + type: boolean 1023 + action: 1024 + $ref: "#/components/schemas/IndexAction" 1025 + dirty_values: 1026 + $ref: "#/components/schemas/DirtyValues" 1027 + requestBody: 1028 + description: The json array of documents or the JSONL file to import 1029 + content: 1030 + application/octet-stream: 1031 + schema: 1032 + type: string 1033 + description: The JSONL file to import 1034 + required: true 1035 + responses: 1036 + '200': 1037 + description: 1038 + Result of the import operation. Each line of the response indicates the result 1039 + of each document present in the request body (in the same order). If the import 1040 + of a single document fails, it does not affect the other documents. 1041 + If there is a failure, the response line will include a corresponding error 1042 + message and as well as the actual document content. 1043 + content: 1044 + application/octet-stream: 1045 + schema: 1046 + type: string 1047 + example: | 1048 + {"success": true} 1049 + {"success": false, "error": "Bad JSON.", "document": "[bad doc"} 1050 + '400': 1051 + description: Bad request, see error message for details 1052 + content: 1053 + application/json: 1054 + schema: 1055 + $ref: "#/components/schemas/ApiResponse" 1056 + '404': 1057 + description: The collection was not found 1058 + content: 1059 + application/json: 1060 + schema: 1061 + $ref: "#/components/schemas/ApiResponse" 1062 + /collections/{collectionName}/documents/{documentId}: 1063 + get: 1064 + tags: 1065 + - documents 1066 + summary: Retrieve a document 1067 + description: Fetch an individual document from a collection by using its ID. 1068 + operationId: getDocument 1069 + parameters: 1070 + - name: collectionName 1071 + in: path 1072 + description: The name of the collection to search for the document under 1073 + required: true 1074 + schema: 1075 + type: string 1076 + - name: documentId 1077 + in: path 1078 + description: The Document ID 1079 + required: true 1080 + schema: 1081 + type: string 1082 + responses: 1083 + '200': 1084 + description: The document referenced by the ID 1085 + content: 1086 + application/json: 1087 + schema: 1088 + type: object 1089 + description: Can be any key-value pair 1090 + '404': 1091 + description: The document or collection was not found 1092 + content: 1093 + application/json: 1094 + schema: 1095 + $ref: "#/components/schemas/ApiResponse" 1096 + patch: 1097 + tags: 1098 + - documents 1099 + summary: Update a document 1100 + description: 1101 + Update an individual document from a collection by using its ID. 1102 + The update can be partial. 1103 + operationId: updateDocument 1104 + parameters: 1105 + - name: collectionName 1106 + in: path 1107 + description: The name of the collection to search for the document under 1108 + required: true 1109 + schema: 1110 + type: string 1111 + - name: documentId 1112 + in: path 1113 + description: The Document ID 1114 + required: true 1115 + schema: 1116 + type: string 1117 + - name: dirty_values 1118 + in: query 1119 + description: Dealing with Dirty Data 1120 + schema: 1121 + $ref: "#/components/schemas/DirtyValues" 1122 + requestBody: 1123 + description: The document object with fields to be updated 1124 + content: 1125 + application/json: 1126 + schema: 1127 + type: object 1128 + description: Can be any key-value pair 1129 + x-go-type: "interface{}" 1130 + required: true 1131 + responses: 1132 + '200': 1133 + description: The document referenced by the ID was updated 1134 + content: 1135 + application/json: 1136 + schema: 1137 + type: object 1138 + description: Can be any key-value pair 1139 + '404': 1140 + description: The document or collection was not found 1141 + content: 1142 + application/json: 1143 + schema: 1144 + $ref: "#/components/schemas/ApiResponse" 1145 + delete: 1146 + tags: 1147 + - documents 1148 + summary: Delete a document 1149 + description: Delete an individual document from a collection by using its ID. 1150 + operationId: deleteDocument 1151 + parameters: 1152 + - name: collectionName 1153 + in: path 1154 + description: The name of the collection to search for the document under 1155 + required: true 1156 + schema: 1157 + type: string 1158 + - name: documentId 1159 + in: path 1160 + description: The Document ID 1161 + required: true 1162 + schema: 1163 + type: string 1164 + responses: 1165 + '200': 1166 + description: The document referenced by the ID was deleted 1167 + content: 1168 + application/json: 1169 + schema: 1170 + type: object 1171 + description: Can be any key-value pair 1172 + '404': 1173 + description: The document or collection was not found 1174 + content: 1175 + application/json: 1176 + schema: 1177 + $ref: "#/components/schemas/ApiResponse" 1178 + /conversations/models: 1179 + get: 1180 + description: Retrieve all conversation models 1181 + operationId: retrieveAllConversationModels 1182 + responses: 1183 + '200': 1184 + content: 1185 + application/json: 1186 + schema: 1187 + items: 1188 + $ref: '#/components/schemas/ConversationModelSchema' 1189 + type: array 1190 + x-go-type: '[]*ConversationModelSchema' 1191 + description: List of all conversation models 1192 + summary: List all conversation models 1193 + tags: 1194 + - conversations 1195 + post: 1196 + summary: Create a conversation model 1197 + description: Create a Conversation Model 1198 + operationId: createConversationModel 1199 + requestBody: 1200 + content: 1201 + application/json: 1202 + schema: 1203 + $ref: '#/components/schemas/ConversationModelCreateSchema' 1204 + required: true 1205 + responses: 1206 + '201': 1207 + content: 1208 + application/json: 1209 + schema: 1210 + $ref: '#/components/schemas/ConversationModelSchema' 1211 + description: Created Conversation Model 1212 + '400': 1213 + content: 1214 + application/json: 1215 + schema: 1216 + $ref: '#/components/schemas/ApiResponse' 1217 + description: Bad request, see error message for details 1218 + tags: 1219 + - conversations 1220 + /conversations/models/{modelId}: 1221 + get: 1222 + description: Retrieve a conversation model 1223 + operationId: retrieveConversationModel 1224 + parameters: 1225 + - name: modelId 1226 + in: path 1227 + description: The id of the conversation model to retrieve 1228 + required: true 1229 + schema: 1230 + type: string 1231 + responses: 1232 + '200': 1233 + content: 1234 + application/json: 1235 + schema: 1236 + $ref: '#/components/schemas/ConversationModelSchema' 1237 + description: A conversation model 1238 + summary: Retrieve a conversation model 1239 + tags: 1240 + - conversations 1241 + put: 1242 + description: Update a conversation model 1243 + operationId: updateConversationModel 1244 + requestBody: 1245 + content: 1246 + application/json: 1247 + schema: 1248 + $ref: '#/components/schemas/ConversationModelUpdateSchema' 1249 + required: true 1250 + parameters: 1251 + - name: modelId 1252 + in: path 1253 + description: The id of the conversation model to update 1254 + required: true 1255 + schema: 1256 + type: string 1257 + responses: 1258 + '200': 1259 + content: 1260 + application/json: 1261 + schema: 1262 + $ref: '#/components/schemas/ConversationModelSchema' 1263 + description: The conversation model was successfully updated 1264 + summary: Update a conversation model 1265 + tags: 1266 + - conversations 1267 + delete: 1268 + description: Delete a conversation model 1269 + operationId: deleteConversationModel 1270 + parameters: 1271 + - name: modelId 1272 + in: path 1273 + description: The id of the conversation model to delete 1274 + required: true 1275 + schema: 1276 + type: string 1277 + responses: 1278 + '200': 1279 + content: 1280 + application/json: 1281 + schema: 1282 + $ref: '#/components/schemas/ConversationModelSchema' 1283 + description: The conversation model was successfully deleted 1284 + summary: Delete a conversation model 1285 + tags: 1286 + - conversations 1287 + /keys: 1288 + get: 1289 + tags: 1290 + - keys 1291 + summary: Retrieve (metadata about) all keys. 1292 + operationId: getKeys 1293 + responses: 1294 + '200': 1295 + description: List of all keys 1296 + content: 1297 + application/json: 1298 + schema: 1299 + $ref: "#/components/schemas/ApiKeysResponse" 1300 + post: 1301 + tags: 1302 + - keys 1303 + summary: Create an API Key 1304 + description: 1305 + Create an API Key with fine-grain access control. You can restrict access 1306 + on both a per-collection and per-action level. 1307 + The generated key is returned only during creation. You want to store 1308 + this key carefully in a secure place. 1309 + operationId: createKey 1310 + requestBody: 1311 + description: The object that describes API key scope 1312 + content: 1313 + application/json: 1314 + schema: 1315 + $ref: "#/components/schemas/ApiKeySchema" 1316 + responses: 1317 + '201': 1318 + description: Created API key 1319 + content: 1320 + application/json: 1321 + schema: 1322 + $ref: "#/components/schemas/ApiKey" 1323 + '400': 1324 + description: Bad request, see error message for details 1325 + content: 1326 + application/json: 1327 + schema: 1328 + $ref: "#/components/schemas/ApiResponse" 1329 + '409': 1330 + description: API key generation conflict 1331 + content: 1332 + application/json: 1333 + schema: 1334 + $ref: "#/components/schemas/ApiResponse" 1335 + /keys/{keyId}: 1336 + get: 1337 + tags: 1338 + - keys 1339 + summary: Retrieve (metadata about) a key 1340 + description: 1341 + Retrieve (metadata about) a key. Only the key prefix is returned 1342 + when you retrieve a key. Due to security reasons, only the create endpoint 1343 + returns the full API key. 1344 + operationId: getKey 1345 + parameters: 1346 + - name: keyId 1347 + in: path 1348 + description: The ID of the key to retrieve 1349 + required: true 1350 + schema: 1351 + type: integer 1352 + format: int64 1353 + responses: 1354 + '200': 1355 + description: The key referenced by the ID 1356 + content: 1357 + application/json: 1358 + schema: 1359 + $ref: "#/components/schemas/ApiKey" 1360 + '404': 1361 + description: The key was not found 1362 + content: 1363 + application/json: 1364 + schema: 1365 + $ref: "#/components/schemas/ApiResponse" 1366 + delete: 1367 + tags: 1368 + - keys 1369 + summary: Delete an API key given its ID. 1370 + operationId: deleteKey 1371 + parameters: 1372 + - name: keyId 1373 + in: path 1374 + description: The ID of the key to delete 1375 + required: true 1376 + schema: 1377 + type: integer 1378 + format: int64 1379 + responses: 1380 + '200': 1381 + description: The key referenced by the ID 1382 + content: 1383 + application/json: 1384 + schema: 1385 + $ref: "#/components/schemas/ApiKeyDeleteResponse" 1386 + '400': 1387 + description: Bad request, see error message for details 1388 + content: 1389 + application/json: 1390 + schema: 1391 + $ref: "#/components/schemas/ApiResponse" 1392 + '404': 1393 + description: Key not found 1394 + content: 1395 + application/json: 1396 + schema: 1397 + $ref: "#/components/schemas/ApiResponse" 1398 + /aliases: 1399 + get: 1400 + tags: 1401 + - collections 1402 + summary: List all aliases 1403 + description: List all aliases and the corresponding collections that they map to. 1404 + operationId: getAliases 1405 + responses: 1406 + '200': 1407 + description: List of all collection aliases 1408 + content: 1409 + application/json: 1410 + schema: 1411 + $ref: "#/components/schemas/CollectionAliasesResponse" 1412 + /aliases/{aliasName}: 1413 + put: 1414 + tags: 1415 + - collections 1416 + summary: Create or update a collection alias 1417 + description: 1418 + Create or update a collection alias. An alias is a virtual collection name that points 1419 + to a real collection. If you're familiar with symbolic links on Linux, it's very similar 1420 + to that. Aliases are useful when you want to reindex your data in the 1421 + background on a new collection and switch your application to it without any changes to 1422 + your code. 1423 + operationId: upsertAlias 1424 + parameters: 1425 + - name: aliasName 1426 + in: path 1427 + description: The name of the alias to create/update 1428 + required: true 1429 + schema: 1430 + type: string 1431 + requestBody: 1432 + description: Collection alias to be created/updated 1433 + content: 1434 + application/json: 1435 + schema: 1436 + $ref: "#/components/schemas/CollectionAliasSchema" 1437 + responses: 1438 + '200': 1439 + description: The collection alias was created/updated 1440 + content: 1441 + application/json: 1442 + schema: 1443 + $ref: "#/components/schemas/CollectionAlias" 1444 + '400': 1445 + description: Bad request, see error message for details 1446 + content: 1447 + application/json: 1448 + schema: 1449 + $ref: "#/components/schemas/ApiResponse" 1450 + '404': 1451 + description: Alias not found 1452 + content: 1453 + application/json: 1454 + schema: 1455 + $ref: "#/components/schemas/ApiResponse" 1456 + get: 1457 + tags: 1458 + - collections 1459 + summary: Retrieve an alias 1460 + description: Find out which collection an alias points to by fetching it 1461 + operationId: getAlias 1462 + parameters: 1463 + - name: aliasName 1464 + in: path 1465 + description: The name of the alias to retrieve 1466 + required: true 1467 + schema: 1468 + type: string 1469 + responses: 1470 + '200': 1471 + description: Collection alias fetched 1472 + content: 1473 + application/json: 1474 + schema: 1475 + $ref: "#/components/schemas/CollectionAlias" 1476 + '404': 1477 + description: The alias was not found 1478 + content: 1479 + application/json: 1480 + schema: 1481 + $ref: "#/components/schemas/ApiResponse" 1482 + delete: 1483 + tags: 1484 + - collections 1485 + summary: Delete an alias 1486 + operationId: deleteAlias 1487 + parameters: 1488 + - name: aliasName 1489 + in: path 1490 + description: The name of the alias to delete 1491 + required: true 1492 + schema: 1493 + type: string 1494 + responses: 1495 + '200': 1496 + description: Collection alias was deleted 1497 + content: 1498 + application/json: 1499 + schema: 1500 + $ref: "#/components/schemas/CollectionAlias" 1501 + '404': 1502 + description: Alias not found 1503 + content: 1504 + application/json: 1505 + schema: 1506 + $ref: "#/components/schemas/ApiResponse" 1507 + /debug: 1508 + get: 1509 + tags: 1510 + - debug 1511 + summary: Print debugging information 1512 + description: Print debugging information 1513 + operationId: debug 1514 + responses: 1515 + '200': 1516 + description: Debugging information 1517 + content: 1518 + application/json: 1519 + schema: 1520 + type: object 1521 + properties: 1522 + version: 1523 + type: string 1524 + /health: 1525 + get: 1526 + tags: 1527 + - health 1528 + summary: Checks if Typesense server is ready to accept requests. 1529 + description: Checks if Typesense server is ready to accept requests. 1530 + operationId: health 1531 + responses: 1532 + '200': 1533 + description: Search service is ready for requests. 1534 + content: 1535 + application/json: 1536 + schema: 1537 + $ref: "#/components/schemas/HealthStatus" 1538 + /operations/schema_changes: 1539 + get: 1540 + tags: 1541 + - operations 1542 + summary: Get the status of in-progress schema change operations 1543 + description: Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. 1544 + operationId: getSchemaChanges 1545 + responses: 1546 + '200': 1547 + description: List of schema changes in progress 1548 + content: 1549 + application/json: 1550 + schema: 1551 + type: array 1552 + items: 1553 + $ref: "#/components/schemas/SchemaChangeStatus" 1554 + /operations/snapshot: 1555 + post: 1556 + tags: 1557 + - operations 1558 + summary: Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. 1559 + description: 1560 + Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. 1561 + You can then backup the snapshot directory that gets created and later restore it 1562 + as a data directory, as needed. 1563 + operationId: takeSnapshot 1564 + parameters: 1565 + - name: snapshot_path 1566 + in: query 1567 + description: The directory on the server where the snapshot should be saved. 1568 + required: true 1569 + schema: 1570 + type: string 1571 + responses: 1572 + '201': 1573 + description: Snapshot is created. 1574 + content: 1575 + application/json: 1576 + schema: 1577 + $ref: "#/components/schemas/SuccessStatus" 1578 + /operations/vote: 1579 + post: 1580 + tags: 1581 + - operations 1582 + summary: Triggers a follower node to initiate the raft voting process, which triggers leader re-election. 1583 + description: 1584 + Triggers a follower node to initiate the raft voting process, which triggers leader re-election. 1585 + The follower node that you run this operation against will become the new leader, 1586 + once this command succeeds. 1587 + operationId: vote 1588 + responses: 1589 + '200': 1590 + description: Re-election is performed. 1591 + content: 1592 + application/json: 1593 + schema: 1594 + $ref: "#/components/schemas/SuccessStatus" 1595 + /operations/cache/clear: 1596 + post: 1597 + tags: 1598 + - operations 1599 + summary: Clear the cached responses of search requests in the LRU cache. 1600 + description: 1601 + Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. 1602 + operationId: clearCache 1603 + responses: 1604 + '200': 1605 + description: Clear cache succeeded. 1606 + content: 1607 + application/json: 1608 + schema: 1609 + $ref: "#/components/schemas/SuccessStatus" 1610 + /operations/db/compact: 1611 + post: 1612 + tags: 1613 + - operations 1614 + summary: Compacting the on-disk database 1615 + description: 1616 + 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. 1617 + 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. 1618 + operationId: compactDb 1619 + responses: 1620 + '200': 1621 + description: Compacting the on-disk database succeeded. 1622 + content: 1623 + application/json: 1624 + schema: 1625 + $ref: "#/components/schemas/SuccessStatus" 1626 + /config: 1627 + post: 1628 + tags: 1629 + - operations 1630 + summary: Toggle Slow Request Log 1631 + description: 1632 + Enable logging of requests that take over a defined threshold of time. 1633 + Default is `-1` which disables slow request logging. 1634 + Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. 1635 + operationId: toggleSlowRequestLog 1636 + requestBody: 1637 + content: 1638 + application/json: 1639 + schema: 1640 + type: object 1641 + properties: 1642 + log-slow-requests-time-ms: 1643 + type: integer 1644 + required: 1645 + - log-slow-requests-time-ms 1646 + example: | 1647 + {"log-slow-requests-time-ms": 2000} 1648 + responses: 1649 + '200': 1650 + description: Toggle Slow Request Log database succeeded. 1651 + content: 1652 + application/json: 1653 + schema: 1654 + $ref: "#/components/schemas/SuccessStatus" 1655 + /multi_search: 1656 + post: 1657 + operationId: multiSearch 1658 + tags: 1659 + - documents 1660 + summary: send multiple search requests in a single HTTP request 1661 + description: 1662 + This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. 1663 + You can also use this feature to do a federated search across multiple collections in a single HTTP request. 1664 + parameters: 1665 + - name: multiSearchParameters 1666 + required: true 1667 + in: query 1668 + schema: 1669 + $ref: "#/components/schemas/MultiSearchParameters" 1670 + requestBody: 1671 + content: 1672 + application/json: 1673 + schema: 1674 + $ref: "#/components/schemas/MultiSearchSearchesParameter" 1675 + responses: 1676 + '200': 1677 + description: Search results 1678 + content: 1679 + application/json: 1680 + schema: 1681 + $ref: "#/components/schemas/MultiSearchResult" 1682 + '400': 1683 + description: Bad request, see error message for details 1684 + content: 1685 + application/json: 1686 + schema: 1687 + $ref: "#/components/schemas/ApiResponse" 1688 + /analytics/events: 1689 + post: 1690 + tags: 1691 + - analytics 1692 + summary: Create an analytics event 1693 + description: Submit a single analytics event. The event must correspond to an existing analytics rule by name. 1694 + operationId: createAnalyticsEvent 1695 + requestBody: 1696 + description: The analytics event to be created 1697 + content: 1698 + application/json: 1699 + schema: 1700 + $ref: '#/components/schemas/AnalyticsEvent' 1701 + required: true 1702 + responses: 1703 + '200': 1704 + description: Analytics event successfully created 1705 + content: 1706 + application/json: 1707 + schema: 1708 + $ref: '#/components/schemas/AnalyticsEventCreateResponse' 1709 + '400': 1710 + description: Bad request, see error message for details 1711 + content: 1712 + application/json: 1713 + schema: 1714 + $ref: '#/components/schemas/ApiResponse' 1715 + get: 1716 + tags: 1717 + - analytics 1718 + summary: Retrieve analytics events 1719 + description: Retrieve the most recent events for a user and rule. 1720 + operationId: getAnalyticsEvents 1721 + parameters: 1722 + - name: user_id 1723 + in: query 1724 + required: true 1725 + schema: 1726 + type: string 1727 + - name: name 1728 + in: query 1729 + description: Analytics rule name 1730 + required: true 1731 + schema: 1732 + type: string 1733 + - name: n 1734 + in: query 1735 + description: Number of events to return (max 1000) 1736 + required: true 1737 + schema: 1738 + type: integer 1739 + responses: 1740 + '200': 1741 + description: Events fetched 1742 + content: 1743 + application/json: 1744 + schema: 1745 + $ref: '#/components/schemas/AnalyticsEventsResponse' 1746 + '400': 1747 + description: Bad request, see error message for details 1748 + content: 1749 + application/json: 1750 + schema: 1751 + $ref: '#/components/schemas/ApiResponse' 1752 + /analytics/flush: 1753 + post: 1754 + tags: 1755 + - analytics 1756 + summary: Flush in-memory analytics to disk 1757 + description: Triggers a flush of analytics data to persistent storage. 1758 + operationId: flushAnalytics 1759 + responses: 1760 + '200': 1761 + description: Flush triggered 1762 + content: 1763 + application/json: 1764 + schema: 1765 + $ref: '#/components/schemas/AnalyticsEventCreateResponse' 1766 + /analytics/status: 1767 + get: 1768 + tags: 1769 + - analytics 1770 + summary: Get analytics subsystem status 1771 + description: Returns sizes of internal analytics buffers and queues. 1772 + operationId: getAnalyticsStatus 1773 + responses: 1774 + '200': 1775 + description: Status fetched 1776 + content: 1777 + application/json: 1778 + schema: 1779 + $ref: '#/components/schemas/AnalyticsStatus' 1780 + /analytics/rules: 1781 + post: 1782 + tags: 1783 + - analytics 1784 + summary: Create analytics rule(s) 1785 + description: Create one or more analytics rules. You can send a single rule object or an array of rule objects. 1786 + operationId: createAnalyticsRule 1787 + requestBody: 1788 + description: The analytics rule(s) to be created 1789 + content: 1790 + application/json: 1791 + schema: 1792 + oneOf: 1793 + - $ref: "#/components/schemas/AnalyticsRuleCreate" 1794 + - type: array 1795 + items: 1796 + $ref: "#/components/schemas/AnalyticsRuleCreate" 1797 + required: true 1798 + responses: 1799 + '200': 1800 + description: Analytics rule(s) successfully created 1801 + content: 1802 + application/json: 1803 + schema: 1804 + oneOf: 1805 + - $ref: "#/components/schemas/AnalyticsRule" 1806 + - type: array 1807 + items: 1808 + oneOf: 1809 + - $ref: "#/components/schemas/AnalyticsRule" 1810 + - type: object 1811 + properties: 1812 + error: 1813 + type: string 1814 + '400': 1815 + description: Bad request, see error message for details 1816 + content: 1817 + application/json: 1818 + schema: 1819 + $ref: "#/components/schemas/ApiResponse" 1820 + get: 1821 + tags: 1822 + - analytics 1823 + summary: Retrieve analytics rules 1824 + description: Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. 1825 + operationId: retrieveAnalyticsRules 1826 + parameters: 1827 + - in: query 1828 + name: rule_tag 1829 + schema: 1830 + type: string 1831 + required: false 1832 + description: Filter rules by rule_tag 1833 + responses: 1834 + '200': 1835 + description: Analytics rules fetched 1836 + content: 1837 + application/json: 1838 + schema: 1839 + type: array 1840 + items: 1841 + $ref: "#/components/schemas/AnalyticsRule" 1842 + /analytics/rules/{ruleName}: 1843 + put: 1844 + tags: 1845 + - analytics 1846 + summary: Upserts an analytics rule 1847 + description: 1848 + Upserts an analytics rule with the given name. 1849 + operationId: upsertAnalyticsRule 1850 + parameters: 1851 + - in: path 1852 + name: ruleName 1853 + description: The name of the analytics rule to upsert 1854 + schema: 1855 + type: string 1856 + required: true 1857 + requestBody: 1858 + description: The Analytics rule to be upserted 1859 + content: 1860 + application/json: 1861 + schema: 1862 + $ref: "#/components/schemas/AnalyticsRuleUpdate" 1863 + required: true 1864 + responses: 1865 + '200': 1866 + description: Analytics rule successfully upserted 1867 + content: 1868 + application/json: 1869 + schema: 1870 + $ref: "#/components/schemas/AnalyticsRule" 1871 + '400': 1872 + description: Bad request, see error message for details 1873 + content: 1874 + application/json: 1875 + schema: 1876 + $ref: "#/components/schemas/ApiResponse" 1877 + get: 1878 + tags: 1879 + - analytics 1880 + summary: Retrieves an analytics rule 1881 + description: 1882 + Retrieve the details of an analytics rule, given it's name 1883 + operationId: retrieveAnalyticsRule 1884 + parameters: 1885 + - in: path 1886 + name: ruleName 1887 + description: The name of the analytics rule to retrieve 1888 + schema: 1889 + type: string 1890 + required: true 1891 + responses: 1892 + '200': 1893 + description: Analytics rule fetched 1894 + content: 1895 + application/json: 1896 + schema: 1897 + $ref: "#/components/schemas/AnalyticsRule" 1898 + '404': 1899 + description: Analytics rule not found 1900 + content: 1901 + application/json: 1902 + schema: 1903 + $ref: "#/components/schemas/ApiResponse" 1904 + delete: 1905 + tags: 1906 + - analytics 1907 + summary: Delete an analytics rule 1908 + description: 1909 + Permanently deletes an analytics rule, given it's name 1910 + operationId: deleteAnalyticsRule 1911 + parameters: 1912 + - in: path 1913 + name: ruleName 1914 + description: The name of the analytics rule to delete 1915 + schema: 1916 + type: string 1917 + required: true 1918 + responses: 1919 + '200': 1920 + description: Analytics rule deleted 1921 + content: 1922 + application/json: 1923 + schema: 1924 + $ref: "#/components/schemas/AnalyticsRule" 1925 + '404': 1926 + description: Analytics rule not found 1927 + content: 1928 + application/json: 1929 + schema: 1930 + $ref: "#/components/schemas/ApiResponse" 1931 + /metrics.json: 1932 + get: 1933 + tags: 1934 + - operations 1935 + summary: Get current RAM, CPU, Disk & Network usage metrics. 1936 + description: 1937 + Retrieve the metrics. 1938 + operationId: retrieveMetrics 1939 + responses: 1940 + '200': 1941 + description: Metrics fetched. 1942 + content: 1943 + application/json: 1944 + schema: 1945 + type: object 1946 + /stats.json: 1947 + get: 1948 + tags: 1949 + - operations 1950 + summary: Get stats about API endpoints. 1951 + description: 1952 + Retrieve the stats about API endpoints. 1953 + operationId: retrieveAPIStats 1954 + responses: 1955 + '200': 1956 + description: Stats fetched. 1957 + content: 1958 + application/json: 1959 + schema: 1960 + $ref: "#/components/schemas/APIStatsResponse" 1961 + /stopwords: 1962 + get: 1963 + tags: 1964 + - stopwords 1965 + summary: Retrieves all stopwords sets. 1966 + description: 1967 + Retrieve the details of all stopwords sets 1968 + operationId: retrieveStopwordsSets 1969 + responses: 1970 + '200': 1971 + description: Stopwords sets fetched. 1972 + content: 1973 + application/json: 1974 + schema: 1975 + $ref: "#/components/schemas/StopwordsSetsRetrieveAllSchema" 1976 + /stopwords/{setId}: 1977 + put: 1978 + tags: 1979 + - stopwords 1980 + summary: Upserts a stopwords set. 1981 + description: 1982 + When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. 1983 + operationId: upsertStopwordsSet 1984 + parameters: 1985 + - in: path 1986 + name: setId 1987 + description: The ID of the stopwords set to upsert. 1988 + schema: 1989 + type: string 1990 + required: true 1991 + example: countries 1992 + requestBody: 1993 + description: The stopwords set to upsert. 1994 + content: 1995 + application/json: 1996 + schema: 1997 + $ref: "#/components/schemas/StopwordsSetUpsertSchema" 1998 + required: true 1999 + responses: 2000 + '200': 2001 + description: Stopwords set successfully upserted. 2002 + content: 2003 + application/json: 2004 + schema: 2005 + $ref: "#/components/schemas/StopwordsSetSchema" 2006 + '400': 2007 + description: Bad request, see error message for details. 2008 + content: 2009 + application/json: 2010 + schema: 2011 + $ref: "#/components/schemas/ApiResponse" 2012 + get: 2013 + tags: 2014 + - stopwords 2015 + summary: Retrieves a stopwords set. 2016 + description: 2017 + Retrieve the details of a stopwords set, given it's name. 2018 + operationId: retrieveStopwordsSet 2019 + parameters: 2020 + - in: path 2021 + name: setId 2022 + description: The ID of the stopwords set to retrieve. 2023 + schema: 2024 + type: string 2025 + required: true 2026 + example: countries 2027 + responses: 2028 + '200': 2029 + description: Stopwords set fetched. 2030 + content: 2031 + application/json: 2032 + schema: 2033 + $ref: "#/components/schemas/StopwordsSetRetrieveSchema" 2034 + '404': 2035 + description: Stopwords set not found. 2036 + content: 2037 + application/json: 2038 + schema: 2039 + $ref: "#/components/schemas/ApiResponse" 2040 + delete: 2041 + tags: 2042 + - stopwords 2043 + summary: Delete a stopwords set. 2044 + description: 2045 + Permanently deletes a stopwords set, given it's name. 2046 + operationId: deleteStopwordsSet 2047 + parameters: 2048 + - in: path 2049 + name: setId 2050 + description: The ID of the stopwords set to delete. 2051 + schema: 2052 + type: string 2053 + required: true 2054 + example: countries 2055 + responses: 2056 + '200': 2057 + description: Stopwords set rule deleted. 2058 + content: 2059 + application/json: 2060 + schema: 2061 + type: object 2062 + properties: 2063 + id: 2064 + type: string 2065 + required: 2066 + - id 2067 + example: | 2068 + {"id": "countries"} 2069 + '404': 2070 + description: Stopwords set not found. 2071 + content: 2072 + application/json: 2073 + schema: 2074 + $ref: "#/components/schemas/ApiResponse" 2075 + /presets: 2076 + get: 2077 + tags: 2078 + - presets 2079 + summary: Retrieves all presets. 2080 + description: Retrieve the details of all presets 2081 + operationId: retrieveAllPresets 2082 + responses: 2083 + '200': 2084 + description: Presets fetched. 2085 + content: 2086 + application/json: 2087 + schema: 2088 + $ref: '#/components/schemas/PresetsRetrieveSchema' 2089 + /presets/{presetId}: 2090 + get: 2091 + tags: 2092 + - presets 2093 + summary: Retrieves a preset. 2094 + description: Retrieve the details of a preset, given it's name. 2095 + operationId: retrievePreset 2096 + parameters: 2097 + - in: path 2098 + name: presetId 2099 + description: The ID of the preset to retrieve. 2100 + schema: 2101 + type: string 2102 + required: true 2103 + example: listing_view 2104 + responses: 2105 + '200': 2106 + description: Preset fetched. 2107 + content: 2108 + application/json: 2109 + schema: 2110 + $ref: '#/components/schemas/PresetSchema' 2111 + '404': 2112 + description: Preset not found. 2113 + content: 2114 + application/json: 2115 + schema: 2116 + $ref: '#/components/schemas/ApiResponse' 2117 + put: 2118 + tags: 2119 + - presets 2120 + summary: Upserts a preset. 2121 + description: Create or update an existing preset. 2122 + operationId: upsertPreset 2123 + parameters: 2124 + - in: path 2125 + name: presetId 2126 + description: The name of the preset set to upsert. 2127 + schema: 2128 + type: string 2129 + required: true 2130 + example: listing_view 2131 + requestBody: 2132 + description: The stopwords set to upsert. 2133 + content: 2134 + application/json: 2135 + schema: 2136 + $ref: '#/components/schemas/PresetUpsertSchema' 2137 + required: true 2138 + responses: 2139 + '200': 2140 + description: Preset successfully upserted. 2141 + content: 2142 + application/json: 2143 + schema: 2144 + $ref: '#/components/schemas/PresetSchema' 2145 + '400': 2146 + description: Bad request, see error message for details 2147 + content: 2148 + application/json: 2149 + schema: 2150 + $ref: '#/components/schemas/ApiResponse' 2151 + delete: 2152 + tags: 2153 + - presets 2154 + summary: Delete a preset. 2155 + description: Permanently deletes a preset, given it's name. 2156 + operationId: deletePreset 2157 + parameters: 2158 + - in: path 2159 + name: presetId 2160 + description: The ID of the preset to delete. 2161 + schema: 2162 + type: string 2163 + required: true 2164 + example: listing_view 2165 + responses: 2166 + '200': 2167 + description: Preset deleted. 2168 + content: 2169 + application/json: 2170 + schema: 2171 + $ref: '#/components/schemas/PresetDeleteSchema' 2172 + '404': 2173 + description: Preset not found. 2174 + content: 2175 + application/json: 2176 + schema: 2177 + $ref: '#/components/schemas/ApiResponse' 2178 + /stemming/dictionaries: 2179 + get: 2180 + tags: 2181 + - stemming 2182 + summary: List all stemming dictionaries 2183 + description: Retrieve a list of all available stemming dictionaries. 2184 + operationId: listStemmingDictionaries 2185 + responses: 2186 + '200': 2187 + description: List of all dictionaries 2188 + content: 2189 + application/json: 2190 + schema: 2191 + type: object 2192 + properties: 2193 + dictionaries: 2194 + type: array 2195 + items: 2196 + type: string 2197 + example: ["irregular-plurals", "company-terms"] 2198 + 2199 + /stemming/dictionaries/{dictionaryId}: 2200 + get: 2201 + tags: 2202 + - stemming 2203 + summary: Retrieve a stemming dictionary 2204 + description: Fetch details of a specific stemming dictionary. 2205 + operationId: getStemmingDictionary 2206 + parameters: 2207 + - name: dictionaryId 2208 + in: path 2209 + description: The ID of the dictionary to retrieve 2210 + required: true 2211 + schema: 2212 + type: string 2213 + example: irregular-plurals 2214 + responses: 2215 + '200': 2216 + description: Stemming dictionary details 2217 + content: 2218 + application/json: 2219 + schema: 2220 + $ref: "#/components/schemas/StemmingDictionary" 2221 + '404': 2222 + description: Dictionary not found 2223 + content: 2224 + application/json: 2225 + schema: 2226 + $ref: "#/components/schemas/ApiResponse" 2227 + 2228 + /stemming/dictionaries/import: 2229 + post: 2230 + tags: 2231 + - stemming 2232 + summary: Import a stemming dictionary 2233 + description: Upload a JSONL file containing word mappings to create or update a stemming dictionary. 2234 + operationId: importStemmingDictionary 2235 + parameters: 2236 + - name: id 2237 + in: query 2238 + description: The ID to assign to the dictionary 2239 + required: true 2240 + schema: 2241 + type: string 2242 + example: irregular-plurals 2243 + requestBody: 2244 + description: The JSONL file containing word mappings 2245 + required: true 2246 + content: 2247 + application/json: 2248 + schema: 2249 + type: string 2250 + example: | 2251 + {"word": "people", "root": "person"} 2252 + {"word": "children", "root": "child"} 2253 + responses: 2254 + '200': 2255 + description: Dictionary successfully imported 2256 + content: 2257 + application/octet-stream: 2258 + schema: 2259 + type: string 2260 + example: > 2261 + {"word": "people", "root": "person"} 2262 + {"word": "children", "root": "child"} 2263 + '400': 2264 + description: Bad request, see error message for details 2265 + content: 2266 + application/json: 2267 + schema: 2268 + $ref: "#/components/schemas/ApiResponse" 2269 + /nl_search_models: 2270 + get: 2271 + tags: 2272 + - nl_search_models 2273 + summary: List all NL search models 2274 + description: Retrieve all NL search models. 2275 + operationId: retrieveAllNLSearchModels 2276 + responses: 2277 + '200': 2278 + description: List of all NL search models 2279 + content: 2280 + application/json: 2281 + schema: 2282 + type: array 2283 + items: 2284 + $ref: '#/components/schemas/NLSearchModelSchema' 2285 + post: 2286 + tags: 2287 + - nl_search_models 2288 + summary: Create a NL search model 2289 + description: Create a new NL search model. 2290 + operationId: createNLSearchModel 2291 + requestBody: 2292 + description: The NL search model to be created 2293 + content: 2294 + application/json: 2295 + schema: 2296 + $ref: '#/components/schemas/NLSearchModelCreateSchema' 2297 + required: true 2298 + responses: 2299 + '201': 2300 + description: NL search model successfully created 2301 + content: 2302 + application/json: 2303 + schema: 2304 + $ref: '#/components/schemas/NLSearchModelSchema' 2305 + '400': 2306 + description: Bad request, see error message for details 2307 + content: 2308 + application/json: 2309 + schema: 2310 + $ref: '#/components/schemas/ApiResponse' 2311 + /nl_search_models/{modelId}: 2312 + get: 2313 + tags: 2314 + - nl_search_models 2315 + summary: Retrieve a NL search model 2316 + description: Retrieve a specific NL search model by its ID. 2317 + operationId: retrieveNLSearchModel 2318 + parameters: 2319 + - name: modelId 2320 + in: path 2321 + description: The ID of the NL search model to retrieve 2322 + required: true 2323 + schema: 2324 + type: string 2325 + responses: 2326 + '200': 2327 + description: NL search model fetched 2328 + content: 2329 + application/json: 2330 + schema: 2331 + $ref: '#/components/schemas/NLSearchModelSchema' 2332 + '404': 2333 + description: NL search model not found 2334 + content: 2335 + application/json: 2336 + schema: 2337 + $ref: '#/components/schemas/ApiResponse' 2338 + put: 2339 + tags: 2340 + - nl_search_models 2341 + summary: Update a NL search model 2342 + description: Update an existing NL search model. 2343 + operationId: updateNLSearchModel 2344 + parameters: 2345 + - name: modelId 2346 + in: path 2347 + description: The ID of the NL search model to update 2348 + required: true 2349 + schema: 2350 + type: string 2351 + requestBody: 2352 + description: The NL search model fields to update 2353 + content: 2354 + application/json: 2355 + schema: 2356 + $ref: '#/components/schemas/NLSearchModelUpdateSchema' 2357 + required: true 2358 + responses: 2359 + '200': 2360 + description: NL search model successfully updated 2361 + content: 2362 + application/json: 2363 + schema: 2364 + $ref: '#/components/schemas/NLSearchModelSchema' 2365 + '400': 2366 + description: Bad request, see error message for details 2367 + content: 2368 + application/json: 2369 + schema: 2370 + $ref: '#/components/schemas/ApiResponse' 2371 + '404': 2372 + description: NL search model not found 2373 + content: 2374 + application/json: 2375 + schema: 2376 + $ref: '#/components/schemas/ApiResponse' 2377 + delete: 2378 + tags: 2379 + - nl_search_models 2380 + summary: Delete a NL search model 2381 + description: Delete a specific NL search model by its ID. 2382 + operationId: deleteNLSearchModel 2383 + parameters: 2384 + - name: modelId 2385 + in: path 2386 + description: The ID of the NL search model to delete 2387 + required: true 2388 + schema: 2389 + type: string 2390 + responses: 2391 + '200': 2392 + description: NL search model successfully deleted 2393 + content: 2394 + application/json: 2395 + schema: 2396 + $ref: '#/components/schemas/NLSearchModelDeleteSchema' 2397 + '404': 2398 + description: NL search model not found 2399 + content: 2400 + application/json: 2401 + schema: 2402 + $ref: '#/components/schemas/ApiResponse' 2403 + 2404 + components: 2405 + schemas: 2406 + CollectionSchema: 2407 + required: 2408 + - name 2409 + - fields 2410 + type: object 2411 + properties: 2412 + name: 2413 + type: string 2414 + description: Name of the collection 2415 + example: companies 2416 + fields: 2417 + type: array 2418 + description: A list of fields for querying, filtering and faceting 2419 + example: 2420 + - name: num_employees 2421 + type: int32 2422 + facet: false 2423 + - name: company_name 2424 + type: string 2425 + facet: false 2426 + - name: country 2427 + type: string 2428 + facet: true 2429 + items: 2430 + $ref: "#/components/schemas/Field" 2431 + default_sorting_field: 2432 + type: string 2433 + description: 2434 + The name of an int32 / float field that determines the order in which 2435 + the search results are ranked when a sort_by clause is not provided during 2436 + searching. This field must indicate some kind of popularity. 2437 + example: num_employees # Go with the first field name listed above to produce sane defaults 2438 + default: "" 2439 + token_separators: 2440 + type: array 2441 + description: > 2442 + List of symbols or special characters to be used for 2443 + splitting the text into individual words in addition to space and new-line characters. 2444 + items: 2445 + type: string # characters only 2446 + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: 2447 + # enum: ["@", "!", ".", "/", ","] 2448 + minLength: 1 2449 + maxLength: 1 2450 + default: [] 2451 + synonym_sets: 2452 + type: array 2453 + description: List of synonym set names to associate with this collection 2454 + items: 2455 + type: string 2456 + example: "synonym_set_1" 2457 + enable_nested_fields: 2458 + type: boolean 2459 + description: 2460 + Enables experimental support at a collection level for nested object or object array fields. 2461 + This field is only available if the Typesense server is version `0.24.0.rcn34` or later. 2462 + default: false 2463 + example: true 2464 + symbols_to_index: 2465 + type: array 2466 + description: > 2467 + List of symbols or special characters to be indexed. 2468 + items: 2469 + type: string # characters only 2470 + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: 2471 + # enum: ["@", "!", ".", "/", ","] 2472 + minLength: 1 2473 + maxLength: 1 2474 + default: [] 2475 + voice_query_model: 2476 + $ref: "#/components/schemas/VoiceQueryModelCollectionConfig" 2477 + metadata: 2478 + type: object 2479 + description: > 2480 + Optional details about the collection, e.g., when it was created, who created it etc. 2481 + CollectionUpdateSchema: 2482 + required: 2483 + - fields 2484 + type: object 2485 + properties: 2486 + fields: 2487 + type: array 2488 + description: A list of fields for querying, filtering and faceting 2489 + example: 2490 + - name: company_name 2491 + type: string 2492 + facet: false 2493 + - name: num_employees 2494 + type: int32 2495 + facet: false 2496 + - name: country 2497 + type: string 2498 + facet: true 2499 + items: 2500 + $ref: "#/components/schemas/Field" 2501 + synonym_sets: 2502 + type: array 2503 + description: List of synonym set names to associate with this collection 2504 + items: 2505 + type: string 2506 + example: "synonym_set_1" 2507 + metadata: 2508 + type: object 2509 + description: > 2510 + Optional details about the collection, e.g., when it was created, who created it etc. 2511 + CollectionResponse: 2512 + allOf: 2513 + - $ref: "#/components/schemas/CollectionSchema" 2514 + - type: object 2515 + required: 2516 + - num_documents 2517 + - created_at 2518 + properties: 2519 + num_documents: 2520 + type: integer 2521 + description: Number of documents in the collection 2522 + format: int64 2523 + readOnly: true 2524 + created_at: 2525 + type: integer 2526 + description: Timestamp of when the collection was created (Unix epoch in seconds) 2527 + format: int64 2528 + readOnly: true 2529 + Field: 2530 + required: 2531 + - name 2532 + - type 2533 + type: object 2534 + properties: 2535 + name: 2536 + type: string 2537 + example: company_name 2538 + type: 2539 + type: string 2540 + example: string 2541 + optional: 2542 + type: boolean 2543 + example: true 2544 + facet: 2545 + type: boolean 2546 + example: false 2547 + index: 2548 + type: boolean 2549 + example: true 2550 + default: true 2551 + locale: 2552 + type: string 2553 + example: el 2554 + sort: 2555 + type: boolean 2556 + example: true 2557 + infix: 2558 + type: boolean 2559 + example: true 2560 + default: false 2561 + reference: 2562 + type: string 2563 + description: > 2564 + Name of a field in another collection that should be linked to this collection so that it can be joined during query. 2565 + async_reference: 2566 + type: boolean 2567 + description: > 2568 + Allow documents to be indexed successfully even when the referenced document doesn't exist yet. 2569 + num_dim: 2570 + type: integer 2571 + example: 256 2572 + drop: 2573 + type: boolean 2574 + example: true 2575 + # omitting default value since we want it to be null 2576 + store: 2577 + type: boolean 2578 + description: > 2579 + When set to false, the field value will not be stored on disk. Default: true. 2580 + vec_dist: 2581 + type: string 2582 + description: > 2583 + The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. 2584 + range_index: 2585 + type: boolean 2586 + description: > 2587 + Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. 2588 + stem: 2589 + type: boolean 2590 + description: > 2591 + Values are stemmed before indexing in-memory. Default: false. 2592 + stem_dictionary: 2593 + type: string 2594 + description: Name of the stemming dictionary to use for this field 2595 + example: irregular-plurals 2596 + token_separators: 2597 + type: array 2598 + description: > 2599 + List of symbols or special characters to be used for 2600 + splitting the text into individual words in addition to space and new-line characters. 2601 + items: 2602 + type: string # characters only 2603 + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: 2604 + # enum: ["@", "!", ".", "/", ","] 2605 + minLength: 1 2606 + maxLength: 1 2607 + default: [] 2608 + symbols_to_index: 2609 + type: array 2610 + description: > 2611 + List of symbols or special characters to be indexed. 2612 + items: 2613 + type: string # characters only 2614 + # Could `enum` be used instead, given it's symbols/special *characters*, e.g.: 2615 + # enum: ["@", "!", ".", "/", ","] 2616 + minLength: 1 2617 + maxLength: 1 2618 + default: [] 2619 + embed: 2620 + type: object 2621 + required: 2622 + - from 2623 + - model_config 2624 + properties: 2625 + from: 2626 + type: array 2627 + items: 2628 + type: string 2629 + model_config: 2630 + type: object 2631 + required: 2632 + - model_name 2633 + properties: 2634 + model_name: 2635 + type: string 2636 + api_key: 2637 + type: string 2638 + url: 2639 + type: string 2640 + access_token: 2641 + type: string 2642 + refresh_token: 2643 + type: string 2644 + client_id: 2645 + type: string 2646 + client_secret: 2647 + type: string 2648 + project_id: 2649 + type: string 2650 + indexing_prefix: 2651 + type: string 2652 + query_prefix: 2653 + type: string 2654 + VoiceQueryModelCollectionConfig: 2655 + type: object 2656 + description: > 2657 + Configuration for the voice query model 2658 + properties: 2659 + model_name: 2660 + type: string 2661 + example: "ts/whisper/base.en" 2662 + CollectionAliasSchema: 2663 + type: object 2664 + required: 2665 + - collection_name 2666 + properties: 2667 + collection_name: 2668 + type: string 2669 + description: Name of the collection you wish to map the alias to 2670 + CollectionAlias: 2671 + type: object 2672 + required: 2673 + - collection_name 2674 + - name 2675 + properties: 2676 + name: 2677 + type: string 2678 + readOnly: true 2679 + description: Name of the collection alias 2680 + collection_name: 2681 + type: string 2682 + description: Name of the collection the alias mapped to 2683 + CollectionAliasesResponse: 2684 + type: object 2685 + required: 2686 + - aliases 2687 + properties: 2688 + aliases: 2689 + type: array 2690 + x-go-type: "[]*CollectionAlias" 2691 + items: 2692 + $ref: "#/components/schemas/CollectionAlias" 2693 + SearchResult: 2694 + type: object 2695 + properties: 2696 + facet_counts: 2697 + type: array 2698 + items: 2699 + $ref: "#/components/schemas/FacetCounts" 2700 + found: 2701 + type: integer 2702 + description: The number of documents found 2703 + found_docs: 2704 + type: integer 2705 + search_time_ms: 2706 + type: integer 2707 + description: The number of milliseconds the search took 2708 + out_of: 2709 + type: integer 2710 + description: The total number of documents in the collection 2711 + search_cutoff: 2712 + type: boolean 2713 + description: Whether the search was cut off 2714 + page: 2715 + type: integer 2716 + description: The search result page number 2717 + grouped_hits: 2718 + type: array 2719 + items: 2720 + $ref: "#/components/schemas/SearchGroupedHit" 2721 + hits: 2722 + type: array 2723 + description: The documents that matched the search query 2724 + items: 2725 + $ref: "#/components/schemas/SearchResultHit" 2726 + request_params: 2727 + $ref: "#/components/schemas/SearchRequestParams" 2728 + conversation: 2729 + $ref: "#/components/schemas/SearchResultConversation" 2730 + union_request_params: 2731 + type: array 2732 + description: Returned only for union query response. 2733 + items: 2734 + $ref: "#/components/schemas/SearchRequestParams" 2735 + metadata: 2736 + type: object 2737 + description: Custom JSON object that can be returned in the search response 2738 + additionalProperties: true 2739 + SearchRequestParams: 2740 + type: object 2741 + required: 2742 + - collection_name 2743 + - q 2744 + - per_page 2745 + properties: 2746 + collection_name: 2747 + type: string 2748 + q: 2749 + type: string 2750 + per_page: 2751 + type: integer 2752 + voice_query: 2753 + type: object 2754 + properties: 2755 + transcribed_query: 2756 + type: string 2757 + SearchResultConversation: 2758 + type: object 2759 + required: 2760 + - answer 2761 + - conversation_history 2762 + - conversation_id 2763 + - query 2764 + properties: 2765 + answer: 2766 + type: string 2767 + conversation_history: 2768 + type: array 2769 + items: 2770 + type: object 2771 + conversation_id: 2772 + type: string 2773 + query: 2774 + type: string 2775 + SearchGroupedHit: 2776 + type: object 2777 + required: 2778 + - group_key 2779 + - hits 2780 + properties: 2781 + found: 2782 + type: integer 2783 + group_key: 2784 + type: array 2785 + items: {} 2786 + hits: 2787 + type: array 2788 + description: The documents that matched the search query 2789 + items: 2790 + $ref: "#/components/schemas/SearchResultHit" 2791 + SearchResultHit: 2792 + type: object 2793 + properties: 2794 + highlights: 2795 + type: array 2796 + description: (Deprecated) Contains highlighted portions of the search fields 2797 + items: 2798 + $ref: "#/components/schemas/SearchHighlight" 2799 + highlight: 2800 + type: object 2801 + description: Highlighted version of the matching document 2802 + additionalProperties: true 2803 + document: 2804 + type: object 2805 + description: Can be any key-value pair 2806 + additionalProperties: 2807 + type: object 2808 + text_match: 2809 + type: integer 2810 + format: int64 2811 + text_match_info: 2812 + type: object 2813 + properties: 2814 + best_field_score: 2815 + type: string 2816 + best_field_weight: 2817 + type: integer 2818 + fields_matched: 2819 + type: integer 2820 + num_tokens_dropped: 2821 + type: integer 2822 + format: int64 2823 + x-go-type: uint64 2824 + score: 2825 + type: string 2826 + tokens_matched: 2827 + type: integer 2828 + typo_prefix_score: 2829 + type: integer 2830 + geo_distance_meters: 2831 + type: object 2832 + description: Can be any key-value pair 2833 + additionalProperties: 2834 + type: integer 2835 + vector_distance: 2836 + type: number 2837 + format: float 2838 + description: Distance between the query vector and matching document's vector value 2839 + hybrid_search_info: 2840 + type: object 2841 + description: Information about hybrid search scoring 2842 + properties: 2843 + rank_fusion_score: 2844 + type: number 2845 + format: float 2846 + description: Combined score from rank fusion of text and vector search 2847 + search_index: 2848 + type: integer 2849 + description: Returned only for union query response. Indicates the index of the query which this document matched to. 2850 + example: 2851 + highlights: 2852 + company_name: 2853 + field: company_name 2854 + snippet: <mark>Stark</mark> Industries 2855 + document: 2856 + id: "124" 2857 + company_name: Stark Industries 2858 + num_employees: 5215 2859 + country: USA 2860 + text_match: 1234556 2861 + SearchHighlight: 2862 + type: object 2863 + properties: 2864 + field: 2865 + type: string 2866 + example: company_name 2867 + snippet: 2868 + type: string 2869 + description: Present only for (non-array) string fields 2870 + example: <mark>Stark</mark> Industries 2871 + snippets: 2872 + type: array 2873 + description: Present only for (array) string[] fields 2874 + example: 2875 + - <mark>Stark</mark> Industries 2876 + - <mark>Stark</mark> Corp 2877 + items: 2878 + type: string 2879 + value: 2880 + type: string 2881 + description: Full field value with highlighting, present only for (non-array) string fields 2882 + example: <mark>Stark</mark> Industries is a major supplier of space equipment. 2883 + values: 2884 + type: array 2885 + description: Full field value with highlighting, present only for (array) string[] fields 2886 + example: 2887 + - <mark>Stark</mark> Industries 2888 + - <mark>Stark</mark> Corp 2889 + items: 2890 + type: string 2891 + indices: 2892 + type: array 2893 + description: The indices property will be present only for string[] 2894 + fields and will contain the corresponding indices of the snippets 2895 + in the search field 2896 + example: 1 2897 + items: 2898 + type: integer 2899 + matched_tokens: 2900 + type: array 2901 + items: 2902 + type: object 2903 + x-go-type: "interface{}" 2904 + SearchSynonymSchema: 2905 + type: object 2906 + required: 2907 + - synonyms 2908 + properties: 2909 + root: 2910 + type: string 2911 + description: For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. 2912 + synonyms: 2913 + type: array 2914 + description: Array of words that should be considered as synonyms. 2915 + items: 2916 + type: string 2917 + locale: 2918 + type: string 2919 + description: Locale for the synonym, leave blank to use the standard tokenizer. 2920 + symbols_to_index: 2921 + type: array 2922 + description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. 2923 + items: 2924 + type: string 2925 + SearchSynonym: 2926 + allOf: 2927 + - $ref: "#/components/schemas/SearchSynonymSchema" 2928 + - type: object 2929 + required: 2930 + - id 2931 + properties: 2932 + id: 2933 + type: string 2934 + readOnly: true 2935 + SearchSynonymDeleteResponse: 2936 + type: object 2937 + required: 2938 + - id 2939 + properties: 2940 + id: 2941 + type: string 2942 + description: The id of the synonym that was deleted 2943 + SearchSynonymsResponse: 2944 + type: object 2945 + required: 2946 + - synonyms 2947 + properties: 2948 + synonyms: 2949 + type: array 2950 + x-go-type: "[]*SearchSynonym" 2951 + items: 2952 + $ref: "#/components/schemas/SearchSynonym" 2953 + HealthStatus: 2954 + type: object 2955 + required: 2956 + - ok 2957 + properties: 2958 + ok: 2959 + type: boolean 2960 + SchemaChangeStatus: 2961 + type: object 2962 + properties: 2963 + collection: 2964 + type: string 2965 + description: Name of the collection being modified 2966 + validated_docs: 2967 + type: integer 2968 + description: Number of documents that have been validated 2969 + altered_docs: 2970 + type: integer 2971 + description: Number of documents that have been altered 2972 + SuccessStatus: 2973 + type: object 2974 + required: 2975 + - success 2976 + properties: 2977 + success: 2978 + type: boolean 2979 + ApiResponse: 2980 + type: object 2981 + required: 2982 + - message 2983 + properties: 2984 + message: 2985 + type: string 2986 + ApiKeySchema: 2987 + type: object 2988 + required: 2989 + - actions 2990 + - collections 2991 + - description 2992 + properties: 2993 + value: 2994 + type: string 2995 + description: 2996 + type: string 2997 + actions: 2998 + type: array 2999 + items: 3000 + type: string 3001 + collections: 3002 + type: array 3003 + items: 3004 + type: string 3005 + expires_at: 3006 + type: integer 3007 + format: int64 3008 + ApiKey: 3009 + allOf: 3010 + - $ref: "#/components/schemas/ApiKeySchema" 3011 + - type: object 3012 + properties: 3013 + id: 3014 + type: integer 3015 + format: int64 3016 + readOnly: true 3017 + value_prefix: 3018 + type: string 3019 + readOnly: true 3020 + ApiKeyDeleteResponse: 3021 + type: object 3022 + required: 3023 + - id 3024 + properties: 3025 + id: 3026 + type: integer 3027 + format: int64 3028 + description: The id of the API key that was deleted 3029 + ApiKeysResponse: 3030 + type: object 3031 + required: 3032 + - keys 3033 + properties: 3034 + keys: 3035 + type: array 3036 + x-go-type: "[]*ApiKey" 3037 + items: 3038 + $ref: "#/components/schemas/ApiKey" 3039 + MultiSearchResult: 3040 + type: object 3041 + required: 3042 + - results 3043 + properties: 3044 + results: 3045 + type: array 3046 + items: 3047 + $ref: "#/components/schemas/MultiSearchResultItem" 3048 + conversation: 3049 + $ref: "#/components/schemas/SearchResultConversation" 3050 + MultiSearchResultItem: 3051 + allOf: 3052 + - $ref: "#/components/schemas/SearchResult" 3053 + - type: object 3054 + properties: 3055 + code: 3056 + type: integer 3057 + description: HTTP error code 3058 + format: int64 3059 + error: 3060 + type: string 3061 + description: Error description 3062 + SearchParameters: 3063 + type: object 3064 + properties: 3065 + q: 3066 + description: The query text to search for in the collection. 3067 + Use * as the search string to return all documents. 3068 + This is typically useful when used in conjunction with filter_by. 3069 + type: string 3070 + 3071 + query_by: 3072 + description: A list of `string` fields that should be queried 3073 + against. Multiple fields are separated with a comma. 3074 + type: string 3075 + 3076 + nl_query: 3077 + description: Whether to use natural language processing to parse the query. 3078 + type: boolean 3079 + 3080 + nl_model_id: 3081 + description: The ID of the natural language model to use. 3082 + type: string 3083 + 3084 + query_by_weights: 3085 + description: 3086 + The relative weight to give each `query_by` field when ranking results. 3087 + This can be used to boost fields in priority, when looking for matches. 3088 + Multiple fields are separated with a comma. 3089 + type: string 3090 + 3091 + text_match_type: 3092 + description: 3093 + In a multi-field matching context, this parameter determines how the representative text match 3094 + score of a record is calculated. Possible values are max_score (default) or max_weight. 3095 + type: string 3096 + 3097 + prefix: 3098 + description: 3099 + Boolean field to indicate that the last word in the query should 3100 + be treated as a prefix, and not as a whole word. This is used for building 3101 + autocomplete and instant search interfaces. Defaults to true. 3102 + type: string 3103 + 3104 + infix: 3105 + description: 3106 + If infix index is enabled for this field, infix searching can be done on a per-field 3107 + basis by sending a comma separated string parameter called infix to the search query. 3108 + This parameter can have 3 values; `off` infix search is disabled, which is default 3109 + `always` infix search is performed along with regular search 3110 + `fallback` infix search is performed if regular search does not produce results 3111 + type: string 3112 + 3113 + max_extra_prefix: 3114 + description: 3115 + There are also 2 parameters that allow you to control the extent of infix searching 3116 + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before 3117 + or after the query that can be present in the token. For example query "K2100" has 2 extra 3118 + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. 3119 + type: integer 3120 + 3121 + max_extra_suffix: 3122 + description: 3123 + There are also 2 parameters that allow you to control the extent of infix searching 3124 + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before 3125 + or after the query that can be present in the token. For example query "K2100" has 2 extra 3126 + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. 3127 + type: integer 3128 + 3129 + filter_by: 3130 + description: 3131 + Filter conditions for refining your open api validator search results. Separate 3132 + multiple conditions with &&. 3133 + type: string 3134 + example: "num_employees:>100 && country: [USA, UK]" 3135 + 3136 + max_filter_by_candidates: 3137 + description: 3138 + Controls the number of similar words that Typesense considers during fuzzy search 3139 + on filter_by values. Useful for controlling prefix matches like company_name:Acm*. 3140 + type: integer 3141 + 3142 + sort_by: 3143 + description: 3144 + A list of numerical fields and their corresponding sort orders 3145 + that will be used for ordering your results. 3146 + Up to 3 sort fields can be specified. 3147 + The text similarity score is exposed as a special `_text_match` field that 3148 + you can use in the list of sorting fields. 3149 + If no `sort_by` parameter is specified, results are sorted by 3150 + `_text_match:desc,default_sorting_field:desc` 3151 + type: string 3152 + example: num_employees:desc 3153 + 3154 + facet_by: 3155 + description: 3156 + A list of fields that will be used for faceting your results 3157 + on. Separate multiple fields with a comma. 3158 + type: string 3159 + 3160 + max_facet_values: 3161 + description: Maximum number of facet values to be returned. 3162 + type: integer 3163 + 3164 + facet_query: 3165 + description: 3166 + Facet values that are returned can now be filtered via this parameter. 3167 + The matching facet text is also highlighted. For example, when faceting 3168 + by `category`, you can set `facet_query=category:shoe` to return only 3169 + facet values that contain the prefix "shoe". 3170 + type: string 3171 + 3172 + num_typos: 3173 + description: > 3174 + The number of typographical errors (1 or 2) that would be tolerated. 3175 + Default: 2 3176 + type: string 3177 + 3178 + page: 3179 + description: Results from this specific page number would be fetched. 3180 + type: integer 3181 + 3182 + per_page: 3183 + description: "Number of results to fetch per page. Default: 10" 3184 + type: integer 3185 + 3186 + limit: 3187 + description: > 3188 + Number of hits to fetch. Can be used as an alternative to the per_page parameter. 3189 + Default: 10. 3190 + type: integer 3191 + 3192 + offset: 3193 + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. 3194 + type: integer 3195 + 3196 + group_by: 3197 + description: 3198 + You can aggregate search results into groups or buckets by specify 3199 + one or more `group_by` fields. Separate multiple fields with a comma. 3200 + To group on a particular field, it must be a faceted field. 3201 + type: string 3202 + 3203 + group_limit: 3204 + description: > 3205 + Maximum number of hits to be returned for every group. If the `group_limit` is 3206 + set as `K` then only the top K hits in each group are returned in the response. 3207 + Default: 3 3208 + type: integer 3209 + 3210 + group_missing_values: 3211 + description: > 3212 + Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. 3213 + 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. 3214 + Default: true 3215 + type: boolean 3216 + 3217 + include_fields: 3218 + description: List of fields from the document to include in the search result 3219 + type: string 3220 + 3221 + exclude_fields: 3222 + description: List of fields from the document to exclude in the search result 3223 + type: string 3224 + 3225 + highlight_full_fields: 3226 + description: List of fields which should be highlighted fully without snippeting 3227 + type: string 3228 + 3229 + highlight_affix_num_tokens: 3230 + description: > 3231 + The number of tokens that should surround the highlighted text on each side. 3232 + Default: 4 3233 + type: integer 3234 + 3235 + highlight_start_tag: 3236 + description: > 3237 + The start tag used for the highlighted snippets. 3238 + Default: `<mark>` 3239 + type: string 3240 + highlight_end_tag: 3241 + description: > 3242 + The end tag used for the highlighted snippets. 3243 + Default: `</mark>` 3244 + type: string 3245 + 3246 + enable_highlight_v1: 3247 + description: > 3248 + Flag for enabling/disabling the deprecated, old highlight structure in the response. 3249 + Default: true 3250 + type: boolean 3251 + default: true 3252 + 3253 + enable_analytics: 3254 + description: > 3255 + Flag for enabling/disabling analytics aggregation for specific search 3256 + queries (for e.g. those originating from a test script). 3257 + type: boolean 3258 + default: true 3259 + 3260 + snippet_threshold: 3261 + description: > 3262 + Field values under this length will be fully highlighted, instead of showing 3263 + a snippet of relevant portion. Default: 30 3264 + type: integer 3265 + 3266 + synonym_sets: 3267 + type: string 3268 + description: List of synonym set names to associate with this search query 3269 + example: "synonym_set_1,synonym_set_2" 3270 + 3271 + drop_tokens_threshold: 3272 + description: > 3273 + If the number of results found for a specific query is less than 3274 + this number, Typesense will attempt to drop the tokens in the query until 3275 + enough results are found. Tokens that have the least individual hits 3276 + are dropped first. Set to 0 to disable. Default: 10 3277 + type: integer 3278 + drop_tokens_mode: 3279 + $ref: "#/components/schemas/DropTokensMode" 3280 + typo_tokens_threshold: 3281 + description: > 3282 + If the number of results found for a specific query is less than this number, 3283 + Typesense will attempt to look for tokens with more typos until 3284 + enough results are found. Default: 100 3285 + type: integer 3286 + enable_typos_for_alpha_numerical_tokens: 3287 + type: boolean 3288 + description: > 3289 + Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 3290 + 3291 + filter_curated_hits: 3292 + type: boolean 3293 + description: > 3294 + Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false 3295 + enable_synonyms: 3296 + type: boolean 3297 + description: > 3298 + 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 3299 + synonym_prefix: 3300 + type: boolean 3301 + description: > 3302 + Allow synonym resolution on word prefixes in the query. Default: false 3303 + synonym_num_typos: 3304 + type: integer 3305 + description: > 3306 + Allow synonym resolution on typo-corrected words in the query. Default: 0 3307 + 3308 + pinned_hits: 3309 + description: > 3310 + A list of records to unconditionally include in the search results 3311 + at specific positions. An example use case would be to feature or promote 3312 + certain items on the top of search results. 3313 + A list of `record_id:hit_position`. Eg: to include a record with ID 123 3314 + at Position 1 and another record with ID 456 at Position 5, 3315 + you'd specify `123:1,456:5`. 3316 + 3317 + You could also use the Overrides feature to override search results based 3318 + on rules. Overrides are applied first, followed by `pinned_hits` and 3319 + finally `hidden_hits`. 3320 + type: string 3321 + 3322 + hidden_hits: 3323 + description: > 3324 + A list of records to unconditionally hide from search results. 3325 + A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, 3326 + you'd specify `123,456`. 3327 + 3328 + You could also use the Overrides feature to override search results based 3329 + on rules. Overrides are applied first, followed by `pinned_hits` and 3330 + finally `hidden_hits`. 3331 + type: string 3332 + 3333 + override_tags: 3334 + description: Comma separated list of tags to trigger the curations rules that match the tags. 3335 + type: string 3336 + 3337 + highlight_fields: 3338 + description: > 3339 + A list of custom fields that must be highlighted even if you don't query 3340 + for them 3341 + type: string 3342 + 3343 + split_join_tokens: 3344 + description: > 3345 + Treat space as typo: search for q=basket ball if q=basketball is not found or vice-versa. 3346 + Splitting/joining of tokens will only be attempted if the original query produces no results. 3347 + To always trigger this behavior, set value to `always``. 3348 + To disable, set value to `off`. Default is `fallback`. 3349 + type: string 3350 + 3351 + pre_segmented_query: 3352 + description: > 3353 + You can index content from any logographic language into Typesense if you 3354 + are able to segment / split the text into space-separated words yourself 3355 + before indexing and querying. 3356 + 3357 + Set this parameter to true to do the same 3358 + type: boolean 3359 + 3360 + preset: 3361 + description: > 3362 + Search using a bunch of search parameters by setting this parameter to 3363 + the name of the existing Preset. 3364 + type: string 3365 + 3366 + enable_overrides: 3367 + description: > 3368 + If you have some overrides defined but want to disable all of them during 3369 + query time, you can do that by setting this parameter to false 3370 + type: boolean 3371 + default: false 3372 + 3373 + prioritize_exact_match: 3374 + description: > 3375 + Set this parameter to true to ensure that an exact match is ranked above 3376 + the others 3377 + type: boolean 3378 + default: true 3379 + max_candidates: 3380 + description: > 3381 + Control the number of words that Typesense considers for typo and prefix searching. 3382 + type: integer 3383 + prioritize_token_position: 3384 + description: > 3385 + Make Typesense prioritize documents where the query words appear earlier in the text. 3386 + type: boolean 3387 + default: false 3388 + prioritize_num_matching_fields: 3389 + description: > 3390 + Make Typesense prioritize documents where the query words appear in more number of fields. 3391 + type: boolean 3392 + default: true 3393 + enable_typos_for_numerical_tokens: 3394 + description: > 3395 + Make Typesense disable typos for numerical tokens. 3396 + type: boolean 3397 + default: true 3398 + exhaustive_search: 3399 + description: > 3400 + Setting this to true will make Typesense consider all prefixes and typo 3401 + corrections of the words in the query without stopping early when enough results are found 3402 + (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). 3403 + type: boolean 3404 + search_cutoff_ms: 3405 + description: > 3406 + Typesense will attempt to return results early if the cutoff time has elapsed. 3407 + This is not a strict guarantee and facet computation is not bound by this parameter. 3408 + type: integer 3409 + use_cache: 3410 + description: > 3411 + Enable server side caching of search query results. By default, caching is disabled. 3412 + type: boolean 3413 + cache_ttl: 3414 + description: > 3415 + The duration (in seconds) that determines how long the search query is cached. 3416 + This value can be set on a per-query basis. Default: 60. 3417 + type: integer 3418 + min_len_1typo: 3419 + description: > 3420 + Minimum word length for 1-typo correction to be applied. 3421 + The value of num_typos is still treated as the maximum allowed typos. 3422 + type: integer 3423 + min_len_2typo: 3424 + description: > 3425 + Minimum word length for 2-typo correction to be applied. 3426 + The value of num_typos is still treated as the maximum allowed typos. 3427 + type: integer 3428 + vector_query: 3429 + description: > 3430 + Vector query expression for fetching documents "closest" to a given query/document vector. 3431 + type: string 3432 + remote_embedding_timeout_ms: 3433 + description: > 3434 + Timeout (in milliseconds) for fetching remote embeddings. 3435 + type: integer 3436 + remote_embedding_num_tries: 3437 + description: > 3438 + Number of times to retry fetching remote embeddings. 3439 + type: integer 3440 + facet_strategy: 3441 + description: > 3442 + Choose the underlying faceting strategy used. Comma separated string of allows values: 3443 + exhaustive, top_values or automatic (default). 3444 + type: string 3445 + stopwords: 3446 + description: > 3447 + Name of the stopwords set to apply for this search, 3448 + the keywords present in the set will be removed from the search query. 3449 + type: string 3450 + facet_return_parent: 3451 + description: > 3452 + Comma separated string of nested facet fields whose parent object should be returned in facet response. 3453 + type: string 3454 + voice_query: 3455 + description: > 3456 + The base64 encoded audio file in 16 khz 16-bit WAV format. 3457 + type: string 3458 + conversation: 3459 + description: > 3460 + Enable conversational search. 3461 + type: boolean 3462 + conversation_model_id: 3463 + description: > 3464 + The Id of Conversation Model to be used. 3465 + type: string 3466 + conversation_id: 3467 + description: > 3468 + The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 3469 + type: string 3470 + 3471 + MultiSearchParameters: 3472 + description: > 3473 + Parameters for the multi search API. 3474 + type: object 3475 + properties: 3476 + q: 3477 + description: The query text to search for in the collection. 3478 + Use * as the search string to return all documents. 3479 + This is typically useful when used in conjunction with filter_by. 3480 + type: string 3481 + 3482 + query_by: 3483 + description: A list of `string` fields that should be queried 3484 + against. Multiple fields are separated with a comma. 3485 + type: string 3486 + 3487 + query_by_weights: 3488 + description: 3489 + The relative weight to give each `query_by` field when ranking results. 3490 + This can be used to boost fields in priority, when looking for matches. 3491 + Multiple fields are separated with a comma. 3492 + type: string 3493 + 3494 + text_match_type: 3495 + description: 3496 + In a multi-field matching context, this parameter determines how the representative text match 3497 + score of a record is calculated. Possible values are max_score (default) or max_weight. 3498 + type: string 3499 + 3500 + prefix: 3501 + description: 3502 + Boolean field to indicate that the last word in the query should 3503 + be treated as a prefix, and not as a whole word. This is used for building 3504 + autocomplete and instant search interfaces. Defaults to true. 3505 + type: string 3506 + 3507 + infix: 3508 + description: 3509 + If infix index is enabled for this field, infix searching can be done on a per-field 3510 + basis by sending a comma separated string parameter called infix to the search query. 3511 + This parameter can have 3 values; `off` infix search is disabled, which is default 3512 + `always` infix search is performed along with regular search 3513 + `fallback` infix search is performed if regular search does not produce results 3514 + type: string 3515 + 3516 + max_extra_prefix: 3517 + description: 3518 + There are also 2 parameters that allow you to control the extent of infix searching 3519 + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before 3520 + or after the query that can be present in the token. For example query "K2100" has 2 extra 3521 + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. 3522 + type: integer 3523 + 3524 + max_extra_suffix: 3525 + description: 3526 + There are also 2 parameters that allow you to control the extent of infix searching 3527 + max_extra_prefix and max_extra_suffix which specify the maximum number of symbols before 3528 + or after the query that can be present in the token. For example query "K2100" has 2 extra 3529 + symbols in "6PK2100". By default, any number of prefixes/suffixes can be present for a match. 3530 + type: integer 3531 + 3532 + filter_by: 3533 + description: 3534 + Filter conditions for refining youropen api validator search results. Separate 3535 + multiple conditions with &&. 3536 + type: string 3537 + example: "num_employees:>100 && country: [USA, UK]" 3538 + 3539 + sort_by: 3540 + description: 3541 + A list of numerical fields and their corresponding sort orders 3542 + that will be used for ordering your results. 3543 + Up to 3 sort fields can be specified. 3544 + The text similarity score is exposed as a special `_text_match` field that 3545 + you can use in the list of sorting fields. 3546 + If no `sort_by` parameter is specified, results are sorted by 3547 + `_text_match:desc,default_sorting_field:desc` 3548 + type: string 3549 + 3550 + facet_by: 3551 + description: 3552 + A list of fields that will be used for faceting your results 3553 + on. Separate multiple fields with a comma. 3554 + type: string 3555 + 3556 + max_facet_values: 3557 + description: Maximum number of facet values to be returned. 3558 + type: integer 3559 + 3560 + facet_query: 3561 + description: 3562 + Facet values that are returned can now be filtered via this parameter. 3563 + The matching facet text is also highlighted. For example, when faceting 3564 + by `category`, you can set `facet_query=category:shoe` to return only 3565 + facet values that contain the prefix "shoe". 3566 + type: string 3567 + 3568 + num_typos: 3569 + description: > 3570 + The number of typographical errors (1 or 2) that would be tolerated. 3571 + Default: 2 3572 + type: string 3573 + 3574 + page: 3575 + description: Results from this specific page number would be fetched. 3576 + type: integer 3577 + 3578 + per_page: 3579 + description: "Number of results to fetch per page. Default: 10" 3580 + type: integer 3581 + 3582 + limit: 3583 + description: > 3584 + Number of hits to fetch. Can be used as an alternative to the per_page parameter. 3585 + Default: 10. 3586 + type: integer 3587 + 3588 + offset: 3589 + description: Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. 3590 + type: integer 3591 + 3592 + group_by: 3593 + description: 3594 + You can aggregate search results into groups or buckets by specify 3595 + one or more `group_by` fields. Separate multiple fields with a comma. 3596 + To group on a particular field, it must be a faceted field. 3597 + type: string 3598 + 3599 + group_limit: 3600 + description: > 3601 + Maximum number of hits to be returned for every group. If the `group_limit` is 3602 + set as `K` then only the top K hits in each group are returned in the response. 3603 + Default: 3 3604 + type: integer 3605 + 3606 + group_missing_values: 3607 + description: > 3608 + Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. 3609 + 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. 3610 + Default: true 3611 + type: boolean 3612 + 3613 + include_fields: 3614 + description: List of fields from the document to include in the search result 3615 + type: string 3616 + 3617 + exclude_fields: 3618 + description: List of fields from the document to exclude in the search result 3619 + type: string 3620 + 3621 + highlight_full_fields: 3622 + description: List of fields which should be highlighted fully without snippeting 3623 + type: string 3624 + 3625 + highlight_affix_num_tokens: 3626 + description: > 3627 + The number of tokens that should surround the highlighted text on each side. 3628 + Default: 4 3629 + type: integer 3630 + 3631 + highlight_start_tag: 3632 + description: > 3633 + The start tag used for the highlighted snippets. 3634 + Default: `<mark>` 3635 + type: string 3636 + highlight_end_tag: 3637 + description: > 3638 + The end tag used for the highlighted snippets. 3639 + Default: `</mark>` 3640 + type: string 3641 + 3642 + snippet_threshold: 3643 + description: > 3644 + Field values under this length will be fully highlighted, instead of showing 3645 + a snippet of relevant portion. Default: 30 3646 + type: integer 3647 + 3648 + drop_tokens_threshold: 3649 + description: > 3650 + If the number of results found for a specific query is less than 3651 + this number, Typesense will attempt to drop the tokens in the query until 3652 + enough results are found. Tokens that have the least individual hits 3653 + are dropped first. Set to 0 to disable. Default: 10 3654 + type: integer 3655 + drop_tokens_mode: 3656 + $ref: "#/components/schemas/DropTokensMode" 3657 + typo_tokens_threshold: 3658 + description: > 3659 + If the number of results found for a specific query is less than this number, 3660 + Typesense will attempt to look for tokens with more typos until 3661 + enough results are found. Default: 100 3662 + type: integer 3663 + enable_typos_for_alpha_numerical_tokens: 3664 + type: boolean 3665 + description: > 3666 + Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 3667 + 3668 + filter_curated_hits: 3669 + type: boolean 3670 + description: > 3671 + Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false 3672 + enable_synonyms: 3673 + type: boolean 3674 + description: > 3675 + 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 3676 + 3677 + enable_analytics: 3678 + description: > 3679 + Flag for enabling/disabling analytics aggregation for specific search 3680 + queries (for e.g. those originating from a test script). 3681 + type: boolean 3682 + default: true 3683 + 3684 + synonym_prefix: 3685 + type: boolean 3686 + description: > 3687 + Allow synonym resolution on word prefixes in the query. Default: false 3688 + synonym_num_typos: 3689 + type: integer 3690 + description: > 3691 + Allow synonym resolution on typo-corrected words in the query. Default: 0 3692 + 3693 + pinned_hits: 3694 + description: > 3695 + A list of records to unconditionally include in the search results 3696 + at specific positions. An example use case would be to feature or promote 3697 + certain items on the top of search results. 3698 + A list of `record_id:hit_position`. Eg: to include a record with ID 123 3699 + at Position 1 and another record with ID 456 at Position 5, 3700 + you'd specify `123:1,456:5`. 3701 + 3702 + You could also use the Overrides feature to override search results based 3703 + on rules. Overrides are applied first, followed by `pinned_hits` and 3704 + finally `hidden_hits`. 3705 + type: string 3706 + 3707 + hidden_hits: 3708 + description: > 3709 + A list of records to unconditionally hide from search results. 3710 + A list of `record_id`s to hide. Eg: to hide records with IDs 123 and 456, 3711 + you'd specify `123,456`. 3712 + 3713 + You could also use the Overrides feature to override search results based 3714 + on rules. Overrides are applied first, followed by `pinned_hits` and 3715 + finally `hidden_hits`. 3716 + type: string 3717 + 3718 + override_tags: 3719 + description: Comma separated list of tags to trigger the curations rules that match the tags. 3720 + type: string 3721 + 3722 + highlight_fields: 3723 + description: > 3724 + A list of custom fields that must be highlighted even if you don't query 3725 + for them 3726 + type: string 3727 + 3728 + pre_segmented_query: 3729 + description: > 3730 + You can index content from any logographic language into Typesense if you 3731 + are able to segment / split the text into space-separated words yourself 3732 + before indexing and querying. 3733 + 3734 + Set this parameter to true to do the same 3735 + type: boolean 3736 + default: false 3737 + 3738 + preset: 3739 + description: > 3740 + Search using a bunch of search parameters by setting this parameter to 3741 + the name of the existing Preset. 3742 + type: string 3743 + 3744 + enable_overrides: 3745 + description: > 3746 + If you have some overrides defined but want to disable all of them during 3747 + query time, you can do that by setting this parameter to false 3748 + type: boolean 3749 + default: false 3750 + 3751 + prioritize_exact_match: 3752 + description: > 3753 + Set this parameter to true to ensure that an exact match is ranked above 3754 + the others 3755 + type: boolean 3756 + default: true 3757 + 3758 + prioritize_token_position: 3759 + description: > 3760 + Make Typesense prioritize documents where the query words appear earlier in the text. 3761 + type: boolean 3762 + default: false 3763 + 3764 + prioritize_num_matching_fields: 3765 + description: > 3766 + Make Typesense prioritize documents where the query words appear in more number of fields. 3767 + type: boolean 3768 + default: true 3769 + 3770 + enable_typos_for_numerical_tokens: 3771 + description: > 3772 + Make Typesense disable typos for numerical tokens. 3773 + type: boolean 3774 + default: true 3775 + 3776 + exhaustive_search: 3777 + description: > 3778 + Setting this to true will make Typesense consider all prefixes and typo 3779 + corrections of the words in the query without stopping early when enough results are found 3780 + (drop_tokens_threshold and typo_tokens_threshold configurations are ignored). 3781 + type: boolean 3782 + search_cutoff_ms: 3783 + description: > 3784 + Typesense will attempt to return results early if the cutoff time has elapsed. 3785 + This is not a strict guarantee and facet computation is not bound by this parameter. 3786 + type: integer 3787 + use_cache: 3788 + description: > 3789 + Enable server side caching of search query results. By default, caching is disabled. 3790 + type: boolean 3791 + cache_ttl: 3792 + description: > 3793 + The duration (in seconds) that determines how long the search query is cached. 3794 + This value can be set on a per-query basis. Default: 60. 3795 + type: integer 3796 + min_len_1typo: 3797 + description: > 3798 + Minimum word length for 1-typo correction to be applied. 3799 + The value of num_typos is still treated as the maximum allowed typos. 3800 + type: integer 3801 + min_len_2typo: 3802 + description: > 3803 + Minimum word length for 2-typo correction to be applied. 3804 + The value of num_typos is still treated as the maximum allowed typos. 3805 + type: integer 3806 + vector_query: 3807 + description: > 3808 + Vector query expression for fetching documents "closest" to a given query/document vector. 3809 + type: string 3810 + remote_embedding_timeout_ms: 3811 + description: > 3812 + Timeout (in milliseconds) for fetching remote embeddings. 3813 + type: integer 3814 + remote_embedding_num_tries: 3815 + description: > 3816 + Number of times to retry fetching remote embeddings. 3817 + type: integer 3818 + facet_strategy: 3819 + description: > 3820 + Choose the underlying faceting strategy used. Comma separated string of allows values: 3821 + exhaustive, top_values or automatic (default). 3822 + type: string 3823 + stopwords: 3824 + description: > 3825 + Name of the stopwords set to apply for this search, 3826 + the keywords present in the set will be removed from the search query. 3827 + type: string 3828 + facet_return_parent: 3829 + description: > 3830 + Comma separated string of nested facet fields whose parent object should be returned in facet response. 3831 + type: string 3832 + voice_query: 3833 + description: > 3834 + The base64 encoded audio file in 16 khz 16-bit WAV format. 3835 + type: string 3836 + conversation: 3837 + description: > 3838 + Enable conversational search. 3839 + type: boolean 3840 + conversation_model_id: 3841 + description: > 3842 + The Id of Conversation Model to be used. 3843 + type: string 3844 + conversation_id: 3845 + description: > 3846 + The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 3847 + type: string 3848 + MultiSearchSearchesParameter: 3849 + type: object 3850 + required: 3851 + - searches 3852 + properties: 3853 + union: 3854 + type: boolean 3855 + default: false 3856 + description: When true, merges the search results from each search query into a single ordered set of hits. 3857 + searches: 3858 + type: array 3859 + items: 3860 + $ref: "#/components/schemas/MultiSearchCollectionParameters" 3861 + MultiSearchCollectionParameters: 3862 + allOf: 3863 + - $ref: "#/components/schemas/MultiSearchParameters" 3864 + - type: object 3865 + properties: 3866 + collection: 3867 + type: string 3868 + description: > 3869 + The collection to search in. 3870 + x-typesense-api-key: 3871 + type: string 3872 + description: A separate search API key for each search within a multi_search request 3873 + rerank_hybrid_matches: 3874 + type: boolean 3875 + description: > 3876 + When true, computes both text match and vector distance scores for all matches in hybrid search. 3877 + Documents found only through keyword search will get a vector distance score, and 3878 + documents found only through vector search will get a text match score. 3879 + default: false 3880 + FacetCounts: 3881 + type: object 3882 + properties: 3883 + counts: 3884 + type: array 3885 + items: 3886 + type: object 3887 + properties: 3888 + count: 3889 + type: integer 3890 + highlighted: 3891 + type: string 3892 + value: 3893 + type: string 3894 + parent: 3895 + type: object 3896 + field_name: 3897 + type: string 3898 + stats: 3899 + type: object 3900 + properties: 3901 + max: 3902 + type: number 3903 + format: double 3904 + min: 3905 + type: number 3906 + format: double 3907 + sum: 3908 + type: number 3909 + format: double 3910 + total_values: 3911 + type: integer 3912 + avg: 3913 + type: number 3914 + format: double 3915 + AnalyticsEventCreateResponse: 3916 + type: object 3917 + required: 3918 + - ok 3919 + properties: 3920 + ok: 3921 + type: boolean 3922 + AnalyticsEvent: 3923 + type: object 3924 + required: 3925 + - name 3926 + - event_type 3927 + - data 3928 + properties: 3929 + name: 3930 + type: string 3931 + description: Name of the analytics rule this event corresponds to 3932 + event_type: 3933 + type: string 3934 + description: Type of event (e.g., click, conversion, query, visit) 3935 + data: 3936 + type: object 3937 + description: Event payload 3938 + properties: 3939 + user_id: 3940 + type: string 3941 + doc_id: 3942 + type: string 3943 + doc_ids: 3944 + type: array 3945 + items: 3946 + type: string 3947 + q: 3948 + type: string 3949 + analytics_tag: 3950 + type: string 3951 + AnalyticsEventsResponse: 3952 + type: object 3953 + required: 3954 + - events 3955 + properties: 3956 + events: 3957 + type: array 3958 + items: 3959 + type: object 3960 + properties: 3961 + name: { type: string } 3962 + event_type: { type: string } 3963 + collection: { type: string } 3964 + timestamp: { type: integer, format: int64 } 3965 + user_id: { type: string } 3966 + doc_id: { type: string } 3967 + doc_ids: 3968 + type: array 3969 + items: { type: string } 3970 + query: { type: string } 3971 + AnalyticsRuleCreate: 3972 + type: object 3973 + required: 3974 + - name 3975 + - type 3976 + - collection 3977 + - event_type 3978 + properties: 3979 + name: 3980 + type: string 3981 + type: 3982 + $ref: "#/components/schemas/AnalyticsRuleType" 3983 + collection: 3984 + type: string 3985 + event_type: 3986 + type: string 3987 + rule_tag: 3988 + type: string 3989 + params: 3990 + type: object 3991 + properties: 3992 + destination_collection: 3993 + type: string 3994 + limit: 3995 + type: integer 3996 + capture_search_requests: 3997 + type: boolean 3998 + meta_fields: 3999 + type: array 4000 + items: { type: string } 4001 + expand_query: 4002 + type: boolean 4003 + counter_field: 4004 + type: string 4005 + weight: 4006 + type: integer 4007 + AnalyticsRuleType: 4008 + type: string 4009 + enum: [popular_queries, nohits_queries, counter, log] 4010 + AnalyticsRuleUpdate: 4011 + type: object 4012 + description: Fields allowed to update on an analytics rule 4013 + properties: 4014 + name: 4015 + type: string 4016 + rule_tag: 4017 + type: string 4018 + params: 4019 + type: object 4020 + properties: 4021 + destination_collection: 4022 + type: string 4023 + limit: 4024 + type: integer 4025 + capture_search_requests: 4026 + type: boolean 4027 + meta_fields: 4028 + type: array 4029 + items: { type: string } 4030 + expand_query: 4031 + type: boolean 4032 + counter_field: 4033 + type: string 4034 + weight: 4035 + type: integer 4036 + AnalyticsRule: 4037 + allOf: 4038 + - $ref: '#/components/schemas/AnalyticsRuleCreate' 4039 + - type: object 4040 + AnalyticsStatus: 4041 + type: object 4042 + properties: 4043 + popular_prefix_queries: { type: integer } 4044 + nohits_prefix_queries: { type: integer } 4045 + log_prefix_queries: { type: integer } 4046 + query_log_events: { type: integer } 4047 + query_counter_events: { type: integer } 4048 + doc_log_events: { type: integer } 4049 + doc_counter_events: { type: integer } 4050 + 4051 + APIStatsResponse: 4052 + type: object 4053 + properties: 4054 + delete_latency_ms: 4055 + type: number 4056 + format: double 4057 + delete_requests_per_second: 4058 + type: number 4059 + format: double 4060 + import_latency_ms: 4061 + type: number 4062 + format: double 4063 + import_requests_per_second: 4064 + type: number 4065 + format: double 4066 + latency_ms: 4067 + type: object 4068 + x-go-type: "map[string]float64" 4069 + overloaded_requests_per_second: 4070 + type: number 4071 + format: double 4072 + pending_write_batches: 4073 + type: number 4074 + format: double 4075 + requests_per_second: 4076 + type: object 4077 + x-go-type: "map[string]float64" 4078 + search_latency_ms: 4079 + type: number 4080 + format: double 4081 + search_requests_per_second: 4082 + type: number 4083 + format: double 4084 + total_requests_per_second: 4085 + type: number 4086 + format: double 4087 + write_latency_ms: 4088 + type: number 4089 + format: double 4090 + write_requests_per_second: 4091 + type: number 4092 + format: double 4093 + StopwordsSetUpsertSchema: 4094 + type: object 4095 + properties: 4096 + stopwords: 4097 + type: array 4098 + items: 4099 + type: string 4100 + locale: 4101 + type: string 4102 + required: 4103 + - stopwords 4104 + example: | 4105 + {"stopwords": ["Germany", "France", "Italy"], "locale": "en"} 4106 + StopwordsSetSchema: 4107 + type: object 4108 + properties: 4109 + id: 4110 + type: string 4111 + stopwords: 4112 + type: array 4113 + items: 4114 + type: string 4115 + locale: 4116 + type: string 4117 + required: 4118 + - id 4119 + - stopwords 4120 + example: | 4121 + {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"} 4122 + StopwordsSetRetrieveSchema: 4123 + type: object 4124 + properties: 4125 + stopwords: 4126 + $ref: "#/components/schemas/StopwordsSetSchema" 4127 + required: 4128 + - stopwords 4129 + example: | 4130 + {"stopwords": {"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}} 4131 + StopwordsSetsRetrieveAllSchema: 4132 + type: object 4133 + properties: 4134 + stopwords: 4135 + type: array 4136 + items: 4137 + $ref: "#/components/schemas/StopwordsSetSchema" 4138 + required: 4139 + - stopwords 4140 + example: | 4141 + {"stopwords": [{"id": "countries", "stopwords": ["Germany", "France", "Italy"], "locale": "en"}]} 4142 + PresetUpsertSchema: 4143 + properties: 4144 + value: 4145 + oneOf: 4146 + - $ref: '#/components/schemas/SearchParameters' 4147 + - $ref: '#/components/schemas/MultiSearchSearchesParameter' 4148 + required: 4149 + - value 4150 + PresetSchema: 4151 + allOf: 4152 + - $ref: '#/components/schemas/PresetUpsertSchema' 4153 + - type: object 4154 + required: 4155 + - name 4156 + properties: 4157 + name: 4158 + type: string 4159 + PresetsRetrieveSchema: 4160 + type: object 4161 + required: 4162 + - presets 4163 + properties: 4164 + presets: 4165 + type: array 4166 + items: 4167 + $ref: '#/components/schemas/PresetSchema' 4168 + x-go-type: '[]*PresetSchema' 4169 + PresetDeleteSchema: 4170 + type: object 4171 + required: 4172 + - name 4173 + properties: 4174 + name: 4175 + type: string 4176 + DirtyValues: 4177 + type: string 4178 + enum: [coerce_or_reject, coerce_or_drop, drop, reject] 4179 + IndexAction: 4180 + type: string 4181 + enum: [create, update, upsert, emplace] 4182 + DropTokensMode: 4183 + type: string 4184 + enum: [right_to_left, left_to_right, both_sides:3] 4185 + description: > 4186 + 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. 4187 + Values: right_to_left (default), left_to_right, both_sides:3 4188 + 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. 4189 + If query length is greater than 3 words, Typesense will just fallback to default behavior of right_to_left 4190 + ConversationModelCreateSchema: 4191 + required: 4192 + - model_name 4193 + - max_bytes 4194 + allOf: 4195 + - $ref: '#/components/schemas/ConversationModelUpdateSchema' 4196 + - type: object 4197 + required: 4198 + - model_name 4199 + - max_bytes 4200 + - history_collection 4201 + properties: 4202 + model_name: 4203 + description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM 4204 + type: string 4205 + max_bytes: 4206 + description: | 4207 + 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. 4208 + type: integer 4209 + history_collection: 4210 + type: string 4211 + description: Typesense collection that stores the historical conversations 4212 + ConversationModelUpdateSchema: 4213 + type: object 4214 + properties: 4215 + id: 4216 + type: string 4217 + description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. 4218 + model_name: 4219 + description: Name of the LLM model offered by OpenAI, Cloudflare or vLLM 4220 + type: string 4221 + api_key: 4222 + description: The LLM service's API Key 4223 + type: string 4224 + history_collection: 4225 + type: string 4226 + description: Typesense collection that stores the historical conversations 4227 + account_id: 4228 + description: LLM service's account ID (only applicable for Cloudflare) 4229 + type: string 4230 + system_prompt: 4231 + description: The system prompt that contains special instructions to the LLM 4232 + type: string 4233 + ttl: 4234 + type: integer 4235 + description: | 4236 + Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 4237 + max_bytes: 4238 + description: | 4239 + 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. 4240 + type: integer 4241 + vllm_url: 4242 + description: URL of vLLM service 4243 + type: string 4244 + ConversationModelSchema: 4245 + allOf: 4246 + - $ref: '#/components/schemas/ConversationModelCreateSchema' 4247 + - type: object 4248 + required: 4249 + - id 4250 + properties: 4251 + id: 4252 + type: string 4253 + description: An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. 4254 + StemmingDictionary: 4255 + type: object 4256 + required: 4257 + - id 4258 + - words 4259 + properties: 4260 + id: 4261 + type: string 4262 + description: Unique identifier for the dictionary 4263 + example: irregular-plurals 4264 + words: 4265 + type: array 4266 + description: List of word mappings in the dictionary 4267 + items: 4268 + type: object 4269 + required: 4270 + - word 4271 + - root 4272 + properties: 4273 + word: 4274 + type: string 4275 + description: The word form to be stemmed 4276 + example: people 4277 + root: 4278 + type: string 4279 + description: The root form of the word 4280 + example: person 4281 + NLSearchModelBase: 4282 + type: object 4283 + properties: 4284 + model_name: 4285 + type: string 4286 + description: Name of the NL model to use 4287 + api_key: 4288 + type: string 4289 + description: API key for the NL model service 4290 + api_url: 4291 + type: string 4292 + description: Custom API URL for the NL model service 4293 + max_bytes: 4294 + type: integer 4295 + description: Maximum number of bytes to process 4296 + temperature: 4297 + type: number 4298 + description: Temperature parameter for the NL model 4299 + system_prompt: 4300 + type: string 4301 + description: System prompt for the NL model 4302 + top_p: 4303 + type: number 4304 + description: Top-p parameter for the NL model (Google-specific) 4305 + top_k: 4306 + type: integer 4307 + description: Top-k parameter for the NL model (Google-specific) 4308 + stop_sequences: 4309 + type: array 4310 + items: 4311 + type: string 4312 + description: Stop sequences for the NL model (Google-specific) 4313 + api_version: 4314 + type: string 4315 + description: API version for the NL model service 4316 + project_id: 4317 + type: string 4318 + description: Project ID for GCP Vertex AI 4319 + access_token: 4320 + type: string 4321 + description: Access token for GCP Vertex AI 4322 + refresh_token: 4323 + type: string 4324 + description: Refresh token for GCP Vertex AI 4325 + client_id: 4326 + type: string 4327 + description: Client ID for GCP Vertex AI 4328 + client_secret: 4329 + type: string 4330 + description: Client secret for GCP Vertex AI 4331 + region: 4332 + type: string 4333 + description: Region for GCP Vertex AI 4334 + max_output_tokens: 4335 + type: integer 4336 + description: Maximum output tokens for GCP Vertex AI 4337 + account_id: 4338 + type: string 4339 + description: Account ID for Cloudflare-specific models 4340 + 4341 + NLSearchModelCreateSchema: 4342 + allOf: 4343 + - $ref: '#/components/schemas/NLSearchModelBase' 4344 + - type: object 4345 + properties: 4346 + id: 4347 + type: string 4348 + description: Optional ID for the NL search model 4349 + 4350 + NLSearchModelSchema: 4351 + allOf: 4352 + - $ref: '#/components/schemas/NLSearchModelCreateSchema' 4353 + - type: object 4354 + required: 4355 + - id 4356 + properties: 4357 + id: 4358 + type: string 4359 + description: ID of the NL search model 4360 + 4361 + NLSearchModelUpdateSchema: 4362 + $ref: '#/components/schemas/NLSearchModelCreateSchema' 4363 + 4364 + NLSearchModelDeleteSchema: 4365 + type: object 4366 + required: 4367 + - id 4368 + properties: 4369 + id: 4370 + type: string 4371 + description: ID of the deleted NL search model 4372 + 4373 + SynonymItemUpsertSchema: 4374 + type: object 4375 + required: 4376 + - synonyms 4377 + properties: 4378 + synonyms: 4379 + type: array 4380 + description: Array of words that should be considered as synonyms 4381 + items: 4382 + type: string 4383 + root: 4384 + type: string 4385 + description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to 4386 + locale: 4387 + type: string 4388 + description: Locale for the synonym, leave blank to use the standard tokenizer 4389 + symbols_to_index: 4390 + type: array 4391 + description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is 4392 + items: 4393 + type: string 4394 + 4395 + SynonymItemSchema: 4396 + allOf: 4397 + - type: object 4398 + required: 4399 + - id 4400 + properties: 4401 + id: 4402 + type: string 4403 + description: Unique identifier for the synonym item 4404 + - $ref: "#/components/schemas/SynonymItemUpsertSchema" 4405 + 4406 + SynonymSetCreateSchema: 4407 + type: object 4408 + required: 4409 + - items 4410 + properties: 4411 + items: 4412 + type: array 4413 + description: Array of synonym items 4414 + items: 4415 + $ref: "#/components/schemas/SynonymItemSchema" 4416 + 4417 + SynonymSetSchema: 4418 + allOf: 4419 + - $ref: "#/components/schemas/SynonymSetCreateSchema" 4420 + - type: object 4421 + required: 4422 + - name 4423 + properties: 4424 + name: 4425 + type: string 4426 + description: Name of the synonym set 4427 + 4428 + SynonymSetsRetrieveSchema: 4429 + type: object 4430 + required: 4431 + - synonym_sets 4432 + properties: 4433 + synonym_sets: 4434 + type: array 4435 + description: Array of synonym sets 4436 + items: 4437 + $ref: "#/components/schemas/SynonymSetSchema" 4438 + 4439 + SynonymSetDeleteSchema: 4440 + type: object 4441 + required: 4442 + - name 4443 + properties: 4444 + name: 4445 + type: string 4446 + description: Name of the deleted synonym set 4447 + 4448 + SynonymItemDeleteSchema: 4449 + type: object 4450 + required: 4451 + - id 4452 + properties: 4453 + id: 4454 + type: string 4455 + description: ID of the deleted synonym item 4456 + 4457 + CurationItemCreateSchema: 4458 + type: object 4459 + required: 4460 + - rule 4461 + properties: 4462 + rule: 4463 + $ref: '#/components/schemas/CurationRule' 4464 + includes: 4465 + type: array 4466 + description: 4467 + List of document `id`s that should be included in the search results with their 4468 + corresponding `position`s. 4469 + items: 4470 + $ref: '#/components/schemas/CurationInclude' 4471 + excludes: 4472 + type: array 4473 + description: List of document `id`s that should be excluded from the search results. 4474 + items: 4475 + $ref: '#/components/schemas/CurationExclude' 4476 + filter_by: 4477 + type: string 4478 + description: > 4479 + A filter by clause that is applied to any search query that matches the curation rule. 4480 + remove_matched_tokens: 4481 + type: boolean 4482 + description: > 4483 + Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 4484 + metadata: 4485 + type: object 4486 + description: > 4487 + 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. 4488 + sort_by: 4489 + type: string 4490 + description: > 4491 + A sort by clause that is applied to any search query that matches the curation rule. 4492 + replace_query: 4493 + type: string 4494 + description: > 4495 + Replaces the current search query with this value, when the search query matches the curation rule. 4496 + filter_curated_hits: 4497 + type: boolean 4498 + description: > 4499 + When set to true, the filter conditions of the query is applied to the curated records as well. 4500 + Default: false. 4501 + effective_from_ts: 4502 + type: integer 4503 + description: > 4504 + 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. 4505 + effective_to_ts: 4506 + type: integer 4507 + description: > 4508 + 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. 4509 + stop_processing: 4510 + type: boolean 4511 + description: > 4512 + 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. 4513 + Curations are processed in the lexical sort order of their id field. 4514 + id: 4515 + type: string 4516 + description: ID of the curation item 4517 + 4518 + 4519 + CurationItemSchema: 4520 + allOf: 4521 + - $ref: '#/components/schemas/CurationItemCreateSchema' 4522 + - type: object 4523 + required: 4524 + - id 4525 + properties: 4526 + id: 4527 + type: string 4528 + 4529 + CurationSetCreateSchema: 4530 + type: object 4531 + required: 4532 + - items 4533 + properties: 4534 + items: 4535 + type: array 4536 + description: Array of curation items 4537 + items: 4538 + $ref: '#/components/schemas/CurationItemCreateSchema' 4539 + description: 4540 + type: string 4541 + description: Optional description for the curation set 4542 + 4543 + CurationSetSchema: 4544 + allOf: 4545 + - $ref: '#/components/schemas/CurationSetCreateSchema' 4546 + - type: object 4547 + required: 4548 + - name 4549 + properties: 4550 + name: 4551 + type: string 4552 + 4553 + CurationRule: 4554 + type: object 4555 + properties: 4556 + tags: 4557 + type: array 4558 + description: List of tag values to associate with this curation rule. 4559 + items: 4560 + type: string 4561 + query: 4562 + type: string 4563 + description: Indicates what search queries should be curated 4564 + match: 4565 + type: string 4566 + description: > 4567 + Indicates whether the match on the query term should be `exact` or `contains`. 4568 + If we want to match all queries that contained the word `apple`, we will use the `contains` match instead. 4569 + enum: 4570 + - exact 4571 + - contains 4572 + filter_by: 4573 + type: string 4574 + description: > 4575 + 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). 4576 + 4577 + CurationInclude: 4578 + type: object 4579 + required: 4580 + - id 4581 + - position 4582 + properties: 4583 + id: 4584 + type: string 4585 + description: document id that should be included 4586 + position: 4587 + type: integer 4588 + description: position number where document should be included in the search results 4589 + 4590 + CurationExclude: 4591 + type: object 4592 + required: 4593 + - id 4594 + properties: 4595 + id: 4596 + type: string 4597 + description: document id that should be excluded from the search results. 4598 + 4599 + CurationSetDeleteSchema: 4600 + type: object 4601 + required: 4602 + - name 4603 + properties: 4604 + name: 4605 + type: string 4606 + description: Name of the deleted curation set 4607 + CurationItemDeleteSchema: 4608 + type: object 4609 + required: 4610 + - id 4611 + properties: 4612 + id: 4613 + type: string 4614 + description: ID of the deleted curation item 4615 + 4616 + securitySchemes: 4617 + api_key_header: 4618 + type: apiKey 4619 + name: X-TYPESENSE-API-KEY 4620 + in: header
+6524
typesense.ml
··· 1 + (** {1 Typesense} 2 + 3 + An open source search engine for building delightful search experiences. 4 + 5 + @version 30.0 *) 6 + 7 + type t = { 8 + session : Requests.t; 9 + base_url : string; 10 + } 11 + 12 + let create ?session ~sw env ~base_url = 13 + let session = match session with 14 + | Some s -> s 15 + | None -> Requests.create ~sw env 16 + in 17 + { session; base_url } 18 + 19 + let base_url t = t.base_url 20 + let session t = t.session 21 + 22 + module VoiceQueryModelCollection = struct 23 + module Types = struct 24 + module Config = struct 25 + (** Configuration for the voice query model 26 + *) 27 + type t = { 28 + model_name : string option; 29 + } 30 + end 31 + end 32 + 33 + module Config = struct 34 + include Types.Config 35 + 36 + let v ?model_name () = { model_name } 37 + 38 + let model_name t = t.model_name 39 + 40 + let jsont : t Jsont.t = 41 + Jsont.Object.map ~kind:"VoiceQueryModelCollectionConfig" 42 + (fun model_name -> { model_name }) 43 + |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 44 + |> Jsont.Object.skip_unknown 45 + |> Jsont.Object.finish 46 + end 47 + end 48 + 49 + module SynonymSetDeleteSchema = struct 50 + module Types = struct 51 + module T = struct 52 + type t = { 53 + name : string; (** Name of the deleted synonym set *) 54 + } 55 + end 56 + end 57 + 58 + module T = struct 59 + include Types.T 60 + 61 + let v ~name () = { name } 62 + 63 + let name t = t.name 64 + 65 + let jsont : t Jsont.t = 66 + Jsont.Object.map ~kind:"SynonymSetDeleteSchema" 67 + (fun name -> { name }) 68 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 69 + |> Jsont.Object.skip_unknown 70 + |> Jsont.Object.finish 71 + end 72 + 73 + (** Delete a synonym set 74 + 75 + Delete a specific synonym set by its name 76 + @param synonym_set_name The name of the synonym set to delete 77 + *) 78 + let delete_synonym_set ~synonym_set_name client () = 79 + let op_name = "delete_synonym_set" in 80 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in 81 + let query = "" in 82 + let url = client.base_url ^ url_path ^ query in 83 + let response = 84 + try Requests.delete client.session url 85 + with Eio.Io _ as ex -> 86 + let bt = Printexc.get_raw_backtrace () in 87 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 88 + in 89 + if Requests.Response.ok response then 90 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 91 + else 92 + let body = Requests.Response.text response in 93 + let status = Requests.Response.status_code response in 94 + let parsed_body = match status with 95 + | 404 -> 96 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 97 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 98 + | Error _ -> None) 99 + | _ -> 100 + (match Jsont_bytesrw.decode_string Jsont.json body with 101 + | Ok json -> Some (Openapi.Runtime.Json json) 102 + | Error _ -> Some (Openapi.Runtime.Raw body)) 103 + in 104 + raise (Openapi.Runtime.Api_error { 105 + operation = op_name; 106 + method_ = "DELETE"; 107 + url; 108 + status; 109 + body; 110 + parsed_body; 111 + }) 112 + end 113 + 114 + module SynonymItemUpsertSchema = struct 115 + module Types = struct 116 + module T = struct 117 + type t = { 118 + locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer *) 119 + root : string option; (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *) 120 + 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 *) 121 + synonyms : string list; (** Array of words that should be considered as synonyms *) 122 + } 123 + end 124 + end 125 + 126 + module T = struct 127 + include Types.T 128 + 129 + let v ~synonyms ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms } 130 + 131 + let locale t = t.locale 132 + let root t = t.root 133 + let symbols_to_index t = t.symbols_to_index 134 + let synonyms t = t.synonyms 135 + 136 + let jsont : t Jsont.t = 137 + Jsont.Object.map ~kind:"SynonymItemUpsertSchema" 138 + (fun locale root symbols_to_index synonyms -> { locale; root; symbols_to_index; synonyms }) 139 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 140 + |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root) 141 + |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index) 142 + |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms) 143 + |> Jsont.Object.skip_unknown 144 + |> Jsont.Object.finish 145 + end 146 + end 147 + 148 + module SynonymItemSchema = struct 149 + module Types = struct 150 + module T = struct 151 + type t = { 152 + id : string; (** Unique identifier for the synonym item *) 153 + locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer *) 154 + root : string option; (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *) 155 + 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 *) 156 + synonyms : string list; (** Array of words that should be considered as synonyms *) 157 + } 158 + end 159 + end 160 + 161 + module T = struct 162 + include Types.T 163 + 164 + let v ~id ~synonyms ?locale ?root ?symbols_to_index () = { id; locale; root; symbols_to_index; synonyms } 165 + 166 + let id t = t.id 167 + let locale t = t.locale 168 + let root t = t.root 169 + let symbols_to_index t = t.symbols_to_index 170 + let synonyms t = t.synonyms 171 + 172 + let jsont : t Jsont.t = 173 + Jsont.Object.map ~kind:"SynonymItemSchema" 174 + (fun id locale root symbols_to_index synonyms -> { id; locale; root; symbols_to_index; synonyms }) 175 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 176 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 177 + |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root) 178 + |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index) 179 + |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms) 180 + |> Jsont.Object.skip_unknown 181 + |> Jsont.Object.finish 182 + end 183 + 184 + (** List items in a synonym set 185 + 186 + Retrieve all synonym items in a set 187 + @param synonym_set_name The name of the synonym set to retrieve items for 188 + *) 189 + let retrieve_synonym_set_items ~synonym_set_name client () = 190 + let op_name = "retrieve_synonym_set_items" in 191 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}/items" in 192 + let query = "" in 193 + let url = client.base_url ^ url_path ^ query in 194 + let response = 195 + try Requests.get client.session url 196 + with Eio.Io _ as ex -> 197 + let bt = Printexc.get_raw_backtrace () in 198 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 199 + in 200 + if Requests.Response.ok response then 201 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 202 + else 203 + let body = Requests.Response.text response in 204 + let status = Requests.Response.status_code response in 205 + let parsed_body = match status with 206 + | 404 -> 207 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 208 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 209 + | Error _ -> None) 210 + | _ -> 211 + (match Jsont_bytesrw.decode_string Jsont.json body with 212 + | Ok json -> Some (Openapi.Runtime.Json json) 213 + | Error _ -> Some (Openapi.Runtime.Raw body)) 214 + in 215 + raise (Openapi.Runtime.Api_error { 216 + operation = op_name; 217 + method_ = "GET"; 218 + url; 219 + status; 220 + body; 221 + parsed_body; 222 + }) 223 + 224 + (** Retrieve a synonym set item 225 + 226 + Retrieve a specific synonym item by its id 227 + @param synonym_set_name The name of the synonym set 228 + @param item_id The id of the synonym item to retrieve 229 + *) 230 + let retrieve_synonym_set_item ~synonym_set_name ~item_id client () = 231 + let op_name = "retrieve_synonym_set_item" in 232 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in 233 + let query = "" in 234 + let url = client.base_url ^ url_path ^ query in 235 + let response = 236 + try Requests.get client.session url 237 + with Eio.Io _ as ex -> 238 + let bt = Printexc.get_raw_backtrace () in 239 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 240 + in 241 + if Requests.Response.ok response then 242 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 243 + else 244 + let body = Requests.Response.text response in 245 + let status = Requests.Response.status_code response in 246 + let parsed_body = match status with 247 + | 404 -> 248 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 249 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 250 + | Error _ -> None) 251 + | _ -> 252 + (match Jsont_bytesrw.decode_string Jsont.json body with 253 + | Ok json -> Some (Openapi.Runtime.Json json) 254 + | Error _ -> Some (Openapi.Runtime.Raw body)) 255 + in 256 + raise (Openapi.Runtime.Api_error { 257 + operation = op_name; 258 + method_ = "GET"; 259 + url; 260 + status; 261 + body; 262 + parsed_body; 263 + }) 264 + 265 + (** Create or update a synonym set item 266 + 267 + Create or update a synonym set item with the given id 268 + @param synonym_set_name The name of the synonym set 269 + @param item_id The id of the synonym item to upsert 270 + *) 271 + let upsert_synonym_set_item ~synonym_set_name ~item_id ~body client () = 272 + let op_name = "upsert_synonym_set_item" in 273 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in 274 + let query = "" in 275 + let url = client.base_url ^ url_path ^ query in 276 + let response = 277 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json SynonymItemUpsertSchema.T.jsont body)) url 278 + with Eio.Io _ as ex -> 279 + let bt = Printexc.get_raw_backtrace () in 280 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 281 + in 282 + if Requests.Response.ok response then 283 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 284 + else 285 + let body = Requests.Response.text response in 286 + let status = Requests.Response.status_code response in 287 + let parsed_body = match status with 288 + | 400 -> 289 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 290 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 291 + | Error _ -> None) 292 + | _ -> 293 + (match Jsont_bytesrw.decode_string Jsont.json body with 294 + | Ok json -> Some (Openapi.Runtime.Json json) 295 + | Error _ -> Some (Openapi.Runtime.Raw body)) 296 + in 297 + raise (Openapi.Runtime.Api_error { 298 + operation = op_name; 299 + method_ = "PUT"; 300 + url; 301 + status; 302 + body; 303 + parsed_body; 304 + }) 305 + end 306 + 307 + module SynonymSetCreateSchema = struct 308 + module Types = struct 309 + module T = struct 310 + type t = { 311 + items : SynonymItemSchema.T.t list; (** Array of synonym items *) 312 + } 313 + end 314 + end 315 + 316 + module T = struct 317 + include Types.T 318 + 319 + let v ~items () = { items } 320 + 321 + let items t = t.items 322 + 323 + let jsont : t Jsont.t = 324 + Jsont.Object.map ~kind:"SynonymSetCreateSchema" 325 + (fun items -> { items }) 326 + |> Jsont.Object.mem "items" (Jsont.list SynonymItemSchema.T.jsont) ~enc:(fun r -> r.items) 327 + |> Jsont.Object.skip_unknown 328 + |> Jsont.Object.finish 329 + end 330 + end 331 + 332 + module SynonymSetSchema = struct 333 + module Types = struct 334 + module T = struct 335 + type t = { 336 + items : SynonymItemSchema.T.t list; (** Array of synonym items *) 337 + name : string; (** Name of the synonym set *) 338 + } 339 + end 340 + end 341 + 342 + module T = struct 343 + include Types.T 344 + 345 + let v ~items ~name () = { items; name } 346 + 347 + let items t = t.items 348 + let name t = t.name 349 + 350 + let jsont : t Jsont.t = 351 + Jsont.Object.map ~kind:"SynonymSetSchema" 352 + (fun items name -> { items; name }) 353 + |> Jsont.Object.mem "items" (Jsont.list SynonymItemSchema.T.jsont) ~enc:(fun r -> r.items) 354 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 355 + |> Jsont.Object.skip_unknown 356 + |> Jsont.Object.finish 357 + end 358 + 359 + (** List all synonym sets 360 + 361 + Retrieve all synonym sets *) 362 + let retrieve_synonym_sets client () = 363 + let op_name = "retrieve_synonym_sets" in 364 + let url_path = "/synonym_sets" in 365 + let query = "" in 366 + let url = client.base_url ^ url_path ^ query in 367 + let response = 368 + try Requests.get client.session url 369 + with Eio.Io _ as ex -> 370 + let bt = Printexc.get_raw_backtrace () in 371 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 372 + in 373 + if Requests.Response.ok response then 374 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 375 + else 376 + let body = Requests.Response.text response in 377 + let parsed_body = 378 + match Jsont_bytesrw.decode_string Jsont.json body with 379 + | Ok json -> Some (Openapi.Runtime.Json json) 380 + | Error _ -> Some (Openapi.Runtime.Raw body) 381 + in 382 + raise (Openapi.Runtime.Api_error { 383 + operation = op_name; 384 + method_ = "GET"; 385 + url; 386 + status = Requests.Response.status_code response; 387 + body; 388 + parsed_body; 389 + }) 390 + 391 + (** Retrieve a synonym set 392 + 393 + Retrieve a specific synonym set by its name 394 + @param synonym_set_name The name of the synonym set to retrieve 395 + *) 396 + let retrieve_synonym_set ~synonym_set_name client () = 397 + let op_name = "retrieve_synonym_set" in 398 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in 399 + let query = "" in 400 + let url = client.base_url ^ url_path ^ query in 401 + let response = 402 + try Requests.get client.session url 403 + with Eio.Io _ as ex -> 404 + let bt = Printexc.get_raw_backtrace () in 405 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 406 + in 407 + if Requests.Response.ok response then 408 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 409 + else 410 + let body = Requests.Response.text response in 411 + let status = Requests.Response.status_code response in 412 + let parsed_body = match status with 413 + | 404 -> 414 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 415 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 416 + | Error _ -> None) 417 + | _ -> 418 + (match Jsont_bytesrw.decode_string Jsont.json body with 419 + | Ok json -> Some (Openapi.Runtime.Json json) 420 + | Error _ -> Some (Openapi.Runtime.Raw body)) 421 + in 422 + raise (Openapi.Runtime.Api_error { 423 + operation = op_name; 424 + method_ = "GET"; 425 + url; 426 + status; 427 + body; 428 + parsed_body; 429 + }) 430 + 431 + (** Create or update a synonym set 432 + 433 + Create or update a synonym set with the given name 434 + @param synonym_set_name The name of the synonym set to create/update 435 + *) 436 + let upsert_synonym_set ~synonym_set_name ~body client () = 437 + let op_name = "upsert_synonym_set" in 438 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name)] "/synonym_sets/{synonymSetName}" in 439 + let query = "" in 440 + let url = client.base_url ^ url_path ^ query in 441 + let response = 442 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json SynonymSetCreateSchema.T.jsont body)) url 443 + with Eio.Io _ as ex -> 444 + let bt = Printexc.get_raw_backtrace () in 445 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 446 + in 447 + if Requests.Response.ok response then 448 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 449 + else 450 + let body = Requests.Response.text response in 451 + let status = Requests.Response.status_code response in 452 + let parsed_body = match status with 453 + | 400 -> 454 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 455 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 456 + | Error _ -> None) 457 + | _ -> 458 + (match Jsont_bytesrw.decode_string Jsont.json body with 459 + | Ok json -> Some (Openapi.Runtime.Json json) 460 + | Error _ -> Some (Openapi.Runtime.Raw body)) 461 + in 462 + raise (Openapi.Runtime.Api_error { 463 + operation = op_name; 464 + method_ = "PUT"; 465 + url; 466 + status; 467 + body; 468 + parsed_body; 469 + }) 470 + end 471 + 472 + module SynonymSetsRetrieveSchema = struct 473 + module Types = struct 474 + module T = struct 475 + type t = { 476 + synonym_sets : SynonymSetSchema.T.t list; (** Array of synonym sets *) 477 + } 478 + end 479 + end 480 + 481 + module T = struct 482 + include Types.T 483 + 484 + let v ~synonym_sets () = { synonym_sets } 485 + 486 + let synonym_sets t = t.synonym_sets 487 + 488 + let jsont : t Jsont.t = 489 + Jsont.Object.map ~kind:"SynonymSetsRetrieveSchema" 490 + (fun synonym_sets -> { synonym_sets }) 491 + |> Jsont.Object.mem "synonym_sets" (Jsont.list SynonymSetSchema.T.jsont) ~enc:(fun r -> r.synonym_sets) 492 + |> Jsont.Object.skip_unknown 493 + |> Jsont.Object.finish 494 + end 495 + end 496 + 497 + module SynonymItemDeleteSchema = struct 498 + module Types = struct 499 + module T = struct 500 + type t = { 501 + id : string; (** ID of the deleted synonym item *) 502 + } 503 + end 504 + end 505 + 506 + module T = struct 507 + include Types.T 508 + 509 + let v ~id () = { id } 510 + 511 + let id t = t.id 512 + 513 + let jsont : t Jsont.t = 514 + Jsont.Object.map ~kind:"SynonymItemDeleteSchema" 515 + (fun id -> { id }) 516 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 517 + |> Jsont.Object.skip_unknown 518 + |> Jsont.Object.finish 519 + end 520 + 521 + (** Delete a synonym set item 522 + 523 + Delete a specific synonym item by its id 524 + @param synonym_set_name The name of the synonym set 525 + @param item_id The id of the synonym item to delete 526 + *) 527 + let delete_synonym_set_item ~synonym_set_name ~item_id client () = 528 + let op_name = "delete_synonym_set_item" in 529 + let url_path = Openapi.Runtime.Path.render ~params:[("synonymSetName", synonym_set_name); ("itemId", item_id)] "/synonym_sets/{synonymSetName}/items/{itemId}" in 530 + let query = "" in 531 + let url = client.base_url ^ url_path ^ query in 532 + let response = 533 + try Requests.delete client.session url 534 + with Eio.Io _ as ex -> 535 + let bt = Printexc.get_raw_backtrace () in 536 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 537 + in 538 + if Requests.Response.ok response then 539 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 540 + else 541 + let body = Requests.Response.text response in 542 + let status = Requests.Response.status_code response in 543 + let parsed_body = match status with 544 + | 404 -> 545 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 546 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 547 + | Error _ -> None) 548 + | _ -> 549 + (match Jsont_bytesrw.decode_string Jsont.json body with 550 + | Ok json -> Some (Openapi.Runtime.Json json) 551 + | Error _ -> Some (Openapi.Runtime.Raw body)) 552 + in 553 + raise (Openapi.Runtime.Api_error { 554 + operation = op_name; 555 + method_ = "DELETE"; 556 + url; 557 + status; 558 + body; 559 + parsed_body; 560 + }) 561 + end 562 + 563 + module Success = struct 564 + module Types = struct 565 + module Status = struct 566 + type t = { 567 + success : bool; 568 + } 569 + end 570 + end 571 + 572 + module Status = struct 573 + include Types.Status 574 + 575 + let v ~success () = { success } 576 + 577 + let success t = t.success 578 + 579 + let jsont : t Jsont.t = 580 + Jsont.Object.map ~kind:"SuccessStatus" 581 + (fun success -> { success }) 582 + |> Jsont.Object.mem "success" Jsont.bool ~enc:(fun r -> r.success) 583 + |> Jsont.Object.skip_unknown 584 + |> Jsont.Object.finish 585 + end 586 + 587 + (** Toggle Slow Request Log 588 + 589 + 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. *) 590 + let toggle_slow_request_log client () = 591 + let op_name = "toggle_slow_request_log" in 592 + let url_path = "/config" in 593 + let query = "" in 594 + let url = client.base_url ^ url_path ^ query in 595 + let response = 596 + try Requests.post client.session url 597 + with Eio.Io _ as ex -> 598 + let bt = Printexc.get_raw_backtrace () in 599 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 600 + in 601 + if Requests.Response.ok response then 602 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 603 + else 604 + let body = Requests.Response.text response in 605 + let parsed_body = 606 + match Jsont_bytesrw.decode_string Jsont.json body with 607 + | Ok json -> Some (Openapi.Runtime.Json json) 608 + | Error _ -> Some (Openapi.Runtime.Raw body) 609 + in 610 + raise (Openapi.Runtime.Api_error { 611 + operation = op_name; 612 + method_ = "POST"; 613 + url; 614 + status = Requests.Response.status_code response; 615 + body; 616 + parsed_body; 617 + }) 618 + 619 + (** Clear the cached responses of search requests in the LRU cache. 620 + 621 + Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. *) 622 + let clear_cache client () = 623 + let op_name = "clear_cache" in 624 + let url_path = "/operations/cache/clear" in 625 + let query = "" in 626 + let url = client.base_url ^ url_path ^ query in 627 + let response = 628 + try Requests.post client.session url 629 + with Eio.Io _ as ex -> 630 + let bt = Printexc.get_raw_backtrace () in 631 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 632 + in 633 + if Requests.Response.ok response then 634 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 635 + else 636 + let body = Requests.Response.text response in 637 + let parsed_body = 638 + match Jsont_bytesrw.decode_string Jsont.json body with 639 + | Ok json -> Some (Openapi.Runtime.Json json) 640 + | Error _ -> Some (Openapi.Runtime.Raw body) 641 + in 642 + raise (Openapi.Runtime.Api_error { 643 + operation = op_name; 644 + method_ = "POST"; 645 + url; 646 + status = Requests.Response.status_code response; 647 + body; 648 + parsed_body; 649 + }) 650 + 651 + (** Compacting the on-disk database 652 + 653 + 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. *) 654 + let compact_db client () = 655 + let op_name = "compact_db" in 656 + let url_path = "/operations/db/compact" in 657 + let query = "" in 658 + let url = client.base_url ^ url_path ^ query in 659 + let response = 660 + try Requests.post client.session url 661 + with Eio.Io _ as ex -> 662 + let bt = Printexc.get_raw_backtrace () in 663 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 664 + in 665 + if Requests.Response.ok response then 666 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 667 + else 668 + let body = Requests.Response.text response in 669 + let parsed_body = 670 + match Jsont_bytesrw.decode_string Jsont.json body with 671 + | Ok json -> Some (Openapi.Runtime.Json json) 672 + | Error _ -> Some (Openapi.Runtime.Raw body) 673 + in 674 + raise (Openapi.Runtime.Api_error { 675 + operation = op_name; 676 + method_ = "POST"; 677 + url; 678 + status = Requests.Response.status_code response; 679 + body; 680 + parsed_body; 681 + }) 682 + 683 + (** Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. 684 + 685 + 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. 686 + @param snapshot_path The directory on the server where the snapshot should be saved. 687 + *) 688 + let take_snapshot ~snapshot_path client () = 689 + let op_name = "take_snapshot" in 690 + let url_path = "/operations/snapshot" in 691 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"snapshot_path" ~value:snapshot_path]) in 692 + let url = client.base_url ^ url_path ^ query in 693 + let response = 694 + try Requests.post client.session url 695 + with Eio.Io _ as ex -> 696 + let bt = Printexc.get_raw_backtrace () in 697 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 698 + in 699 + if Requests.Response.ok response then 700 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 701 + else 702 + let body = Requests.Response.text response in 703 + let parsed_body = 704 + match Jsont_bytesrw.decode_string Jsont.json body with 705 + | Ok json -> Some (Openapi.Runtime.Json json) 706 + | Error _ -> Some (Openapi.Runtime.Raw body) 707 + in 708 + raise (Openapi.Runtime.Api_error { 709 + operation = op_name; 710 + method_ = "POST"; 711 + url; 712 + status = Requests.Response.status_code response; 713 + body; 714 + parsed_body; 715 + }) 716 + 717 + (** Triggers a follower node to initiate the raft voting process, which triggers leader re-election. 718 + 719 + 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. *) 720 + let vote client () = 721 + let op_name = "vote" in 722 + let url_path = "/operations/vote" in 723 + let query = "" in 724 + let url = client.base_url ^ url_path ^ query in 725 + let response = 726 + try Requests.post client.session url 727 + with Eio.Io _ as ex -> 728 + let bt = Printexc.get_raw_backtrace () in 729 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 730 + in 731 + if Requests.Response.ok response then 732 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 733 + else 734 + let body = Requests.Response.text response in 735 + let parsed_body = 736 + match Jsont_bytesrw.decode_string Jsont.json body with 737 + | Ok json -> Some (Openapi.Runtime.Json json) 738 + | Error _ -> Some (Openapi.Runtime.Raw body) 739 + in 740 + raise (Openapi.Runtime.Api_error { 741 + operation = op_name; 742 + method_ = "POST"; 743 + url; 744 + status = Requests.Response.status_code response; 745 + body; 746 + parsed_body; 747 + }) 748 + end 749 + 750 + module StopwordsSetUpsertSchema = struct 751 + module Types = struct 752 + module T = struct 753 + type t = { 754 + locale : string option; 755 + stopwords : string list; 756 + } 757 + end 758 + end 759 + 760 + module T = struct 761 + include Types.T 762 + 763 + let v ~stopwords ?locale () = { locale; stopwords } 764 + 765 + let locale t = t.locale 766 + let stopwords t = t.stopwords 767 + 768 + let jsont : t Jsont.t = 769 + Jsont.Object.map ~kind:"StopwordsSetUpsertSchema" 770 + (fun locale stopwords -> { locale; stopwords }) 771 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 772 + |> Jsont.Object.mem "stopwords" (Jsont.list Jsont.string) ~enc:(fun r -> r.stopwords) 773 + |> Jsont.Object.skip_unknown 774 + |> Jsont.Object.finish 775 + end 776 + end 777 + 778 + module StopwordsSetSchema = struct 779 + module Types = struct 780 + module T = struct 781 + type t = { 782 + id : string; 783 + locale : string option; 784 + stopwords : string list; 785 + } 786 + end 787 + end 788 + 789 + module T = struct 790 + include Types.T 791 + 792 + let v ~id ~stopwords ?locale () = { id; locale; stopwords } 793 + 794 + let id t = t.id 795 + let locale t = t.locale 796 + let stopwords t = t.stopwords 797 + 798 + let jsont : t Jsont.t = 799 + Jsont.Object.map ~kind:"StopwordsSetSchema" 800 + (fun id locale stopwords -> { id; locale; stopwords }) 801 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 802 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 803 + |> Jsont.Object.mem "stopwords" (Jsont.list Jsont.string) ~enc:(fun r -> r.stopwords) 804 + |> Jsont.Object.skip_unknown 805 + |> Jsont.Object.finish 806 + end 807 + 808 + (** Upserts a stopwords set. 809 + 810 + When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. 811 + @param set_id The ID of the stopwords set to upsert. 812 + *) 813 + let upsert_stopwords_set ~set_id ~body client () = 814 + let op_name = "upsert_stopwords_set" in 815 + let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in 816 + let query = "" in 817 + let url = client.base_url ^ url_path ^ query in 818 + let response = 819 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json StopwordsSetUpsertSchema.T.jsont body)) url 820 + with Eio.Io _ as ex -> 821 + let bt = Printexc.get_raw_backtrace () in 822 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 823 + in 824 + if Requests.Response.ok response then 825 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 826 + else 827 + let body = Requests.Response.text response in 828 + let status = Requests.Response.status_code response in 829 + let parsed_body = match status with 830 + | 400 -> 831 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 832 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 833 + | Error _ -> None) 834 + | _ -> 835 + (match Jsont_bytesrw.decode_string Jsont.json body with 836 + | Ok json -> Some (Openapi.Runtime.Json json) 837 + | Error _ -> Some (Openapi.Runtime.Raw body)) 838 + in 839 + raise (Openapi.Runtime.Api_error { 840 + operation = op_name; 841 + method_ = "PUT"; 842 + url; 843 + status; 844 + body; 845 + parsed_body; 846 + }) 847 + end 848 + 849 + module StopwordsSetsRetrieveAllSchema = struct 850 + module Types = struct 851 + module T = struct 852 + type t = { 853 + stopwords : StopwordsSetSchema.T.t list; 854 + } 855 + end 856 + end 857 + 858 + module T = struct 859 + include Types.T 860 + 861 + let v ~stopwords () = { stopwords } 862 + 863 + let stopwords t = t.stopwords 864 + 865 + let jsont : t Jsont.t = 866 + Jsont.Object.map ~kind:"StopwordsSetsRetrieveAllSchema" 867 + (fun stopwords -> { stopwords }) 868 + |> Jsont.Object.mem "stopwords" (Jsont.list StopwordsSetSchema.T.jsont) ~enc:(fun r -> r.stopwords) 869 + |> Jsont.Object.skip_unknown 870 + |> Jsont.Object.finish 871 + end 872 + 873 + (** Retrieves all stopwords sets. 874 + 875 + Retrieve the details of all stopwords sets *) 876 + let retrieve_stopwords_sets client () = 877 + let op_name = "retrieve_stopwords_sets" in 878 + let url_path = "/stopwords" in 879 + let query = "" in 880 + let url = client.base_url ^ url_path ^ query in 881 + let response = 882 + try Requests.get client.session url 883 + with Eio.Io _ as ex -> 884 + let bt = Printexc.get_raw_backtrace () in 885 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 886 + in 887 + if Requests.Response.ok response then 888 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 889 + else 890 + let body = Requests.Response.text response in 891 + let parsed_body = 892 + match Jsont_bytesrw.decode_string Jsont.json body with 893 + | Ok json -> Some (Openapi.Runtime.Json json) 894 + | Error _ -> Some (Openapi.Runtime.Raw body) 895 + in 896 + raise (Openapi.Runtime.Api_error { 897 + operation = op_name; 898 + method_ = "GET"; 899 + url; 900 + status = Requests.Response.status_code response; 901 + body; 902 + parsed_body; 903 + }) 904 + end 905 + 906 + module StopwordsSetRetrieveSchema = struct 907 + module Types = struct 908 + module T = struct 909 + type t = { 910 + stopwords : StopwordsSetSchema.T.t; 911 + } 912 + end 913 + end 914 + 915 + module T = struct 916 + include Types.T 917 + 918 + let v ~stopwords () = { stopwords } 919 + 920 + let stopwords t = t.stopwords 921 + 922 + let jsont : t Jsont.t = 923 + Jsont.Object.map ~kind:"StopwordsSetRetrieveSchema" 924 + (fun stopwords -> { stopwords }) 925 + |> Jsont.Object.mem "stopwords" StopwordsSetSchema.T.jsont ~enc:(fun r -> r.stopwords) 926 + |> Jsont.Object.skip_unknown 927 + |> Jsont.Object.finish 928 + end 929 + 930 + (** Retrieves a stopwords set. 931 + 932 + Retrieve the details of a stopwords set, given it's name. 933 + @param set_id The ID of the stopwords set to retrieve. 934 + *) 935 + let retrieve_stopwords_set ~set_id client () = 936 + let op_name = "retrieve_stopwords_set" in 937 + let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in 938 + let query = "" in 939 + let url = client.base_url ^ url_path ^ query in 940 + let response = 941 + try Requests.get client.session url 942 + with Eio.Io _ as ex -> 943 + let bt = Printexc.get_raw_backtrace () in 944 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 945 + in 946 + if Requests.Response.ok response then 947 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 948 + else 949 + let body = Requests.Response.text response in 950 + let status = Requests.Response.status_code response in 951 + let parsed_body = match status with 952 + | 404 -> 953 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 954 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 955 + | Error _ -> None) 956 + | _ -> 957 + (match Jsont_bytesrw.decode_string Jsont.json body with 958 + | Ok json -> Some (Openapi.Runtime.Json json) 959 + | Error _ -> Some (Openapi.Runtime.Raw body)) 960 + in 961 + raise (Openapi.Runtime.Api_error { 962 + operation = op_name; 963 + method_ = "GET"; 964 + url; 965 + status; 966 + body; 967 + parsed_body; 968 + }) 969 + end 970 + 971 + module StemmingDictionary = struct 972 + module Types = struct 973 + module T = struct 974 + type t = { 975 + id : string; (** Unique identifier for the dictionary *) 976 + words : Jsont.json list; (** List of word mappings in the dictionary *) 977 + } 978 + end 979 + end 980 + 981 + module T = struct 982 + include Types.T 983 + 984 + let v ~id ~words () = { id; words } 985 + 986 + let id t = t.id 987 + let words t = t.words 988 + 989 + let jsont : t Jsont.t = 990 + Jsont.Object.map ~kind:"StemmingDictionary" 991 + (fun id words -> { id; words }) 992 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 993 + |> Jsont.Object.mem "words" (Jsont.list Jsont.json) ~enc:(fun r -> r.words) 994 + |> Jsont.Object.skip_unknown 995 + |> Jsont.Object.finish 996 + end 997 + 998 + (** Retrieve a stemming dictionary 999 + 1000 + Fetch details of a specific stemming dictionary. 1001 + @param dictionary_id The ID of the dictionary to retrieve 1002 + *) 1003 + let get_stemming_dictionary ~dictionary_id client () = 1004 + let op_name = "get_stemming_dictionary" in 1005 + let url_path = Openapi.Runtime.Path.render ~params:[("dictionaryId", dictionary_id)] "/stemming/dictionaries/{dictionaryId}" in 1006 + let query = "" in 1007 + let url = client.base_url ^ url_path ^ query in 1008 + let response = 1009 + try Requests.get client.session url 1010 + with Eio.Io _ as ex -> 1011 + let bt = Printexc.get_raw_backtrace () in 1012 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1013 + in 1014 + if Requests.Response.ok response then 1015 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1016 + else 1017 + let body = Requests.Response.text response in 1018 + let status = Requests.Response.status_code response in 1019 + let parsed_body = match status with 1020 + | 404 -> 1021 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1022 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1023 + | Error _ -> None) 1024 + | _ -> 1025 + (match Jsont_bytesrw.decode_string Jsont.json body with 1026 + | Ok json -> Some (Openapi.Runtime.Json json) 1027 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1028 + in 1029 + raise (Openapi.Runtime.Api_error { 1030 + operation = op_name; 1031 + method_ = "GET"; 1032 + url; 1033 + status; 1034 + body; 1035 + parsed_body; 1036 + }) 1037 + end 1038 + 1039 + module SearchSynonymSchema = struct 1040 + module Types = struct 1041 + module T = struct 1042 + type t = { 1043 + locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer. *) 1044 + root : string option; (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *) 1045 + 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. *) 1046 + synonyms : string list; (** Array of words that should be considered as synonyms. *) 1047 + } 1048 + end 1049 + end 1050 + 1051 + module T = struct 1052 + include Types.T 1053 + 1054 + let v ~synonyms ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms } 1055 + 1056 + let locale t = t.locale 1057 + let root t = t.root 1058 + let symbols_to_index t = t.symbols_to_index 1059 + let synonyms t = t.synonyms 1060 + 1061 + let jsont : t Jsont.t = 1062 + Jsont.Object.map ~kind:"SearchSynonymSchema" 1063 + (fun locale root symbols_to_index synonyms -> { locale; root; symbols_to_index; synonyms }) 1064 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 1065 + |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root) 1066 + |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index) 1067 + |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms) 1068 + |> Jsont.Object.skip_unknown 1069 + |> Jsont.Object.finish 1070 + end 1071 + end 1072 + 1073 + module SearchSynonymDelete = struct 1074 + module Types = struct 1075 + module Response = struct 1076 + type t = { 1077 + id : string; (** The id of the synonym that was deleted *) 1078 + } 1079 + end 1080 + end 1081 + 1082 + module Response = struct 1083 + include Types.Response 1084 + 1085 + let v ~id () = { id } 1086 + 1087 + let id t = t.id 1088 + 1089 + let jsont : t Jsont.t = 1090 + Jsont.Object.map ~kind:"SearchSynonymDeleteResponse" 1091 + (fun id -> { id }) 1092 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 1093 + |> Jsont.Object.skip_unknown 1094 + |> Jsont.Object.finish 1095 + end 1096 + end 1097 + 1098 + module SearchSynonym = struct 1099 + module Types = struct 1100 + module T = struct 1101 + type t = { 1102 + locale : string option; (** Locale for the synonym, leave blank to use the standard tokenizer. *) 1103 + root : string option; (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *) 1104 + 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. *) 1105 + synonyms : string list; (** Array of words that should be considered as synonyms. *) 1106 + id : string; 1107 + } 1108 + end 1109 + end 1110 + 1111 + module T = struct 1112 + include Types.T 1113 + 1114 + let v ~synonyms ~id ?locale ?root ?symbols_to_index () = { locale; root; symbols_to_index; synonyms; id } 1115 + 1116 + let locale t = t.locale 1117 + let root t = t.root 1118 + let symbols_to_index t = t.symbols_to_index 1119 + let synonyms t = t.synonyms 1120 + let id t = t.id 1121 + 1122 + let jsont : t Jsont.t = 1123 + Jsont.Object.map ~kind:"SearchSynonym" 1124 + (fun locale root symbols_to_index synonyms id -> { locale; root; symbols_to_index; synonyms; id }) 1125 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 1126 + |> Jsont.Object.opt_mem "root" Jsont.string ~enc:(fun r -> r.root) 1127 + |> Jsont.Object.opt_mem "symbols_to_index" (Jsont.list Jsont.string) ~enc:(fun r -> r.symbols_to_index) 1128 + |> Jsont.Object.mem "synonyms" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonyms) 1129 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 1130 + |> Jsont.Object.skip_unknown 1131 + |> Jsont.Object.finish 1132 + end 1133 + end 1134 + 1135 + module SearchSynonyms = struct 1136 + module Types = struct 1137 + module Response = struct 1138 + type t = { 1139 + synonyms : SearchSynonym.T.t list; 1140 + } 1141 + end 1142 + end 1143 + 1144 + module Response = struct 1145 + include Types.Response 1146 + 1147 + let v ~synonyms () = { synonyms } 1148 + 1149 + let synonyms t = t.synonyms 1150 + 1151 + let jsont : t Jsont.t = 1152 + Jsont.Object.map ~kind:"SearchSynonymsResponse" 1153 + (fun synonyms -> { synonyms }) 1154 + |> Jsont.Object.mem "synonyms" (Jsont.list SearchSynonym.T.jsont) ~enc:(fun r -> r.synonyms) 1155 + |> Jsont.Object.skip_unknown 1156 + |> Jsont.Object.finish 1157 + end 1158 + end 1159 + 1160 + module SearchResultConversation = struct 1161 + module Types = struct 1162 + module T = struct 1163 + type t = { 1164 + answer : string; 1165 + conversation_history : Jsont.json list; 1166 + conversation_id : string; 1167 + query : string; 1168 + } 1169 + end 1170 + end 1171 + 1172 + module T = struct 1173 + include Types.T 1174 + 1175 + let v ~answer ~conversation_history ~conversation_id ~query () = { answer; conversation_history; conversation_id; query } 1176 + 1177 + let answer t = t.answer 1178 + let conversation_history t = t.conversation_history 1179 + let conversation_id t = t.conversation_id 1180 + let query t = t.query 1181 + 1182 + let jsont : t Jsont.t = 1183 + Jsont.Object.map ~kind:"SearchResultConversation" 1184 + (fun answer conversation_history conversation_id query -> { answer; conversation_history; conversation_id; query }) 1185 + |> Jsont.Object.mem "answer" Jsont.string ~enc:(fun r -> r.answer) 1186 + |> Jsont.Object.mem "conversation_history" (Jsont.list Jsont.json) ~enc:(fun r -> r.conversation_history) 1187 + |> Jsont.Object.mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id) 1188 + |> Jsont.Object.mem "query" Jsont.string ~enc:(fun r -> r.query) 1189 + |> Jsont.Object.skip_unknown 1190 + |> Jsont.Object.finish 1191 + end 1192 + end 1193 + 1194 + module SearchRequestParams = struct 1195 + module Types = struct 1196 + module T = struct 1197 + type t = { 1198 + collection_name : string; 1199 + per_page : int; 1200 + q : string; 1201 + voice_query : Jsont.json option; 1202 + } 1203 + end 1204 + end 1205 + 1206 + module T = struct 1207 + include Types.T 1208 + 1209 + let v ~collection_name ~per_page ~q ?voice_query () = { collection_name; per_page; q; voice_query } 1210 + 1211 + let collection_name t = t.collection_name 1212 + let per_page t = t.per_page 1213 + let q t = t.q 1214 + let voice_query t = t.voice_query 1215 + 1216 + let jsont : t Jsont.t = 1217 + Jsont.Object.map ~kind:"SearchRequestParams" 1218 + (fun collection_name per_page q voice_query -> { collection_name; per_page; q; voice_query }) 1219 + |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name) 1220 + |> Jsont.Object.mem "per_page" Jsont.int ~enc:(fun r -> r.per_page) 1221 + |> Jsont.Object.mem "q" Jsont.string ~enc:(fun r -> r.q) 1222 + |> Jsont.Object.opt_mem "voice_query" Jsont.json ~enc:(fun r -> r.voice_query) 1223 + |> Jsont.Object.skip_unknown 1224 + |> Jsont.Object.finish 1225 + end 1226 + end 1227 + 1228 + module SearchHighlight = struct 1229 + module Types = struct 1230 + module T = struct 1231 + type t = { 1232 + field : string option; 1233 + 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 *) 1234 + matched_tokens : Jsont.json list option; 1235 + snippet : string option; (** Present only for (non-array) string fields *) 1236 + snippets : string list option; (** Present only for (array) string[] fields *) 1237 + value : string option; (** Full field value with highlighting, present only for (non-array) string fields *) 1238 + values : string list option; (** Full field value with highlighting, present only for (array) string[] fields *) 1239 + } 1240 + end 1241 + end 1242 + 1243 + module T = struct 1244 + include Types.T 1245 + 1246 + let v ?field ?indices ?matched_tokens ?snippet ?snippets ?value ?values () = { field; indices; matched_tokens; snippet; snippets; value; values } 1247 + 1248 + let field t = t.field 1249 + let indices t = t.indices 1250 + let matched_tokens t = t.matched_tokens 1251 + let snippet t = t.snippet 1252 + let snippets t = t.snippets 1253 + let value t = t.value 1254 + let values t = t.values 1255 + 1256 + let jsont : t Jsont.t = 1257 + Jsont.Object.map ~kind:"SearchHighlight" 1258 + (fun field indices matched_tokens snippet snippets value values -> { field; indices; matched_tokens; snippet; snippets; value; values }) 1259 + |> Jsont.Object.opt_mem "field" Jsont.string ~enc:(fun r -> r.field) 1260 + |> Jsont.Object.opt_mem "indices" (Jsont.list Jsont.int) ~enc:(fun r -> r.indices) 1261 + |> Jsont.Object.opt_mem "matched_tokens" (Jsont.list Jsont.json) ~enc:(fun r -> r.matched_tokens) 1262 + |> Jsont.Object.opt_mem "snippet" Jsont.string ~enc:(fun r -> r.snippet) 1263 + |> Jsont.Object.opt_mem "snippets" (Jsont.list Jsont.string) ~enc:(fun r -> r.snippets) 1264 + |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value) 1265 + |> Jsont.Object.opt_mem "values" (Jsont.list Jsont.string) ~enc:(fun r -> r.values) 1266 + |> Jsont.Object.skip_unknown 1267 + |> Jsont.Object.finish 1268 + end 1269 + end 1270 + 1271 + module SearchResultHit = struct 1272 + module Types = struct 1273 + module T = struct 1274 + type t = { 1275 + document : Jsont.json option; (** Can be any key-value pair *) 1276 + geo_distance_meters : Jsont.json option; (** Can be any key-value pair *) 1277 + highlight : Jsont.json option; (** Highlighted version of the matching document *) 1278 + highlights : SearchHighlight.T.t list option; (** (Deprecated) Contains highlighted portions of the search fields *) 1279 + hybrid_search_info : Jsont.json option; (** Information about hybrid search scoring *) 1280 + search_index : int option; (** Returned only for union query response. Indicates the index of the query which this document matched to. *) 1281 + text_match : int64 option; 1282 + text_match_info : Jsont.json option; 1283 + vector_distance : float option; (** Distance between the query vector and matching document's vector value *) 1284 + } 1285 + end 1286 + end 1287 + 1288 + module T = struct 1289 + include Types.T 1290 + 1291 + 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 } 1292 + 1293 + let document t = t.document 1294 + let geo_distance_meters t = t.geo_distance_meters 1295 + let highlight t = t.highlight 1296 + let highlights t = t.highlights 1297 + let hybrid_search_info t = t.hybrid_search_info 1298 + let search_index t = t.search_index 1299 + let text_match t = t.text_match 1300 + let text_match_info t = t.text_match_info 1301 + let vector_distance t = t.vector_distance 1302 + 1303 + let jsont : t Jsont.t = 1304 + Jsont.Object.map ~kind:"SearchResultHit" 1305 + (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 }) 1306 + |> Jsont.Object.opt_mem "document" Jsont.json ~enc:(fun r -> r.document) 1307 + |> Jsont.Object.opt_mem "geo_distance_meters" Jsont.json ~enc:(fun r -> r.geo_distance_meters) 1308 + |> Jsont.Object.opt_mem "highlight" Jsont.json ~enc:(fun r -> r.highlight) 1309 + |> Jsont.Object.opt_mem "highlights" (Jsont.list SearchHighlight.T.jsont) ~enc:(fun r -> r.highlights) 1310 + |> Jsont.Object.opt_mem "hybrid_search_info" Jsont.json ~enc:(fun r -> r.hybrid_search_info) 1311 + |> Jsont.Object.opt_mem "search_index" Jsont.int ~enc:(fun r -> r.search_index) 1312 + |> Jsont.Object.opt_mem "text_match" Jsont.int64 ~enc:(fun r -> r.text_match) 1313 + |> Jsont.Object.opt_mem "text_match_info" Jsont.json ~enc:(fun r -> r.text_match_info) 1314 + |> Jsont.Object.opt_mem "vector_distance" Jsont.number ~enc:(fun r -> r.vector_distance) 1315 + |> Jsont.Object.skip_unknown 1316 + |> Jsont.Object.finish 1317 + end 1318 + end 1319 + 1320 + module SearchGroupedHit = struct 1321 + module Types = struct 1322 + module T = struct 1323 + type t = { 1324 + found : int option; 1325 + group_key : Jsont.json list; 1326 + hits : SearchResultHit.T.t list; (** The documents that matched the search query *) 1327 + } 1328 + end 1329 + end 1330 + 1331 + module T = struct 1332 + include Types.T 1333 + 1334 + let v ~group_key ~hits ?found () = { found; group_key; hits } 1335 + 1336 + let found t = t.found 1337 + let group_key t = t.group_key 1338 + let hits t = t.hits 1339 + 1340 + let jsont : t Jsont.t = 1341 + Jsont.Object.map ~kind:"SearchGroupedHit" 1342 + (fun found group_key hits -> { found; group_key; hits }) 1343 + |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found) 1344 + |> Jsont.Object.mem "group_key" (Jsont.list Jsont.json) ~enc:(fun r -> r.group_key) 1345 + |> Jsont.Object.mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits) 1346 + |> Jsont.Object.skip_unknown 1347 + |> Jsont.Object.finish 1348 + end 1349 + end 1350 + 1351 + module SchemaChange = struct 1352 + module Types = struct 1353 + module Status = struct 1354 + type t = { 1355 + altered_docs : int option; (** Number of documents that have been altered *) 1356 + collection : string option; (** Name of the collection being modified *) 1357 + validated_docs : int option; (** Number of documents that have been validated *) 1358 + } 1359 + end 1360 + end 1361 + 1362 + module Status = struct 1363 + include Types.Status 1364 + 1365 + let v ?altered_docs ?collection ?validated_docs () = { altered_docs; collection; validated_docs } 1366 + 1367 + let altered_docs t = t.altered_docs 1368 + let collection t = t.collection 1369 + let validated_docs t = t.validated_docs 1370 + 1371 + let jsont : t Jsont.t = 1372 + Jsont.Object.map ~kind:"SchemaChangeStatus" 1373 + (fun altered_docs collection validated_docs -> { altered_docs; collection; validated_docs }) 1374 + |> Jsont.Object.opt_mem "altered_docs" Jsont.int ~enc:(fun r -> r.altered_docs) 1375 + |> Jsont.Object.opt_mem "collection" Jsont.string ~enc:(fun r -> r.collection) 1376 + |> Jsont.Object.opt_mem "validated_docs" Jsont.int ~enc:(fun r -> r.validated_docs) 1377 + |> Jsont.Object.skip_unknown 1378 + |> Jsont.Object.finish 1379 + end 1380 + 1381 + (** Get the status of in-progress schema change operations 1382 + 1383 + Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. *) 1384 + let get_schema_changes client () = 1385 + let op_name = "get_schema_changes" in 1386 + let url_path = "/operations/schema_changes" in 1387 + let query = "" in 1388 + let url = client.base_url ^ url_path ^ query in 1389 + let response = 1390 + try Requests.get client.session url 1391 + with Eio.Io _ as ex -> 1392 + let bt = Printexc.get_raw_backtrace () in 1393 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1394 + in 1395 + if Requests.Response.ok response then 1396 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 1397 + else 1398 + let body = Requests.Response.text response in 1399 + let parsed_body = 1400 + match Jsont_bytesrw.decode_string Jsont.json body with 1401 + | Ok json -> Some (Openapi.Runtime.Json json) 1402 + | Error _ -> Some (Openapi.Runtime.Raw body) 1403 + in 1404 + raise (Openapi.Runtime.Api_error { 1405 + operation = op_name; 1406 + method_ = "GET"; 1407 + url; 1408 + status = Requests.Response.status_code response; 1409 + body; 1410 + parsed_body; 1411 + }) 1412 + end 1413 + 1414 + module PresetUpsertSchema = struct 1415 + module Types = struct 1416 + module T = struct 1417 + type t = { 1418 + value : Jsont.json; 1419 + } 1420 + end 1421 + end 1422 + 1423 + module T = struct 1424 + include Types.T 1425 + 1426 + let v ~value () = { value } 1427 + 1428 + let value t = t.value 1429 + 1430 + let jsont : t Jsont.t = 1431 + Jsont.Object.map ~kind:"PresetUpsertSchema" 1432 + (fun value -> { value }) 1433 + |> Jsont.Object.mem "value" Jsont.json ~enc:(fun r -> r.value) 1434 + |> Jsont.Object.skip_unknown 1435 + |> Jsont.Object.finish 1436 + end 1437 + end 1438 + 1439 + module PresetSchema = struct 1440 + module Types = struct 1441 + module T = struct 1442 + type t = { 1443 + value : Jsont.json; 1444 + name : string; 1445 + } 1446 + end 1447 + end 1448 + 1449 + module T = struct 1450 + include Types.T 1451 + 1452 + let v ~value ~name () = { value; name } 1453 + 1454 + let value t = t.value 1455 + let name t = t.name 1456 + 1457 + let jsont : t Jsont.t = 1458 + Jsont.Object.map ~kind:"PresetSchema" 1459 + (fun value name -> { value; name }) 1460 + |> Jsont.Object.mem "value" Jsont.json ~enc:(fun r -> r.value) 1461 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 1462 + |> Jsont.Object.skip_unknown 1463 + |> Jsont.Object.finish 1464 + end 1465 + 1466 + (** Retrieves a preset. 1467 + 1468 + Retrieve the details of a preset, given it's name. 1469 + @param preset_id The ID of the preset to retrieve. 1470 + *) 1471 + let retrieve_preset ~preset_id client () = 1472 + let op_name = "retrieve_preset" in 1473 + let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in 1474 + let query = "" in 1475 + let url = client.base_url ^ url_path ^ query in 1476 + let response = 1477 + try Requests.get client.session url 1478 + with Eio.Io _ as ex -> 1479 + let bt = Printexc.get_raw_backtrace () in 1480 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1481 + in 1482 + if Requests.Response.ok response then 1483 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1484 + else 1485 + let body = Requests.Response.text response in 1486 + let status = Requests.Response.status_code response in 1487 + let parsed_body = match status with 1488 + | 404 -> 1489 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1490 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1491 + | Error _ -> None) 1492 + | _ -> 1493 + (match Jsont_bytesrw.decode_string Jsont.json body with 1494 + | Ok json -> Some (Openapi.Runtime.Json json) 1495 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1496 + in 1497 + raise (Openapi.Runtime.Api_error { 1498 + operation = op_name; 1499 + method_ = "GET"; 1500 + url; 1501 + status; 1502 + body; 1503 + parsed_body; 1504 + }) 1505 + 1506 + (** Upserts a preset. 1507 + 1508 + Create or update an existing preset. 1509 + @param preset_id The name of the preset set to upsert. 1510 + *) 1511 + let upsert_preset ~preset_id ~body client () = 1512 + let op_name = "upsert_preset" in 1513 + let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in 1514 + let query = "" in 1515 + let url = client.base_url ^ url_path ^ query in 1516 + let response = 1517 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json PresetUpsertSchema.T.jsont body)) url 1518 + with Eio.Io _ as ex -> 1519 + let bt = Printexc.get_raw_backtrace () in 1520 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 1521 + in 1522 + if Requests.Response.ok response then 1523 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1524 + else 1525 + let body = Requests.Response.text response in 1526 + let status = Requests.Response.status_code response in 1527 + let parsed_body = match status with 1528 + | 400 -> 1529 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1530 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1531 + | Error _ -> None) 1532 + | _ -> 1533 + (match Jsont_bytesrw.decode_string Jsont.json body with 1534 + | Ok json -> Some (Openapi.Runtime.Json json) 1535 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1536 + in 1537 + raise (Openapi.Runtime.Api_error { 1538 + operation = op_name; 1539 + method_ = "PUT"; 1540 + url; 1541 + status; 1542 + body; 1543 + parsed_body; 1544 + }) 1545 + end 1546 + 1547 + module PresetsRetrieveSchema = struct 1548 + module Types = struct 1549 + module T = struct 1550 + type t = { 1551 + presets : PresetSchema.T.t list; 1552 + } 1553 + end 1554 + end 1555 + 1556 + module T = struct 1557 + include Types.T 1558 + 1559 + let v ~presets () = { presets } 1560 + 1561 + let presets t = t.presets 1562 + 1563 + let jsont : t Jsont.t = 1564 + Jsont.Object.map ~kind:"PresetsRetrieveSchema" 1565 + (fun presets -> { presets }) 1566 + |> Jsont.Object.mem "presets" (Jsont.list PresetSchema.T.jsont) ~enc:(fun r -> r.presets) 1567 + |> Jsont.Object.skip_unknown 1568 + |> Jsont.Object.finish 1569 + end 1570 + 1571 + (** Retrieves all presets. 1572 + 1573 + Retrieve the details of all presets *) 1574 + let retrieve_all_presets client () = 1575 + let op_name = "retrieve_all_presets" in 1576 + let url_path = "/presets" in 1577 + let query = "" in 1578 + let url = client.base_url ^ url_path ^ query in 1579 + let response = 1580 + try Requests.get client.session url 1581 + with Eio.Io _ as ex -> 1582 + let bt = Printexc.get_raw_backtrace () in 1583 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1584 + in 1585 + if Requests.Response.ok response then 1586 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1587 + else 1588 + let body = Requests.Response.text response in 1589 + let parsed_body = 1590 + match Jsont_bytesrw.decode_string Jsont.json body with 1591 + | Ok json -> Some (Openapi.Runtime.Json json) 1592 + | Error _ -> Some (Openapi.Runtime.Raw body) 1593 + in 1594 + raise (Openapi.Runtime.Api_error { 1595 + operation = op_name; 1596 + method_ = "GET"; 1597 + url; 1598 + status = Requests.Response.status_code response; 1599 + body; 1600 + parsed_body; 1601 + }) 1602 + end 1603 + 1604 + module PresetDeleteSchema = struct 1605 + module Types = struct 1606 + module T = struct 1607 + type t = { 1608 + name : string; 1609 + } 1610 + end 1611 + end 1612 + 1613 + module T = struct 1614 + include Types.T 1615 + 1616 + let v ~name () = { name } 1617 + 1618 + let name t = t.name 1619 + 1620 + let jsont : t Jsont.t = 1621 + Jsont.Object.map ~kind:"PresetDeleteSchema" 1622 + (fun name -> { name }) 1623 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 1624 + |> Jsont.Object.skip_unknown 1625 + |> Jsont.Object.finish 1626 + end 1627 + 1628 + (** Delete a preset. 1629 + 1630 + Permanently deletes a preset, given it's name. 1631 + @param preset_id The ID of the preset to delete. 1632 + *) 1633 + let delete_preset ~preset_id client () = 1634 + let op_name = "delete_preset" in 1635 + let url_path = Openapi.Runtime.Path.render ~params:[("presetId", preset_id)] "/presets/{presetId}" in 1636 + let query = "" in 1637 + let url = client.base_url ^ url_path ^ query in 1638 + let response = 1639 + try Requests.delete client.session url 1640 + with Eio.Io _ as ex -> 1641 + let bt = Printexc.get_raw_backtrace () in 1642 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 1643 + in 1644 + if Requests.Response.ok response then 1645 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1646 + else 1647 + let body = Requests.Response.text response in 1648 + let status = Requests.Response.status_code response in 1649 + let parsed_body = match status with 1650 + | 404 -> 1651 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1652 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1653 + | Error _ -> None) 1654 + | _ -> 1655 + (match Jsont_bytesrw.decode_string Jsont.json body with 1656 + | Ok json -> Some (Openapi.Runtime.Json json) 1657 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1658 + in 1659 + raise (Openapi.Runtime.Api_error { 1660 + operation = op_name; 1661 + method_ = "DELETE"; 1662 + url; 1663 + status; 1664 + body; 1665 + parsed_body; 1666 + }) 1667 + end 1668 + 1669 + module NlsearchModelDeleteSchema = struct 1670 + module Types = struct 1671 + module T = struct 1672 + type t = { 1673 + id : string; (** ID of the deleted NL search model *) 1674 + } 1675 + end 1676 + end 1677 + 1678 + module T = struct 1679 + include Types.T 1680 + 1681 + let v ~id () = { id } 1682 + 1683 + let id t = t.id 1684 + 1685 + let jsont : t Jsont.t = 1686 + Jsont.Object.map ~kind:"NLSearchModelDeleteSchema" 1687 + (fun id -> { id }) 1688 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 1689 + |> Jsont.Object.skip_unknown 1690 + |> Jsont.Object.finish 1691 + end 1692 + 1693 + (** Delete a NL search model 1694 + 1695 + Delete a specific NL search model by its ID. 1696 + @param model_id The ID of the NL search model to delete 1697 + *) 1698 + let delete_nlsearch_model ~model_id client () = 1699 + let op_name = "delete_nlsearch_model" in 1700 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in 1701 + let query = "" in 1702 + let url = client.base_url ^ url_path ^ query in 1703 + let response = 1704 + try Requests.delete client.session url 1705 + with Eio.Io _ as ex -> 1706 + let bt = Printexc.get_raw_backtrace () in 1707 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 1708 + in 1709 + if Requests.Response.ok response then 1710 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1711 + else 1712 + let body = Requests.Response.text response in 1713 + let status = Requests.Response.status_code response in 1714 + let parsed_body = match status with 1715 + | 404 -> 1716 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1717 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1718 + | Error _ -> None) 1719 + | _ -> 1720 + (match Jsont_bytesrw.decode_string Jsont.json body with 1721 + | Ok json -> Some (Openapi.Runtime.Json json) 1722 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1723 + in 1724 + raise (Openapi.Runtime.Api_error { 1725 + operation = op_name; 1726 + method_ = "DELETE"; 1727 + url; 1728 + status; 1729 + body; 1730 + parsed_body; 1731 + }) 1732 + end 1733 + 1734 + module NlsearchModelCreateSchema = struct 1735 + module Types = struct 1736 + module T = struct 1737 + type t = { 1738 + access_token : string option; (** Access token for GCP Vertex AI *) 1739 + account_id : string option; (** Account ID for Cloudflare-specific models *) 1740 + api_key : string option; (** API key for the NL model service *) 1741 + api_url : string option; (** Custom API URL for the NL model service *) 1742 + api_version : string option; (** API version for the NL model service *) 1743 + client_id : string option; (** Client ID for GCP Vertex AI *) 1744 + client_secret : string option; (** Client secret for GCP Vertex AI *) 1745 + max_bytes : int option; (** Maximum number of bytes to process *) 1746 + max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *) 1747 + model_name : string option; (** Name of the NL model to use *) 1748 + project_id : string option; (** Project ID for GCP Vertex AI *) 1749 + refresh_token : string option; (** Refresh token for GCP Vertex AI *) 1750 + region : string option; (** Region for GCP Vertex AI *) 1751 + stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *) 1752 + system_prompt : string option; (** System prompt for the NL model *) 1753 + temperature : float option; (** Temperature parameter for the NL model *) 1754 + top_k : int option; (** Top-k parameter for the NL model (Google-specific) *) 1755 + top_p : float option; (** Top-p parameter for the NL model (Google-specific) *) 1756 + id : string option; (** Optional ID for the NL search model *) 1757 + } 1758 + end 1759 + end 1760 + 1761 + module T = struct 1762 + include Types.T 1763 + 1764 + 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 } 1765 + 1766 + let access_token t = t.access_token 1767 + let account_id t = t.account_id 1768 + let api_key t = t.api_key 1769 + let api_url t = t.api_url 1770 + let api_version t = t.api_version 1771 + let client_id t = t.client_id 1772 + let client_secret t = t.client_secret 1773 + let max_bytes t = t.max_bytes 1774 + let max_output_tokens t = t.max_output_tokens 1775 + let model_name t = t.model_name 1776 + let project_id t = t.project_id 1777 + let refresh_token t = t.refresh_token 1778 + let region t = t.region 1779 + let stop_sequences t = t.stop_sequences 1780 + let system_prompt t = t.system_prompt 1781 + let temperature t = t.temperature 1782 + let top_k t = t.top_k 1783 + let top_p t = t.top_p 1784 + let id t = t.id 1785 + 1786 + let jsont : t Jsont.t = 1787 + Jsont.Object.map ~kind:"NLSearchModelCreateSchema" 1788 + (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 }) 1789 + |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token) 1790 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 1791 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 1792 + |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url) 1793 + |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version) 1794 + |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id) 1795 + |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret) 1796 + |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 1797 + |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens) 1798 + |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 1799 + |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id) 1800 + |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token) 1801 + |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region) 1802 + |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences) 1803 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 1804 + |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature) 1805 + |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k) 1806 + |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p) 1807 + |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id) 1808 + |> Jsont.Object.skip_unknown 1809 + |> Jsont.Object.finish 1810 + end 1811 + end 1812 + 1813 + module NlsearchModelSchema = struct 1814 + module Types = struct 1815 + module T = struct 1816 + type t = { 1817 + access_token : string option; (** Access token for GCP Vertex AI *) 1818 + account_id : string option; (** Account ID for Cloudflare-specific models *) 1819 + api_key : string option; (** API key for the NL model service *) 1820 + api_url : string option; (** Custom API URL for the NL model service *) 1821 + api_version : string option; (** API version for the NL model service *) 1822 + client_id : string option; (** Client ID for GCP Vertex AI *) 1823 + client_secret : string option; (** Client secret for GCP Vertex AI *) 1824 + max_bytes : int option; (** Maximum number of bytes to process *) 1825 + max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *) 1826 + model_name : string option; (** Name of the NL model to use *) 1827 + project_id : string option; (** Project ID for GCP Vertex AI *) 1828 + refresh_token : string option; (** Refresh token for GCP Vertex AI *) 1829 + region : string option; (** Region for GCP Vertex AI *) 1830 + stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *) 1831 + system_prompt : string option; (** System prompt for the NL model *) 1832 + temperature : float option; (** Temperature parameter for the NL model *) 1833 + top_k : int option; (** Top-k parameter for the NL model (Google-specific) *) 1834 + top_p : float option; (** Top-p parameter for the NL model (Google-specific) *) 1835 + id : string; (** ID of the NL search model *) 1836 + } 1837 + end 1838 + end 1839 + 1840 + module T = struct 1841 + include Types.T 1842 + 1843 + 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 } 1844 + 1845 + let access_token t = t.access_token 1846 + let account_id t = t.account_id 1847 + let api_key t = t.api_key 1848 + let api_url t = t.api_url 1849 + let api_version t = t.api_version 1850 + let client_id t = t.client_id 1851 + let client_secret t = t.client_secret 1852 + let max_bytes t = t.max_bytes 1853 + let max_output_tokens t = t.max_output_tokens 1854 + let model_name t = t.model_name 1855 + let project_id t = t.project_id 1856 + let refresh_token t = t.refresh_token 1857 + let region t = t.region 1858 + let stop_sequences t = t.stop_sequences 1859 + let system_prompt t = t.system_prompt 1860 + let temperature t = t.temperature 1861 + let top_k t = t.top_k 1862 + let top_p t = t.top_p 1863 + let id t = t.id 1864 + 1865 + let jsont : t Jsont.t = 1866 + Jsont.Object.map ~kind:"NLSearchModelSchema" 1867 + (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 }) 1868 + |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token) 1869 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 1870 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 1871 + |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url) 1872 + |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version) 1873 + |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id) 1874 + |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret) 1875 + |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 1876 + |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens) 1877 + |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 1878 + |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id) 1879 + |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token) 1880 + |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region) 1881 + |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences) 1882 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 1883 + |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature) 1884 + |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k) 1885 + |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p) 1886 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 1887 + |> Jsont.Object.skip_unknown 1888 + |> Jsont.Object.finish 1889 + end 1890 + 1891 + (** List all NL search models 1892 + 1893 + Retrieve all NL search models. *) 1894 + let retrieve_all_nlsearch_models client () = 1895 + let op_name = "retrieve_all_nlsearch_models" in 1896 + let url_path = "/nl_search_models" in 1897 + let query = "" in 1898 + let url = client.base_url ^ url_path ^ query in 1899 + let response = 1900 + try Requests.get client.session url 1901 + with Eio.Io _ as ex -> 1902 + let bt = Printexc.get_raw_backtrace () in 1903 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1904 + in 1905 + if Requests.Response.ok response then 1906 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1907 + else 1908 + let body = Requests.Response.text response in 1909 + let parsed_body = 1910 + match Jsont_bytesrw.decode_string Jsont.json body with 1911 + | Ok json -> Some (Openapi.Runtime.Json json) 1912 + | Error _ -> Some (Openapi.Runtime.Raw body) 1913 + in 1914 + raise (Openapi.Runtime.Api_error { 1915 + operation = op_name; 1916 + method_ = "GET"; 1917 + url; 1918 + status = Requests.Response.status_code response; 1919 + body; 1920 + parsed_body; 1921 + }) 1922 + 1923 + (** Create a NL search model 1924 + 1925 + Create a new NL search model. *) 1926 + let create_nlsearch_model ~body client () = 1927 + let op_name = "create_nlsearch_model" in 1928 + let url_path = "/nl_search_models" in 1929 + let query = "" in 1930 + let url = client.base_url ^ url_path ^ query in 1931 + let response = 1932 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json NlsearchModelCreateSchema.T.jsont body)) url 1933 + with Eio.Io _ as ex -> 1934 + let bt = Printexc.get_raw_backtrace () in 1935 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 1936 + in 1937 + if Requests.Response.ok response then 1938 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1939 + else 1940 + let body = Requests.Response.text response in 1941 + let status = Requests.Response.status_code response in 1942 + let parsed_body = match status with 1943 + | 400 -> 1944 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1945 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1946 + | Error _ -> None) 1947 + | _ -> 1948 + (match Jsont_bytesrw.decode_string Jsont.json body with 1949 + | Ok json -> Some (Openapi.Runtime.Json json) 1950 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1951 + in 1952 + raise (Openapi.Runtime.Api_error { 1953 + operation = op_name; 1954 + method_ = "POST"; 1955 + url; 1956 + status; 1957 + body; 1958 + parsed_body; 1959 + }) 1960 + 1961 + (** Retrieve a NL search model 1962 + 1963 + Retrieve a specific NL search model by its ID. 1964 + @param model_id The ID of the NL search model to retrieve 1965 + *) 1966 + let retrieve_nlsearch_model ~model_id client () = 1967 + let op_name = "retrieve_nlsearch_model" in 1968 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in 1969 + let query = "" in 1970 + let url = client.base_url ^ url_path ^ query in 1971 + let response = 1972 + try Requests.get client.session url 1973 + with Eio.Io _ as ex -> 1974 + let bt = Printexc.get_raw_backtrace () in 1975 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 1976 + in 1977 + if Requests.Response.ok response then 1978 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 1979 + else 1980 + let body = Requests.Response.text response in 1981 + let status = Requests.Response.status_code response in 1982 + let parsed_body = match status with 1983 + | 404 -> 1984 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 1985 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 1986 + | Error _ -> None) 1987 + | _ -> 1988 + (match Jsont_bytesrw.decode_string Jsont.json body with 1989 + | Ok json -> Some (Openapi.Runtime.Json json) 1990 + | Error _ -> Some (Openapi.Runtime.Raw body)) 1991 + in 1992 + raise (Openapi.Runtime.Api_error { 1993 + operation = op_name; 1994 + method_ = "GET"; 1995 + url; 1996 + status; 1997 + body; 1998 + parsed_body; 1999 + }) 2000 + 2001 + (** Update a NL search model 2002 + 2003 + Update an existing NL search model. 2004 + @param model_id The ID of the NL search model to update 2005 + *) 2006 + let update_nlsearch_model ~model_id client () = 2007 + let op_name = "update_nlsearch_model" in 2008 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/nl_search_models/{modelId}" in 2009 + let query = "" in 2010 + let url = client.base_url ^ url_path ^ query in 2011 + let response = 2012 + try Requests.put client.session url 2013 + with Eio.Io _ as ex -> 2014 + let bt = Printexc.get_raw_backtrace () in 2015 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 2016 + in 2017 + if Requests.Response.ok response then 2018 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 2019 + else 2020 + let body = Requests.Response.text response in 2021 + let status = Requests.Response.status_code response in 2022 + let parsed_body = match status with 2023 + | 400 -> 2024 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2025 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2026 + | Error _ -> None) 2027 + | 404 -> 2028 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2029 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2030 + | Error _ -> None) 2031 + | _ -> 2032 + (match Jsont_bytesrw.decode_string Jsont.json body with 2033 + | Ok json -> Some (Openapi.Runtime.Json json) 2034 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2035 + in 2036 + raise (Openapi.Runtime.Api_error { 2037 + operation = op_name; 2038 + method_ = "PUT"; 2039 + url; 2040 + status; 2041 + body; 2042 + parsed_body; 2043 + }) 2044 + end 2045 + 2046 + module NlsearchModelBase = struct 2047 + module Types = struct 2048 + module T = struct 2049 + type t = { 2050 + access_token : string option; (** Access token for GCP Vertex AI *) 2051 + account_id : string option; (** Account ID for Cloudflare-specific models *) 2052 + api_key : string option; (** API key for the NL model service *) 2053 + api_url : string option; (** Custom API URL for the NL model service *) 2054 + api_version : string option; (** API version for the NL model service *) 2055 + client_id : string option; (** Client ID for GCP Vertex AI *) 2056 + client_secret : string option; (** Client secret for GCP Vertex AI *) 2057 + max_bytes : int option; (** Maximum number of bytes to process *) 2058 + max_output_tokens : int option; (** Maximum output tokens for GCP Vertex AI *) 2059 + model_name : string option; (** Name of the NL model to use *) 2060 + project_id : string option; (** Project ID for GCP Vertex AI *) 2061 + refresh_token : string option; (** Refresh token for GCP Vertex AI *) 2062 + region : string option; (** Region for GCP Vertex AI *) 2063 + stop_sequences : string list option; (** Stop sequences for the NL model (Google-specific) *) 2064 + system_prompt : string option; (** System prompt for the NL model *) 2065 + temperature : float option; (** Temperature parameter for the NL model *) 2066 + top_k : int option; (** Top-k parameter for the NL model (Google-specific) *) 2067 + top_p : float option; (** Top-p parameter for the NL model (Google-specific) *) 2068 + } 2069 + end 2070 + end 2071 + 2072 + module T = struct 2073 + include Types.T 2074 + 2075 + 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 } 2076 + 2077 + let access_token t = t.access_token 2078 + let account_id t = t.account_id 2079 + let api_key t = t.api_key 2080 + let api_url t = t.api_url 2081 + let api_version t = t.api_version 2082 + let client_id t = t.client_id 2083 + let client_secret t = t.client_secret 2084 + let max_bytes t = t.max_bytes 2085 + let max_output_tokens t = t.max_output_tokens 2086 + let model_name t = t.model_name 2087 + let project_id t = t.project_id 2088 + let refresh_token t = t.refresh_token 2089 + let region t = t.region 2090 + let stop_sequences t = t.stop_sequences 2091 + let system_prompt t = t.system_prompt 2092 + let temperature t = t.temperature 2093 + let top_k t = t.top_k 2094 + let top_p t = t.top_p 2095 + 2096 + let jsont : t Jsont.t = 2097 + Jsont.Object.map ~kind:"NLSearchModelBase" 2098 + (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 }) 2099 + |> Jsont.Object.opt_mem "access_token" Jsont.string ~enc:(fun r -> r.access_token) 2100 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 2101 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 2102 + |> Jsont.Object.opt_mem "api_url" Jsont.string ~enc:(fun r -> r.api_url) 2103 + |> Jsont.Object.opt_mem "api_version" Jsont.string ~enc:(fun r -> r.api_version) 2104 + |> Jsont.Object.opt_mem "client_id" Jsont.string ~enc:(fun r -> r.client_id) 2105 + |> Jsont.Object.opt_mem "client_secret" Jsont.string ~enc:(fun r -> r.client_secret) 2106 + |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 2107 + |> Jsont.Object.opt_mem "max_output_tokens" Jsont.int ~enc:(fun r -> r.max_output_tokens) 2108 + |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 2109 + |> Jsont.Object.opt_mem "project_id" Jsont.string ~enc:(fun r -> r.project_id) 2110 + |> Jsont.Object.opt_mem "refresh_token" Jsont.string ~enc:(fun r -> r.refresh_token) 2111 + |> Jsont.Object.opt_mem "region" Jsont.string ~enc:(fun r -> r.region) 2112 + |> Jsont.Object.opt_mem "stop_sequences" (Jsont.list Jsont.string) ~enc:(fun r -> r.stop_sequences) 2113 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 2114 + |> Jsont.Object.opt_mem "temperature" Jsont.number ~enc:(fun r -> r.temperature) 2115 + |> Jsont.Object.opt_mem "top_k" Jsont.int ~enc:(fun r -> r.top_k) 2116 + |> Jsont.Object.opt_mem "top_p" Jsont.number ~enc:(fun r -> r.top_p) 2117 + |> Jsont.Object.skip_unknown 2118 + |> Jsont.Object.finish 2119 + end 2120 + end 2121 + 2122 + module IndexAction = struct 2123 + module Types = struct 2124 + module T = struct 2125 + type t = [ 2126 + | `Create 2127 + | `Update 2128 + | `Upsert 2129 + | `Emplace 2130 + ] 2131 + end 2132 + end 2133 + 2134 + module T = struct 2135 + include Types.T 2136 + 2137 + let jsont : t Jsont.t = 2138 + Jsont.map Jsont.string ~kind:"IndexAction" 2139 + ~dec:(function 2140 + | "create" -> `Create 2141 + | "update" -> `Update 2142 + | "upsert" -> `Upsert 2143 + | "emplace" -> `Emplace 2144 + | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s) 2145 + ~enc:(function 2146 + | `Create -> "create" 2147 + | `Update -> "update" 2148 + | `Upsert -> "upsert" 2149 + | `Emplace -> "emplace") 2150 + end 2151 + end 2152 + 2153 + module Health = struct 2154 + module Types = struct 2155 + module Status = struct 2156 + type t = { 2157 + ok : bool; 2158 + } 2159 + end 2160 + end 2161 + 2162 + module Status = struct 2163 + include Types.Status 2164 + 2165 + let v ~ok () = { ok } 2166 + 2167 + let ok t = t.ok 2168 + 2169 + let jsont : t Jsont.t = 2170 + Jsont.Object.map ~kind:"HealthStatus" 2171 + (fun ok -> { ok }) 2172 + |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok) 2173 + |> Jsont.Object.skip_unknown 2174 + |> Jsont.Object.finish 2175 + end 2176 + 2177 + (** Checks if Typesense server is ready to accept requests. 2178 + 2179 + Checks if Typesense server is ready to accept requests. *) 2180 + let health client () = 2181 + let op_name = "health" in 2182 + let url_path = "/health" in 2183 + let query = "" in 2184 + let url = client.base_url ^ url_path ^ query in 2185 + let response = 2186 + try Requests.get client.session url 2187 + with Eio.Io _ as ex -> 2188 + let bt = Printexc.get_raw_backtrace () in 2189 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 2190 + in 2191 + if Requests.Response.ok response then 2192 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 2193 + else 2194 + let body = Requests.Response.text response in 2195 + let parsed_body = 2196 + match Jsont_bytesrw.decode_string Jsont.json body with 2197 + | Ok json -> Some (Openapi.Runtime.Json json) 2198 + | Error _ -> Some (Openapi.Runtime.Raw body) 2199 + in 2200 + raise (Openapi.Runtime.Api_error { 2201 + operation = op_name; 2202 + method_ = "GET"; 2203 + url; 2204 + status = Requests.Response.status_code response; 2205 + body; 2206 + parsed_body; 2207 + }) 2208 + end 2209 + 2210 + module Field = struct 2211 + module Types = struct 2212 + module T = struct 2213 + type t = { 2214 + async_reference : bool option; (** Allow documents to be indexed successfully even when the referenced document doesn't exist yet. 2215 + *) 2216 + drop : bool option; 2217 + embed : Jsont.json option; 2218 + facet : bool option; 2219 + index : bool; 2220 + infix : bool; 2221 + locale : string option; 2222 + name : string; 2223 + num_dim : int option; 2224 + optional : bool option; 2225 + range_index : bool option; (** Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. 2226 + *) 2227 + 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. 2228 + *) 2229 + sort : bool option; 2230 + stem : bool option; (** Values are stemmed before indexing in-memory. Default: false. 2231 + *) 2232 + stem_dictionary : string option; (** Name of the stemming dictionary to use for this field *) 2233 + store : bool option; (** When set to false, the field value will not be stored on disk. Default: true. 2234 + *) 2235 + symbols_to_index : string list; (** List of symbols or special characters to be indexed. 2236 + *) 2237 + 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. 2238 + *) 2239 + type_ : string; 2240 + vec_dist : string option; (** The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. 2241 + *) 2242 + } 2243 + end 2244 + end 2245 + 2246 + module T = struct 2247 + include Types.T 2248 + 2249 + 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 } 2250 + 2251 + let async_reference t = t.async_reference 2252 + let drop t = t.drop 2253 + let embed t = t.embed 2254 + let facet t = t.facet 2255 + let index t = t.index 2256 + let infix t = t.infix 2257 + let locale t = t.locale 2258 + let name t = t.name 2259 + let num_dim t = t.num_dim 2260 + let optional t = t.optional 2261 + let range_index t = t.range_index 2262 + let reference t = t.reference 2263 + let sort t = t.sort 2264 + let stem t = t.stem 2265 + let stem_dictionary t = t.stem_dictionary 2266 + let store t = t.store 2267 + let symbols_to_index t = t.symbols_to_index 2268 + let token_separators t = t.token_separators 2269 + let type_ t = t.type_ 2270 + let vec_dist t = t.vec_dist 2271 + 2272 + let jsont : t Jsont.t = 2273 + Jsont.Object.map ~kind:"Field" 2274 + (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 }) 2275 + |> Jsont.Object.opt_mem "async_reference" Jsont.bool ~enc:(fun r -> r.async_reference) 2276 + |> Jsont.Object.opt_mem "drop" Jsont.bool ~enc:(fun r -> r.drop) 2277 + |> Jsont.Object.opt_mem "embed" Jsont.json ~enc:(fun r -> r.embed) 2278 + |> Jsont.Object.opt_mem "facet" Jsont.bool ~enc:(fun r -> r.facet) 2279 + |> Jsont.Object.mem "index" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.index) 2280 + |> Jsont.Object.mem "infix" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.infix) 2281 + |> Jsont.Object.opt_mem "locale" Jsont.string ~enc:(fun r -> r.locale) 2282 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 2283 + |> Jsont.Object.opt_mem "num_dim" Jsont.int ~enc:(fun r -> r.num_dim) 2284 + |> Jsont.Object.opt_mem "optional" Jsont.bool ~enc:(fun r -> r.optional) 2285 + |> Jsont.Object.opt_mem "range_index" Jsont.bool ~enc:(fun r -> r.range_index) 2286 + |> Jsont.Object.opt_mem "reference" Jsont.string ~enc:(fun r -> r.reference) 2287 + |> Jsont.Object.opt_mem "sort" Jsont.bool ~enc:(fun r -> r.sort) 2288 + |> Jsont.Object.opt_mem "stem" Jsont.bool ~enc:(fun r -> r.stem) 2289 + |> Jsont.Object.opt_mem "stem_dictionary" Jsont.string ~enc:(fun r -> r.stem_dictionary) 2290 + |> Jsont.Object.opt_mem "store" Jsont.bool ~enc:(fun r -> r.store) 2291 + |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index) 2292 + |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators) 2293 + |> Jsont.Object.mem "type" Jsont.string ~enc:(fun r -> r.type_) 2294 + |> Jsont.Object.opt_mem "vec_dist" Jsont.string ~enc:(fun r -> r.vec_dist) 2295 + |> Jsont.Object.skip_unknown 2296 + |> Jsont.Object.finish 2297 + end 2298 + end 2299 + 2300 + module CollectionUpdateSchema = struct 2301 + module Types = struct 2302 + module T = struct 2303 + type t = { 2304 + fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *) 2305 + metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc. 2306 + *) 2307 + synonym_sets : string list option; (** List of synonym set names to associate with this collection *) 2308 + } 2309 + end 2310 + end 2311 + 2312 + module T = struct 2313 + include Types.T 2314 + 2315 + let v ~fields ?metadata ?synonym_sets () = { fields; metadata; synonym_sets } 2316 + 2317 + let fields t = t.fields 2318 + let metadata t = t.metadata 2319 + let synonym_sets t = t.synonym_sets 2320 + 2321 + let jsont : t Jsont.t = 2322 + Jsont.Object.map ~kind:"CollectionUpdateSchema" 2323 + (fun fields metadata synonym_sets -> { fields; metadata; synonym_sets }) 2324 + |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields) 2325 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 2326 + |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets) 2327 + |> Jsont.Object.skip_unknown 2328 + |> Jsont.Object.finish 2329 + end 2330 + 2331 + (** Update a collection 2332 + 2333 + Update a collection's schema to modify the fields and their types. 2334 + @param collection_name The name of the collection to update 2335 + *) 2336 + let update_collection ~collection_name ~body client () = 2337 + let op_name = "update_collection" in 2338 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in 2339 + let query = "" in 2340 + let url = client.base_url ^ url_path ^ query in 2341 + let response = 2342 + try Requests.patch client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json T.jsont body)) url 2343 + with Eio.Io _ as ex -> 2344 + let bt = Printexc.get_raw_backtrace () in 2345 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url 2346 + in 2347 + if Requests.Response.ok response then 2348 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 2349 + else 2350 + let body = Requests.Response.text response in 2351 + let status = Requests.Response.status_code response in 2352 + let parsed_body = match status with 2353 + | 400 -> 2354 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2355 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2356 + | Error _ -> None) 2357 + | 404 -> 2358 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2359 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2360 + | Error _ -> None) 2361 + | _ -> 2362 + (match Jsont_bytesrw.decode_string Jsont.json body with 2363 + | Ok json -> Some (Openapi.Runtime.Json json) 2364 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2365 + in 2366 + raise (Openapi.Runtime.Api_error { 2367 + operation = op_name; 2368 + method_ = "PATCH"; 2369 + url; 2370 + status; 2371 + body; 2372 + parsed_body; 2373 + }) 2374 + end 2375 + 2376 + module CollectionSchema = struct 2377 + module Types = struct 2378 + module T = struct 2379 + type t = { 2380 + 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. *) 2381 + 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. *) 2382 + fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *) 2383 + metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc. 2384 + *) 2385 + name : string; (** Name of the collection *) 2386 + symbols_to_index : string list; (** List of symbols or special characters to be indexed. 2387 + *) 2388 + synonym_sets : string list option; (** List of synonym set names to associate with this collection *) 2389 + 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. 2390 + *) 2391 + voice_query_model : VoiceQueryModelCollection.Config.t option; 2392 + } 2393 + end 2394 + end 2395 + 2396 + module T = struct 2397 + include Types.T 2398 + 2399 + 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 } 2400 + 2401 + let default_sorting_field t = t.default_sorting_field 2402 + let enable_nested_fields t = t.enable_nested_fields 2403 + let fields t = t.fields 2404 + let metadata t = t.metadata 2405 + let name t = t.name 2406 + let symbols_to_index t = t.symbols_to_index 2407 + let synonym_sets t = t.synonym_sets 2408 + let token_separators t = t.token_separators 2409 + let voice_query_model t = t.voice_query_model 2410 + 2411 + let jsont : t Jsont.t = 2412 + Jsont.Object.map ~kind:"CollectionSchema" 2413 + (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 }) 2414 + |> Jsont.Object.mem "default_sorting_field" Jsont.string ~dec_absent:"" ~enc:(fun r -> r.default_sorting_field) 2415 + |> Jsont.Object.mem "enable_nested_fields" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_nested_fields) 2416 + |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields) 2417 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 2418 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 2419 + |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index) 2420 + |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets) 2421 + |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators) 2422 + |> Jsont.Object.opt_mem "voice_query_model" VoiceQueryModelCollection.Config.jsont ~enc:(fun r -> r.voice_query_model) 2423 + |> Jsont.Object.skip_unknown 2424 + |> Jsont.Object.finish 2425 + end 2426 + end 2427 + 2428 + module Collection = struct 2429 + module Types = struct 2430 + module Response = struct 2431 + type t = { 2432 + 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. *) 2433 + 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. *) 2434 + fields : Field.T.t list; (** A list of fields for querying, filtering and faceting *) 2435 + metadata : Jsont.json option; (** Optional details about the collection, e.g., when it was created, who created it etc. 2436 + *) 2437 + name : string; (** Name of the collection *) 2438 + symbols_to_index : string list; (** List of symbols or special characters to be indexed. 2439 + *) 2440 + synonym_sets : string list option; (** List of synonym set names to associate with this collection *) 2441 + 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. 2442 + *) 2443 + voice_query_model : VoiceQueryModelCollection.Config.t option; 2444 + num_documents : int64; (** Number of documents in the collection *) 2445 + created_at : int64; (** Timestamp of when the collection was created (Unix epoch in seconds) *) 2446 + } 2447 + end 2448 + end 2449 + 2450 + module Response = struct 2451 + include Types.Response 2452 + 2453 + 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 } 2454 + 2455 + let default_sorting_field t = t.default_sorting_field 2456 + let enable_nested_fields t = t.enable_nested_fields 2457 + let fields t = t.fields 2458 + let metadata t = t.metadata 2459 + let name t = t.name 2460 + let symbols_to_index t = t.symbols_to_index 2461 + let synonym_sets t = t.synonym_sets 2462 + let token_separators t = t.token_separators 2463 + let voice_query_model t = t.voice_query_model 2464 + let num_documents t = t.num_documents 2465 + let created_at t = t.created_at 2466 + 2467 + let jsont : t Jsont.t = 2468 + Jsont.Object.map ~kind:"CollectionResponse" 2469 + (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 }) 2470 + |> Jsont.Object.mem "default_sorting_field" Jsont.string ~dec_absent:"" ~enc:(fun r -> r.default_sorting_field) 2471 + |> Jsont.Object.mem "enable_nested_fields" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_nested_fields) 2472 + |> Jsont.Object.mem "fields" (Jsont.list Field.T.jsont) ~enc:(fun r -> r.fields) 2473 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 2474 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 2475 + |> Jsont.Object.mem "symbols_to_index" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.symbols_to_index) 2476 + |> Jsont.Object.opt_mem "synonym_sets" (Jsont.list Jsont.string) ~enc:(fun r -> r.synonym_sets) 2477 + |> Jsont.Object.mem "token_separators" (Jsont.list Jsont.string) ~dec_absent:[] ~enc:(fun r -> r.token_separators) 2478 + |> Jsont.Object.opt_mem "voice_query_model" VoiceQueryModelCollection.Config.jsont ~enc:(fun r -> r.voice_query_model) 2479 + |> Jsont.Object.mem "num_documents" Jsont.int64 ~enc:(fun r -> r.num_documents) 2480 + |> Jsont.Object.mem "created_at" Jsont.int64 ~enc:(fun r -> r.created_at) 2481 + |> Jsont.Object.skip_unknown 2482 + |> Jsont.Object.finish 2483 + end 2484 + 2485 + (** List all collections 2486 + 2487 + Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. *) 2488 + let get_collections ?get_collections_parameters client () = 2489 + let op_name = "get_collections" in 2490 + let url_path = "/collections" in 2491 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"getCollectionsParameters" ~value:get_collections_parameters]) in 2492 + let url = client.base_url ^ url_path ^ query in 2493 + let response = 2494 + try Requests.get client.session url 2495 + with Eio.Io _ as ex -> 2496 + let bt = Printexc.get_raw_backtrace () in 2497 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 2498 + in 2499 + if Requests.Response.ok response then 2500 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 2501 + else 2502 + let body = Requests.Response.text response in 2503 + let parsed_body = 2504 + match Jsont_bytesrw.decode_string Jsont.json body with 2505 + | Ok json -> Some (Openapi.Runtime.Json json) 2506 + | Error _ -> Some (Openapi.Runtime.Raw body) 2507 + in 2508 + raise (Openapi.Runtime.Api_error { 2509 + operation = op_name; 2510 + method_ = "GET"; 2511 + url; 2512 + status = Requests.Response.status_code response; 2513 + body; 2514 + parsed_body; 2515 + }) 2516 + 2517 + (** Create a new collection 2518 + 2519 + 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. *) 2520 + let create_collection ~body client () = 2521 + let op_name = "create_collection" in 2522 + let url_path = "/collections" in 2523 + let query = "" in 2524 + let url = client.base_url ^ url_path ^ query in 2525 + let response = 2526 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CollectionSchema.T.jsont body)) url 2527 + with Eio.Io _ as ex -> 2528 + let bt = Printexc.get_raw_backtrace () in 2529 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 2530 + in 2531 + if Requests.Response.ok response then 2532 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 2533 + else 2534 + let body = Requests.Response.text response in 2535 + let status = Requests.Response.status_code response in 2536 + let parsed_body = match status with 2537 + | 400 -> 2538 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2539 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2540 + | Error _ -> None) 2541 + | 409 -> 2542 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2543 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2544 + | Error _ -> None) 2545 + | _ -> 2546 + (match Jsont_bytesrw.decode_string Jsont.json body with 2547 + | Ok json -> Some (Openapi.Runtime.Json json) 2548 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2549 + in 2550 + raise (Openapi.Runtime.Api_error { 2551 + operation = op_name; 2552 + method_ = "POST"; 2553 + url; 2554 + status; 2555 + body; 2556 + parsed_body; 2557 + }) 2558 + 2559 + (** Retrieve a single collection 2560 + 2561 + Retrieve the details of a collection, given its name. 2562 + @param collection_name The name of the collection to retrieve 2563 + *) 2564 + let get_collection ~collection_name client () = 2565 + let op_name = "get_collection" in 2566 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in 2567 + let query = "" in 2568 + let url = client.base_url ^ url_path ^ query in 2569 + let response = 2570 + try Requests.get client.session url 2571 + with Eio.Io _ as ex -> 2572 + let bt = Printexc.get_raw_backtrace () in 2573 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 2574 + in 2575 + if Requests.Response.ok response then 2576 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 2577 + else 2578 + let body = Requests.Response.text response in 2579 + let status = Requests.Response.status_code response in 2580 + let parsed_body = match status with 2581 + | 404 -> 2582 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2583 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2584 + | Error _ -> None) 2585 + | _ -> 2586 + (match Jsont_bytesrw.decode_string Jsont.json body with 2587 + | Ok json -> Some (Openapi.Runtime.Json json) 2588 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2589 + in 2590 + raise (Openapi.Runtime.Api_error { 2591 + operation = op_name; 2592 + method_ = "GET"; 2593 + url; 2594 + status; 2595 + body; 2596 + parsed_body; 2597 + }) 2598 + 2599 + (** Delete a collection 2600 + 2601 + Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies. 2602 + @param collection_name The name of the collection to delete 2603 + *) 2604 + let delete_collection ~collection_name client () = 2605 + let op_name = "delete_collection" in 2606 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}" in 2607 + let query = "" in 2608 + let url = client.base_url ^ url_path ^ query in 2609 + let response = 2610 + try Requests.delete client.session url 2611 + with Eio.Io _ as ex -> 2612 + let bt = Printexc.get_raw_backtrace () in 2613 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 2614 + in 2615 + if Requests.Response.ok response then 2616 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 2617 + else 2618 + let body = Requests.Response.text response in 2619 + let status = Requests.Response.status_code response in 2620 + let parsed_body = match status with 2621 + | 404 -> 2622 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2623 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2624 + | Error _ -> None) 2625 + | _ -> 2626 + (match Jsont_bytesrw.decode_string Jsont.json body with 2627 + | Ok json -> Some (Openapi.Runtime.Json json) 2628 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2629 + in 2630 + raise (Openapi.Runtime.Api_error { 2631 + operation = op_name; 2632 + method_ = "DELETE"; 2633 + url; 2634 + status; 2635 + body; 2636 + parsed_body; 2637 + }) 2638 + end 2639 + 2640 + module FacetCounts = struct 2641 + module Types = struct 2642 + module T = struct 2643 + type t = { 2644 + counts : Jsont.json list option; 2645 + field_name : string option; 2646 + stats : Jsont.json option; 2647 + } 2648 + end 2649 + end 2650 + 2651 + module T = struct 2652 + include Types.T 2653 + 2654 + let v ?counts ?field_name ?stats () = { counts; field_name; stats } 2655 + 2656 + let counts t = t.counts 2657 + let field_name t = t.field_name 2658 + let stats t = t.stats 2659 + 2660 + let jsont : t Jsont.t = 2661 + Jsont.Object.map ~kind:"FacetCounts" 2662 + (fun counts field_name stats -> { counts; field_name; stats }) 2663 + |> Jsont.Object.opt_mem "counts" (Jsont.list Jsont.json) ~enc:(fun r -> r.counts) 2664 + |> Jsont.Object.opt_mem "field_name" Jsont.string ~enc:(fun r -> r.field_name) 2665 + |> Jsont.Object.opt_mem "stats" Jsont.json ~enc:(fun r -> r.stats) 2666 + |> Jsont.Object.skip_unknown 2667 + |> Jsont.Object.finish 2668 + end 2669 + end 2670 + 2671 + module Search = struct 2672 + module Types = struct 2673 + module Result = struct 2674 + type t = { 2675 + conversation : SearchResultConversation.T.t option; 2676 + facet_counts : FacetCounts.T.t list option; 2677 + found : int option; (** The number of documents found *) 2678 + found_docs : int option; 2679 + grouped_hits : SearchGroupedHit.T.t list option; 2680 + hits : SearchResultHit.T.t list option; (** The documents that matched the search query *) 2681 + metadata : Jsont.json option; (** Custom JSON object that can be returned in the search response *) 2682 + out_of : int option; (** The total number of documents in the collection *) 2683 + page : int option; (** The search result page number *) 2684 + request_params : SearchRequestParams.T.t option; 2685 + search_cutoff : bool option; (** Whether the search was cut off *) 2686 + search_time_ms : int option; (** The number of milliseconds the search took *) 2687 + union_request_params : SearchRequestParams.T.t list option; (** Returned only for union query response. *) 2688 + } 2689 + end 2690 + end 2691 + 2692 + module Result = struct 2693 + include Types.Result 2694 + 2695 + 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 } 2696 + 2697 + let conversation t = t.conversation 2698 + let facet_counts t = t.facet_counts 2699 + let found t = t.found 2700 + let found_docs t = t.found_docs 2701 + let grouped_hits t = t.grouped_hits 2702 + let hits t = t.hits 2703 + let metadata t = t.metadata 2704 + let out_of t = t.out_of 2705 + let page t = t.page 2706 + let request_params t = t.request_params 2707 + let search_cutoff t = t.search_cutoff 2708 + let search_time_ms t = t.search_time_ms 2709 + let union_request_params t = t.union_request_params 2710 + 2711 + let jsont : t Jsont.t = 2712 + Jsont.Object.map ~kind:"SearchResult" 2713 + (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 }) 2714 + |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation) 2715 + |> Jsont.Object.opt_mem "facet_counts" (Jsont.list FacetCounts.T.jsont) ~enc:(fun r -> r.facet_counts) 2716 + |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found) 2717 + |> Jsont.Object.opt_mem "found_docs" Jsont.int ~enc:(fun r -> r.found_docs) 2718 + |> Jsont.Object.opt_mem "grouped_hits" (Jsont.list SearchGroupedHit.T.jsont) ~enc:(fun r -> r.grouped_hits) 2719 + |> Jsont.Object.opt_mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits) 2720 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 2721 + |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of) 2722 + |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 2723 + |> Jsont.Object.opt_mem "request_params" SearchRequestParams.T.jsont ~enc:(fun r -> r.request_params) 2724 + |> Jsont.Object.opt_mem "search_cutoff" Jsont.bool ~enc:(fun r -> r.search_cutoff) 2725 + |> Jsont.Object.opt_mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms) 2726 + |> Jsont.Object.opt_mem "union_request_params" (Jsont.list SearchRequestParams.T.jsont) ~enc:(fun r -> r.union_request_params) 2727 + |> Jsont.Object.skip_unknown 2728 + |> Jsont.Object.finish 2729 + end 2730 + 2731 + (** Search for documents in a collection 2732 + 2733 + Search for documents in a collection that match the search criteria. 2734 + @param collection_name The name of the collection to search for the document under 2735 + *) 2736 + let search_collection ~collection_name ~search_parameters client () = 2737 + let op_name = "search_collection" in 2738 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/search" in 2739 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"searchParameters" ~value:search_parameters]) in 2740 + let url = client.base_url ^ url_path ^ query in 2741 + let response = 2742 + try Requests.get client.session url 2743 + with Eio.Io _ as ex -> 2744 + let bt = Printexc.get_raw_backtrace () in 2745 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 2746 + in 2747 + if Requests.Response.ok response then 2748 + Openapi.Runtime.Json.decode_json_exn Result.jsont (Requests.Response.json response) 2749 + else 2750 + let body = Requests.Response.text response in 2751 + let status = Requests.Response.status_code response in 2752 + let parsed_body = match status with 2753 + | 400 -> 2754 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2755 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2756 + | Error _ -> None) 2757 + | 404 -> 2758 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 2759 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 2760 + | Error _ -> None) 2761 + | _ -> 2762 + (match Jsont_bytesrw.decode_string Jsont.json body with 2763 + | Ok json -> Some (Openapi.Runtime.Json json) 2764 + | Error _ -> Some (Openapi.Runtime.Raw body)) 2765 + in 2766 + raise (Openapi.Runtime.Api_error { 2767 + operation = op_name; 2768 + method_ = "GET"; 2769 + url; 2770 + status; 2771 + body; 2772 + parsed_body; 2773 + }) 2774 + end 2775 + 2776 + module MultiSearchResult = struct 2777 + module Types = struct 2778 + module Item = struct 2779 + type t = { 2780 + conversation : SearchResultConversation.T.t option; 2781 + facet_counts : FacetCounts.T.t list option; 2782 + found : int option; (** The number of documents found *) 2783 + found_docs : int option; 2784 + grouped_hits : SearchGroupedHit.T.t list option; 2785 + hits : SearchResultHit.T.t list option; (** The documents that matched the search query *) 2786 + metadata : Jsont.json option; (** Custom JSON object that can be returned in the search response *) 2787 + out_of : int option; (** The total number of documents in the collection *) 2788 + page : int option; (** The search result page number *) 2789 + request_params : SearchRequestParams.T.t option; 2790 + search_cutoff : bool option; (** Whether the search was cut off *) 2791 + search_time_ms : int option; (** The number of milliseconds the search took *) 2792 + union_request_params : SearchRequestParams.T.t list option; (** Returned only for union query response. *) 2793 + code : int64 option; (** HTTP error code *) 2794 + error : string option; (** Error description *) 2795 + } 2796 + end 2797 + end 2798 + 2799 + module Item = struct 2800 + include Types.Item 2801 + 2802 + 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 } 2803 + 2804 + let conversation t = t.conversation 2805 + let facet_counts t = t.facet_counts 2806 + let found t = t.found 2807 + let found_docs t = t.found_docs 2808 + let grouped_hits t = t.grouped_hits 2809 + let hits t = t.hits 2810 + let metadata t = t.metadata 2811 + let out_of t = t.out_of 2812 + let page t = t.page 2813 + let request_params t = t.request_params 2814 + let search_cutoff t = t.search_cutoff 2815 + let search_time_ms t = t.search_time_ms 2816 + let union_request_params t = t.union_request_params 2817 + let code t = t.code 2818 + let error t = t.error 2819 + 2820 + let jsont : t Jsont.t = 2821 + Jsont.Object.map ~kind:"MultiSearchResultItem" 2822 + (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 }) 2823 + |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation) 2824 + |> Jsont.Object.opt_mem "facet_counts" (Jsont.list FacetCounts.T.jsont) ~enc:(fun r -> r.facet_counts) 2825 + |> Jsont.Object.opt_mem "found" Jsont.int ~enc:(fun r -> r.found) 2826 + |> Jsont.Object.opt_mem "found_docs" Jsont.int ~enc:(fun r -> r.found_docs) 2827 + |> Jsont.Object.opt_mem "grouped_hits" (Jsont.list SearchGroupedHit.T.jsont) ~enc:(fun r -> r.grouped_hits) 2828 + |> Jsont.Object.opt_mem "hits" (Jsont.list SearchResultHit.T.jsont) ~enc:(fun r -> r.hits) 2829 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 2830 + |> Jsont.Object.opt_mem "out_of" Jsont.int ~enc:(fun r -> r.out_of) 2831 + |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 2832 + |> Jsont.Object.opt_mem "request_params" SearchRequestParams.T.jsont ~enc:(fun r -> r.request_params) 2833 + |> Jsont.Object.opt_mem "search_cutoff" Jsont.bool ~enc:(fun r -> r.search_cutoff) 2834 + |> Jsont.Object.opt_mem "search_time_ms" Jsont.int ~enc:(fun r -> r.search_time_ms) 2835 + |> Jsont.Object.opt_mem "union_request_params" (Jsont.list SearchRequestParams.T.jsont) ~enc:(fun r -> r.union_request_params) 2836 + |> Jsont.Object.opt_mem "code" Jsont.int64 ~enc:(fun r -> r.code) 2837 + |> Jsont.Object.opt_mem "error" Jsont.string ~enc:(fun r -> r.error) 2838 + |> Jsont.Object.skip_unknown 2839 + |> Jsont.Object.finish 2840 + end 2841 + end 2842 + 2843 + module DropTokensMode = struct 2844 + module Types = struct 2845 + module T = struct 2846 + (** 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 2847 + *) 2848 + type t = [ 2849 + | `Right_to_left 2850 + | `Left_to_right 2851 + | `Both_sides3 2852 + ] 2853 + end 2854 + end 2855 + 2856 + module T = struct 2857 + include Types.T 2858 + 2859 + let jsont : t Jsont.t = 2860 + Jsont.map Jsont.string ~kind:"DropTokensMode" 2861 + ~dec:(function 2862 + | "right_to_left" -> `Right_to_left 2863 + | "left_to_right" -> `Left_to_right 2864 + | "both_sides:3" -> `Both_sides3 2865 + | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s) 2866 + ~enc:(function 2867 + | `Right_to_left -> "right_to_left" 2868 + | `Left_to_right -> "left_to_right" 2869 + | `Both_sides3 -> "both_sides:3") 2870 + end 2871 + end 2872 + 2873 + module SearchParameters = struct 2874 + module Types = struct 2875 + module T = struct 2876 + type t = { 2877 + 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. 2878 + *) 2879 + conversation : bool option; (** Enable conversational search. 2880 + *) 2881 + conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 2882 + *) 2883 + conversation_model_id : string option; (** The Id of Conversation Model to be used. 2884 + *) 2885 + drop_tokens_mode : DropTokensMode.T.t option; 2886 + 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 2887 + *) 2888 + enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 2889 + *) 2890 + enable_highlight_v1 : bool; (** Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true 2891 + *) 2892 + 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 2893 + *) 2894 + 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 2895 + *) 2896 + enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 2897 + *) 2898 + enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens. 2899 + *) 2900 + exclude_fields : string option; (** List of fields from the document to exclude in the search result *) 2901 + 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). 2902 + *) 2903 + facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 2904 + 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". *) 2905 + facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 2906 + *) 2907 + facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 2908 + *) 2909 + filter_by : string option; (** Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. *) 2910 + 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 2911 + *) 2912 + 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. *) 2913 + 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 2914 + *) 2915 + 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 2916 + *) 2917 + 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`. 2918 + 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`. 2919 + *) 2920 + highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4 2921 + *) 2922 + highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>` 2923 + *) 2924 + highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them 2925 + *) 2926 + highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *) 2927 + highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>` 2928 + *) 2929 + include_fields : string option; (** List of fields from the document to include in the search result *) 2930 + 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 *) 2931 + limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 2932 + *) 2933 + max_candidates : int option; (** Control the number of words that Typesense considers for typo and prefix searching. 2934 + *) 2935 + 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. *) 2936 + 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. *) 2937 + max_facet_values : int option; (** Maximum number of facet values to be returned. *) 2938 + 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*. *) 2939 + 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. 2940 + *) 2941 + 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. 2942 + *) 2943 + nl_model_id : string option; (** The ID of the natural language model to use. *) 2944 + nl_query : bool option; (** Whether to use natural language processing to parse the query. *) 2945 + num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 2946 + *) 2947 + offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 2948 + override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *) 2949 + page : int option; (** Results from this specific page number would be fetched. *) 2950 + per_page : int option; (** Number of results to fetch per page. Default: 10 *) 2951 + 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`. 2952 + 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`. 2953 + *) 2954 + 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. 2955 + Set this parameter to true to do the same 2956 + *) 2957 + 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. *) 2958 + preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 2959 + *) 2960 + prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others 2961 + *) 2962 + prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields. 2963 + *) 2964 + prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text. 2965 + *) 2966 + 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. *) 2967 + query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 2968 + 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. *) 2969 + remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings. 2970 + *) 2971 + remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings. 2972 + *) 2973 + 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. 2974 + *) 2975 + snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 2976 + *) 2977 + 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` *) 2978 + 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`. 2979 + *) 2980 + 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. 2981 + *) 2982 + synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0 2983 + *) 2984 + synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false 2985 + *) 2986 + synonym_sets : string option; (** List of synonym set names to associate with this search query *) 2987 + 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. *) 2988 + 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 2989 + *) 2990 + use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled. 2991 + *) 2992 + vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector. 2993 + *) 2994 + voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format. 2995 + *) 2996 + } 2997 + end 2998 + end 2999 + 3000 + module T = struct 3001 + include Types.T 3002 + 3003 + 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 } 3004 + 3005 + let cache_ttl t = t.cache_ttl 3006 + let conversation t = t.conversation 3007 + let conversation_id t = t.conversation_id 3008 + let conversation_model_id t = t.conversation_model_id 3009 + let drop_tokens_mode t = t.drop_tokens_mode 3010 + let drop_tokens_threshold t = t.drop_tokens_threshold 3011 + let enable_analytics t = t.enable_analytics 3012 + let enable_highlight_v1 t = t.enable_highlight_v1 3013 + let enable_overrides t = t.enable_overrides 3014 + let enable_synonyms t = t.enable_synonyms 3015 + let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens 3016 + let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens 3017 + let exclude_fields t = t.exclude_fields 3018 + let exhaustive_search t = t.exhaustive_search 3019 + let facet_by t = t.facet_by 3020 + let facet_query t = t.facet_query 3021 + let facet_return_parent t = t.facet_return_parent 3022 + let facet_strategy t = t.facet_strategy 3023 + let filter_by t = t.filter_by 3024 + let filter_curated_hits t = t.filter_curated_hits 3025 + let group_by t = t.group_by 3026 + let group_limit t = t.group_limit 3027 + let group_missing_values t = t.group_missing_values 3028 + let hidden_hits t = t.hidden_hits 3029 + let highlight_affix_num_tokens t = t.highlight_affix_num_tokens 3030 + let highlight_end_tag t = t.highlight_end_tag 3031 + let highlight_fields t = t.highlight_fields 3032 + let highlight_full_fields t = t.highlight_full_fields 3033 + let highlight_start_tag t = t.highlight_start_tag 3034 + let include_fields t = t.include_fields 3035 + let infix t = t.infix 3036 + let limit t = t.limit 3037 + let max_candidates t = t.max_candidates 3038 + let max_extra_prefix t = t.max_extra_prefix 3039 + let max_extra_suffix t = t.max_extra_suffix 3040 + let max_facet_values t = t.max_facet_values 3041 + let max_filter_by_candidates t = t.max_filter_by_candidates 3042 + let min_len_1typo t = t.min_len_1typo 3043 + let min_len_2typo t = t.min_len_2typo 3044 + let nl_model_id t = t.nl_model_id 3045 + let nl_query t = t.nl_query 3046 + let num_typos t = t.num_typos 3047 + let offset t = t.offset 3048 + let override_tags t = t.override_tags 3049 + let page t = t.page 3050 + let per_page t = t.per_page 3051 + let pinned_hits t = t.pinned_hits 3052 + let pre_segmented_query t = t.pre_segmented_query 3053 + let prefix t = t.prefix 3054 + let preset t = t.preset 3055 + let prioritize_exact_match t = t.prioritize_exact_match 3056 + let prioritize_num_matching_fields t = t.prioritize_num_matching_fields 3057 + let prioritize_token_position t = t.prioritize_token_position 3058 + let q t = t.q 3059 + let query_by t = t.query_by 3060 + let query_by_weights t = t.query_by_weights 3061 + let remote_embedding_num_tries t = t.remote_embedding_num_tries 3062 + let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms 3063 + let search_cutoff_ms t = t.search_cutoff_ms 3064 + let snippet_threshold t = t.snippet_threshold 3065 + let sort_by t = t.sort_by 3066 + let split_join_tokens t = t.split_join_tokens 3067 + let stopwords t = t.stopwords 3068 + let synonym_num_typos t = t.synonym_num_typos 3069 + let synonym_prefix t = t.synonym_prefix 3070 + let synonym_sets t = t.synonym_sets 3071 + let text_match_type t = t.text_match_type 3072 + let typo_tokens_threshold t = t.typo_tokens_threshold 3073 + let use_cache t = t.use_cache 3074 + let vector_query t = t.vector_query 3075 + let voice_query t = t.voice_query 3076 + 3077 + let jsont : t Jsont.t = 3078 + Jsont.Object.map ~kind:"SearchParameters" 3079 + (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 }) 3080 + |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl) 3081 + |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation) 3082 + |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id) 3083 + |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id) 3084 + |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode) 3085 + |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold) 3086 + |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics) 3087 + |> Jsont.Object.mem "enable_highlight_v1" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_highlight_v1) 3088 + |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides) 3089 + |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms) 3090 + |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens) 3091 + |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens) 3092 + |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields) 3093 + |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search) 3094 + |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by) 3095 + |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query) 3096 + |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent) 3097 + |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy) 3098 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 3099 + |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits) 3100 + |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by) 3101 + |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit) 3102 + |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values) 3103 + |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits) 3104 + |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens) 3105 + |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag) 3106 + |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields) 3107 + |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields) 3108 + |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag) 3109 + |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields) 3110 + |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix) 3111 + |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit) 3112 + |> Jsont.Object.opt_mem "max_candidates" Jsont.int ~enc:(fun r -> r.max_candidates) 3113 + |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix) 3114 + |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix) 3115 + |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values) 3116 + |> Jsont.Object.opt_mem "max_filter_by_candidates" Jsont.int ~enc:(fun r -> r.max_filter_by_candidates) 3117 + |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo) 3118 + |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo) 3119 + |> Jsont.Object.opt_mem "nl_model_id" Jsont.string ~enc:(fun r -> r.nl_model_id) 3120 + |> Jsont.Object.opt_mem "nl_query" Jsont.bool ~enc:(fun r -> r.nl_query) 3121 + |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos) 3122 + |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset) 3123 + |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags) 3124 + |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 3125 + |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page) 3126 + |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits) 3127 + |> Jsont.Object.opt_mem "pre_segmented_query" Jsont.bool ~enc:(fun r -> r.pre_segmented_query) 3128 + |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix) 3129 + |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset) 3130 + |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match) 3131 + |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields) 3132 + |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position) 3133 + |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q) 3134 + |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by) 3135 + |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights) 3136 + |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries) 3137 + |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms) 3138 + |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms) 3139 + |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold) 3140 + |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 3141 + |> Jsont.Object.opt_mem "split_join_tokens" Jsont.string ~enc:(fun r -> r.split_join_tokens) 3142 + |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords) 3143 + |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos) 3144 + |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix) 3145 + |> Jsont.Object.opt_mem "synonym_sets" Jsont.string ~enc:(fun r -> r.synonym_sets) 3146 + |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type) 3147 + |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold) 3148 + |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache) 3149 + |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query) 3150 + |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query) 3151 + |> Jsont.Object.skip_unknown 3152 + |> Jsont.Object.finish 3153 + end 3154 + end 3155 + 3156 + module MultiSearchParameters = struct 3157 + module Types = struct 3158 + module T = struct 3159 + (** Parameters for the multi search API. 3160 + *) 3161 + type t = { 3162 + 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. 3163 + *) 3164 + conversation : bool option; (** Enable conversational search. 3165 + *) 3166 + conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 3167 + *) 3168 + conversation_model_id : string option; (** The Id of Conversation Model to be used. 3169 + *) 3170 + drop_tokens_mode : DropTokensMode.T.t option; 3171 + 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 3172 + *) 3173 + enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 3174 + *) 3175 + 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 3176 + *) 3177 + 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 3178 + *) 3179 + enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 3180 + *) 3181 + enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens. 3182 + *) 3183 + exclude_fields : string option; (** List of fields from the document to exclude in the search result *) 3184 + 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). 3185 + *) 3186 + facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 3187 + 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". *) 3188 + facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 3189 + *) 3190 + facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 3191 + *) 3192 + filter_by : string option; (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *) 3193 + 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 3194 + *) 3195 + 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. *) 3196 + 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 3197 + *) 3198 + 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 3199 + *) 3200 + 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`. 3201 + 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`. 3202 + *) 3203 + highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4 3204 + *) 3205 + highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>` 3206 + *) 3207 + highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them 3208 + *) 3209 + highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *) 3210 + highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>` 3211 + *) 3212 + include_fields : string option; (** List of fields from the document to include in the search result *) 3213 + 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 *) 3214 + limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 3215 + *) 3216 + 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. *) 3217 + 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. *) 3218 + max_facet_values : int option; (** Maximum number of facet values to be returned. *) 3219 + 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. 3220 + *) 3221 + 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. 3222 + *) 3223 + num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 3224 + *) 3225 + offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 3226 + override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *) 3227 + page : int option; (** Results from this specific page number would be fetched. *) 3228 + per_page : int option; (** Number of results to fetch per page. Default: 10 *) 3229 + 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`. 3230 + 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`. 3231 + *) 3232 + 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. 3233 + Set this parameter to true to do the same 3234 + *) 3235 + 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. *) 3236 + preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 3237 + *) 3238 + prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others 3239 + *) 3240 + prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields. 3241 + *) 3242 + prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text. 3243 + *) 3244 + 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. *) 3245 + query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 3246 + 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. *) 3247 + remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings. 3248 + *) 3249 + remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings. 3250 + *) 3251 + 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. 3252 + *) 3253 + snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 3254 + *) 3255 + 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` *) 3256 + 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. 3257 + *) 3258 + synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0 3259 + *) 3260 + synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false 3261 + *) 3262 + 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. *) 3263 + 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 3264 + *) 3265 + use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled. 3266 + *) 3267 + vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector. 3268 + *) 3269 + voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format. 3270 + *) 3271 + } 3272 + end 3273 + end 3274 + 3275 + module T = struct 3276 + include Types.T 3277 + 3278 + 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 } 3279 + 3280 + let cache_ttl t = t.cache_ttl 3281 + let conversation t = t.conversation 3282 + let conversation_id t = t.conversation_id 3283 + let conversation_model_id t = t.conversation_model_id 3284 + let drop_tokens_mode t = t.drop_tokens_mode 3285 + let drop_tokens_threshold t = t.drop_tokens_threshold 3286 + let enable_analytics t = t.enable_analytics 3287 + let enable_overrides t = t.enable_overrides 3288 + let enable_synonyms t = t.enable_synonyms 3289 + let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens 3290 + let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens 3291 + let exclude_fields t = t.exclude_fields 3292 + let exhaustive_search t = t.exhaustive_search 3293 + let facet_by t = t.facet_by 3294 + let facet_query t = t.facet_query 3295 + let facet_return_parent t = t.facet_return_parent 3296 + let facet_strategy t = t.facet_strategy 3297 + let filter_by t = t.filter_by 3298 + let filter_curated_hits t = t.filter_curated_hits 3299 + let group_by t = t.group_by 3300 + let group_limit t = t.group_limit 3301 + let group_missing_values t = t.group_missing_values 3302 + let hidden_hits t = t.hidden_hits 3303 + let highlight_affix_num_tokens t = t.highlight_affix_num_tokens 3304 + let highlight_end_tag t = t.highlight_end_tag 3305 + let highlight_fields t = t.highlight_fields 3306 + let highlight_full_fields t = t.highlight_full_fields 3307 + let highlight_start_tag t = t.highlight_start_tag 3308 + let include_fields t = t.include_fields 3309 + let infix t = t.infix 3310 + let limit t = t.limit 3311 + let max_extra_prefix t = t.max_extra_prefix 3312 + let max_extra_suffix t = t.max_extra_suffix 3313 + let max_facet_values t = t.max_facet_values 3314 + let min_len_1typo t = t.min_len_1typo 3315 + let min_len_2typo t = t.min_len_2typo 3316 + let num_typos t = t.num_typos 3317 + let offset t = t.offset 3318 + let override_tags t = t.override_tags 3319 + let page t = t.page 3320 + let per_page t = t.per_page 3321 + let pinned_hits t = t.pinned_hits 3322 + let pre_segmented_query t = t.pre_segmented_query 3323 + let prefix t = t.prefix 3324 + let preset t = t.preset 3325 + let prioritize_exact_match t = t.prioritize_exact_match 3326 + let prioritize_num_matching_fields t = t.prioritize_num_matching_fields 3327 + let prioritize_token_position t = t.prioritize_token_position 3328 + let q t = t.q 3329 + let query_by t = t.query_by 3330 + let query_by_weights t = t.query_by_weights 3331 + let remote_embedding_num_tries t = t.remote_embedding_num_tries 3332 + let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms 3333 + let search_cutoff_ms t = t.search_cutoff_ms 3334 + let snippet_threshold t = t.snippet_threshold 3335 + let sort_by t = t.sort_by 3336 + let stopwords t = t.stopwords 3337 + let synonym_num_typos t = t.synonym_num_typos 3338 + let synonym_prefix t = t.synonym_prefix 3339 + let text_match_type t = t.text_match_type 3340 + let typo_tokens_threshold t = t.typo_tokens_threshold 3341 + let use_cache t = t.use_cache 3342 + let vector_query t = t.vector_query 3343 + let voice_query t = t.voice_query 3344 + 3345 + let jsont : t Jsont.t = 3346 + Jsont.Object.map ~kind:"MultiSearchParameters" 3347 + (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 }) 3348 + |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl) 3349 + |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation) 3350 + |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id) 3351 + |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id) 3352 + |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode) 3353 + |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold) 3354 + |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics) 3355 + |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides) 3356 + |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms) 3357 + |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens) 3358 + |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens) 3359 + |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields) 3360 + |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search) 3361 + |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by) 3362 + |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query) 3363 + |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent) 3364 + |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy) 3365 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 3366 + |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits) 3367 + |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by) 3368 + |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit) 3369 + |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values) 3370 + |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits) 3371 + |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens) 3372 + |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag) 3373 + |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields) 3374 + |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields) 3375 + |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag) 3376 + |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields) 3377 + |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix) 3378 + |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit) 3379 + |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix) 3380 + |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix) 3381 + |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values) 3382 + |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo) 3383 + |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo) 3384 + |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos) 3385 + |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset) 3386 + |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags) 3387 + |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 3388 + |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page) 3389 + |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits) 3390 + |> Jsont.Object.mem "pre_segmented_query" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.pre_segmented_query) 3391 + |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix) 3392 + |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset) 3393 + |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match) 3394 + |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields) 3395 + |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position) 3396 + |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q) 3397 + |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by) 3398 + |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights) 3399 + |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries) 3400 + |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms) 3401 + |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms) 3402 + |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold) 3403 + |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 3404 + |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords) 3405 + |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos) 3406 + |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix) 3407 + |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type) 3408 + |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold) 3409 + |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache) 3410 + |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query) 3411 + |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query) 3412 + |> Jsont.Object.skip_unknown 3413 + |> Jsont.Object.finish 3414 + end 3415 + end 3416 + 3417 + module MultiSearchCollectionParameters = struct 3418 + module Types = struct 3419 + module T = struct 3420 + type t = { 3421 + 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. 3422 + *) 3423 + conversation : bool option; (** Enable conversational search. 3424 + *) 3425 + conversation_id : string option; (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 3426 + *) 3427 + conversation_model_id : string option; (** The Id of Conversation Model to be used. 3428 + *) 3429 + drop_tokens_mode : DropTokensMode.T.t option; 3430 + 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 3431 + *) 3432 + enable_analytics : bool; (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 3433 + *) 3434 + 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 3435 + *) 3436 + 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 3437 + *) 3438 + enable_typos_for_alpha_numerical_tokens : bool option; (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 3439 + *) 3440 + enable_typos_for_numerical_tokens : bool; (** Make Typesense disable typos for numerical tokens. 3441 + *) 3442 + exclude_fields : string option; (** List of fields from the document to exclude in the search result *) 3443 + 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). 3444 + *) 3445 + facet_by : string option; (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 3446 + 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". *) 3447 + facet_return_parent : string option; (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 3448 + *) 3449 + facet_strategy : string option; (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 3450 + *) 3451 + filter_by : string option; (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *) 3452 + 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 3453 + *) 3454 + 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. *) 3455 + 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 3456 + *) 3457 + 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 3458 + *) 3459 + 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`. 3460 + 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`. 3461 + *) 3462 + highlight_affix_num_tokens : int option; (** The number of tokens that should surround the highlighted text on each side. Default: 4 3463 + *) 3464 + highlight_end_tag : string option; (** The end tag used for the highlighted snippets. Default: `</mark>` 3465 + *) 3466 + highlight_fields : string option; (** A list of custom fields that must be highlighted even if you don't query for them 3467 + *) 3468 + highlight_full_fields : string option; (** List of fields which should be highlighted fully without snippeting *) 3469 + highlight_start_tag : string option; (** The start tag used for the highlighted snippets. Default: `<mark>` 3470 + *) 3471 + include_fields : string option; (** List of fields from the document to include in the search result *) 3472 + 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 *) 3473 + limit : int option; (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 3474 + *) 3475 + 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. *) 3476 + 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. *) 3477 + max_facet_values : int option; (** Maximum number of facet values to be returned. *) 3478 + 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. 3479 + *) 3480 + 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. 3481 + *) 3482 + num_typos : string option; (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 3483 + *) 3484 + offset : int option; (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 3485 + override_tags : string option; (** Comma separated list of tags to trigger the curations rules that match the tags. *) 3486 + page : int option; (** Results from this specific page number would be fetched. *) 3487 + per_page : int option; (** Number of results to fetch per page. Default: 10 *) 3488 + 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`. 3489 + 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`. 3490 + *) 3491 + 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. 3492 + Set this parameter to true to do the same 3493 + *) 3494 + 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. *) 3495 + preset : string option; (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 3496 + *) 3497 + prioritize_exact_match : bool; (** Set this parameter to true to ensure that an exact match is ranked above the others 3498 + *) 3499 + prioritize_num_matching_fields : bool; (** Make Typesense prioritize documents where the query words appear in more number of fields. 3500 + *) 3501 + prioritize_token_position : bool; (** Make Typesense prioritize documents where the query words appear earlier in the text. 3502 + *) 3503 + 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. *) 3504 + query_by : string option; (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 3505 + 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. *) 3506 + remote_embedding_num_tries : int option; (** Number of times to retry fetching remote embeddings. 3507 + *) 3508 + remote_embedding_timeout_ms : int option; (** Timeout (in milliseconds) for fetching remote embeddings. 3509 + *) 3510 + 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. 3511 + *) 3512 + snippet_threshold : int option; (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 3513 + *) 3514 + 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` *) 3515 + 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. 3516 + *) 3517 + synonym_num_typos : int option; (** Allow synonym resolution on typo-corrected words in the query. Default: 0 3518 + *) 3519 + synonym_prefix : bool option; (** Allow synonym resolution on word prefixes in the query. Default: false 3520 + *) 3521 + 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. *) 3522 + 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 3523 + *) 3524 + use_cache : bool option; (** Enable server side caching of search query results. By default, caching is disabled. 3525 + *) 3526 + vector_query : string option; (** Vector query expression for fetching documents "closest" to a given query/document vector. 3527 + *) 3528 + voice_query : string option; (** The base64 encoded audio file in 16 khz 16-bit WAV format. 3529 + *) 3530 + collection : string option; (** The collection to search in. 3531 + *) 3532 + x_typesense_api_key : string option; (** A separate search API key for each search within a multi_search request *) 3533 + 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. 3534 + *) 3535 + } 3536 + end 3537 + end 3538 + 3539 + module T = struct 3540 + include Types.T 3541 + 3542 + 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 } 3543 + 3544 + let cache_ttl t = t.cache_ttl 3545 + let conversation t = t.conversation 3546 + let conversation_id t = t.conversation_id 3547 + let conversation_model_id t = t.conversation_model_id 3548 + let drop_tokens_mode t = t.drop_tokens_mode 3549 + let drop_tokens_threshold t = t.drop_tokens_threshold 3550 + let enable_analytics t = t.enable_analytics 3551 + let enable_overrides t = t.enable_overrides 3552 + let enable_synonyms t = t.enable_synonyms 3553 + let enable_typos_for_alpha_numerical_tokens t = t.enable_typos_for_alpha_numerical_tokens 3554 + let enable_typos_for_numerical_tokens t = t.enable_typos_for_numerical_tokens 3555 + let exclude_fields t = t.exclude_fields 3556 + let exhaustive_search t = t.exhaustive_search 3557 + let facet_by t = t.facet_by 3558 + let facet_query t = t.facet_query 3559 + let facet_return_parent t = t.facet_return_parent 3560 + let facet_strategy t = t.facet_strategy 3561 + let filter_by t = t.filter_by 3562 + let filter_curated_hits t = t.filter_curated_hits 3563 + let group_by t = t.group_by 3564 + let group_limit t = t.group_limit 3565 + let group_missing_values t = t.group_missing_values 3566 + let hidden_hits t = t.hidden_hits 3567 + let highlight_affix_num_tokens t = t.highlight_affix_num_tokens 3568 + let highlight_end_tag t = t.highlight_end_tag 3569 + let highlight_fields t = t.highlight_fields 3570 + let highlight_full_fields t = t.highlight_full_fields 3571 + let highlight_start_tag t = t.highlight_start_tag 3572 + let include_fields t = t.include_fields 3573 + let infix t = t.infix 3574 + let limit t = t.limit 3575 + let max_extra_prefix t = t.max_extra_prefix 3576 + let max_extra_suffix t = t.max_extra_suffix 3577 + let max_facet_values t = t.max_facet_values 3578 + let min_len_1typo t = t.min_len_1typo 3579 + let min_len_2typo t = t.min_len_2typo 3580 + let num_typos t = t.num_typos 3581 + let offset t = t.offset 3582 + let override_tags t = t.override_tags 3583 + let page t = t.page 3584 + let per_page t = t.per_page 3585 + let pinned_hits t = t.pinned_hits 3586 + let pre_segmented_query t = t.pre_segmented_query 3587 + let prefix t = t.prefix 3588 + let preset t = t.preset 3589 + let prioritize_exact_match t = t.prioritize_exact_match 3590 + let prioritize_num_matching_fields t = t.prioritize_num_matching_fields 3591 + let prioritize_token_position t = t.prioritize_token_position 3592 + let q t = t.q 3593 + let query_by t = t.query_by 3594 + let query_by_weights t = t.query_by_weights 3595 + let remote_embedding_num_tries t = t.remote_embedding_num_tries 3596 + let remote_embedding_timeout_ms t = t.remote_embedding_timeout_ms 3597 + let search_cutoff_ms t = t.search_cutoff_ms 3598 + let snippet_threshold t = t.snippet_threshold 3599 + let sort_by t = t.sort_by 3600 + let stopwords t = t.stopwords 3601 + let synonym_num_typos t = t.synonym_num_typos 3602 + let synonym_prefix t = t.synonym_prefix 3603 + let text_match_type t = t.text_match_type 3604 + let typo_tokens_threshold t = t.typo_tokens_threshold 3605 + let use_cache t = t.use_cache 3606 + let vector_query t = t.vector_query 3607 + let voice_query t = t.voice_query 3608 + let collection t = t.collection 3609 + let x_typesense_api_key t = t.x_typesense_api_key 3610 + let rerank_hybrid_matches t = t.rerank_hybrid_matches 3611 + 3612 + let jsont : t Jsont.t = 3613 + Jsont.Object.map ~kind:"MultiSearchCollectionParameters" 3614 + (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 }) 3615 + |> Jsont.Object.opt_mem "cache_ttl" Jsont.int ~enc:(fun r -> r.cache_ttl) 3616 + |> Jsont.Object.opt_mem "conversation" Jsont.bool ~enc:(fun r -> r.conversation) 3617 + |> Jsont.Object.opt_mem "conversation_id" Jsont.string ~enc:(fun r -> r.conversation_id) 3618 + |> Jsont.Object.opt_mem "conversation_model_id" Jsont.string ~enc:(fun r -> r.conversation_model_id) 3619 + |> Jsont.Object.opt_mem "drop_tokens_mode" DropTokensMode.T.jsont ~enc:(fun r -> r.drop_tokens_mode) 3620 + |> Jsont.Object.opt_mem "drop_tokens_threshold" Jsont.int ~enc:(fun r -> r.drop_tokens_threshold) 3621 + |> Jsont.Object.mem "enable_analytics" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_analytics) 3622 + |> Jsont.Object.mem "enable_overrides" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.enable_overrides) 3623 + |> Jsont.Object.opt_mem "enable_synonyms" Jsont.bool ~enc:(fun r -> r.enable_synonyms) 3624 + |> Jsont.Object.opt_mem "enable_typos_for_alpha_numerical_tokens" Jsont.bool ~enc:(fun r -> r.enable_typos_for_alpha_numerical_tokens) 3625 + |> Jsont.Object.mem "enable_typos_for_numerical_tokens" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.enable_typos_for_numerical_tokens) 3626 + |> Jsont.Object.opt_mem "exclude_fields" Jsont.string ~enc:(fun r -> r.exclude_fields) 3627 + |> Jsont.Object.opt_mem "exhaustive_search" Jsont.bool ~enc:(fun r -> r.exhaustive_search) 3628 + |> Jsont.Object.opt_mem "facet_by" Jsont.string ~enc:(fun r -> r.facet_by) 3629 + |> Jsont.Object.opt_mem "facet_query" Jsont.string ~enc:(fun r -> r.facet_query) 3630 + |> Jsont.Object.opt_mem "facet_return_parent" Jsont.string ~enc:(fun r -> r.facet_return_parent) 3631 + |> Jsont.Object.opt_mem "facet_strategy" Jsont.string ~enc:(fun r -> r.facet_strategy) 3632 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 3633 + |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits) 3634 + |> Jsont.Object.opt_mem "group_by" Jsont.string ~enc:(fun r -> r.group_by) 3635 + |> Jsont.Object.opt_mem "group_limit" Jsont.int ~enc:(fun r -> r.group_limit) 3636 + |> Jsont.Object.opt_mem "group_missing_values" Jsont.bool ~enc:(fun r -> r.group_missing_values) 3637 + |> Jsont.Object.opt_mem "hidden_hits" Jsont.string ~enc:(fun r -> r.hidden_hits) 3638 + |> Jsont.Object.opt_mem "highlight_affix_num_tokens" Jsont.int ~enc:(fun r -> r.highlight_affix_num_tokens) 3639 + |> Jsont.Object.opt_mem "highlight_end_tag" Jsont.string ~enc:(fun r -> r.highlight_end_tag) 3640 + |> Jsont.Object.opt_mem "highlight_fields" Jsont.string ~enc:(fun r -> r.highlight_fields) 3641 + |> Jsont.Object.opt_mem "highlight_full_fields" Jsont.string ~enc:(fun r -> r.highlight_full_fields) 3642 + |> Jsont.Object.opt_mem "highlight_start_tag" Jsont.string ~enc:(fun r -> r.highlight_start_tag) 3643 + |> Jsont.Object.opt_mem "include_fields" Jsont.string ~enc:(fun r -> r.include_fields) 3644 + |> Jsont.Object.opt_mem "infix" Jsont.string ~enc:(fun r -> r.infix) 3645 + |> Jsont.Object.opt_mem "limit" Jsont.int ~enc:(fun r -> r.limit) 3646 + |> Jsont.Object.opt_mem "max_extra_prefix" Jsont.int ~enc:(fun r -> r.max_extra_prefix) 3647 + |> Jsont.Object.opt_mem "max_extra_suffix" Jsont.int ~enc:(fun r -> r.max_extra_suffix) 3648 + |> Jsont.Object.opt_mem "max_facet_values" Jsont.int ~enc:(fun r -> r.max_facet_values) 3649 + |> Jsont.Object.opt_mem "min_len_1typo" Jsont.int ~enc:(fun r -> r.min_len_1typo) 3650 + |> Jsont.Object.opt_mem "min_len_2typo" Jsont.int ~enc:(fun r -> r.min_len_2typo) 3651 + |> Jsont.Object.opt_mem "num_typos" Jsont.string ~enc:(fun r -> r.num_typos) 3652 + |> Jsont.Object.opt_mem "offset" Jsont.int ~enc:(fun r -> r.offset) 3653 + |> Jsont.Object.opt_mem "override_tags" Jsont.string ~enc:(fun r -> r.override_tags) 3654 + |> Jsont.Object.opt_mem "page" Jsont.int ~enc:(fun r -> r.page) 3655 + |> Jsont.Object.opt_mem "per_page" Jsont.int ~enc:(fun r -> r.per_page) 3656 + |> Jsont.Object.opt_mem "pinned_hits" Jsont.string ~enc:(fun r -> r.pinned_hits) 3657 + |> Jsont.Object.mem "pre_segmented_query" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.pre_segmented_query) 3658 + |> Jsont.Object.opt_mem "prefix" Jsont.string ~enc:(fun r -> r.prefix) 3659 + |> Jsont.Object.opt_mem "preset" Jsont.string ~enc:(fun r -> r.preset) 3660 + |> Jsont.Object.mem "prioritize_exact_match" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_exact_match) 3661 + |> Jsont.Object.mem "prioritize_num_matching_fields" Jsont.bool ~dec_absent:true ~enc:(fun r -> r.prioritize_num_matching_fields) 3662 + |> Jsont.Object.mem "prioritize_token_position" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.prioritize_token_position) 3663 + |> Jsont.Object.opt_mem "q" Jsont.string ~enc:(fun r -> r.q) 3664 + |> Jsont.Object.opt_mem "query_by" Jsont.string ~enc:(fun r -> r.query_by) 3665 + |> Jsont.Object.opt_mem "query_by_weights" Jsont.string ~enc:(fun r -> r.query_by_weights) 3666 + |> Jsont.Object.opt_mem "remote_embedding_num_tries" Jsont.int ~enc:(fun r -> r.remote_embedding_num_tries) 3667 + |> Jsont.Object.opt_mem "remote_embedding_timeout_ms" Jsont.int ~enc:(fun r -> r.remote_embedding_timeout_ms) 3668 + |> Jsont.Object.opt_mem "search_cutoff_ms" Jsont.int ~enc:(fun r -> r.search_cutoff_ms) 3669 + |> Jsont.Object.opt_mem "snippet_threshold" Jsont.int ~enc:(fun r -> r.snippet_threshold) 3670 + |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 3671 + |> Jsont.Object.opt_mem "stopwords" Jsont.string ~enc:(fun r -> r.stopwords) 3672 + |> Jsont.Object.opt_mem "synonym_num_typos" Jsont.int ~enc:(fun r -> r.synonym_num_typos) 3673 + |> Jsont.Object.opt_mem "synonym_prefix" Jsont.bool ~enc:(fun r -> r.synonym_prefix) 3674 + |> Jsont.Object.opt_mem "text_match_type" Jsont.string ~enc:(fun r -> r.text_match_type) 3675 + |> Jsont.Object.opt_mem "typo_tokens_threshold" Jsont.int ~enc:(fun r -> r.typo_tokens_threshold) 3676 + |> Jsont.Object.opt_mem "use_cache" Jsont.bool ~enc:(fun r -> r.use_cache) 3677 + |> Jsont.Object.opt_mem "vector_query" Jsont.string ~enc:(fun r -> r.vector_query) 3678 + |> Jsont.Object.opt_mem "voice_query" Jsont.string ~enc:(fun r -> r.voice_query) 3679 + |> Jsont.Object.opt_mem "collection" Jsont.string ~enc:(fun r -> r.collection) 3680 + |> Jsont.Object.opt_mem "x-typesense-api-key" Jsont.string ~enc:(fun r -> r.x_typesense_api_key) 3681 + |> Jsont.Object.mem "rerank_hybrid_matches" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.rerank_hybrid_matches) 3682 + |> Jsont.Object.skip_unknown 3683 + |> Jsont.Object.finish 3684 + end 3685 + end 3686 + 3687 + module MultiSearchSearchesParameter = struct 3688 + module Types = struct 3689 + module T = struct 3690 + type t = { 3691 + searches : MultiSearchCollectionParameters.T.t list; 3692 + union : bool; (** When true, merges the search results from each search query into a single ordered set of hits. *) 3693 + } 3694 + end 3695 + end 3696 + 3697 + module T = struct 3698 + include Types.T 3699 + 3700 + let v ~searches ?(union=false) () = { searches; union } 3701 + 3702 + let searches t = t.searches 3703 + let union t = t.union 3704 + 3705 + let jsont : t Jsont.t = 3706 + Jsont.Object.map ~kind:"MultiSearchSearchesParameter" 3707 + (fun searches union -> { searches; union }) 3708 + |> Jsont.Object.mem "searches" (Jsont.list MultiSearchCollectionParameters.T.jsont) ~enc:(fun r -> r.searches) 3709 + |> Jsont.Object.mem "union" Jsont.bool ~dec_absent:false ~enc:(fun r -> r.union) 3710 + |> Jsont.Object.skip_unknown 3711 + |> Jsont.Object.finish 3712 + end 3713 + end 3714 + 3715 + module MultiSearch = struct 3716 + module Types = struct 3717 + module Result = struct 3718 + type t = { 3719 + conversation : SearchResultConversation.T.t option; 3720 + results : MultiSearchResult.Item.t list; 3721 + } 3722 + end 3723 + end 3724 + 3725 + module Result = struct 3726 + include Types.Result 3727 + 3728 + let v ~results ?conversation () = { conversation; results } 3729 + 3730 + let conversation t = t.conversation 3731 + let results t = t.results 3732 + 3733 + let jsont : t Jsont.t = 3734 + Jsont.Object.map ~kind:"MultiSearchResult" 3735 + (fun conversation results -> { conversation; results }) 3736 + |> Jsont.Object.opt_mem "conversation" SearchResultConversation.T.jsont ~enc:(fun r -> r.conversation) 3737 + |> Jsont.Object.mem "results" (Jsont.list MultiSearchResult.Item.jsont) ~enc:(fun r -> r.results) 3738 + |> Jsont.Object.skip_unknown 3739 + |> Jsont.Object.finish 3740 + end 3741 + 3742 + (** send multiple search requests in a single HTTP request 3743 + 3744 + 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. *) 3745 + let multi_search ~multi_search_parameters ~body client () = 3746 + let op_name = "multi_search" in 3747 + let url_path = "/multi_search" in 3748 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"multiSearchParameters" ~value:multi_search_parameters]) in 3749 + let url = client.base_url ^ url_path ^ query in 3750 + let response = 3751 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json MultiSearchSearchesParameter.T.jsont body)) url 3752 + with Eio.Io _ as ex -> 3753 + let bt = Printexc.get_raw_backtrace () in 3754 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 3755 + in 3756 + if Requests.Response.ok response then 3757 + Openapi.Runtime.Json.decode_json_exn Result.jsont (Requests.Response.json response) 3758 + else 3759 + let body = Requests.Response.text response in 3760 + let status = Requests.Response.status_code response in 3761 + let parsed_body = match status with 3762 + | 400 -> 3763 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 3764 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 3765 + | Error _ -> None) 3766 + | _ -> 3767 + (match Jsont_bytesrw.decode_string Jsont.json body with 3768 + | Ok json -> Some (Openapi.Runtime.Json json) 3769 + | Error _ -> Some (Openapi.Runtime.Raw body)) 3770 + in 3771 + raise (Openapi.Runtime.Api_error { 3772 + operation = op_name; 3773 + method_ = "POST"; 3774 + url; 3775 + status; 3776 + body; 3777 + parsed_body; 3778 + }) 3779 + end 3780 + 3781 + module DirtyValues = struct 3782 + module Types = struct 3783 + module T = struct 3784 + type t = [ 3785 + | `Coerce_or_reject 3786 + | `Coerce_or_drop 3787 + | `Drop 3788 + | `Reject 3789 + ] 3790 + end 3791 + end 3792 + 3793 + module T = struct 3794 + include Types.T 3795 + 3796 + let jsont : t Jsont.t = 3797 + Jsont.map Jsont.string ~kind:"DirtyValues" 3798 + ~dec:(function 3799 + | "coerce_or_reject" -> `Coerce_or_reject 3800 + | "coerce_or_drop" -> `Coerce_or_drop 3801 + | "drop" -> `Drop 3802 + | "reject" -> `Reject 3803 + | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s) 3804 + ~enc:(function 3805 + | `Coerce_or_reject -> "coerce_or_reject" 3806 + | `Coerce_or_drop -> "coerce_or_drop" 3807 + | `Drop -> "drop" 3808 + | `Reject -> "reject") 3809 + end 3810 + end 3811 + 3812 + module CurationSetDeleteSchema = struct 3813 + module Types = struct 3814 + module T = struct 3815 + type t = { 3816 + name : string; (** Name of the deleted curation set *) 3817 + } 3818 + end 3819 + end 3820 + 3821 + module T = struct 3822 + include Types.T 3823 + 3824 + let v ~name () = { name } 3825 + 3826 + let name t = t.name 3827 + 3828 + let jsont : t Jsont.t = 3829 + Jsont.Object.map ~kind:"CurationSetDeleteSchema" 3830 + (fun name -> { name }) 3831 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 3832 + |> Jsont.Object.skip_unknown 3833 + |> Jsont.Object.finish 3834 + end 3835 + 3836 + (** Delete a curation set 3837 + 3838 + Delete a specific curation set by its name 3839 + @param curation_set_name The name of the curation set to delete 3840 + *) 3841 + let delete_curation_set ~curation_set_name client () = 3842 + let op_name = "delete_curation_set" in 3843 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in 3844 + let query = "" in 3845 + let url = client.base_url ^ url_path ^ query in 3846 + let response = 3847 + try Requests.delete client.session url 3848 + with Eio.Io _ as ex -> 3849 + let bt = Printexc.get_raw_backtrace () in 3850 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 3851 + in 3852 + if Requests.Response.ok response then 3853 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 3854 + else 3855 + let body = Requests.Response.text response in 3856 + let status = Requests.Response.status_code response in 3857 + let parsed_body = match status with 3858 + | 404 -> 3859 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 3860 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 3861 + | Error _ -> None) 3862 + | _ -> 3863 + (match Jsont_bytesrw.decode_string Jsont.json body with 3864 + | Ok json -> Some (Openapi.Runtime.Json json) 3865 + | Error _ -> Some (Openapi.Runtime.Raw body)) 3866 + in 3867 + raise (Openapi.Runtime.Api_error { 3868 + operation = op_name; 3869 + method_ = "DELETE"; 3870 + url; 3871 + status; 3872 + body; 3873 + parsed_body; 3874 + }) 3875 + end 3876 + 3877 + module CurationRule = struct 3878 + module Types = struct 3879 + module T = struct 3880 + type t = { 3881 + 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). 3882 + *) 3883 + 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. 3884 + *) 3885 + query : string option; (** Indicates what search queries should be curated *) 3886 + tags : string list option; (** List of tag values to associate with this curation rule. *) 3887 + } 3888 + end 3889 + end 3890 + 3891 + module T = struct 3892 + include Types.T 3893 + 3894 + let v ?filter_by ?match_ ?query ?tags () = { filter_by; match_; query; tags } 3895 + 3896 + let filter_by t = t.filter_by 3897 + let match_ t = t.match_ 3898 + let query t = t.query 3899 + let tags t = t.tags 3900 + 3901 + let jsont : t Jsont.t = 3902 + Jsont.Object.map ~kind:"CurationRule" 3903 + (fun filter_by match_ query tags -> { filter_by; match_; query; tags }) 3904 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 3905 + |> Jsont.Object.opt_mem "match" Jsont.string ~enc:(fun r -> r.match_) 3906 + |> Jsont.Object.opt_mem "query" Jsont.string ~enc:(fun r -> r.query) 3907 + |> Jsont.Object.opt_mem "tags" (Jsont.list Jsont.string) ~enc:(fun r -> r.tags) 3908 + |> Jsont.Object.skip_unknown 3909 + |> Jsont.Object.finish 3910 + end 3911 + end 3912 + 3913 + module CurationItemDeleteSchema = struct 3914 + module Types = struct 3915 + module T = struct 3916 + type t = { 3917 + id : string; (** ID of the deleted curation item *) 3918 + } 3919 + end 3920 + end 3921 + 3922 + module T = struct 3923 + include Types.T 3924 + 3925 + let v ~id () = { id } 3926 + 3927 + let id t = t.id 3928 + 3929 + let jsont : t Jsont.t = 3930 + Jsont.Object.map ~kind:"CurationItemDeleteSchema" 3931 + (fun id -> { id }) 3932 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 3933 + |> Jsont.Object.skip_unknown 3934 + |> Jsont.Object.finish 3935 + end 3936 + 3937 + (** Delete a curation set item 3938 + 3939 + Delete a specific curation item by its id 3940 + @param curation_set_name The name of the curation set 3941 + @param item_id The id of the curation item to delete 3942 + *) 3943 + let delete_curation_set_item ~curation_set_name ~item_id client () = 3944 + let op_name = "delete_curation_set_item" in 3945 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in 3946 + let query = "" in 3947 + let url = client.base_url ^ url_path ^ query in 3948 + let response = 3949 + try Requests.delete client.session url 3950 + with Eio.Io _ as ex -> 3951 + let bt = Printexc.get_raw_backtrace () in 3952 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 3953 + in 3954 + if Requests.Response.ok response then 3955 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 3956 + else 3957 + let body = Requests.Response.text response in 3958 + let status = Requests.Response.status_code response in 3959 + let parsed_body = match status with 3960 + | 404 -> 3961 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 3962 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 3963 + | Error _ -> None) 3964 + | _ -> 3965 + (match Jsont_bytesrw.decode_string Jsont.json body with 3966 + | Ok json -> Some (Openapi.Runtime.Json json) 3967 + | Error _ -> Some (Openapi.Runtime.Raw body)) 3968 + in 3969 + raise (Openapi.Runtime.Api_error { 3970 + operation = op_name; 3971 + method_ = "DELETE"; 3972 + url; 3973 + status; 3974 + body; 3975 + parsed_body; 3976 + }) 3977 + end 3978 + 3979 + module CurationInclude = struct 3980 + module Types = struct 3981 + module T = struct 3982 + type t = { 3983 + id : string; (** document id that should be included *) 3984 + position : int; (** position number where document should be included in the search results *) 3985 + } 3986 + end 3987 + end 3988 + 3989 + module T = struct 3990 + include Types.T 3991 + 3992 + let v ~id ~position () = { id; position } 3993 + 3994 + let id t = t.id 3995 + let position t = t.position 3996 + 3997 + let jsont : t Jsont.t = 3998 + Jsont.Object.map ~kind:"CurationInclude" 3999 + (fun id position -> { id; position }) 4000 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 4001 + |> Jsont.Object.mem "position" Jsont.int ~enc:(fun r -> r.position) 4002 + |> Jsont.Object.skip_unknown 4003 + |> Jsont.Object.finish 4004 + end 4005 + end 4006 + 4007 + module CurationExclude = struct 4008 + module Types = struct 4009 + module T = struct 4010 + type t = { 4011 + id : string; (** document id that should be excluded from the search results. *) 4012 + } 4013 + end 4014 + end 4015 + 4016 + module T = struct 4017 + include Types.T 4018 + 4019 + let v ~id () = { id } 4020 + 4021 + let id t = t.id 4022 + 4023 + let jsont : t Jsont.t = 4024 + Jsont.Object.map ~kind:"CurationExclude" 4025 + (fun id -> { id }) 4026 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 4027 + |> Jsont.Object.skip_unknown 4028 + |> Jsont.Object.finish 4029 + end 4030 + end 4031 + 4032 + module CurationItemCreateSchema = struct 4033 + module Types = struct 4034 + module T = struct 4035 + type t = { 4036 + 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. 4037 + *) 4038 + 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. 4039 + *) 4040 + excludes : CurationExclude.T.t list option; (** List of document `id`s that should be excluded from the search results. *) 4041 + filter_by : string option; (** A filter by clause that is applied to any search query that matches the curation rule. 4042 + *) 4043 + 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. 4044 + *) 4045 + id : string option; (** ID of the curation item *) 4046 + includes : CurationInclude.T.t list option; (** List of document `id`s that should be included in the search results with their corresponding `position`s. *) 4047 + 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. 4048 + *) 4049 + remove_matched_tokens : bool option; (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 4050 + *) 4051 + replace_query : string option; (** Replaces the current search query with this value, when the search query matches the curation rule. 4052 + *) 4053 + rule : CurationRule.T.t; 4054 + sort_by : string option; (** A sort by clause that is applied to any search query that matches the curation rule. 4055 + *) 4056 + 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. 4057 + *) 4058 + } 4059 + end 4060 + end 4061 + 4062 + module T = struct 4063 + include Types.T 4064 + 4065 + 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 } 4066 + 4067 + let effective_from_ts t = t.effective_from_ts 4068 + let effective_to_ts t = t.effective_to_ts 4069 + let excludes t = t.excludes 4070 + let filter_by t = t.filter_by 4071 + let filter_curated_hits t = t.filter_curated_hits 4072 + let id t = t.id 4073 + let includes t = t.includes 4074 + let metadata t = t.metadata 4075 + let remove_matched_tokens t = t.remove_matched_tokens 4076 + let replace_query t = t.replace_query 4077 + let rule t = t.rule 4078 + let sort_by t = t.sort_by 4079 + let stop_processing t = t.stop_processing 4080 + 4081 + let jsont : t Jsont.t = 4082 + Jsont.Object.map ~kind:"CurationItemCreateSchema" 4083 + (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 }) 4084 + |> Jsont.Object.opt_mem "effective_from_ts" Jsont.int ~enc:(fun r -> r.effective_from_ts) 4085 + |> Jsont.Object.opt_mem "effective_to_ts" Jsont.int ~enc:(fun r -> r.effective_to_ts) 4086 + |> Jsont.Object.opt_mem "excludes" (Jsont.list CurationExclude.T.jsont) ~enc:(fun r -> r.excludes) 4087 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 4088 + |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits) 4089 + |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id) 4090 + |> Jsont.Object.opt_mem "includes" (Jsont.list CurationInclude.T.jsont) ~enc:(fun r -> r.includes) 4091 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 4092 + |> Jsont.Object.opt_mem "remove_matched_tokens" Jsont.bool ~enc:(fun r -> r.remove_matched_tokens) 4093 + |> Jsont.Object.opt_mem "replace_query" Jsont.string ~enc:(fun r -> r.replace_query) 4094 + |> Jsont.Object.mem "rule" CurationRule.T.jsont ~enc:(fun r -> r.rule) 4095 + |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 4096 + |> Jsont.Object.opt_mem "stop_processing" Jsont.bool ~enc:(fun r -> r.stop_processing) 4097 + |> Jsont.Object.skip_unknown 4098 + |> Jsont.Object.finish 4099 + end 4100 + end 4101 + 4102 + module CurationSetCreateSchema = struct 4103 + module Types = struct 4104 + module T = struct 4105 + type t = { 4106 + description : string option; (** Optional description for the curation set *) 4107 + items : CurationItemCreateSchema.T.t list; (** Array of curation items *) 4108 + } 4109 + end 4110 + end 4111 + 4112 + module T = struct 4113 + include Types.T 4114 + 4115 + let v ~items ?description () = { description; items } 4116 + 4117 + let description t = t.description 4118 + let items t = t.items 4119 + 4120 + let jsont : t Jsont.t = 4121 + Jsont.Object.map ~kind:"CurationSetCreateSchema" 4122 + (fun description items -> { description; items }) 4123 + |> Jsont.Object.opt_mem "description" Jsont.string ~enc:(fun r -> r.description) 4124 + |> Jsont.Object.mem "items" (Jsont.list CurationItemCreateSchema.T.jsont) ~enc:(fun r -> r.items) 4125 + |> Jsont.Object.skip_unknown 4126 + |> Jsont.Object.finish 4127 + end 4128 + end 4129 + 4130 + module CurationSetSchema = struct 4131 + module Types = struct 4132 + module T = struct 4133 + type t = { 4134 + description : string option; (** Optional description for the curation set *) 4135 + items : CurationItemCreateSchema.T.t list; (** Array of curation items *) 4136 + name : string; 4137 + } 4138 + end 4139 + end 4140 + 4141 + module T = struct 4142 + include Types.T 4143 + 4144 + let v ~items ~name ?description () = { description; items; name } 4145 + 4146 + let description t = t.description 4147 + let items t = t.items 4148 + let name t = t.name 4149 + 4150 + let jsont : t Jsont.t = 4151 + Jsont.Object.map ~kind:"CurationSetSchema" 4152 + (fun description items name -> { description; items; name }) 4153 + |> Jsont.Object.opt_mem "description" Jsont.string ~enc:(fun r -> r.description) 4154 + |> Jsont.Object.mem "items" (Jsont.list CurationItemCreateSchema.T.jsont) ~enc:(fun r -> r.items) 4155 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 4156 + |> Jsont.Object.skip_unknown 4157 + |> Jsont.Object.finish 4158 + end 4159 + 4160 + (** List all curation sets 4161 + 4162 + Retrieve all curation sets *) 4163 + let retrieve_curation_sets client () = 4164 + let op_name = "retrieve_curation_sets" in 4165 + let url_path = "/curation_sets" in 4166 + let query = "" in 4167 + let url = client.base_url ^ url_path ^ query in 4168 + let response = 4169 + try Requests.get client.session url 4170 + with Eio.Io _ as ex -> 4171 + let bt = Printexc.get_raw_backtrace () in 4172 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4173 + in 4174 + if Requests.Response.ok response then 4175 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4176 + else 4177 + let body = Requests.Response.text response in 4178 + let parsed_body = 4179 + match Jsont_bytesrw.decode_string Jsont.json body with 4180 + | Ok json -> Some (Openapi.Runtime.Json json) 4181 + | Error _ -> Some (Openapi.Runtime.Raw body) 4182 + in 4183 + raise (Openapi.Runtime.Api_error { 4184 + operation = op_name; 4185 + method_ = "GET"; 4186 + url; 4187 + status = Requests.Response.status_code response; 4188 + body; 4189 + parsed_body; 4190 + }) 4191 + 4192 + (** Retrieve a curation set 4193 + 4194 + Retrieve a specific curation set by its name 4195 + @param curation_set_name The name of the curation set to retrieve 4196 + *) 4197 + let retrieve_curation_set ~curation_set_name client () = 4198 + let op_name = "retrieve_curation_set" in 4199 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in 4200 + let query = "" in 4201 + let url = client.base_url ^ url_path ^ query in 4202 + let response = 4203 + try Requests.get client.session url 4204 + with Eio.Io _ as ex -> 4205 + let bt = Printexc.get_raw_backtrace () in 4206 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4207 + in 4208 + if Requests.Response.ok response then 4209 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4210 + else 4211 + let body = Requests.Response.text response in 4212 + let status = Requests.Response.status_code response in 4213 + let parsed_body = match status with 4214 + | 404 -> 4215 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4216 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4217 + | Error _ -> None) 4218 + | _ -> 4219 + (match Jsont_bytesrw.decode_string Jsont.json body with 4220 + | Ok json -> Some (Openapi.Runtime.Json json) 4221 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4222 + in 4223 + raise (Openapi.Runtime.Api_error { 4224 + operation = op_name; 4225 + method_ = "GET"; 4226 + url; 4227 + status; 4228 + body; 4229 + parsed_body; 4230 + }) 4231 + 4232 + (** Create or update a curation set 4233 + 4234 + Create or update a curation set with the given name 4235 + @param curation_set_name The name of the curation set to create/update 4236 + *) 4237 + let upsert_curation_set ~curation_set_name ~body client () = 4238 + let op_name = "upsert_curation_set" in 4239 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}" in 4240 + let query = "" in 4241 + let url = client.base_url ^ url_path ^ query in 4242 + let response = 4243 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CurationSetCreateSchema.T.jsont body)) url 4244 + with Eio.Io _ as ex -> 4245 + let bt = Printexc.get_raw_backtrace () in 4246 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 4247 + in 4248 + if Requests.Response.ok response then 4249 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4250 + else 4251 + let body = Requests.Response.text response in 4252 + let status = Requests.Response.status_code response in 4253 + let parsed_body = match status with 4254 + | 400 -> 4255 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4256 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4257 + | Error _ -> None) 4258 + | _ -> 4259 + (match Jsont_bytesrw.decode_string Jsont.json body with 4260 + | Ok json -> Some (Openapi.Runtime.Json json) 4261 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4262 + in 4263 + raise (Openapi.Runtime.Api_error { 4264 + operation = op_name; 4265 + method_ = "PUT"; 4266 + url; 4267 + status; 4268 + body; 4269 + parsed_body; 4270 + }) 4271 + end 4272 + 4273 + module CurationItemSchema = struct 4274 + module Types = struct 4275 + module T = struct 4276 + type t = { 4277 + 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. 4278 + *) 4279 + 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. 4280 + *) 4281 + excludes : CurationExclude.T.t list option; (** List of document `id`s that should be excluded from the search results. *) 4282 + filter_by : string option; (** A filter by clause that is applied to any search query that matches the curation rule. 4283 + *) 4284 + 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. 4285 + *) 4286 + includes : CurationInclude.T.t list option; (** List of document `id`s that should be included in the search results with their corresponding `position`s. *) 4287 + 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. 4288 + *) 4289 + remove_matched_tokens : bool option; (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 4290 + *) 4291 + replace_query : string option; (** Replaces the current search query with this value, when the search query matches the curation rule. 4292 + *) 4293 + rule : CurationRule.T.t; 4294 + sort_by : string option; (** A sort by clause that is applied to any search query that matches the curation rule. 4295 + *) 4296 + 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. 4297 + *) 4298 + id : string; 4299 + } 4300 + end 4301 + end 4302 + 4303 + module T = struct 4304 + include Types.T 4305 + 4306 + 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 } 4307 + 4308 + let effective_from_ts t = t.effective_from_ts 4309 + let effective_to_ts t = t.effective_to_ts 4310 + let excludes t = t.excludes 4311 + let filter_by t = t.filter_by 4312 + let filter_curated_hits t = t.filter_curated_hits 4313 + let includes t = t.includes 4314 + let metadata t = t.metadata 4315 + let remove_matched_tokens t = t.remove_matched_tokens 4316 + let replace_query t = t.replace_query 4317 + let rule t = t.rule 4318 + let sort_by t = t.sort_by 4319 + let stop_processing t = t.stop_processing 4320 + let id t = t.id 4321 + 4322 + let jsont : t Jsont.t = 4323 + Jsont.Object.map ~kind:"CurationItemSchema" 4324 + (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 }) 4325 + |> Jsont.Object.opt_mem "effective_from_ts" Jsont.int ~enc:(fun r -> r.effective_from_ts) 4326 + |> Jsont.Object.opt_mem "effective_to_ts" Jsont.int ~enc:(fun r -> r.effective_to_ts) 4327 + |> Jsont.Object.opt_mem "excludes" (Jsont.list CurationExclude.T.jsont) ~enc:(fun r -> r.excludes) 4328 + |> Jsont.Object.opt_mem "filter_by" Jsont.string ~enc:(fun r -> r.filter_by) 4329 + |> Jsont.Object.opt_mem "filter_curated_hits" Jsont.bool ~enc:(fun r -> r.filter_curated_hits) 4330 + |> Jsont.Object.opt_mem "includes" (Jsont.list CurationInclude.T.jsont) ~enc:(fun r -> r.includes) 4331 + |> Jsont.Object.opt_mem "metadata" Jsont.json ~enc:(fun r -> r.metadata) 4332 + |> Jsont.Object.opt_mem "remove_matched_tokens" Jsont.bool ~enc:(fun r -> r.remove_matched_tokens) 4333 + |> Jsont.Object.opt_mem "replace_query" Jsont.string ~enc:(fun r -> r.replace_query) 4334 + |> Jsont.Object.mem "rule" CurationRule.T.jsont ~enc:(fun r -> r.rule) 4335 + |> Jsont.Object.opt_mem "sort_by" Jsont.string ~enc:(fun r -> r.sort_by) 4336 + |> Jsont.Object.opt_mem "stop_processing" Jsont.bool ~enc:(fun r -> r.stop_processing) 4337 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 4338 + |> Jsont.Object.skip_unknown 4339 + |> Jsont.Object.finish 4340 + end 4341 + 4342 + (** List items in a curation set 4343 + 4344 + Retrieve all curation items in a set 4345 + @param curation_set_name The name of the curation set to retrieve items for 4346 + *) 4347 + let retrieve_curation_set_items ~curation_set_name client () = 4348 + let op_name = "retrieve_curation_set_items" in 4349 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name)] "/curation_sets/{curationSetName}/items" in 4350 + let query = "" in 4351 + let url = client.base_url ^ url_path ^ query in 4352 + let response = 4353 + try Requests.get client.session url 4354 + with Eio.Io _ as ex -> 4355 + let bt = Printexc.get_raw_backtrace () in 4356 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4357 + in 4358 + if Requests.Response.ok response then 4359 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4360 + else 4361 + let body = Requests.Response.text response in 4362 + let status = Requests.Response.status_code response in 4363 + let parsed_body = match status with 4364 + | 404 -> 4365 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4366 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4367 + | Error _ -> None) 4368 + | _ -> 4369 + (match Jsont_bytesrw.decode_string Jsont.json body with 4370 + | Ok json -> Some (Openapi.Runtime.Json json) 4371 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4372 + in 4373 + raise (Openapi.Runtime.Api_error { 4374 + operation = op_name; 4375 + method_ = "GET"; 4376 + url; 4377 + status; 4378 + body; 4379 + parsed_body; 4380 + }) 4381 + 4382 + (** Retrieve a curation set item 4383 + 4384 + Retrieve a specific curation item by its id 4385 + @param curation_set_name The name of the curation set 4386 + @param item_id The id of the curation item to retrieve 4387 + *) 4388 + let retrieve_curation_set_item ~curation_set_name ~item_id client () = 4389 + let op_name = "retrieve_curation_set_item" in 4390 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in 4391 + let query = "" in 4392 + let url = client.base_url ^ url_path ^ query in 4393 + let response = 4394 + try Requests.get client.session url 4395 + with Eio.Io _ as ex -> 4396 + let bt = Printexc.get_raw_backtrace () in 4397 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4398 + in 4399 + if Requests.Response.ok response then 4400 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4401 + else 4402 + let body = Requests.Response.text response in 4403 + let status = Requests.Response.status_code response in 4404 + let parsed_body = match status with 4405 + | 404 -> 4406 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4407 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4408 + | Error _ -> None) 4409 + | _ -> 4410 + (match Jsont_bytesrw.decode_string Jsont.json body with 4411 + | Ok json -> Some (Openapi.Runtime.Json json) 4412 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4413 + in 4414 + raise (Openapi.Runtime.Api_error { 4415 + operation = op_name; 4416 + method_ = "GET"; 4417 + url; 4418 + status; 4419 + body; 4420 + parsed_body; 4421 + }) 4422 + 4423 + (** Create or update a curation set item 4424 + 4425 + Create or update a curation set item with the given id 4426 + @param curation_set_name The name of the curation set 4427 + @param item_id The id of the curation item to upsert 4428 + *) 4429 + let upsert_curation_set_item ~curation_set_name ~item_id ~body client () = 4430 + let op_name = "upsert_curation_set_item" in 4431 + let url_path = Openapi.Runtime.Path.render ~params:[("curationSetName", curation_set_name); ("itemId", item_id)] "/curation_sets/{curationSetName}/items/{itemId}" in 4432 + let query = "" in 4433 + let url = client.base_url ^ url_path ^ query in 4434 + let response = 4435 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CurationItemCreateSchema.T.jsont body)) url 4436 + with Eio.Io _ as ex -> 4437 + let bt = Printexc.get_raw_backtrace () in 4438 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 4439 + in 4440 + if Requests.Response.ok response then 4441 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4442 + else 4443 + let body = Requests.Response.text response in 4444 + let status = Requests.Response.status_code response in 4445 + let parsed_body = match status with 4446 + | 400 -> 4447 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4448 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4449 + | Error _ -> None) 4450 + | _ -> 4451 + (match Jsont_bytesrw.decode_string Jsont.json body with 4452 + | Ok json -> Some (Openapi.Runtime.Json json) 4453 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4454 + in 4455 + raise (Openapi.Runtime.Api_error { 4456 + operation = op_name; 4457 + method_ = "PUT"; 4458 + url; 4459 + status; 4460 + body; 4461 + parsed_body; 4462 + }) 4463 + end 4464 + 4465 + module ConversationModelUpdateSchema = struct 4466 + module Types = struct 4467 + module T = struct 4468 + type t = { 4469 + account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *) 4470 + api_key : string option; (** The LLM service's API Key *) 4471 + history_collection : string option; (** Typesense collection that stores the historical conversations *) 4472 + id : string option; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 4473 + 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. 4474 + *) 4475 + model_name : string option; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 4476 + system_prompt : string option; (** The system prompt that contains special instructions to the LLM *) 4477 + ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 4478 + *) 4479 + vllm_url : string option; (** URL of vLLM service *) 4480 + } 4481 + end 4482 + end 4483 + 4484 + module T = struct 4485 + include Types.T 4486 + 4487 + 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 } 4488 + 4489 + let account_id t = t.account_id 4490 + let api_key t = t.api_key 4491 + let history_collection t = t.history_collection 4492 + let id t = t.id 4493 + let max_bytes t = t.max_bytes 4494 + let model_name t = t.model_name 4495 + let system_prompt t = t.system_prompt 4496 + let ttl t = t.ttl 4497 + let vllm_url t = t.vllm_url 4498 + 4499 + let jsont : t Jsont.t = 4500 + Jsont.Object.map ~kind:"ConversationModelUpdateSchema" 4501 + (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 }) 4502 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 4503 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 4504 + |> Jsont.Object.opt_mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection) 4505 + |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id) 4506 + |> Jsont.Object.opt_mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 4507 + |> Jsont.Object.opt_mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 4508 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 4509 + |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl) 4510 + |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url) 4511 + |> Jsont.Object.skip_unknown 4512 + |> Jsont.Object.finish 4513 + end 4514 + end 4515 + 4516 + module ConversationModelCreateSchema = struct 4517 + module Types = struct 4518 + module T = struct 4519 + type t = { 4520 + account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *) 4521 + api_key : string option; (** The LLM service's API Key *) 4522 + id : string option; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 4523 + system_prompt : string option; (** The system prompt that contains special instructions to the LLM *) 4524 + ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 4525 + *) 4526 + vllm_url : string option; (** URL of vLLM service *) 4527 + model_name : string; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 4528 + 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. 4529 + *) 4530 + history_collection : string; (** Typesense collection that stores the historical conversations *) 4531 + } 4532 + end 4533 + end 4534 + 4535 + module T = struct 4536 + include Types.T 4537 + 4538 + 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 } 4539 + 4540 + let account_id t = t.account_id 4541 + let api_key t = t.api_key 4542 + let id t = t.id 4543 + let system_prompt t = t.system_prompt 4544 + let ttl t = t.ttl 4545 + let vllm_url t = t.vllm_url 4546 + let model_name t = t.model_name 4547 + let max_bytes t = t.max_bytes 4548 + let history_collection t = t.history_collection 4549 + 4550 + let jsont : t Jsont.t = 4551 + Jsont.Object.map ~kind:"ConversationModelCreateSchema" 4552 + (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 }) 4553 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 4554 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 4555 + |> Jsont.Object.opt_mem "id" Jsont.string ~enc:(fun r -> r.id) 4556 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 4557 + |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl) 4558 + |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url) 4559 + |> Jsont.Object.mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 4560 + |> Jsont.Object.mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 4561 + |> Jsont.Object.mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection) 4562 + |> Jsont.Object.skip_unknown 4563 + |> Jsont.Object.finish 4564 + end 4565 + end 4566 + 4567 + module ConversationModelSchema = struct 4568 + module Types = struct 4569 + module T = struct 4570 + type t = { 4571 + account_id : string option; (** LLM service's account ID (only applicable for Cloudflare) *) 4572 + api_key : string option; (** The LLM service's API Key *) 4573 + system_prompt : string option; (** The system prompt that contains special instructions to the LLM *) 4574 + ttl : int option; (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 4575 + *) 4576 + vllm_url : string option; (** URL of vLLM service *) 4577 + model_name : string; (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 4578 + 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. 4579 + *) 4580 + history_collection : string; (** Typesense collection that stores the historical conversations *) 4581 + id : string; (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 4582 + } 4583 + end 4584 + end 4585 + 4586 + module T = struct 4587 + include Types.T 4588 + 4589 + 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 } 4590 + 4591 + let account_id t = t.account_id 4592 + let api_key t = t.api_key 4593 + let system_prompt t = t.system_prompt 4594 + let ttl t = t.ttl 4595 + let vllm_url t = t.vllm_url 4596 + let model_name t = t.model_name 4597 + let max_bytes t = t.max_bytes 4598 + let history_collection t = t.history_collection 4599 + let id t = t.id 4600 + 4601 + let jsont : t Jsont.t = 4602 + Jsont.Object.map ~kind:"ConversationModelSchema" 4603 + (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 }) 4604 + |> Jsont.Object.opt_mem "account_id" Jsont.string ~enc:(fun r -> r.account_id) 4605 + |> Jsont.Object.opt_mem "api_key" Jsont.string ~enc:(fun r -> r.api_key) 4606 + |> Jsont.Object.opt_mem "system_prompt" Jsont.string ~enc:(fun r -> r.system_prompt) 4607 + |> Jsont.Object.opt_mem "ttl" Jsont.int ~enc:(fun r -> r.ttl) 4608 + |> Jsont.Object.opt_mem "vllm_url" Jsont.string ~enc:(fun r -> r.vllm_url) 4609 + |> Jsont.Object.mem "model_name" Jsont.string ~enc:(fun r -> r.model_name) 4610 + |> Jsont.Object.mem "max_bytes" Jsont.int ~enc:(fun r -> r.max_bytes) 4611 + |> Jsont.Object.mem "history_collection" Jsont.string ~enc:(fun r -> r.history_collection) 4612 + |> Jsont.Object.mem "id" Jsont.string ~enc:(fun r -> r.id) 4613 + |> Jsont.Object.skip_unknown 4614 + |> Jsont.Object.finish 4615 + end 4616 + 4617 + (** List all conversation models 4618 + 4619 + Retrieve all conversation models *) 4620 + let retrieve_all_conversation_models client () = 4621 + let op_name = "retrieve_all_conversation_models" in 4622 + let url_path = "/conversations/models" in 4623 + let query = "" in 4624 + let url = client.base_url ^ url_path ^ query in 4625 + let response = 4626 + try Requests.get client.session url 4627 + with Eio.Io _ as ex -> 4628 + let bt = Printexc.get_raw_backtrace () in 4629 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4630 + in 4631 + if Requests.Response.ok response then 4632 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4633 + else 4634 + let body = Requests.Response.text response in 4635 + let parsed_body = 4636 + match Jsont_bytesrw.decode_string Jsont.json body with 4637 + | Ok json -> Some (Openapi.Runtime.Json json) 4638 + | Error _ -> Some (Openapi.Runtime.Raw body) 4639 + in 4640 + raise (Openapi.Runtime.Api_error { 4641 + operation = op_name; 4642 + method_ = "GET"; 4643 + url; 4644 + status = Requests.Response.status_code response; 4645 + body; 4646 + parsed_body; 4647 + }) 4648 + 4649 + (** Create a conversation model 4650 + 4651 + Create a Conversation Model *) 4652 + let create_conversation_model ~body client () = 4653 + let op_name = "create_conversation_model" in 4654 + let url_path = "/conversations/models" in 4655 + let query = "" in 4656 + let url = client.base_url ^ url_path ^ query in 4657 + let response = 4658 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ConversationModelCreateSchema.T.jsont body)) url 4659 + with Eio.Io _ as ex -> 4660 + let bt = Printexc.get_raw_backtrace () in 4661 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 4662 + in 4663 + if Requests.Response.ok response then 4664 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4665 + else 4666 + let body = Requests.Response.text response in 4667 + let status = Requests.Response.status_code response in 4668 + let parsed_body = match status with 4669 + | 400 -> 4670 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4671 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4672 + | Error _ -> None) 4673 + | _ -> 4674 + (match Jsont_bytesrw.decode_string Jsont.json body with 4675 + | Ok json -> Some (Openapi.Runtime.Json json) 4676 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4677 + in 4678 + raise (Openapi.Runtime.Api_error { 4679 + operation = op_name; 4680 + method_ = "POST"; 4681 + url; 4682 + status; 4683 + body; 4684 + parsed_body; 4685 + }) 4686 + 4687 + (** Retrieve a conversation model 4688 + 4689 + Retrieve a conversation model 4690 + @param model_id The id of the conversation model to retrieve 4691 + *) 4692 + let retrieve_conversation_model ~model_id client () = 4693 + let op_name = "retrieve_conversation_model" in 4694 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in 4695 + let query = "" in 4696 + let url = client.base_url ^ url_path ^ query in 4697 + let response = 4698 + try Requests.get client.session url 4699 + with Eio.Io _ as ex -> 4700 + let bt = Printexc.get_raw_backtrace () in 4701 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4702 + in 4703 + if Requests.Response.ok response then 4704 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4705 + else 4706 + let body = Requests.Response.text response in 4707 + let parsed_body = 4708 + match Jsont_bytesrw.decode_string Jsont.json body with 4709 + | Ok json -> Some (Openapi.Runtime.Json json) 4710 + | Error _ -> Some (Openapi.Runtime.Raw body) 4711 + in 4712 + raise (Openapi.Runtime.Api_error { 4713 + operation = op_name; 4714 + method_ = "GET"; 4715 + url; 4716 + status = Requests.Response.status_code response; 4717 + body; 4718 + parsed_body; 4719 + }) 4720 + 4721 + (** Update a conversation model 4722 + 4723 + Update a conversation model 4724 + @param model_id The id of the conversation model to update 4725 + *) 4726 + let update_conversation_model ~model_id ~body client () = 4727 + let op_name = "update_conversation_model" in 4728 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in 4729 + let query = "" in 4730 + let url = client.base_url ^ url_path ^ query in 4731 + let response = 4732 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ConversationModelUpdateSchema.T.jsont body)) url 4733 + with Eio.Io _ as ex -> 4734 + let bt = Printexc.get_raw_backtrace () in 4735 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 4736 + in 4737 + if Requests.Response.ok response then 4738 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4739 + else 4740 + let body = Requests.Response.text response in 4741 + let parsed_body = 4742 + match Jsont_bytesrw.decode_string Jsont.json body with 4743 + | Ok json -> Some (Openapi.Runtime.Json json) 4744 + | Error _ -> Some (Openapi.Runtime.Raw body) 4745 + in 4746 + raise (Openapi.Runtime.Api_error { 4747 + operation = op_name; 4748 + method_ = "PUT"; 4749 + url; 4750 + status = Requests.Response.status_code response; 4751 + body; 4752 + parsed_body; 4753 + }) 4754 + 4755 + (** Delete a conversation model 4756 + 4757 + Delete a conversation model 4758 + @param model_id The id of the conversation model to delete 4759 + *) 4760 + let delete_conversation_model ~model_id client () = 4761 + let op_name = "delete_conversation_model" in 4762 + let url_path = Openapi.Runtime.Path.render ~params:[("modelId", model_id)] "/conversations/models/{modelId}" in 4763 + let query = "" in 4764 + let url = client.base_url ^ url_path ^ query in 4765 + let response = 4766 + try Requests.delete client.session url 4767 + with Eio.Io _ as ex -> 4768 + let bt = Printexc.get_raw_backtrace () in 4769 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 4770 + in 4771 + if Requests.Response.ok response then 4772 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4773 + else 4774 + let body = Requests.Response.text response in 4775 + let parsed_body = 4776 + match Jsont_bytesrw.decode_string Jsont.json body with 4777 + | Ok json -> Some (Openapi.Runtime.Json json) 4778 + | Error _ -> Some (Openapi.Runtime.Raw body) 4779 + in 4780 + raise (Openapi.Runtime.Api_error { 4781 + operation = op_name; 4782 + method_ = "DELETE"; 4783 + url; 4784 + status = Requests.Response.status_code response; 4785 + body; 4786 + parsed_body; 4787 + }) 4788 + end 4789 + 4790 + module CollectionAliasSchema = struct 4791 + module Types = struct 4792 + module T = struct 4793 + type t = { 4794 + collection_name : string; (** Name of the collection you wish to map the alias to *) 4795 + } 4796 + end 4797 + end 4798 + 4799 + module T = struct 4800 + include Types.T 4801 + 4802 + let v ~collection_name () = { collection_name } 4803 + 4804 + let collection_name t = t.collection_name 4805 + 4806 + let jsont : t Jsont.t = 4807 + Jsont.Object.map ~kind:"CollectionAliasSchema" 4808 + (fun collection_name -> { collection_name }) 4809 + |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name) 4810 + |> Jsont.Object.skip_unknown 4811 + |> Jsont.Object.finish 4812 + end 4813 + end 4814 + 4815 + module CollectionAlias = struct 4816 + module Types = struct 4817 + module T = struct 4818 + type t = { 4819 + collection_name : string; (** Name of the collection the alias mapped to *) 4820 + name : string; (** Name of the collection alias *) 4821 + } 4822 + end 4823 + end 4824 + 4825 + module T = struct 4826 + include Types.T 4827 + 4828 + let v ~collection_name ~name () = { collection_name; name } 4829 + 4830 + let collection_name t = t.collection_name 4831 + let name t = t.name 4832 + 4833 + let jsont : t Jsont.t = 4834 + Jsont.Object.map ~kind:"CollectionAlias" 4835 + (fun collection_name name -> { collection_name; name }) 4836 + |> Jsont.Object.mem "collection_name" Jsont.string ~enc:(fun r -> r.collection_name) 4837 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 4838 + |> Jsont.Object.skip_unknown 4839 + |> Jsont.Object.finish 4840 + end 4841 + 4842 + (** Retrieve an alias 4843 + 4844 + Find out which collection an alias points to by fetching it 4845 + @param alias_name The name of the alias to retrieve 4846 + *) 4847 + let get_alias ~alias_name client () = 4848 + let op_name = "get_alias" in 4849 + let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in 4850 + let query = "" in 4851 + let url = client.base_url ^ url_path ^ query in 4852 + let response = 4853 + try Requests.get client.session url 4854 + with Eio.Io _ as ex -> 4855 + let bt = Printexc.get_raw_backtrace () in 4856 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 4857 + in 4858 + if Requests.Response.ok response then 4859 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4860 + else 4861 + let body = Requests.Response.text response in 4862 + let status = Requests.Response.status_code response in 4863 + let parsed_body = match status with 4864 + | 404 -> 4865 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4866 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4867 + | Error _ -> None) 4868 + | _ -> 4869 + (match Jsont_bytesrw.decode_string Jsont.json body with 4870 + | Ok json -> Some (Openapi.Runtime.Json json) 4871 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4872 + in 4873 + raise (Openapi.Runtime.Api_error { 4874 + operation = op_name; 4875 + method_ = "GET"; 4876 + url; 4877 + status; 4878 + body; 4879 + parsed_body; 4880 + }) 4881 + 4882 + (** Create or update a collection alias 4883 + 4884 + 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. 4885 + @param alias_name The name of the alias to create/update 4886 + *) 4887 + let upsert_alias ~alias_name ~body client () = 4888 + let op_name = "upsert_alias" in 4889 + let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in 4890 + let query = "" in 4891 + let url = client.base_url ^ url_path ^ query in 4892 + let response = 4893 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json CollectionAliasSchema.T.jsont body)) url 4894 + with Eio.Io _ as ex -> 4895 + let bt = Printexc.get_raw_backtrace () in 4896 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 4897 + in 4898 + if Requests.Response.ok response then 4899 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4900 + else 4901 + let body = Requests.Response.text response in 4902 + let status = Requests.Response.status_code response in 4903 + let parsed_body = match status with 4904 + | 400 -> 4905 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4906 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4907 + | Error _ -> None) 4908 + | 404 -> 4909 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4910 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4911 + | Error _ -> None) 4912 + | _ -> 4913 + (match Jsont_bytesrw.decode_string Jsont.json body with 4914 + | Ok json -> Some (Openapi.Runtime.Json json) 4915 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4916 + in 4917 + raise (Openapi.Runtime.Api_error { 4918 + operation = op_name; 4919 + method_ = "PUT"; 4920 + url; 4921 + status; 4922 + body; 4923 + parsed_body; 4924 + }) 4925 + 4926 + (** Delete an alias 4927 + @param alias_name The name of the alias to delete 4928 + *) 4929 + let delete_alias ~alias_name client () = 4930 + let op_name = "delete_alias" in 4931 + let url_path = Openapi.Runtime.Path.render ~params:[("aliasName", alias_name)] "/aliases/{aliasName}" in 4932 + let query = "" in 4933 + let url = client.base_url ^ url_path ^ query in 4934 + let response = 4935 + try Requests.delete client.session url 4936 + with Eio.Io _ as ex -> 4937 + let bt = Printexc.get_raw_backtrace () in 4938 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 4939 + in 4940 + if Requests.Response.ok response then 4941 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 4942 + else 4943 + let body = Requests.Response.text response in 4944 + let status = Requests.Response.status_code response in 4945 + let parsed_body = match status with 4946 + | 404 -> 4947 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 4948 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 4949 + | Error _ -> None) 4950 + | _ -> 4951 + (match Jsont_bytesrw.decode_string Jsont.json body with 4952 + | Ok json -> Some (Openapi.Runtime.Json json) 4953 + | Error _ -> Some (Openapi.Runtime.Raw body)) 4954 + in 4955 + raise (Openapi.Runtime.Api_error { 4956 + operation = op_name; 4957 + method_ = "DELETE"; 4958 + url; 4959 + status; 4960 + body; 4961 + parsed_body; 4962 + }) 4963 + end 4964 + 4965 + module CollectionAliases = struct 4966 + module Types = struct 4967 + module Response = struct 4968 + type t = { 4969 + aliases : CollectionAlias.T.t list; 4970 + } 4971 + end 4972 + end 4973 + 4974 + module Response = struct 4975 + include Types.Response 4976 + 4977 + let v ~aliases () = { aliases } 4978 + 4979 + let aliases t = t.aliases 4980 + 4981 + let jsont : t Jsont.t = 4982 + Jsont.Object.map ~kind:"CollectionAliasesResponse" 4983 + (fun aliases -> { aliases }) 4984 + |> Jsont.Object.mem "aliases" (Jsont.list CollectionAlias.T.jsont) ~enc:(fun r -> r.aliases) 4985 + |> Jsont.Object.skip_unknown 4986 + |> Jsont.Object.finish 4987 + end 4988 + 4989 + (** List all aliases 4990 + 4991 + List all aliases and the corresponding collections that they map to. *) 4992 + let get_aliases client () = 4993 + let op_name = "get_aliases" in 4994 + let url_path = "/aliases" in 4995 + let query = "" in 4996 + let url = client.base_url ^ url_path ^ query in 4997 + let response = 4998 + try Requests.get client.session url 4999 + with Eio.Io _ as ex -> 5000 + let bt = Printexc.get_raw_backtrace () in 5001 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5002 + in 5003 + if Requests.Response.ok response then 5004 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 5005 + else 5006 + let body = Requests.Response.text response in 5007 + let parsed_body = 5008 + match Jsont_bytesrw.decode_string Jsont.json body with 5009 + | Ok json -> Some (Openapi.Runtime.Json json) 5010 + | Error _ -> Some (Openapi.Runtime.Raw body) 5011 + in 5012 + raise (Openapi.Runtime.Api_error { 5013 + operation = op_name; 5014 + method_ = "GET"; 5015 + url; 5016 + status = Requests.Response.status_code response; 5017 + body; 5018 + parsed_body; 5019 + }) 5020 + end 5021 + 5022 + module Client = struct 5023 + (** Create analytics rule(s) 5024 + 5025 + Create one or more analytics rules. You can send a single rule object or an array of rule objects. *) 5026 + let create_analytics_rule client () = 5027 + let op_name = "create_analytics_rule" in 5028 + let url_path = "/analytics/rules" in 5029 + let query = "" in 5030 + let url = client.base_url ^ url_path ^ query in 5031 + let response = 5032 + try Requests.post client.session url 5033 + with Eio.Io _ as ex -> 5034 + let bt = Printexc.get_raw_backtrace () in 5035 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 5036 + in 5037 + if Requests.Response.ok response then 5038 + Requests.Response.json response 5039 + else 5040 + let body = Requests.Response.text response in 5041 + let status = Requests.Response.status_code response in 5042 + let parsed_body = match status with 5043 + | 400 -> 5044 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5045 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5046 + | Error _ -> None) 5047 + | _ -> 5048 + (match Jsont_bytesrw.decode_string Jsont.json body with 5049 + | Ok json -> Some (Openapi.Runtime.Json json) 5050 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5051 + in 5052 + raise (Openapi.Runtime.Api_error { 5053 + operation = op_name; 5054 + method_ = "POST"; 5055 + url; 5056 + status; 5057 + body; 5058 + parsed_body; 5059 + }) 5060 + 5061 + (** Index a document 5062 + 5063 + A document to be indexed in a given collection must conform to the schema of the collection. 5064 + @param collection_name The name of the collection to add the document to 5065 + @param action Additional action to perform 5066 + @param dirty_values Dealing with Dirty Data 5067 + *) 5068 + let index_document ~collection_name ?action ?dirty_values client () = 5069 + let op_name = "index_document" in 5070 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in 5071 + 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 5072 + let url = client.base_url ^ url_path ^ query in 5073 + let response = 5074 + try Requests.post client.session url 5075 + with Eio.Io _ as ex -> 5076 + let bt = Printexc.get_raw_backtrace () in 5077 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 5078 + in 5079 + if Requests.Response.ok response then 5080 + Requests.Response.json response 5081 + else 5082 + let body = Requests.Response.text response in 5083 + let status = Requests.Response.status_code response in 5084 + let parsed_body = match status with 5085 + | 404 -> 5086 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5087 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5088 + | Error _ -> None) 5089 + | _ -> 5090 + (match Jsont_bytesrw.decode_string Jsont.json body with 5091 + | Ok json -> Some (Openapi.Runtime.Json json) 5092 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5093 + in 5094 + raise (Openapi.Runtime.Api_error { 5095 + operation = op_name; 5096 + method_ = "POST"; 5097 + url; 5098 + status; 5099 + body; 5100 + parsed_body; 5101 + }) 5102 + 5103 + (** Delete a bunch of documents 5104 + 5105 + 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. 5106 + @param collection_name The name of the collection to delete documents from 5107 + *) 5108 + let delete_documents ~collection_name ?delete_documents_parameters client () = 5109 + let op_name = "delete_documents" in 5110 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in 5111 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"deleteDocumentsParameters" ~value:delete_documents_parameters]) in 5112 + let url = client.base_url ^ url_path ^ query in 5113 + let response = 5114 + try Requests.delete client.session url 5115 + with Eio.Io _ as ex -> 5116 + let bt = Printexc.get_raw_backtrace () in 5117 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 5118 + in 5119 + if Requests.Response.ok response then 5120 + Requests.Response.json response 5121 + else 5122 + let body = Requests.Response.text response in 5123 + let status = Requests.Response.status_code response in 5124 + let parsed_body = match status with 5125 + | 404 -> 5126 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5127 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5128 + | Error _ -> None) 5129 + | _ -> 5130 + (match Jsont_bytesrw.decode_string Jsont.json body with 5131 + | Ok json -> Some (Openapi.Runtime.Json json) 5132 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5133 + in 5134 + raise (Openapi.Runtime.Api_error { 5135 + operation = op_name; 5136 + method_ = "DELETE"; 5137 + url; 5138 + status; 5139 + body; 5140 + parsed_body; 5141 + }) 5142 + 5143 + (** Update documents with conditional query 5144 + 5145 + 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. 5146 + @param collection_name The name of the collection to update documents in 5147 + *) 5148 + let update_documents ~collection_name ?update_documents_parameters client () = 5149 + let op_name = "update_documents" in 5150 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents" in 5151 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"updateDocumentsParameters" ~value:update_documents_parameters]) in 5152 + let url = client.base_url ^ url_path ^ query in 5153 + let response = 5154 + try Requests.patch client.session url 5155 + with Eio.Io _ as ex -> 5156 + let bt = Printexc.get_raw_backtrace () in 5157 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url 5158 + in 5159 + if Requests.Response.ok response then 5160 + Requests.Response.json response 5161 + else 5162 + let body = Requests.Response.text response in 5163 + let status = Requests.Response.status_code response in 5164 + let parsed_body = match status with 5165 + | 400 -> 5166 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5167 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5168 + | Error _ -> None) 5169 + | 404 -> 5170 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5171 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5172 + | Error _ -> None) 5173 + | _ -> 5174 + (match Jsont_bytesrw.decode_string Jsont.json body with 5175 + | Ok json -> Some (Openapi.Runtime.Json json) 5176 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5177 + in 5178 + raise (Openapi.Runtime.Api_error { 5179 + operation = op_name; 5180 + method_ = "PATCH"; 5181 + url; 5182 + status; 5183 + body; 5184 + parsed_body; 5185 + }) 5186 + 5187 + (** Export all documents in a collection 5188 + 5189 + Export all documents in a collection in JSON lines format. 5190 + @param collection_name The name of the collection 5191 + *) 5192 + let export_documents ~collection_name ?export_documents_parameters client () = 5193 + let op_name = "export_documents" in 5194 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/export" in 5195 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"exportDocumentsParameters" ~value:export_documents_parameters]) in 5196 + let url = client.base_url ^ url_path ^ query in 5197 + let response = 5198 + try Requests.get client.session url 5199 + with Eio.Io _ as ex -> 5200 + let bt = Printexc.get_raw_backtrace () in 5201 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5202 + in 5203 + if Requests.Response.ok response then 5204 + Requests.Response.json response 5205 + else 5206 + let body = Requests.Response.text response in 5207 + let status = Requests.Response.status_code response in 5208 + let parsed_body = match status with 5209 + | 404 -> 5210 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5211 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5212 + | Error _ -> None) 5213 + | _ -> 5214 + (match Jsont_bytesrw.decode_string Jsont.json body with 5215 + | Ok json -> Some (Openapi.Runtime.Json json) 5216 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5217 + in 5218 + raise (Openapi.Runtime.Api_error { 5219 + operation = op_name; 5220 + method_ = "GET"; 5221 + url; 5222 + status; 5223 + body; 5224 + parsed_body; 5225 + }) 5226 + 5227 + (** Import documents into a collection 5228 + 5229 + 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. 5230 + @param collection_name The name of the collection 5231 + *) 5232 + let import_documents ~collection_name ?import_documents_parameters client () = 5233 + let op_name = "import_documents" in 5234 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name)] "/collections/{collectionName}/documents/import" in 5235 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"importDocumentsParameters" ~value:import_documents_parameters]) in 5236 + let url = client.base_url ^ url_path ^ query in 5237 + let response = 5238 + try Requests.post client.session url 5239 + with Eio.Io _ as ex -> 5240 + let bt = Printexc.get_raw_backtrace () in 5241 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 5242 + in 5243 + if Requests.Response.ok response then 5244 + Requests.Response.json response 5245 + else 5246 + let body = Requests.Response.text response in 5247 + let status = Requests.Response.status_code response in 5248 + let parsed_body = match status with 5249 + | 400 -> 5250 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5251 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5252 + | Error _ -> None) 5253 + | 404 -> 5254 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5255 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5256 + | Error _ -> None) 5257 + | _ -> 5258 + (match Jsont_bytesrw.decode_string Jsont.json body with 5259 + | Ok json -> Some (Openapi.Runtime.Json json) 5260 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5261 + in 5262 + raise (Openapi.Runtime.Api_error { 5263 + operation = op_name; 5264 + method_ = "POST"; 5265 + url; 5266 + status; 5267 + body; 5268 + parsed_body; 5269 + }) 5270 + 5271 + (** Retrieve a document 5272 + 5273 + Fetch an individual document from a collection by using its ID. 5274 + @param collection_name The name of the collection to search for the document under 5275 + @param document_id The Document ID 5276 + *) 5277 + let get_document ~collection_name ~document_id client () = 5278 + let op_name = "get_document" in 5279 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in 5280 + let query = "" in 5281 + let url = client.base_url ^ url_path ^ query in 5282 + let response = 5283 + try Requests.get client.session url 5284 + with Eio.Io _ as ex -> 5285 + let bt = Printexc.get_raw_backtrace () in 5286 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5287 + in 5288 + if Requests.Response.ok response then 5289 + Requests.Response.json response 5290 + else 5291 + let body = Requests.Response.text response in 5292 + let status = Requests.Response.status_code response in 5293 + let parsed_body = match status with 5294 + | 404 -> 5295 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5296 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5297 + | Error _ -> None) 5298 + | _ -> 5299 + (match Jsont_bytesrw.decode_string Jsont.json body with 5300 + | Ok json -> Some (Openapi.Runtime.Json json) 5301 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5302 + in 5303 + raise (Openapi.Runtime.Api_error { 5304 + operation = op_name; 5305 + method_ = "GET"; 5306 + url; 5307 + status; 5308 + body; 5309 + parsed_body; 5310 + }) 5311 + 5312 + (** Delete a document 5313 + 5314 + Delete an individual document from a collection by using its ID. 5315 + @param collection_name The name of the collection to search for the document under 5316 + @param document_id The Document ID 5317 + *) 5318 + let delete_document ~collection_name ~document_id client () = 5319 + let op_name = "delete_document" in 5320 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in 5321 + let query = "" in 5322 + let url = client.base_url ^ url_path ^ query in 5323 + let response = 5324 + try Requests.delete client.session url 5325 + with Eio.Io _ as ex -> 5326 + let bt = Printexc.get_raw_backtrace () in 5327 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 5328 + in 5329 + if Requests.Response.ok response then 5330 + Requests.Response.json response 5331 + else 5332 + let body = Requests.Response.text response in 5333 + let status = Requests.Response.status_code response in 5334 + let parsed_body = match status with 5335 + | 404 -> 5336 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5337 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5338 + | Error _ -> None) 5339 + | _ -> 5340 + (match Jsont_bytesrw.decode_string Jsont.json body with 5341 + | Ok json -> Some (Openapi.Runtime.Json json) 5342 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5343 + in 5344 + raise (Openapi.Runtime.Api_error { 5345 + operation = op_name; 5346 + method_ = "DELETE"; 5347 + url; 5348 + status; 5349 + body; 5350 + parsed_body; 5351 + }) 5352 + 5353 + (** Update a document 5354 + 5355 + Update an individual document from a collection by using its ID. The update can be partial. 5356 + @param collection_name The name of the collection to search for the document under 5357 + @param document_id The Document ID 5358 + @param dirty_values Dealing with Dirty Data 5359 + *) 5360 + let update_document ~collection_name ~document_id ?dirty_values client () = 5361 + let op_name = "update_document" in 5362 + let url_path = Openapi.Runtime.Path.render ~params:[("collectionName", collection_name); ("documentId", document_id)] "/collections/{collectionName}/documents/{documentId}" in 5363 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"dirty_values" ~value:dirty_values]) in 5364 + let url = client.base_url ^ url_path ^ query in 5365 + let response = 5366 + try Requests.patch client.session url 5367 + with Eio.Io _ as ex -> 5368 + let bt = Printexc.get_raw_backtrace () in 5369 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PATCH" url 5370 + in 5371 + if Requests.Response.ok response then 5372 + Requests.Response.json response 5373 + else 5374 + let body = Requests.Response.text response in 5375 + let status = Requests.Response.status_code response in 5376 + let parsed_body = match status with 5377 + | 404 -> 5378 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5379 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5380 + | Error _ -> None) 5381 + | _ -> 5382 + (match Jsont_bytesrw.decode_string Jsont.json body with 5383 + | Ok json -> Some (Openapi.Runtime.Json json) 5384 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5385 + in 5386 + raise (Openapi.Runtime.Api_error { 5387 + operation = op_name; 5388 + method_ = "PATCH"; 5389 + url; 5390 + status; 5391 + body; 5392 + parsed_body; 5393 + }) 5394 + 5395 + (** Print debugging information 5396 + 5397 + Print debugging information *) 5398 + let debug client () = 5399 + let op_name = "debug" in 5400 + let url_path = "/debug" in 5401 + let query = "" in 5402 + let url = client.base_url ^ url_path ^ query in 5403 + let response = 5404 + try Requests.get client.session url 5405 + with Eio.Io _ as ex -> 5406 + let bt = Printexc.get_raw_backtrace () in 5407 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5408 + in 5409 + if Requests.Response.ok response then 5410 + Requests.Response.json response 5411 + else 5412 + let body = Requests.Response.text response in 5413 + let parsed_body = 5414 + match Jsont_bytesrw.decode_string Jsont.json body with 5415 + | Ok json -> Some (Openapi.Runtime.Json json) 5416 + | Error _ -> Some (Openapi.Runtime.Raw body) 5417 + in 5418 + raise (Openapi.Runtime.Api_error { 5419 + operation = op_name; 5420 + method_ = "GET"; 5421 + url; 5422 + status = Requests.Response.status_code response; 5423 + body; 5424 + parsed_body; 5425 + }) 5426 + 5427 + (** Get current RAM, CPU, Disk & Network usage metrics. 5428 + 5429 + Retrieve the metrics. *) 5430 + let retrieve_metrics client () = 5431 + let op_name = "retrieve_metrics" in 5432 + let url_path = "/metrics.json" in 5433 + let query = "" in 5434 + let url = client.base_url ^ url_path ^ query in 5435 + let response = 5436 + try Requests.get client.session url 5437 + with Eio.Io _ as ex -> 5438 + let bt = Printexc.get_raw_backtrace () in 5439 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5440 + in 5441 + if Requests.Response.ok response then 5442 + Requests.Response.json response 5443 + else 5444 + let body = Requests.Response.text response in 5445 + let parsed_body = 5446 + match Jsont_bytesrw.decode_string Jsont.json body with 5447 + | Ok json -> Some (Openapi.Runtime.Json json) 5448 + | Error _ -> Some (Openapi.Runtime.Raw body) 5449 + in 5450 + raise (Openapi.Runtime.Api_error { 5451 + operation = op_name; 5452 + method_ = "GET"; 5453 + url; 5454 + status = Requests.Response.status_code response; 5455 + body; 5456 + parsed_body; 5457 + }) 5458 + 5459 + (** List all stemming dictionaries 5460 + 5461 + Retrieve a list of all available stemming dictionaries. *) 5462 + let list_stemming_dictionaries client () = 5463 + let op_name = "list_stemming_dictionaries" in 5464 + let url_path = "/stemming/dictionaries" in 5465 + let query = "" in 5466 + let url = client.base_url ^ url_path ^ query in 5467 + let response = 5468 + try Requests.get client.session url 5469 + with Eio.Io _ as ex -> 5470 + let bt = Printexc.get_raw_backtrace () in 5471 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5472 + in 5473 + if Requests.Response.ok response then 5474 + Requests.Response.json response 5475 + else 5476 + let body = Requests.Response.text response in 5477 + let parsed_body = 5478 + match Jsont_bytesrw.decode_string Jsont.json body with 5479 + | Ok json -> Some (Openapi.Runtime.Json json) 5480 + | Error _ -> Some (Openapi.Runtime.Raw body) 5481 + in 5482 + raise (Openapi.Runtime.Api_error { 5483 + operation = op_name; 5484 + method_ = "GET"; 5485 + url; 5486 + status = Requests.Response.status_code response; 5487 + body; 5488 + parsed_body; 5489 + }) 5490 + 5491 + (** Import a stemming dictionary 5492 + 5493 + Upload a JSONL file containing word mappings to create or update a stemming dictionary. 5494 + @param id The ID to assign to the dictionary 5495 + *) 5496 + let import_stemming_dictionary ~id client () = 5497 + let op_name = "import_stemming_dictionary" in 5498 + let url_path = "/stemming/dictionaries/import" in 5499 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.singleton ~key:"id" ~value:id]) in 5500 + let url = client.base_url ^ url_path ^ query in 5501 + let response = 5502 + try Requests.post client.session url 5503 + with Eio.Io _ as ex -> 5504 + let bt = Printexc.get_raw_backtrace () in 5505 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 5506 + in 5507 + if Requests.Response.ok response then 5508 + Requests.Response.json response 5509 + else 5510 + let body = Requests.Response.text response in 5511 + let status = Requests.Response.status_code response in 5512 + let parsed_body = match status with 5513 + | 400 -> 5514 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5515 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5516 + | Error _ -> None) 5517 + | _ -> 5518 + (match Jsont_bytesrw.decode_string Jsont.json body with 5519 + | Ok json -> Some (Openapi.Runtime.Json json) 5520 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5521 + in 5522 + raise (Openapi.Runtime.Api_error { 5523 + operation = op_name; 5524 + method_ = "POST"; 5525 + url; 5526 + status; 5527 + body; 5528 + parsed_body; 5529 + }) 5530 + 5531 + (** Delete a stopwords set. 5532 + 5533 + Permanently deletes a stopwords set, given it's name. 5534 + @param set_id The ID of the stopwords set to delete. 5535 + *) 5536 + let delete_stopwords_set ~set_id client () = 5537 + let op_name = "delete_stopwords_set" in 5538 + let url_path = Openapi.Runtime.Path.render ~params:[("setId", set_id)] "/stopwords/{setId}" in 5539 + let query = "" in 5540 + let url = client.base_url ^ url_path ^ query in 5541 + let response = 5542 + try Requests.delete client.session url 5543 + with Eio.Io _ as ex -> 5544 + let bt = Printexc.get_raw_backtrace () in 5545 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 5546 + in 5547 + if Requests.Response.ok response then 5548 + Requests.Response.json response 5549 + else 5550 + let body = Requests.Response.text response in 5551 + let status = Requests.Response.status_code response in 5552 + let parsed_body = match status with 5553 + | 404 -> 5554 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5555 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5556 + | Error _ -> None) 5557 + | _ -> 5558 + (match Jsont_bytesrw.decode_string Jsont.json body with 5559 + | Ok json -> Some (Openapi.Runtime.Json json) 5560 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5561 + in 5562 + raise (Openapi.Runtime.Api_error { 5563 + operation = op_name; 5564 + method_ = "DELETE"; 5565 + url; 5566 + status; 5567 + body; 5568 + parsed_body; 5569 + }) 5570 + end 5571 + 5572 + module Apistats = struct 5573 + module Types = struct 5574 + module Response = struct 5575 + type t = { 5576 + delete_latency_ms : float option; 5577 + delete_requests_per_second : float option; 5578 + import_latency_ms : float option; 5579 + import_requests_per_second : float option; 5580 + latency_ms : Jsont.json option; 5581 + overloaded_requests_per_second : float option; 5582 + pending_write_batches : float option; 5583 + requests_per_second : Jsont.json option; 5584 + search_latency_ms : float option; 5585 + search_requests_per_second : float option; 5586 + total_requests_per_second : float option; 5587 + write_latency_ms : float option; 5588 + write_requests_per_second : float option; 5589 + } 5590 + end 5591 + end 5592 + 5593 + module Response = struct 5594 + include Types.Response 5595 + 5596 + 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 } 5597 + 5598 + let delete_latency_ms t = t.delete_latency_ms 5599 + let delete_requests_per_second t = t.delete_requests_per_second 5600 + let import_latency_ms t = t.import_latency_ms 5601 + let import_requests_per_second t = t.import_requests_per_second 5602 + let latency_ms t = t.latency_ms 5603 + let overloaded_requests_per_second t = t.overloaded_requests_per_second 5604 + let pending_write_batches t = t.pending_write_batches 5605 + let requests_per_second t = t.requests_per_second 5606 + let search_latency_ms t = t.search_latency_ms 5607 + let search_requests_per_second t = t.search_requests_per_second 5608 + let total_requests_per_second t = t.total_requests_per_second 5609 + let write_latency_ms t = t.write_latency_ms 5610 + let write_requests_per_second t = t.write_requests_per_second 5611 + 5612 + let jsont : t Jsont.t = 5613 + Jsont.Object.map ~kind:"APIStatsResponse" 5614 + (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 }) 5615 + |> Jsont.Object.opt_mem "delete_latency_ms" Jsont.number ~enc:(fun r -> r.delete_latency_ms) 5616 + |> Jsont.Object.opt_mem "delete_requests_per_second" Jsont.number ~enc:(fun r -> r.delete_requests_per_second) 5617 + |> Jsont.Object.opt_mem "import_latency_ms" Jsont.number ~enc:(fun r -> r.import_latency_ms) 5618 + |> Jsont.Object.opt_mem "import_requests_per_second" Jsont.number ~enc:(fun r -> r.import_requests_per_second) 5619 + |> Jsont.Object.opt_mem "latency_ms" Jsont.json ~enc:(fun r -> r.latency_ms) 5620 + |> Jsont.Object.opt_mem "overloaded_requests_per_second" Jsont.number ~enc:(fun r -> r.overloaded_requests_per_second) 5621 + |> Jsont.Object.opt_mem "pending_write_batches" Jsont.number ~enc:(fun r -> r.pending_write_batches) 5622 + |> Jsont.Object.opt_mem "requests_per_second" Jsont.json ~enc:(fun r -> r.requests_per_second) 5623 + |> Jsont.Object.opt_mem "search_latency_ms" Jsont.number ~enc:(fun r -> r.search_latency_ms) 5624 + |> Jsont.Object.opt_mem "search_requests_per_second" Jsont.number ~enc:(fun r -> r.search_requests_per_second) 5625 + |> Jsont.Object.opt_mem "total_requests_per_second" Jsont.number ~enc:(fun r -> r.total_requests_per_second) 5626 + |> Jsont.Object.opt_mem "write_latency_ms" Jsont.number ~enc:(fun r -> r.write_latency_ms) 5627 + |> Jsont.Object.opt_mem "write_requests_per_second" Jsont.number ~enc:(fun r -> r.write_requests_per_second) 5628 + |> Jsont.Object.skip_unknown 5629 + |> Jsont.Object.finish 5630 + end 5631 + 5632 + (** Get stats about API endpoints. 5633 + 5634 + Retrieve the stats about API endpoints. *) 5635 + let retrieve_apistats client () = 5636 + let op_name = "retrieve_apistats" in 5637 + let url_path = "/stats.json" in 5638 + let query = "" in 5639 + let url = client.base_url ^ url_path ^ query in 5640 + let response = 5641 + try Requests.get client.session url 5642 + with Eio.Io _ as ex -> 5643 + let bt = Printexc.get_raw_backtrace () in 5644 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5645 + in 5646 + if Requests.Response.ok response then 5647 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 5648 + else 5649 + let body = Requests.Response.text response in 5650 + let parsed_body = 5651 + match Jsont_bytesrw.decode_string Jsont.json body with 5652 + | Ok json -> Some (Openapi.Runtime.Json json) 5653 + | Error _ -> Some (Openapi.Runtime.Raw body) 5654 + in 5655 + raise (Openapi.Runtime.Api_error { 5656 + operation = op_name; 5657 + method_ = "GET"; 5658 + url; 5659 + status = Requests.Response.status_code response; 5660 + body; 5661 + parsed_body; 5662 + }) 5663 + end 5664 + 5665 + module ApiKeySchema = struct 5666 + module Types = struct 5667 + module T = struct 5668 + type t = { 5669 + actions : string list; 5670 + collections : string list; 5671 + description : string; 5672 + expires_at : int64 option; 5673 + value : string option; 5674 + } 5675 + end 5676 + end 5677 + 5678 + module T = struct 5679 + include Types.T 5680 + 5681 + let v ~actions ~collections ~description ?expires_at ?value () = { actions; collections; description; expires_at; value } 5682 + 5683 + let actions t = t.actions 5684 + let collections t = t.collections 5685 + let description t = t.description 5686 + let expires_at t = t.expires_at 5687 + let value t = t.value 5688 + 5689 + let jsont : t Jsont.t = 5690 + Jsont.Object.map ~kind:"ApiKeySchema" 5691 + (fun actions collections description expires_at value -> { actions; collections; description; expires_at; value }) 5692 + |> Jsont.Object.mem "actions" (Jsont.list Jsont.string) ~enc:(fun r -> r.actions) 5693 + |> Jsont.Object.mem "collections" (Jsont.list Jsont.string) ~enc:(fun r -> r.collections) 5694 + |> Jsont.Object.mem "description" Jsont.string ~enc:(fun r -> r.description) 5695 + |> Jsont.Object.opt_mem "expires_at" Jsont.int64 ~enc:(fun r -> r.expires_at) 5696 + |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value) 5697 + |> Jsont.Object.skip_unknown 5698 + |> Jsont.Object.finish 5699 + end 5700 + end 5701 + 5702 + module ApiKey = struct 5703 + module Types = struct 5704 + module T = struct 5705 + type t = { 5706 + actions : string list; 5707 + collections : string list; 5708 + description : string; 5709 + expires_at : int64 option; 5710 + value : string option; 5711 + id : int64 option; 5712 + value_prefix : string option; 5713 + } 5714 + end 5715 + end 5716 + 5717 + module T = struct 5718 + include Types.T 5719 + 5720 + let v ~actions ~collections ~description ?expires_at ?value ?id ?value_prefix () = { actions; collections; description; expires_at; value; id; value_prefix } 5721 + 5722 + let actions t = t.actions 5723 + let collections t = t.collections 5724 + let description t = t.description 5725 + let expires_at t = t.expires_at 5726 + let value t = t.value 5727 + let id t = t.id 5728 + let value_prefix t = t.value_prefix 5729 + 5730 + let jsont : t Jsont.t = 5731 + Jsont.Object.map ~kind:"ApiKey" 5732 + (fun actions collections description expires_at value id value_prefix -> { actions; collections; description; expires_at; value; id; value_prefix }) 5733 + |> Jsont.Object.mem "actions" (Jsont.list Jsont.string) ~enc:(fun r -> r.actions) 5734 + |> Jsont.Object.mem "collections" (Jsont.list Jsont.string) ~enc:(fun r -> r.collections) 5735 + |> Jsont.Object.mem "description" Jsont.string ~enc:(fun r -> r.description) 5736 + |> Jsont.Object.opt_mem "expires_at" Jsont.int64 ~enc:(fun r -> r.expires_at) 5737 + |> Jsont.Object.opt_mem "value" Jsont.string ~enc:(fun r -> r.value) 5738 + |> Jsont.Object.opt_mem "id" Jsont.int64 ~enc:(fun r -> r.id) 5739 + |> Jsont.Object.opt_mem "value_prefix" Jsont.string ~enc:(fun r -> r.value_prefix) 5740 + |> Jsont.Object.skip_unknown 5741 + |> Jsont.Object.finish 5742 + end 5743 + 5744 + (** Create an API Key 5745 + 5746 + 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. *) 5747 + let create_key ~body client () = 5748 + let op_name = "create_key" in 5749 + let url_path = "/keys" in 5750 + let query = "" in 5751 + let url = client.base_url ^ url_path ^ query in 5752 + let response = 5753 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json ApiKeySchema.T.jsont body)) url 5754 + with Eio.Io _ as ex -> 5755 + let bt = Printexc.get_raw_backtrace () in 5756 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 5757 + in 5758 + if Requests.Response.ok response then 5759 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 5760 + else 5761 + let body = Requests.Response.text response in 5762 + let status = Requests.Response.status_code response in 5763 + let parsed_body = match status with 5764 + | 400 -> 5765 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5766 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5767 + | Error _ -> None) 5768 + | 409 -> 5769 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5770 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5771 + | Error _ -> None) 5772 + | _ -> 5773 + (match Jsont_bytesrw.decode_string Jsont.json body with 5774 + | Ok json -> Some (Openapi.Runtime.Json json) 5775 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5776 + in 5777 + raise (Openapi.Runtime.Api_error { 5778 + operation = op_name; 5779 + method_ = "POST"; 5780 + url; 5781 + status; 5782 + body; 5783 + parsed_body; 5784 + }) 5785 + 5786 + (** Retrieve (metadata about) a key 5787 + 5788 + 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. 5789 + @param key_id The ID of the key to retrieve 5790 + *) 5791 + let get_key ~key_id client () = 5792 + let op_name = "get_key" in 5793 + let url_path = Openapi.Runtime.Path.render ~params:[("keyId", key_id)] "/keys/{keyId}" in 5794 + let query = "" in 5795 + let url = client.base_url ^ url_path ^ query in 5796 + let response = 5797 + try Requests.get client.session url 5798 + with Eio.Io _ as ex -> 5799 + let bt = Printexc.get_raw_backtrace () in 5800 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5801 + in 5802 + if Requests.Response.ok response then 5803 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 5804 + else 5805 + let body = Requests.Response.text response in 5806 + let status = Requests.Response.status_code response in 5807 + let parsed_body = match status with 5808 + | 404 -> 5809 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5810 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5811 + | Error _ -> None) 5812 + | _ -> 5813 + (match Jsont_bytesrw.decode_string Jsont.json body with 5814 + | Ok json -> Some (Openapi.Runtime.Json json) 5815 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5816 + in 5817 + raise (Openapi.Runtime.Api_error { 5818 + operation = op_name; 5819 + method_ = "GET"; 5820 + url; 5821 + status; 5822 + body; 5823 + parsed_body; 5824 + }) 5825 + end 5826 + 5827 + module ApiKeys = struct 5828 + module Types = struct 5829 + module Response = struct 5830 + type t = { 5831 + keys : ApiKey.T.t list; 5832 + } 5833 + end 5834 + end 5835 + 5836 + module Response = struct 5837 + include Types.Response 5838 + 5839 + let v ~keys () = { keys } 5840 + 5841 + let keys t = t.keys 5842 + 5843 + let jsont : t Jsont.t = 5844 + Jsont.Object.map ~kind:"ApiKeysResponse" 5845 + (fun keys -> { keys }) 5846 + |> Jsont.Object.mem "keys" (Jsont.list ApiKey.T.jsont) ~enc:(fun r -> r.keys) 5847 + |> Jsont.Object.skip_unknown 5848 + |> Jsont.Object.finish 5849 + end 5850 + 5851 + (** Retrieve (metadata about) all keys. *) 5852 + let get_keys client () = 5853 + let op_name = "get_keys" in 5854 + let url_path = "/keys" in 5855 + let query = "" in 5856 + let url = client.base_url ^ url_path ^ query in 5857 + let response = 5858 + try Requests.get client.session url 5859 + with Eio.Io _ as ex -> 5860 + let bt = Printexc.get_raw_backtrace () in 5861 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 5862 + in 5863 + if Requests.Response.ok response then 5864 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 5865 + else 5866 + let body = Requests.Response.text response in 5867 + let parsed_body = 5868 + match Jsont_bytesrw.decode_string Jsont.json body with 5869 + | Ok json -> Some (Openapi.Runtime.Json json) 5870 + | Error _ -> Some (Openapi.Runtime.Raw body) 5871 + in 5872 + raise (Openapi.Runtime.Api_error { 5873 + operation = op_name; 5874 + method_ = "GET"; 5875 + url; 5876 + status = Requests.Response.status_code response; 5877 + body; 5878 + parsed_body; 5879 + }) 5880 + end 5881 + 5882 + module ApiKeyDelete = struct 5883 + module Types = struct 5884 + module Response = struct 5885 + type t = { 5886 + id : int64; (** The id of the API key that was deleted *) 5887 + } 5888 + end 5889 + end 5890 + 5891 + module Response = struct 5892 + include Types.Response 5893 + 5894 + let v ~id () = { id } 5895 + 5896 + let id t = t.id 5897 + 5898 + let jsont : t Jsont.t = 5899 + Jsont.Object.map ~kind:"ApiKeyDeleteResponse" 5900 + (fun id -> { id }) 5901 + |> Jsont.Object.mem "id" Jsont.int64 ~enc:(fun r -> r.id) 5902 + |> Jsont.Object.skip_unknown 5903 + |> Jsont.Object.finish 5904 + end 5905 + 5906 + (** Delete an API key given its ID. 5907 + @param key_id The ID of the key to delete 5908 + *) 5909 + let delete_key ~key_id client () = 5910 + let op_name = "delete_key" in 5911 + let url_path = Openapi.Runtime.Path.render ~params:[("keyId", key_id)] "/keys/{keyId}" in 5912 + let query = "" in 5913 + let url = client.base_url ^ url_path ^ query in 5914 + let response = 5915 + try Requests.delete client.session url 5916 + with Eio.Io _ as ex -> 5917 + let bt = Printexc.get_raw_backtrace () in 5918 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 5919 + in 5920 + if Requests.Response.ok response then 5921 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 5922 + else 5923 + let body = Requests.Response.text response in 5924 + let status = Requests.Response.status_code response in 5925 + let parsed_body = match status with 5926 + | 400 -> 5927 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5928 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5929 + | Error _ -> None) 5930 + | 404 -> 5931 + (match Openapi.Runtime.Json.decode_json Jsont.json (Requests.Response.json response) with 5932 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Jsont.json v)) 5933 + | Error _ -> None) 5934 + | _ -> 5935 + (match Jsont_bytesrw.decode_string Jsont.json body with 5936 + | Ok json -> Some (Openapi.Runtime.Json json) 5937 + | Error _ -> Some (Openapi.Runtime.Raw body)) 5938 + in 5939 + raise (Openapi.Runtime.Api_error { 5940 + operation = op_name; 5941 + method_ = "DELETE"; 5942 + url; 5943 + status; 5944 + body; 5945 + parsed_body; 5946 + }) 5947 + end 5948 + 5949 + module Api = struct 5950 + module Types = struct 5951 + module Response = struct 5952 + type t = { 5953 + message : string; 5954 + } 5955 + end 5956 + end 5957 + 5958 + module Response = struct 5959 + include Types.Response 5960 + 5961 + let v ~message () = { message } 5962 + 5963 + let message t = t.message 5964 + 5965 + let jsont : t Jsont.t = 5966 + Jsont.Object.map ~kind:"ApiResponse" 5967 + (fun message -> { message }) 5968 + |> Jsont.Object.mem "message" Jsont.string ~enc:(fun r -> r.message) 5969 + |> Jsont.Object.skip_unknown 5970 + |> Jsont.Object.finish 5971 + end 5972 + end 5973 + 5974 + module AnalyticsRule = struct 5975 + module Types = struct 5976 + module Update = struct 5977 + (** Fields allowed to update on an analytics rule *) 5978 + type t = { 5979 + name : string option; 5980 + params : Jsont.json option; 5981 + rule_tag : string option; 5982 + } 5983 + end 5984 + 5985 + module Type = struct 5986 + type t = [ 5987 + | `Popular_queries 5988 + | `Nohits_queries 5989 + | `Counter 5990 + | `Log 5991 + ] 5992 + end 5993 + 5994 + module Create = struct 5995 + type t = { 5996 + collection : string; 5997 + event_type : string; 5998 + name : string; 5999 + params : Jsont.json option; 6000 + rule_tag : string option; 6001 + type_ : Type.t; 6002 + } 6003 + end 6004 + 6005 + module T = struct 6006 + type t = { 6007 + collection : string; 6008 + event_type : string; 6009 + name : string; 6010 + params : Jsont.json option; 6011 + rule_tag : string option; 6012 + type_ : Type.t; 6013 + } 6014 + end 6015 + end 6016 + 6017 + module Update = struct 6018 + include Types.Update 6019 + 6020 + let v ?name ?params ?rule_tag () = { name; params; rule_tag } 6021 + 6022 + let name t = t.name 6023 + let params t = t.params 6024 + let rule_tag t = t.rule_tag 6025 + 6026 + let jsont : t Jsont.t = 6027 + Jsont.Object.map ~kind:"AnalyticsRuleUpdate" 6028 + (fun name params rule_tag -> { name; params; rule_tag }) 6029 + |> Jsont.Object.opt_mem "name" Jsont.string ~enc:(fun r -> r.name) 6030 + |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params) 6031 + |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag) 6032 + |> Jsont.Object.skip_unknown 6033 + |> Jsont.Object.finish 6034 + end 6035 + 6036 + module Type = struct 6037 + include Types.Type 6038 + 6039 + let jsont : t Jsont.t = 6040 + Jsont.map Jsont.string ~kind:"AnalyticsRuleType" 6041 + ~dec:(function 6042 + | "popular_queries" -> `Popular_queries 6043 + | "nohits_queries" -> `Nohits_queries 6044 + | "counter" -> `Counter 6045 + | "log" -> `Log 6046 + | s -> Jsont.Error.msgf Jsont.Meta.none "Unknown value: %s" s) 6047 + ~enc:(function 6048 + | `Popular_queries -> "popular_queries" 6049 + | `Nohits_queries -> "nohits_queries" 6050 + | `Counter -> "counter" 6051 + | `Log -> "log") 6052 + end 6053 + 6054 + module Create = struct 6055 + include Types.Create 6056 + 6057 + let v ~collection ~event_type ~name ~type_ ?params ?rule_tag () = { collection; event_type; name; params; rule_tag; type_ } 6058 + 6059 + let collection t = t.collection 6060 + let event_type t = t.event_type 6061 + let name t = t.name 6062 + let params t = t.params 6063 + let rule_tag t = t.rule_tag 6064 + let type_ t = t.type_ 6065 + 6066 + let jsont : t Jsont.t = 6067 + Jsont.Object.map ~kind:"AnalyticsRuleCreate" 6068 + (fun collection event_type name params rule_tag type_ -> { collection; event_type; name; params; rule_tag; type_ }) 6069 + |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection) 6070 + |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type) 6071 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 6072 + |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params) 6073 + |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag) 6074 + |> Jsont.Object.mem "type" Type.jsont ~enc:(fun r -> r.type_) 6075 + |> Jsont.Object.skip_unknown 6076 + |> Jsont.Object.finish 6077 + end 6078 + 6079 + module T = struct 6080 + include Types.T 6081 + 6082 + let v ~collection ~event_type ~name ~type_ ?params ?rule_tag () = { collection; event_type; name; params; rule_tag; type_ } 6083 + 6084 + let collection t = t.collection 6085 + let event_type t = t.event_type 6086 + let name t = t.name 6087 + let params t = t.params 6088 + let rule_tag t = t.rule_tag 6089 + let type_ t = t.type_ 6090 + 6091 + let jsont : t Jsont.t = 6092 + Jsont.Object.map ~kind:"AnalyticsRule" 6093 + (fun collection event_type name params rule_tag type_ -> { collection; event_type; name; params; rule_tag; type_ }) 6094 + |> Jsont.Object.mem "collection" Jsont.string ~enc:(fun r -> r.collection) 6095 + |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type) 6096 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 6097 + |> Jsont.Object.opt_mem "params" Jsont.json ~enc:(fun r -> r.params) 6098 + |> Jsont.Object.opt_mem "rule_tag" Jsont.string ~enc:(fun r -> r.rule_tag) 6099 + |> Jsont.Object.mem "type" Type.jsont ~enc:(fun r -> r.type_) 6100 + |> Jsont.Object.skip_unknown 6101 + |> Jsont.Object.finish 6102 + end 6103 + 6104 + (** Retrieve analytics rules 6105 + 6106 + Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. 6107 + @param rule_tag Filter rules by rule_tag 6108 + *) 6109 + let retrieve_analytics_rules ?rule_tag client () = 6110 + let op_name = "retrieve_analytics_rules" in 6111 + let url_path = "/analytics/rules" in 6112 + let query = Openapi.Runtime.Query.encode (List.concat [Openapi.Runtime.Query.optional ~key:"rule_tag" ~value:rule_tag]) in 6113 + let url = client.base_url ^ url_path ^ query in 6114 + let response = 6115 + try Requests.get client.session url 6116 + with Eio.Io _ as ex -> 6117 + let bt = Printexc.get_raw_backtrace () in 6118 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 6119 + in 6120 + if Requests.Response.ok response then 6121 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 6122 + else 6123 + let body = Requests.Response.text response in 6124 + let parsed_body = 6125 + match Jsont_bytesrw.decode_string Jsont.json body with 6126 + | Ok json -> Some (Openapi.Runtime.Json json) 6127 + | Error _ -> Some (Openapi.Runtime.Raw body) 6128 + in 6129 + raise (Openapi.Runtime.Api_error { 6130 + operation = op_name; 6131 + method_ = "GET"; 6132 + url; 6133 + status = Requests.Response.status_code response; 6134 + body; 6135 + parsed_body; 6136 + }) 6137 + 6138 + (** Retrieves an analytics rule 6139 + 6140 + Retrieve the details of an analytics rule, given it's name 6141 + @param rule_name The name of the analytics rule to retrieve 6142 + *) 6143 + let retrieve_analytics_rule ~rule_name client () = 6144 + let op_name = "retrieve_analytics_rule" in 6145 + let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in 6146 + let query = "" in 6147 + let url = client.base_url ^ url_path ^ query in 6148 + let response = 6149 + try Requests.get client.session url 6150 + with Eio.Io _ as ex -> 6151 + let bt = Printexc.get_raw_backtrace () in 6152 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 6153 + in 6154 + if Requests.Response.ok response then 6155 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 6156 + else 6157 + let body = Requests.Response.text response in 6158 + let status = Requests.Response.status_code response in 6159 + let parsed_body = match status with 6160 + | 404 -> 6161 + (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with 6162 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v)) 6163 + | Error _ -> None) 6164 + | _ -> 6165 + (match Jsont_bytesrw.decode_string Jsont.json body with 6166 + | Ok json -> Some (Openapi.Runtime.Json json) 6167 + | Error _ -> Some (Openapi.Runtime.Raw body)) 6168 + in 6169 + raise (Openapi.Runtime.Api_error { 6170 + operation = op_name; 6171 + method_ = "GET"; 6172 + url; 6173 + status; 6174 + body; 6175 + parsed_body; 6176 + }) 6177 + 6178 + (** Upserts an analytics rule 6179 + 6180 + Upserts an analytics rule with the given name. 6181 + @param rule_name The name of the analytics rule to upsert 6182 + *) 6183 + let upsert_analytics_rule ~rule_name ~body client () = 6184 + let op_name = "upsert_analytics_rule" in 6185 + let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in 6186 + let query = "" in 6187 + let url = client.base_url ^ url_path ^ query in 6188 + let response = 6189 + try Requests.put client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json Update.jsont body)) url 6190 + with Eio.Io _ as ex -> 6191 + let bt = Printexc.get_raw_backtrace () in 6192 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "PUT" url 6193 + in 6194 + if Requests.Response.ok response then 6195 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 6196 + else 6197 + let body = Requests.Response.text response in 6198 + let status = Requests.Response.status_code response in 6199 + let parsed_body = match status with 6200 + | 400 -> 6201 + (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with 6202 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v)) 6203 + | Error _ -> None) 6204 + | _ -> 6205 + (match Jsont_bytesrw.decode_string Jsont.json body with 6206 + | Ok json -> Some (Openapi.Runtime.Json json) 6207 + | Error _ -> Some (Openapi.Runtime.Raw body)) 6208 + in 6209 + raise (Openapi.Runtime.Api_error { 6210 + operation = op_name; 6211 + method_ = "PUT"; 6212 + url; 6213 + status; 6214 + body; 6215 + parsed_body; 6216 + }) 6217 + 6218 + (** Delete an analytics rule 6219 + 6220 + Permanently deletes an analytics rule, given it's name 6221 + @param rule_name The name of the analytics rule to delete 6222 + *) 6223 + let delete_analytics_rule ~rule_name client () = 6224 + let op_name = "delete_analytics_rule" in 6225 + let url_path = Openapi.Runtime.Path.render ~params:[("ruleName", rule_name)] "/analytics/rules/{ruleName}" in 6226 + let query = "" in 6227 + let url = client.base_url ^ url_path ^ query in 6228 + let response = 6229 + try Requests.delete client.session url 6230 + with Eio.Io _ as ex -> 6231 + let bt = Printexc.get_raw_backtrace () in 6232 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "DELETE" url 6233 + in 6234 + if Requests.Response.ok response then 6235 + Openapi.Runtime.Json.decode_json_exn T.jsont (Requests.Response.json response) 6236 + else 6237 + let body = Requests.Response.text response in 6238 + let status = Requests.Response.status_code response in 6239 + let parsed_body = match status with 6240 + | 404 -> 6241 + (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with 6242 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v)) 6243 + | Error _ -> None) 6244 + | _ -> 6245 + (match Jsont_bytesrw.decode_string Jsont.json body with 6246 + | Ok json -> Some (Openapi.Runtime.Json json) 6247 + | Error _ -> Some (Openapi.Runtime.Raw body)) 6248 + in 6249 + raise (Openapi.Runtime.Api_error { 6250 + operation = op_name; 6251 + method_ = "DELETE"; 6252 + url; 6253 + status; 6254 + body; 6255 + parsed_body; 6256 + }) 6257 + end 6258 + 6259 + module AnalyticsEvents = struct 6260 + module Types = struct 6261 + module Response = struct 6262 + type t = { 6263 + events : Jsont.json list; 6264 + } 6265 + end 6266 + end 6267 + 6268 + module Response = struct 6269 + include Types.Response 6270 + 6271 + let v ~events () = { events } 6272 + 6273 + let events t = t.events 6274 + 6275 + let jsont : t Jsont.t = 6276 + Jsont.Object.map ~kind:"AnalyticsEventsResponse" 6277 + (fun events -> { events }) 6278 + |> Jsont.Object.mem "events" (Jsont.list Jsont.json) ~enc:(fun r -> r.events) 6279 + |> Jsont.Object.skip_unknown 6280 + |> Jsont.Object.finish 6281 + end 6282 + 6283 + (** Retrieve analytics events 6284 + 6285 + Retrieve the most recent events for a user and rule. 6286 + @param name Analytics rule name 6287 + @param n Number of events to return (max 1000) 6288 + *) 6289 + let get_analytics_events ~user_id ~name ~n client () = 6290 + let op_name = "get_analytics_events" in 6291 + let url_path = "/analytics/events" in 6292 + 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 6293 + let url = client.base_url ^ url_path ^ query in 6294 + let response = 6295 + try Requests.get client.session url 6296 + with Eio.Io _ as ex -> 6297 + let bt = Printexc.get_raw_backtrace () in 6298 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 6299 + in 6300 + if Requests.Response.ok response then 6301 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 6302 + else 6303 + let body = Requests.Response.text response in 6304 + let status = Requests.Response.status_code response in 6305 + let parsed_body = match status with 6306 + | 400 -> 6307 + (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with 6308 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v)) 6309 + | Error _ -> None) 6310 + | _ -> 6311 + (match Jsont_bytesrw.decode_string Jsont.json body with 6312 + | Ok json -> Some (Openapi.Runtime.Json json) 6313 + | Error _ -> Some (Openapi.Runtime.Raw body)) 6314 + in 6315 + raise (Openapi.Runtime.Api_error { 6316 + operation = op_name; 6317 + method_ = "GET"; 6318 + url; 6319 + status; 6320 + body; 6321 + parsed_body; 6322 + }) 6323 + end 6324 + 6325 + module AnalyticsEvent = struct 6326 + module Types = struct 6327 + module T = struct 6328 + type t = { 6329 + data : Jsont.json; (** Event payload *) 6330 + event_type : string; (** Type of event (e.g., click, conversion, query, visit) *) 6331 + name : string; (** Name of the analytics rule this event corresponds to *) 6332 + } 6333 + end 6334 + end 6335 + 6336 + module T = struct 6337 + include Types.T 6338 + 6339 + let v ~data ~event_type ~name () = { data; event_type; name } 6340 + 6341 + let data t = t.data 6342 + let event_type t = t.event_type 6343 + let name t = t.name 6344 + 6345 + let jsont : t Jsont.t = 6346 + Jsont.Object.map ~kind:"AnalyticsEvent" 6347 + (fun data event_type name -> { data; event_type; name }) 6348 + |> Jsont.Object.mem "data" Jsont.json ~enc:(fun r -> r.data) 6349 + |> Jsont.Object.mem "event_type" Jsont.string ~enc:(fun r -> r.event_type) 6350 + |> Jsont.Object.mem "name" Jsont.string ~enc:(fun r -> r.name) 6351 + |> Jsont.Object.skip_unknown 6352 + |> Jsont.Object.finish 6353 + end 6354 + end 6355 + 6356 + module AnalyticsEventCreate = struct 6357 + module Types = struct 6358 + module Response = struct 6359 + type t = { 6360 + ok : bool; 6361 + } 6362 + end 6363 + end 6364 + 6365 + module Response = struct 6366 + include Types.Response 6367 + 6368 + let v ~ok () = { ok } 6369 + 6370 + let ok t = t.ok 6371 + 6372 + let jsont : t Jsont.t = 6373 + Jsont.Object.map ~kind:"AnalyticsEventCreateResponse" 6374 + (fun ok -> { ok }) 6375 + |> Jsont.Object.mem "ok" Jsont.bool ~enc:(fun r -> r.ok) 6376 + |> Jsont.Object.skip_unknown 6377 + |> Jsont.Object.finish 6378 + end 6379 + 6380 + (** Create an analytics event 6381 + 6382 + Submit a single analytics event. The event must correspond to an existing analytics rule by name. *) 6383 + let create_analytics_event ~body client () = 6384 + let op_name = "create_analytics_event" in 6385 + let url_path = "/analytics/events" in 6386 + let query = "" in 6387 + let url = client.base_url ^ url_path ^ query in 6388 + let response = 6389 + try Requests.post client.session ~body:(Requests.Body.json (Openapi.Runtime.Json.encode_json AnalyticsEvent.T.jsont body)) url 6390 + with Eio.Io _ as ex -> 6391 + let bt = Printexc.get_raw_backtrace () in 6392 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 6393 + in 6394 + if Requests.Response.ok response then 6395 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 6396 + else 6397 + let body = Requests.Response.text response in 6398 + let status = Requests.Response.status_code response in 6399 + let parsed_body = match status with 6400 + | 400 -> 6401 + (match Openapi.Runtime.Json.decode_json Api.Response.jsont (Requests.Response.json response) with 6402 + | Ok v -> Some (Openapi.Runtime.Typed ("ApiResponse", Openapi.Runtime.Json.encode_json Api.Response.jsont v)) 6403 + | Error _ -> None) 6404 + | _ -> 6405 + (match Jsont_bytesrw.decode_string Jsont.json body with 6406 + | Ok json -> Some (Openapi.Runtime.Json json) 6407 + | Error _ -> Some (Openapi.Runtime.Raw body)) 6408 + in 6409 + raise (Openapi.Runtime.Api_error { 6410 + operation = op_name; 6411 + method_ = "POST"; 6412 + url; 6413 + status; 6414 + body; 6415 + parsed_body; 6416 + }) 6417 + 6418 + (** Flush in-memory analytics to disk 6419 + 6420 + Triggers a flush of analytics data to persistent storage. *) 6421 + let flush_analytics client () = 6422 + let op_name = "flush_analytics" in 6423 + let url_path = "/analytics/flush" in 6424 + let query = "" in 6425 + let url = client.base_url ^ url_path ^ query in 6426 + let response = 6427 + try Requests.post client.session url 6428 + with Eio.Io _ as ex -> 6429 + let bt = Printexc.get_raw_backtrace () in 6430 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "POST" url 6431 + in 6432 + if Requests.Response.ok response then 6433 + Openapi.Runtime.Json.decode_json_exn Response.jsont (Requests.Response.json response) 6434 + else 6435 + let body = Requests.Response.text response in 6436 + let parsed_body = 6437 + match Jsont_bytesrw.decode_string Jsont.json body with 6438 + | Ok json -> Some (Openapi.Runtime.Json json) 6439 + | Error _ -> Some (Openapi.Runtime.Raw body) 6440 + in 6441 + raise (Openapi.Runtime.Api_error { 6442 + operation = op_name; 6443 + method_ = "POST"; 6444 + url; 6445 + status = Requests.Response.status_code response; 6446 + body; 6447 + parsed_body; 6448 + }) 6449 + end 6450 + 6451 + module Analytics = struct 6452 + module Types = struct 6453 + module Status = struct 6454 + type t = { 6455 + doc_counter_events : int option; 6456 + doc_log_events : int option; 6457 + log_prefix_queries : int option; 6458 + nohits_prefix_queries : int option; 6459 + popular_prefix_queries : int option; 6460 + query_counter_events : int option; 6461 + query_log_events : int option; 6462 + } 6463 + end 6464 + end 6465 + 6466 + module Status = struct 6467 + include Types.Status 6468 + 6469 + 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 } 6470 + 6471 + let doc_counter_events t = t.doc_counter_events 6472 + let doc_log_events t = t.doc_log_events 6473 + let log_prefix_queries t = t.log_prefix_queries 6474 + let nohits_prefix_queries t = t.nohits_prefix_queries 6475 + let popular_prefix_queries t = t.popular_prefix_queries 6476 + let query_counter_events t = t.query_counter_events 6477 + let query_log_events t = t.query_log_events 6478 + 6479 + let jsont : t Jsont.t = 6480 + Jsont.Object.map ~kind:"AnalyticsStatus" 6481 + (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 }) 6482 + |> Jsont.Object.opt_mem "doc_counter_events" Jsont.int ~enc:(fun r -> r.doc_counter_events) 6483 + |> Jsont.Object.opt_mem "doc_log_events" Jsont.int ~enc:(fun r -> r.doc_log_events) 6484 + |> Jsont.Object.opt_mem "log_prefix_queries" Jsont.int ~enc:(fun r -> r.log_prefix_queries) 6485 + |> Jsont.Object.opt_mem "nohits_prefix_queries" Jsont.int ~enc:(fun r -> r.nohits_prefix_queries) 6486 + |> Jsont.Object.opt_mem "popular_prefix_queries" Jsont.int ~enc:(fun r -> r.popular_prefix_queries) 6487 + |> Jsont.Object.opt_mem "query_counter_events" Jsont.int ~enc:(fun r -> r.query_counter_events) 6488 + |> Jsont.Object.opt_mem "query_log_events" Jsont.int ~enc:(fun r -> r.query_log_events) 6489 + |> Jsont.Object.skip_unknown 6490 + |> Jsont.Object.finish 6491 + end 6492 + 6493 + (** Get analytics subsystem status 6494 + 6495 + Returns sizes of internal analytics buffers and queues. *) 6496 + let get_analytics_status client () = 6497 + let op_name = "get_analytics_status" in 6498 + let url_path = "/analytics/status" in 6499 + let query = "" in 6500 + let url = client.base_url ^ url_path ^ query in 6501 + let response = 6502 + try Requests.get client.session url 6503 + with Eio.Io _ as ex -> 6504 + let bt = Printexc.get_raw_backtrace () in 6505 + Eio.Exn.reraise_with_context ex bt "calling %s %s" "GET" url 6506 + in 6507 + if Requests.Response.ok response then 6508 + Openapi.Runtime.Json.decode_json_exn Status.jsont (Requests.Response.json response) 6509 + else 6510 + let body = Requests.Response.text response in 6511 + let parsed_body = 6512 + match Jsont_bytesrw.decode_string Jsont.json body with 6513 + | Ok json -> Some (Openapi.Runtime.Json json) 6514 + | Error _ -> Some (Openapi.Runtime.Raw body) 6515 + in 6516 + raise (Openapi.Runtime.Api_error { 6517 + operation = op_name; 6518 + method_ = "GET"; 6519 + url; 6520 + status = Requests.Response.status_code response; 6521 + body; 6522 + parsed_body; 6523 + }) 6524 + end
+3691
typesense.mli
··· 1 + (** {1 Typesense} 2 + 3 + An open source search engine for building delightful search experiences. 4 + 5 + @version 30.0 *) 6 + 7 + type t 8 + 9 + val create : 10 + ?session:Requests.t -> 11 + sw:Eio.Switch.t -> 12 + < net : _ Eio.Net.t ; fs : Eio.Fs.dir_ty Eio.Path.t ; clock : _ Eio.Time.clock ; .. > -> 13 + base_url:string -> 14 + t 15 + 16 + val base_url : t -> string 17 + val session : t -> Requests.t 18 + 19 + module VoiceQueryModelCollection : sig 20 + module Config : sig 21 + (** Configuration for the voice query model 22 + *) 23 + type t 24 + 25 + (** Construct a value *) 26 + val v : ?model_name:string -> unit -> t 27 + 28 + val model_name : t -> string option 29 + 30 + val jsont : t Jsont.t 31 + end 32 + end 33 + 34 + module SynonymSetDeleteSchema : sig 35 + module T : sig 36 + type t 37 + 38 + (** Construct a value 39 + @param name Name of the deleted synonym set 40 + *) 41 + val v : name:string -> unit -> t 42 + 43 + (** Name of the deleted synonym set *) 44 + val name : t -> string 45 + 46 + val jsont : t Jsont.t 47 + end 48 + 49 + (** Delete a synonym set 50 + 51 + Delete a specific synonym set by its name 52 + @param synonym_set_name The name of the synonym set to delete 53 + *) 54 + val delete_synonym_set : synonym_set_name:string -> t -> unit -> T.t 55 + end 56 + 57 + module SynonymItemUpsertSchema : sig 58 + module T : sig 59 + type t 60 + 61 + (** Construct a value 62 + @param synonyms Array of words that should be considered as synonyms 63 + @param locale Locale for the synonym, leave blank to use the standard tokenizer 64 + @param root For 1-way synonyms, indicates the root word that words in the synonyms parameter map to 65 + @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 66 + *) 67 + val v : synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t 68 + 69 + (** Locale for the synonym, leave blank to use the standard tokenizer *) 70 + val locale : t -> string option 71 + 72 + (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *) 73 + val root : t -> string option 74 + 75 + (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *) 76 + val symbols_to_index : t -> string list option 77 + 78 + (** Array of words that should be considered as synonyms *) 79 + val synonyms : t -> string list 80 + 81 + val jsont : t Jsont.t 82 + end 83 + end 84 + 85 + module SynonymItemSchema : sig 86 + module T : sig 87 + type t 88 + 89 + (** Construct a value 90 + @param id Unique identifier for the synonym item 91 + @param synonyms Array of words that should be considered as synonyms 92 + @param locale Locale for the synonym, leave blank to use the standard tokenizer 93 + @param root For 1-way synonyms, indicates the root word that words in the synonyms parameter map to 94 + @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 95 + *) 96 + val v : id:string -> synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t 97 + 98 + (** Unique identifier for the synonym item *) 99 + val id : t -> string 100 + 101 + (** Locale for the synonym, leave blank to use the standard tokenizer *) 102 + val locale : t -> string option 103 + 104 + (** For 1-way synonyms, indicates the root word that words in the synonyms parameter map to *) 105 + val root : t -> string option 106 + 107 + (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is *) 108 + val symbols_to_index : t -> string list option 109 + 110 + (** Array of words that should be considered as synonyms *) 111 + val synonyms : t -> string list 112 + 113 + val jsont : t Jsont.t 114 + end 115 + 116 + (** List items in a synonym set 117 + 118 + Retrieve all synonym items in a set 119 + @param synonym_set_name The name of the synonym set to retrieve items for 120 + *) 121 + val retrieve_synonym_set_items : synonym_set_name:string -> t -> unit -> T.t 122 + 123 + (** Retrieve a synonym set item 124 + 125 + Retrieve a specific synonym item by its id 126 + @param synonym_set_name The name of the synonym set 127 + @param item_id The id of the synonym item to retrieve 128 + *) 129 + val retrieve_synonym_set_item : synonym_set_name:string -> item_id:string -> t -> unit -> T.t 130 + 131 + (** Create or update a synonym set item 132 + 133 + Create or update a synonym set item with the given id 134 + @param synonym_set_name The name of the synonym set 135 + @param item_id The id of the synonym item to upsert 136 + *) 137 + val upsert_synonym_set_item : synonym_set_name:string -> item_id:string -> body:SynonymItemUpsertSchema.T.t -> t -> unit -> T.t 138 + end 139 + 140 + module SynonymSetCreateSchema : sig 141 + module T : sig 142 + type t 143 + 144 + (** Construct a value 145 + @param items Array of synonym items 146 + *) 147 + val v : items:SynonymItemSchema.T.t list -> unit -> t 148 + 149 + (** Array of synonym items *) 150 + val items : t -> SynonymItemSchema.T.t list 151 + 152 + val jsont : t Jsont.t 153 + end 154 + end 155 + 156 + module SynonymSetSchema : sig 157 + module T : sig 158 + type t 159 + 160 + (** Construct a value 161 + @param items Array of synonym items 162 + @param name Name of the synonym set 163 + *) 164 + val v : items:SynonymItemSchema.T.t list -> name:string -> unit -> t 165 + 166 + (** Array of synonym items *) 167 + val items : t -> SynonymItemSchema.T.t list 168 + 169 + (** Name of the synonym set *) 170 + val name : t -> string 171 + 172 + val jsont : t Jsont.t 173 + end 174 + 175 + (** List all synonym sets 176 + 177 + Retrieve all synonym sets *) 178 + val retrieve_synonym_sets : t -> unit -> T.t 179 + 180 + (** Retrieve a synonym set 181 + 182 + Retrieve a specific synonym set by its name 183 + @param synonym_set_name The name of the synonym set to retrieve 184 + *) 185 + val retrieve_synonym_set : synonym_set_name:string -> t -> unit -> T.t 186 + 187 + (** Create or update a synonym set 188 + 189 + Create or update a synonym set with the given name 190 + @param synonym_set_name The name of the synonym set to create/update 191 + *) 192 + val upsert_synonym_set : synonym_set_name:string -> body:SynonymSetCreateSchema.T.t -> t -> unit -> T.t 193 + end 194 + 195 + module SynonymSetsRetrieveSchema : sig 196 + module T : sig 197 + type t 198 + 199 + (** Construct a value 200 + @param synonym_sets Array of synonym sets 201 + *) 202 + val v : synonym_sets:SynonymSetSchema.T.t list -> unit -> t 203 + 204 + (** Array of synonym sets *) 205 + val synonym_sets : t -> SynonymSetSchema.T.t list 206 + 207 + val jsont : t Jsont.t 208 + end 209 + end 210 + 211 + module SynonymItemDeleteSchema : sig 212 + module T : sig 213 + type t 214 + 215 + (** Construct a value 216 + @param id ID of the deleted synonym item 217 + *) 218 + val v : id:string -> unit -> t 219 + 220 + (** ID of the deleted synonym item *) 221 + val id : t -> string 222 + 223 + val jsont : t Jsont.t 224 + end 225 + 226 + (** Delete a synonym set item 227 + 228 + Delete a specific synonym item by its id 229 + @param synonym_set_name The name of the synonym set 230 + @param item_id The id of the synonym item to delete 231 + *) 232 + val delete_synonym_set_item : synonym_set_name:string -> item_id:string -> t -> unit -> T.t 233 + end 234 + 235 + module Success : sig 236 + module Status : sig 237 + type t 238 + 239 + (** Construct a value *) 240 + val v : success:bool -> unit -> t 241 + 242 + val success : t -> bool 243 + 244 + val jsont : t Jsont.t 245 + end 246 + 247 + (** Toggle Slow Request Log 248 + 249 + 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. *) 250 + val toggle_slow_request_log : t -> unit -> Status.t 251 + 252 + (** Clear the cached responses of search requests in the LRU cache. 253 + 254 + Clear the cached responses of search requests that are sent with `use_cache` parameter in the LRU cache. *) 255 + val clear_cache : t -> unit -> Status.t 256 + 257 + (** Compacting the on-disk database 258 + 259 + 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. *) 260 + val compact_db : t -> unit -> Status.t 261 + 262 + (** Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory. 263 + 264 + 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. 265 + @param snapshot_path The directory on the server where the snapshot should be saved. 266 + *) 267 + val take_snapshot : snapshot_path:string -> t -> unit -> Status.t 268 + 269 + (** Triggers a follower node to initiate the raft voting process, which triggers leader re-election. 270 + 271 + 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. *) 272 + val vote : t -> unit -> Status.t 273 + end 274 + 275 + module StopwordsSetUpsertSchema : sig 276 + module T : sig 277 + type t 278 + 279 + (** Construct a value *) 280 + val v : stopwords:string list -> ?locale:string -> unit -> t 281 + 282 + val locale : t -> string option 283 + 284 + val stopwords : t -> string list 285 + 286 + val jsont : t Jsont.t 287 + end 288 + end 289 + 290 + module StopwordsSetSchema : sig 291 + module T : sig 292 + type t 293 + 294 + (** Construct a value *) 295 + val v : id:string -> stopwords:string list -> ?locale:string -> unit -> t 296 + 297 + val id : t -> string 298 + 299 + val locale : t -> string option 300 + 301 + val stopwords : t -> string list 302 + 303 + val jsont : t Jsont.t 304 + end 305 + 306 + (** Upserts a stopwords set. 307 + 308 + When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. 309 + @param set_id The ID of the stopwords set to upsert. 310 + *) 311 + val upsert_stopwords_set : set_id:string -> body:StopwordsSetUpsertSchema.T.t -> t -> unit -> T.t 312 + end 313 + 314 + module StopwordsSetsRetrieveAllSchema : sig 315 + module T : sig 316 + type t 317 + 318 + (** Construct a value *) 319 + val v : stopwords:StopwordsSetSchema.T.t list -> unit -> t 320 + 321 + val stopwords : t -> StopwordsSetSchema.T.t list 322 + 323 + val jsont : t Jsont.t 324 + end 325 + 326 + (** Retrieves all stopwords sets. 327 + 328 + Retrieve the details of all stopwords sets *) 329 + val retrieve_stopwords_sets : t -> unit -> T.t 330 + end 331 + 332 + module StopwordsSetRetrieveSchema : sig 333 + module T : sig 334 + type t 335 + 336 + (** Construct a value *) 337 + val v : stopwords:StopwordsSetSchema.T.t -> unit -> t 338 + 339 + val stopwords : t -> StopwordsSetSchema.T.t 340 + 341 + val jsont : t Jsont.t 342 + end 343 + 344 + (** Retrieves a stopwords set. 345 + 346 + Retrieve the details of a stopwords set, given it's name. 347 + @param set_id The ID of the stopwords set to retrieve. 348 + *) 349 + val retrieve_stopwords_set : set_id:string -> t -> unit -> T.t 350 + end 351 + 352 + module StemmingDictionary : sig 353 + module T : sig 354 + type t 355 + 356 + (** Construct a value 357 + @param id Unique identifier for the dictionary 358 + @param words List of word mappings in the dictionary 359 + *) 360 + val v : id:string -> words:Jsont.json list -> unit -> t 361 + 362 + (** Unique identifier for the dictionary *) 363 + val id : t -> string 364 + 365 + (** List of word mappings in the dictionary *) 366 + val words : t -> Jsont.json list 367 + 368 + val jsont : t Jsont.t 369 + end 370 + 371 + (** Retrieve a stemming dictionary 372 + 373 + Fetch details of a specific stemming dictionary. 374 + @param dictionary_id The ID of the dictionary to retrieve 375 + *) 376 + val get_stemming_dictionary : dictionary_id:string -> t -> unit -> T.t 377 + end 378 + 379 + module SearchSynonymSchema : sig 380 + module T : sig 381 + type t 382 + 383 + (** Construct a value 384 + @param synonyms Array of words that should be considered as synonyms. 385 + @param locale Locale for the synonym, leave blank to use the standard tokenizer. 386 + @param root For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. 387 + @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. 388 + *) 389 + val v : synonyms:string list -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t 390 + 391 + (** Locale for the synonym, leave blank to use the standard tokenizer. *) 392 + val locale : t -> string option 393 + 394 + (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *) 395 + val root : t -> string option 396 + 397 + (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *) 398 + val symbols_to_index : t -> string list option 399 + 400 + (** Array of words that should be considered as synonyms. *) 401 + val synonyms : t -> string list 402 + 403 + val jsont : t Jsont.t 404 + end 405 + end 406 + 407 + module SearchSynonymDelete : sig 408 + module Response : sig 409 + type t 410 + 411 + (** Construct a value 412 + @param id The id of the synonym that was deleted 413 + *) 414 + val v : id:string -> unit -> t 415 + 416 + (** The id of the synonym that was deleted *) 417 + val id : t -> string 418 + 419 + val jsont : t Jsont.t 420 + end 421 + end 422 + 423 + module SearchSynonym : sig 424 + module T : sig 425 + type t 426 + 427 + (** Construct a value 428 + @param synonyms Array of words that should be considered as synonyms. 429 + @param locale Locale for the synonym, leave blank to use the standard tokenizer. 430 + @param root For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. 431 + @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. 432 + *) 433 + val v : synonyms:string list -> id:string -> ?locale:string -> ?root:string -> ?symbols_to_index:string list -> unit -> t 434 + 435 + (** Locale for the synonym, leave blank to use the standard tokenizer. *) 436 + val locale : t -> string option 437 + 438 + (** For 1-way synonyms, indicates the root word that words in the `synonyms` parameter map to. *) 439 + val root : t -> string option 440 + 441 + (** By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is. *) 442 + val symbols_to_index : t -> string list option 443 + 444 + (** Array of words that should be considered as synonyms. *) 445 + val synonyms : t -> string list 446 + 447 + val id : t -> string 448 + 449 + val jsont : t Jsont.t 450 + end 451 + end 452 + 453 + module SearchSynonyms : sig 454 + module Response : sig 455 + type t 456 + 457 + (** Construct a value *) 458 + val v : synonyms:SearchSynonym.T.t list -> unit -> t 459 + 460 + val synonyms : t -> SearchSynonym.T.t list 461 + 462 + val jsont : t Jsont.t 463 + end 464 + end 465 + 466 + module SearchResultConversation : sig 467 + module T : sig 468 + type t 469 + 470 + (** Construct a value *) 471 + val v : answer:string -> conversation_history:Jsont.json list -> conversation_id:string -> query:string -> unit -> t 472 + 473 + val answer : t -> string 474 + 475 + val conversation_history : t -> Jsont.json list 476 + 477 + val conversation_id : t -> string 478 + 479 + val query : t -> string 480 + 481 + val jsont : t Jsont.t 482 + end 483 + end 484 + 485 + module SearchRequestParams : sig 486 + module T : sig 487 + type t 488 + 489 + (** Construct a value *) 490 + val v : collection_name:string -> per_page:int -> q:string -> ?voice_query:Jsont.json -> unit -> t 491 + 492 + val collection_name : t -> string 493 + 494 + val per_page : t -> int 495 + 496 + val q : t -> string 497 + 498 + val voice_query : t -> Jsont.json option 499 + 500 + val jsont : t Jsont.t 501 + end 502 + end 503 + 504 + module SearchHighlight : sig 505 + module T : sig 506 + type t 507 + 508 + (** Construct a value 509 + @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 510 + @param snippet Present only for (non-array) string fields 511 + @param snippets Present only for (array) string[] fields 512 + @param value Full field value with highlighting, present only for (non-array) string fields 513 + @param values Full field value with highlighting, present only for (array) string[] fields 514 + *) 515 + val v : ?field:string -> ?indices:int list -> ?matched_tokens:Jsont.json list -> ?snippet:string -> ?snippets:string list -> ?value:string -> ?values:string list -> unit -> t 516 + 517 + val field : t -> string option 518 + 519 + (** The indices property will be present only for string[] fields and will contain the corresponding indices of the snippets in the search field *) 520 + val indices : t -> int list option 521 + 522 + val matched_tokens : t -> Jsont.json list option 523 + 524 + (** Present only for (non-array) string fields *) 525 + val snippet : t -> string option 526 + 527 + (** Present only for (array) string[] fields *) 528 + val snippets : t -> string list option 529 + 530 + (** Full field value with highlighting, present only for (non-array) string fields *) 531 + val value : t -> string option 532 + 533 + (** Full field value with highlighting, present only for (array) string[] fields *) 534 + val values : t -> string list option 535 + 536 + val jsont : t Jsont.t 537 + end 538 + end 539 + 540 + module SearchResultHit : sig 541 + module T : sig 542 + type t 543 + 544 + (** Construct a value 545 + @param document Can be any key-value pair 546 + @param geo_distance_meters Can be any key-value pair 547 + @param highlight Highlighted version of the matching document 548 + @param highlights (Deprecated) Contains highlighted portions of the search fields 549 + @param hybrid_search_info Information about hybrid search scoring 550 + @param search_index Returned only for union query response. Indicates the index of the query which this document matched to. 551 + @param vector_distance Distance between the query vector and matching document's vector value 552 + *) 553 + 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 554 + 555 + (** Can be any key-value pair *) 556 + val document : t -> Jsont.json option 557 + 558 + (** Can be any key-value pair *) 559 + val geo_distance_meters : t -> Jsont.json option 560 + 561 + (** Highlighted version of the matching document *) 562 + val highlight : t -> Jsont.json option 563 + 564 + (** (Deprecated) Contains highlighted portions of the search fields *) 565 + val highlights : t -> SearchHighlight.T.t list option 566 + 567 + (** Information about hybrid search scoring *) 568 + val hybrid_search_info : t -> Jsont.json option 569 + 570 + (** Returned only for union query response. Indicates the index of the query which this document matched to. *) 571 + val search_index : t -> int option 572 + 573 + val text_match : t -> int64 option 574 + 575 + val text_match_info : t -> Jsont.json option 576 + 577 + (** Distance between the query vector and matching document's vector value *) 578 + val vector_distance : t -> float option 579 + 580 + val jsont : t Jsont.t 581 + end 582 + end 583 + 584 + module SearchGroupedHit : sig 585 + module T : sig 586 + type t 587 + 588 + (** Construct a value 589 + @param hits The documents that matched the search query 590 + *) 591 + val v : group_key:Jsont.json list -> hits:SearchResultHit.T.t list -> ?found:int -> unit -> t 592 + 593 + val found : t -> int option 594 + 595 + val group_key : t -> Jsont.json list 596 + 597 + (** The documents that matched the search query *) 598 + val hits : t -> SearchResultHit.T.t list 599 + 600 + val jsont : t Jsont.t 601 + end 602 + end 603 + 604 + module SchemaChange : sig 605 + module Status : sig 606 + type t 607 + 608 + (** Construct a value 609 + @param altered_docs Number of documents that have been altered 610 + @param collection Name of the collection being modified 611 + @param validated_docs Number of documents that have been validated 612 + *) 613 + val v : ?altered_docs:int -> ?collection:string -> ?validated_docs:int -> unit -> t 614 + 615 + (** Number of documents that have been altered *) 616 + val altered_docs : t -> int option 617 + 618 + (** Name of the collection being modified *) 619 + val collection : t -> string option 620 + 621 + (** Number of documents that have been validated *) 622 + val validated_docs : t -> int option 623 + 624 + val jsont : t Jsont.t 625 + end 626 + 627 + (** Get the status of in-progress schema change operations 628 + 629 + Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response. *) 630 + val get_schema_changes : t -> unit -> Status.t 631 + end 632 + 633 + module PresetUpsertSchema : sig 634 + module T : sig 635 + type t 636 + 637 + (** Construct a value *) 638 + val v : value:Jsont.json -> unit -> t 639 + 640 + val value : t -> Jsont.json 641 + 642 + val jsont : t Jsont.t 643 + end 644 + end 645 + 646 + module PresetSchema : sig 647 + module T : sig 648 + type t 649 + 650 + (** Construct a value *) 651 + val v : value:Jsont.json -> name:string -> unit -> t 652 + 653 + val value : t -> Jsont.json 654 + 655 + val name : t -> string 656 + 657 + val jsont : t Jsont.t 658 + end 659 + 660 + (** Retrieves a preset. 661 + 662 + Retrieve the details of a preset, given it's name. 663 + @param preset_id The ID of the preset to retrieve. 664 + *) 665 + val retrieve_preset : preset_id:string -> t -> unit -> T.t 666 + 667 + (** Upserts a preset. 668 + 669 + Create or update an existing preset. 670 + @param preset_id The name of the preset set to upsert. 671 + *) 672 + val upsert_preset : preset_id:string -> body:PresetUpsertSchema.T.t -> t -> unit -> T.t 673 + end 674 + 675 + module PresetsRetrieveSchema : sig 676 + module T : sig 677 + type t 678 + 679 + (** Construct a value *) 680 + val v : presets:PresetSchema.T.t list -> unit -> t 681 + 682 + val presets : t -> PresetSchema.T.t list 683 + 684 + val jsont : t Jsont.t 685 + end 686 + 687 + (** Retrieves all presets. 688 + 689 + Retrieve the details of all presets *) 690 + val retrieve_all_presets : t -> unit -> T.t 691 + end 692 + 693 + module PresetDeleteSchema : sig 694 + module T : sig 695 + type t 696 + 697 + (** Construct a value *) 698 + val v : name:string -> unit -> t 699 + 700 + val name : t -> string 701 + 702 + val jsont : t Jsont.t 703 + end 704 + 705 + (** Delete a preset. 706 + 707 + Permanently deletes a preset, given it's name. 708 + @param preset_id The ID of the preset to delete. 709 + *) 710 + val delete_preset : preset_id:string -> t -> unit -> T.t 711 + end 712 + 713 + module NlsearchModelDeleteSchema : sig 714 + module T : sig 715 + type t 716 + 717 + (** Construct a value 718 + @param id ID of the deleted NL search model 719 + *) 720 + val v : id:string -> unit -> t 721 + 722 + (** ID of the deleted NL search model *) 723 + val id : t -> string 724 + 725 + val jsont : t Jsont.t 726 + end 727 + 728 + (** Delete a NL search model 729 + 730 + Delete a specific NL search model by its ID. 731 + @param model_id The ID of the NL search model to delete 732 + *) 733 + val delete_nlsearch_model : model_id:string -> t -> unit -> T.t 734 + end 735 + 736 + module NlsearchModelCreateSchema : sig 737 + module T : sig 738 + type t 739 + 740 + (** Construct a value 741 + @param access_token Access token for GCP Vertex AI 742 + @param account_id Account ID for Cloudflare-specific models 743 + @param api_key API key for the NL model service 744 + @param api_url Custom API URL for the NL model service 745 + @param api_version API version for the NL model service 746 + @param client_id Client ID for GCP Vertex AI 747 + @param client_secret Client secret for GCP Vertex AI 748 + @param max_bytes Maximum number of bytes to process 749 + @param max_output_tokens Maximum output tokens for GCP Vertex AI 750 + @param model_name Name of the NL model to use 751 + @param project_id Project ID for GCP Vertex AI 752 + @param refresh_token Refresh token for GCP Vertex AI 753 + @param region Region for GCP Vertex AI 754 + @param stop_sequences Stop sequences for the NL model (Google-specific) 755 + @param system_prompt System prompt for the NL model 756 + @param temperature Temperature parameter for the NL model 757 + @param top_k Top-k parameter for the NL model (Google-specific) 758 + @param top_p Top-p parameter for the NL model (Google-specific) 759 + @param id Optional ID for the NL search model 760 + *) 761 + 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 762 + 763 + (** Access token for GCP Vertex AI *) 764 + val access_token : t -> string option 765 + 766 + (** Account ID for Cloudflare-specific models *) 767 + val account_id : t -> string option 768 + 769 + (** API key for the NL model service *) 770 + val api_key : t -> string option 771 + 772 + (** Custom API URL for the NL model service *) 773 + val api_url : t -> string option 774 + 775 + (** API version for the NL model service *) 776 + val api_version : t -> string option 777 + 778 + (** Client ID for GCP Vertex AI *) 779 + val client_id : t -> string option 780 + 781 + (** Client secret for GCP Vertex AI *) 782 + val client_secret : t -> string option 783 + 784 + (** Maximum number of bytes to process *) 785 + val max_bytes : t -> int option 786 + 787 + (** Maximum output tokens for GCP Vertex AI *) 788 + val max_output_tokens : t -> int option 789 + 790 + (** Name of the NL model to use *) 791 + val model_name : t -> string option 792 + 793 + (** Project ID for GCP Vertex AI *) 794 + val project_id : t -> string option 795 + 796 + (** Refresh token for GCP Vertex AI *) 797 + val refresh_token : t -> string option 798 + 799 + (** Region for GCP Vertex AI *) 800 + val region : t -> string option 801 + 802 + (** Stop sequences for the NL model (Google-specific) *) 803 + val stop_sequences : t -> string list option 804 + 805 + (** System prompt for the NL model *) 806 + val system_prompt : t -> string option 807 + 808 + (** Temperature parameter for the NL model *) 809 + val temperature : t -> float option 810 + 811 + (** Top-k parameter for the NL model (Google-specific) *) 812 + val top_k : t -> int option 813 + 814 + (** Top-p parameter for the NL model (Google-specific) *) 815 + val top_p : t -> float option 816 + 817 + (** Optional ID for the NL search model *) 818 + val id : t -> string option 819 + 820 + val jsont : t Jsont.t 821 + end 822 + end 823 + 824 + module NlsearchModelSchema : sig 825 + module T : sig 826 + type t 827 + 828 + (** Construct a value 829 + @param id ID of the NL search model 830 + @param access_token Access token for GCP Vertex AI 831 + @param account_id Account ID for Cloudflare-specific models 832 + @param api_key API key for the NL model service 833 + @param api_url Custom API URL for the NL model service 834 + @param api_version API version for the NL model service 835 + @param client_id Client ID for GCP Vertex AI 836 + @param client_secret Client secret for GCP Vertex AI 837 + @param max_bytes Maximum number of bytes to process 838 + @param max_output_tokens Maximum output tokens for GCP Vertex AI 839 + @param model_name Name of the NL model to use 840 + @param project_id Project ID for GCP Vertex AI 841 + @param refresh_token Refresh token for GCP Vertex AI 842 + @param region Region for GCP Vertex AI 843 + @param stop_sequences Stop sequences for the NL model (Google-specific) 844 + @param system_prompt System prompt for the NL model 845 + @param temperature Temperature parameter for the NL model 846 + @param top_k Top-k parameter for the NL model (Google-specific) 847 + @param top_p Top-p parameter for the NL model (Google-specific) 848 + *) 849 + 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 850 + 851 + (** Access token for GCP Vertex AI *) 852 + val access_token : t -> string option 853 + 854 + (** Account ID for Cloudflare-specific models *) 855 + val account_id : t -> string option 856 + 857 + (** API key for the NL model service *) 858 + val api_key : t -> string option 859 + 860 + (** Custom API URL for the NL model service *) 861 + val api_url : t -> string option 862 + 863 + (** API version for the NL model service *) 864 + val api_version : t -> string option 865 + 866 + (** Client ID for GCP Vertex AI *) 867 + val client_id : t -> string option 868 + 869 + (** Client secret for GCP Vertex AI *) 870 + val client_secret : t -> string option 871 + 872 + (** Maximum number of bytes to process *) 873 + val max_bytes : t -> int option 874 + 875 + (** Maximum output tokens for GCP Vertex AI *) 876 + val max_output_tokens : t -> int option 877 + 878 + (** Name of the NL model to use *) 879 + val model_name : t -> string option 880 + 881 + (** Project ID for GCP Vertex AI *) 882 + val project_id : t -> string option 883 + 884 + (** Refresh token for GCP Vertex AI *) 885 + val refresh_token : t -> string option 886 + 887 + (** Region for GCP Vertex AI *) 888 + val region : t -> string option 889 + 890 + (** Stop sequences for the NL model (Google-specific) *) 891 + val stop_sequences : t -> string list option 892 + 893 + (** System prompt for the NL model *) 894 + val system_prompt : t -> string option 895 + 896 + (** Temperature parameter for the NL model *) 897 + val temperature : t -> float option 898 + 899 + (** Top-k parameter for the NL model (Google-specific) *) 900 + val top_k : t -> int option 901 + 902 + (** Top-p parameter for the NL model (Google-specific) *) 903 + val top_p : t -> float option 904 + 905 + (** ID of the NL search model *) 906 + val id : t -> string 907 + 908 + val jsont : t Jsont.t 909 + end 910 + 911 + (** List all NL search models 912 + 913 + Retrieve all NL search models. *) 914 + val retrieve_all_nlsearch_models : t -> unit -> T.t 915 + 916 + (** Create a NL search model 917 + 918 + Create a new NL search model. *) 919 + val create_nlsearch_model : body:NlsearchModelCreateSchema.T.t -> t -> unit -> T.t 920 + 921 + (** Retrieve a NL search model 922 + 923 + Retrieve a specific NL search model by its ID. 924 + @param model_id The ID of the NL search model to retrieve 925 + *) 926 + val retrieve_nlsearch_model : model_id:string -> t -> unit -> T.t 927 + 928 + (** Update a NL search model 929 + 930 + Update an existing NL search model. 931 + @param model_id The ID of the NL search model to update 932 + *) 933 + val update_nlsearch_model : model_id:string -> t -> unit -> T.t 934 + end 935 + 936 + module NlsearchModelBase : sig 937 + module T : sig 938 + type t 939 + 940 + (** Construct a value 941 + @param access_token Access token for GCP Vertex AI 942 + @param account_id Account ID for Cloudflare-specific models 943 + @param api_key API key for the NL model service 944 + @param api_url Custom API URL for the NL model service 945 + @param api_version API version for the NL model service 946 + @param client_id Client ID for GCP Vertex AI 947 + @param client_secret Client secret for GCP Vertex AI 948 + @param max_bytes Maximum number of bytes to process 949 + @param max_output_tokens Maximum output tokens for GCP Vertex AI 950 + @param model_name Name of the NL model to use 951 + @param project_id Project ID for GCP Vertex AI 952 + @param refresh_token Refresh token for GCP Vertex AI 953 + @param region Region for GCP Vertex AI 954 + @param stop_sequences Stop sequences for the NL model (Google-specific) 955 + @param system_prompt System prompt for the NL model 956 + @param temperature Temperature parameter for the NL model 957 + @param top_k Top-k parameter for the NL model (Google-specific) 958 + @param top_p Top-p parameter for the NL model (Google-specific) 959 + *) 960 + 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 961 + 962 + (** Access token for GCP Vertex AI *) 963 + val access_token : t -> string option 964 + 965 + (** Account ID for Cloudflare-specific models *) 966 + val account_id : t -> string option 967 + 968 + (** API key for the NL model service *) 969 + val api_key : t -> string option 970 + 971 + (** Custom API URL for the NL model service *) 972 + val api_url : t -> string option 973 + 974 + (** API version for the NL model service *) 975 + val api_version : t -> string option 976 + 977 + (** Client ID for GCP Vertex AI *) 978 + val client_id : t -> string option 979 + 980 + (** Client secret for GCP Vertex AI *) 981 + val client_secret : t -> string option 982 + 983 + (** Maximum number of bytes to process *) 984 + val max_bytes : t -> int option 985 + 986 + (** Maximum output tokens for GCP Vertex AI *) 987 + val max_output_tokens : t -> int option 988 + 989 + (** Name of the NL model to use *) 990 + val model_name : t -> string option 991 + 992 + (** Project ID for GCP Vertex AI *) 993 + val project_id : t -> string option 994 + 995 + (** Refresh token for GCP Vertex AI *) 996 + val refresh_token : t -> string option 997 + 998 + (** Region for GCP Vertex AI *) 999 + val region : t -> string option 1000 + 1001 + (** Stop sequences for the NL model (Google-specific) *) 1002 + val stop_sequences : t -> string list option 1003 + 1004 + (** System prompt for the NL model *) 1005 + val system_prompt : t -> string option 1006 + 1007 + (** Temperature parameter for the NL model *) 1008 + val temperature : t -> float option 1009 + 1010 + (** Top-k parameter for the NL model (Google-specific) *) 1011 + val top_k : t -> int option 1012 + 1013 + (** Top-p parameter for the NL model (Google-specific) *) 1014 + val top_p : t -> float option 1015 + 1016 + val jsont : t Jsont.t 1017 + end 1018 + end 1019 + 1020 + module IndexAction : sig 1021 + module T : sig 1022 + type t = [ 1023 + | `Create 1024 + | `Update 1025 + | `Upsert 1026 + | `Emplace 1027 + ] 1028 + 1029 + val jsont : t Jsont.t 1030 + end 1031 + end 1032 + 1033 + module Health : sig 1034 + module Status : sig 1035 + type t 1036 + 1037 + (** Construct a value *) 1038 + val v : ok:bool -> unit -> t 1039 + 1040 + val ok : t -> bool 1041 + 1042 + val jsont : t Jsont.t 1043 + end 1044 + 1045 + (** Checks if Typesense server is ready to accept requests. 1046 + 1047 + Checks if Typesense server is ready to accept requests. *) 1048 + val health : t -> unit -> Status.t 1049 + end 1050 + 1051 + module Field : sig 1052 + module T : sig 1053 + type t 1054 + 1055 + (** Construct a value 1056 + @param symbols_to_index List of symbols or special characters to be indexed. 1057 + 1058 + @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. 1059 + 1060 + @param async_reference Allow documents to be indexed successfully even when the referenced document doesn't exist yet. 1061 + 1062 + @param range_index Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. 1063 + 1064 + @param reference Name of a field in another collection that should be linked to this collection so that it can be joined during query. 1065 + 1066 + @param stem Values are stemmed before indexing in-memory. Default: false. 1067 + 1068 + @param stem_dictionary Name of the stemming dictionary to use for this field 1069 + @param store When set to false, the field value will not be stored on disk. Default: true. 1070 + 1071 + @param vec_dist The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. 1072 + 1073 + *) 1074 + 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 1075 + 1076 + (** Allow documents to be indexed successfully even when the referenced document doesn't exist yet. 1077 + *) 1078 + val async_reference : t -> bool option 1079 + 1080 + val drop : t -> bool option 1081 + 1082 + val embed : t -> Jsont.json option 1083 + 1084 + val facet : t -> bool option 1085 + 1086 + val index : t -> bool 1087 + 1088 + val infix : t -> bool 1089 + 1090 + val locale : t -> string option 1091 + 1092 + val name : t -> string 1093 + 1094 + val num_dim : t -> int option 1095 + 1096 + val optional : t -> bool option 1097 + 1098 + (** Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: false. 1099 + *) 1100 + val range_index : t -> bool option 1101 + 1102 + (** Name of a field in another collection that should be linked to this collection so that it can be joined during query. 1103 + *) 1104 + val reference : t -> string option 1105 + 1106 + val sort : t -> bool option 1107 + 1108 + (** Values are stemmed before indexing in-memory. Default: false. 1109 + *) 1110 + val stem : t -> bool option 1111 + 1112 + (** Name of the stemming dictionary to use for this field *) 1113 + val stem_dictionary : t -> string option 1114 + 1115 + (** When set to false, the field value will not be stored on disk. Default: true. 1116 + *) 1117 + val store : t -> bool option 1118 + 1119 + (** List of symbols or special characters to be indexed. 1120 + *) 1121 + val symbols_to_index : t -> string list 1122 + 1123 + (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. 1124 + *) 1125 + val token_separators : t -> string list 1126 + 1127 + val type_ : t -> string 1128 + 1129 + (** The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product. 1130 + *) 1131 + val vec_dist : t -> string option 1132 + 1133 + val jsont : t Jsont.t 1134 + end 1135 + end 1136 + 1137 + module CollectionUpdateSchema : sig 1138 + module T : sig 1139 + type t 1140 + 1141 + (** Construct a value 1142 + @param fields A list of fields for querying, filtering and faceting 1143 + @param metadata Optional details about the collection, e.g., when it was created, who created it etc. 1144 + 1145 + @param synonym_sets List of synonym set names to associate with this collection 1146 + *) 1147 + val v : fields:Field.T.t list -> ?metadata:Jsont.json -> ?synonym_sets:string list -> unit -> t 1148 + 1149 + (** A list of fields for querying, filtering and faceting *) 1150 + val fields : t -> Field.T.t list 1151 + 1152 + (** Optional details about the collection, e.g., when it was created, who created it etc. 1153 + *) 1154 + val metadata : t -> Jsont.json option 1155 + 1156 + (** List of synonym set names to associate with this collection *) 1157 + val synonym_sets : t -> string list option 1158 + 1159 + val jsont : t Jsont.t 1160 + end 1161 + 1162 + (** Update a collection 1163 + 1164 + Update a collection's schema to modify the fields and their types. 1165 + @param collection_name The name of the collection to update 1166 + *) 1167 + val update_collection : collection_name:string -> body:T.t -> t -> unit -> T.t 1168 + end 1169 + 1170 + module CollectionSchema : sig 1171 + module T : sig 1172 + type t 1173 + 1174 + (** Construct a value 1175 + @param fields A list of fields for querying, filtering and faceting 1176 + @param name Name of the collection 1177 + @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. 1178 + @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. 1179 + @param symbols_to_index List of symbols or special characters to be indexed. 1180 + 1181 + @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. 1182 + 1183 + @param metadata Optional details about the collection, e.g., when it was created, who created it etc. 1184 + 1185 + @param synonym_sets List of synonym set names to associate with this collection 1186 + *) 1187 + 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 1188 + 1189 + (** 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. *) 1190 + val default_sorting_field : t -> string 1191 + 1192 + (** 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. *) 1193 + val enable_nested_fields : t -> bool 1194 + 1195 + (** A list of fields for querying, filtering and faceting *) 1196 + val fields : t -> Field.T.t list 1197 + 1198 + (** Optional details about the collection, e.g., when it was created, who created it etc. 1199 + *) 1200 + val metadata : t -> Jsont.json option 1201 + 1202 + (** Name of the collection *) 1203 + val name : t -> string 1204 + 1205 + (** List of symbols or special characters to be indexed. 1206 + *) 1207 + val symbols_to_index : t -> string list 1208 + 1209 + (** List of synonym set names to associate with this collection *) 1210 + val synonym_sets : t -> string list option 1211 + 1212 + (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. 1213 + *) 1214 + val token_separators : t -> string list 1215 + 1216 + val voice_query_model : t -> VoiceQueryModelCollection.Config.t option 1217 + 1218 + val jsont : t Jsont.t 1219 + end 1220 + end 1221 + 1222 + module Collection : sig 1223 + module Response : sig 1224 + type t 1225 + 1226 + (** Construct a value 1227 + @param fields A list of fields for querying, filtering and faceting 1228 + @param name Name of the collection 1229 + @param num_documents Number of documents in the collection 1230 + @param created_at Timestamp of when the collection was created (Unix epoch in seconds) 1231 + @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. 1232 + @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. 1233 + @param symbols_to_index List of symbols or special characters to be indexed. 1234 + 1235 + @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. 1236 + 1237 + @param metadata Optional details about the collection, e.g., when it was created, who created it etc. 1238 + 1239 + @param synonym_sets List of synonym set names to associate with this collection 1240 + *) 1241 + 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 1242 + 1243 + (** 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. *) 1244 + val default_sorting_field : t -> string 1245 + 1246 + (** 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. *) 1247 + val enable_nested_fields : t -> bool 1248 + 1249 + (** A list of fields for querying, filtering and faceting *) 1250 + val fields : t -> Field.T.t list 1251 + 1252 + (** Optional details about the collection, e.g., when it was created, who created it etc. 1253 + *) 1254 + val metadata : t -> Jsont.json option 1255 + 1256 + (** Name of the collection *) 1257 + val name : t -> string 1258 + 1259 + (** List of symbols or special characters to be indexed. 1260 + *) 1261 + val symbols_to_index : t -> string list 1262 + 1263 + (** List of synonym set names to associate with this collection *) 1264 + val synonym_sets : t -> string list option 1265 + 1266 + (** List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters. 1267 + *) 1268 + val token_separators : t -> string list 1269 + 1270 + val voice_query_model : t -> VoiceQueryModelCollection.Config.t option 1271 + 1272 + (** Number of documents in the collection *) 1273 + val num_documents : t -> int64 1274 + 1275 + (** Timestamp of when the collection was created (Unix epoch in seconds) *) 1276 + val created_at : t -> int64 1277 + 1278 + val jsont : t Jsont.t 1279 + end 1280 + 1281 + (** List all collections 1282 + 1283 + Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. *) 1284 + val get_collections : ?get_collections_parameters:string -> t -> unit -> Response.t 1285 + 1286 + (** Create a new collection 1287 + 1288 + 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. *) 1289 + val create_collection : body:CollectionSchema.T.t -> t -> unit -> Response.t 1290 + 1291 + (** Retrieve a single collection 1292 + 1293 + Retrieve the details of a collection, given its name. 1294 + @param collection_name The name of the collection to retrieve 1295 + *) 1296 + val get_collection : collection_name:string -> t -> unit -> Response.t 1297 + 1298 + (** Delete a collection 1299 + 1300 + Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies. 1301 + @param collection_name The name of the collection to delete 1302 + *) 1303 + val delete_collection : collection_name:string -> t -> unit -> Response.t 1304 + end 1305 + 1306 + module FacetCounts : sig 1307 + module T : sig 1308 + type t 1309 + 1310 + (** Construct a value *) 1311 + val v : ?counts:Jsont.json list -> ?field_name:string -> ?stats:Jsont.json -> unit -> t 1312 + 1313 + val counts : t -> Jsont.json list option 1314 + 1315 + val field_name : t -> string option 1316 + 1317 + val stats : t -> Jsont.json option 1318 + 1319 + val jsont : t Jsont.t 1320 + end 1321 + end 1322 + 1323 + module Search : sig 1324 + module Result : sig 1325 + type t 1326 + 1327 + (** Construct a value 1328 + @param found The number of documents found 1329 + @param hits The documents that matched the search query 1330 + @param metadata Custom JSON object that can be returned in the search response 1331 + @param out_of The total number of documents in the collection 1332 + @param page The search result page number 1333 + @param search_cutoff Whether the search was cut off 1334 + @param search_time_ms The number of milliseconds the search took 1335 + @param union_request_params Returned only for union query response. 1336 + *) 1337 + 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 1338 + 1339 + val conversation : t -> SearchResultConversation.T.t option 1340 + 1341 + val facet_counts : t -> FacetCounts.T.t list option 1342 + 1343 + (** The number of documents found *) 1344 + val found : t -> int option 1345 + 1346 + val found_docs : t -> int option 1347 + 1348 + val grouped_hits : t -> SearchGroupedHit.T.t list option 1349 + 1350 + (** The documents that matched the search query *) 1351 + val hits : t -> SearchResultHit.T.t list option 1352 + 1353 + (** Custom JSON object that can be returned in the search response *) 1354 + val metadata : t -> Jsont.json option 1355 + 1356 + (** The total number of documents in the collection *) 1357 + val out_of : t -> int option 1358 + 1359 + (** The search result page number *) 1360 + val page : t -> int option 1361 + 1362 + val request_params : t -> SearchRequestParams.T.t option 1363 + 1364 + (** Whether the search was cut off *) 1365 + val search_cutoff : t -> bool option 1366 + 1367 + (** The number of milliseconds the search took *) 1368 + val search_time_ms : t -> int option 1369 + 1370 + (** Returned only for union query response. *) 1371 + val union_request_params : t -> SearchRequestParams.T.t list option 1372 + 1373 + val jsont : t Jsont.t 1374 + end 1375 + 1376 + (** Search for documents in a collection 1377 + 1378 + Search for documents in a collection that match the search criteria. 1379 + @param collection_name The name of the collection to search for the document under 1380 + *) 1381 + val search_collection : collection_name:string -> search_parameters:string -> t -> unit -> Result.t 1382 + end 1383 + 1384 + module MultiSearchResult : sig 1385 + module Item : sig 1386 + type t 1387 + 1388 + (** Construct a value 1389 + @param found The number of documents found 1390 + @param hits The documents that matched the search query 1391 + @param metadata Custom JSON object that can be returned in the search response 1392 + @param out_of The total number of documents in the collection 1393 + @param page The search result page number 1394 + @param search_cutoff Whether the search was cut off 1395 + @param search_time_ms The number of milliseconds the search took 1396 + @param union_request_params Returned only for union query response. 1397 + @param code HTTP error code 1398 + @param error Error description 1399 + *) 1400 + 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 1401 + 1402 + val conversation : t -> SearchResultConversation.T.t option 1403 + 1404 + val facet_counts : t -> FacetCounts.T.t list option 1405 + 1406 + (** The number of documents found *) 1407 + val found : t -> int option 1408 + 1409 + val found_docs : t -> int option 1410 + 1411 + val grouped_hits : t -> SearchGroupedHit.T.t list option 1412 + 1413 + (** The documents that matched the search query *) 1414 + val hits : t -> SearchResultHit.T.t list option 1415 + 1416 + (** Custom JSON object that can be returned in the search response *) 1417 + val metadata : t -> Jsont.json option 1418 + 1419 + (** The total number of documents in the collection *) 1420 + val out_of : t -> int option 1421 + 1422 + (** The search result page number *) 1423 + val page : t -> int option 1424 + 1425 + val request_params : t -> SearchRequestParams.T.t option 1426 + 1427 + (** Whether the search was cut off *) 1428 + val search_cutoff : t -> bool option 1429 + 1430 + (** The number of milliseconds the search took *) 1431 + val search_time_ms : t -> int option 1432 + 1433 + (** Returned only for union query response. *) 1434 + val union_request_params : t -> SearchRequestParams.T.t list option 1435 + 1436 + (** HTTP error code *) 1437 + val code : t -> int64 option 1438 + 1439 + (** Error description *) 1440 + val error : t -> string option 1441 + 1442 + val jsont : t Jsont.t 1443 + end 1444 + end 1445 + 1446 + module DropTokensMode : sig 1447 + module T : sig 1448 + (** 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 1449 + *) 1450 + type t = [ 1451 + | `Right_to_left 1452 + | `Left_to_right 1453 + | `Both_sides3 1454 + ] 1455 + 1456 + val jsont : t Jsont.t 1457 + end 1458 + end 1459 + 1460 + module SearchParameters : sig 1461 + module T : sig 1462 + type t 1463 + 1464 + (** Construct a value 1465 + @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 1466 + 1467 + @param enable_highlight_v1 Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true 1468 + 1469 + @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 1470 + 1471 + @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens. 1472 + 1473 + @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others 1474 + 1475 + @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields. 1476 + 1477 + @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text. 1478 + 1479 + @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. 1480 + 1481 + @param conversation Enable conversational search. 1482 + 1483 + @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 1484 + 1485 + @param conversation_model_id The Id of Conversation Model to be used. 1486 + 1487 + @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 1488 + 1489 + @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 1490 + 1491 + @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 1492 + 1493 + @param exclude_fields List of fields from the document to exclude in the search result 1494 + @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). 1495 + 1496 + @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. 1497 + @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". 1498 + @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response. 1499 + 1500 + @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 1501 + 1502 + @param filter_by Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. 1503 + @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 1504 + 1505 + @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. 1506 + @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 1507 + 1508 + @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 1509 + 1510 + @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`. 1511 + 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`. 1512 + 1513 + @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4 1514 + 1515 + @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>` 1516 + 1517 + @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them 1518 + 1519 + @param highlight_full_fields List of fields which should be highlighted fully without snippeting 1520 + @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>` 1521 + 1522 + @param include_fields List of fields from the document to include in the search result 1523 + @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 1524 + @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 1525 + 1526 + @param max_candidates Control the number of words that Typesense considers for typo and prefix searching. 1527 + 1528 + @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. 1529 + @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. 1530 + @param max_facet_values Maximum number of facet values to be returned. 1531 + @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*. 1532 + @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. 1533 + 1534 + @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. 1535 + 1536 + @param nl_model_id The ID of the natural language model to use. 1537 + @param nl_query Whether to use natural language processing to parse the query. 1538 + @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2 1539 + 1540 + @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. 1541 + @param override_tags Comma separated list of tags to trigger the curations rules that match the tags. 1542 + @param page Results from this specific page number would be fetched. 1543 + @param per_page Number of results to fetch per page. Default: 10 1544 + @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`. 1545 + 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`. 1546 + 1547 + @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. 1548 + Set this parameter to true to do the same 1549 + 1550 + @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. 1551 + @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 1552 + 1553 + @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. 1554 + @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma. 1555 + @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. 1556 + @param remote_embedding_num_tries Number of times to retry fetching remote embeddings. 1557 + 1558 + @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings. 1559 + 1560 + @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. 1561 + 1562 + @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 1563 + 1564 + @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` 1565 + @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`. 1566 + 1567 + @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. 1568 + 1569 + @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0 1570 + 1571 + @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false 1572 + 1573 + @param synonym_sets List of synonym set names to associate with this search query 1574 + @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. 1575 + @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 1576 + 1577 + @param use_cache Enable server side caching of search query results. By default, caching is disabled. 1578 + 1579 + @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector. 1580 + 1581 + @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format. 1582 + 1583 + *) 1584 + 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 1585 + 1586 + (** 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. 1587 + *) 1588 + val cache_ttl : t -> int option 1589 + 1590 + (** Enable conversational search. 1591 + *) 1592 + val conversation : t -> bool option 1593 + 1594 + (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 1595 + *) 1596 + val conversation_id : t -> string option 1597 + 1598 + (** The Id of Conversation Model to be used. 1599 + *) 1600 + val conversation_model_id : t -> string option 1601 + 1602 + val drop_tokens_mode : t -> DropTokensMode.T.t option 1603 + 1604 + (** 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 1605 + *) 1606 + val drop_tokens_threshold : t -> int option 1607 + 1608 + (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 1609 + *) 1610 + val enable_analytics : t -> bool 1611 + 1612 + (** Flag for enabling/disabling the deprecated, old highlight structure in the response. Default: true 1613 + *) 1614 + val enable_highlight_v1 : t -> bool 1615 + 1616 + (** 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 1617 + *) 1618 + val enable_overrides : t -> bool 1619 + 1620 + (** 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 1621 + *) 1622 + val enable_synonyms : t -> bool option 1623 + 1624 + (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 1625 + *) 1626 + val enable_typos_for_alpha_numerical_tokens : t -> bool option 1627 + 1628 + (** Make Typesense disable typos for numerical tokens. 1629 + *) 1630 + val enable_typos_for_numerical_tokens : t -> bool 1631 + 1632 + (** List of fields from the document to exclude in the search result *) 1633 + val exclude_fields : t -> string option 1634 + 1635 + (** 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). 1636 + *) 1637 + val exhaustive_search : t -> bool option 1638 + 1639 + (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 1640 + val facet_by : t -> string option 1641 + 1642 + (** 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". *) 1643 + val facet_query : t -> string option 1644 + 1645 + (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 1646 + *) 1647 + val facet_return_parent : t -> string option 1648 + 1649 + (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 1650 + *) 1651 + val facet_strategy : t -> string option 1652 + 1653 + (** Filter conditions for refining your open api validator search results. Separate multiple conditions with &&. *) 1654 + val filter_by : t -> string option 1655 + 1656 + (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false 1657 + *) 1658 + val filter_curated_hits : t -> bool option 1659 + 1660 + (** 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. *) 1661 + val group_by : t -> string option 1662 + 1663 + (** 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 1664 + *) 1665 + val group_limit : t -> int option 1666 + 1667 + (** 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 1668 + *) 1669 + val group_missing_values : t -> bool option 1670 + 1671 + (** 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`. 1672 + 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`. 1673 + *) 1674 + val hidden_hits : t -> string option 1675 + 1676 + (** The number of tokens that should surround the highlighted text on each side. Default: 4 1677 + *) 1678 + val highlight_affix_num_tokens : t -> int option 1679 + 1680 + (** The end tag used for the highlighted snippets. Default: `</mark>` 1681 + *) 1682 + val highlight_end_tag : t -> string option 1683 + 1684 + (** A list of custom fields that must be highlighted even if you don't query for them 1685 + *) 1686 + val highlight_fields : t -> string option 1687 + 1688 + (** List of fields which should be highlighted fully without snippeting *) 1689 + val highlight_full_fields : t -> string option 1690 + 1691 + (** The start tag used for the highlighted snippets. Default: `<mark>` 1692 + *) 1693 + val highlight_start_tag : t -> string option 1694 + 1695 + (** List of fields from the document to include in the search result *) 1696 + val include_fields : t -> string option 1697 + 1698 + (** 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 *) 1699 + val infix : t -> string option 1700 + 1701 + (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 1702 + *) 1703 + val limit : t -> int option 1704 + 1705 + (** Control the number of words that Typesense considers for typo and prefix searching. 1706 + *) 1707 + val max_candidates : t -> int option 1708 + 1709 + (** 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. *) 1710 + val max_extra_prefix : t -> int option 1711 + 1712 + (** 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. *) 1713 + val max_extra_suffix : t -> int option 1714 + 1715 + (** Maximum number of facet values to be returned. *) 1716 + val max_facet_values : t -> int option 1717 + 1718 + (** 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*. *) 1719 + val max_filter_by_candidates : t -> int option 1720 + 1721 + (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 1722 + *) 1723 + val min_len_1typo : t -> int option 1724 + 1725 + (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 1726 + *) 1727 + val min_len_2typo : t -> int option 1728 + 1729 + (** The ID of the natural language model to use. *) 1730 + val nl_model_id : t -> string option 1731 + 1732 + (** Whether to use natural language processing to parse the query. *) 1733 + val nl_query : t -> bool option 1734 + 1735 + (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 1736 + *) 1737 + val num_typos : t -> string option 1738 + 1739 + (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 1740 + val offset : t -> int option 1741 + 1742 + (** Comma separated list of tags to trigger the curations rules that match the tags. *) 1743 + val override_tags : t -> string option 1744 + 1745 + (** Results from this specific page number would be fetched. *) 1746 + val page : t -> int option 1747 + 1748 + (** Number of results to fetch per page. Default: 10 *) 1749 + val per_page : t -> int option 1750 + 1751 + (** 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`. 1752 + 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`. 1753 + *) 1754 + val pinned_hits : t -> string option 1755 + 1756 + (** 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. 1757 + Set this parameter to true to do the same 1758 + *) 1759 + val pre_segmented_query : t -> bool option 1760 + 1761 + (** 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. *) 1762 + val prefix : t -> string option 1763 + 1764 + (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 1765 + *) 1766 + val preset : t -> string option 1767 + 1768 + (** Set this parameter to true to ensure that an exact match is ranked above the others 1769 + *) 1770 + val prioritize_exact_match : t -> bool 1771 + 1772 + (** Make Typesense prioritize documents where the query words appear in more number of fields. 1773 + *) 1774 + val prioritize_num_matching_fields : t -> bool 1775 + 1776 + (** Make Typesense prioritize documents where the query words appear earlier in the text. 1777 + *) 1778 + val prioritize_token_position : t -> bool 1779 + 1780 + (** 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. *) 1781 + val q : t -> string option 1782 + 1783 + (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 1784 + val query_by : t -> string option 1785 + 1786 + (** 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. *) 1787 + val query_by_weights : t -> string option 1788 + 1789 + (** Number of times to retry fetching remote embeddings. 1790 + *) 1791 + val remote_embedding_num_tries : t -> int option 1792 + 1793 + (** Timeout (in milliseconds) for fetching remote embeddings. 1794 + *) 1795 + val remote_embedding_timeout_ms : t -> int option 1796 + 1797 + (** 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. 1798 + *) 1799 + val search_cutoff_ms : t -> int option 1800 + 1801 + (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 1802 + *) 1803 + val snippet_threshold : t -> int option 1804 + 1805 + (** 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` *) 1806 + val sort_by : t -> string option 1807 + 1808 + (** 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`. 1809 + *) 1810 + val split_join_tokens : t -> string option 1811 + 1812 + (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. 1813 + *) 1814 + val stopwords : t -> string option 1815 + 1816 + (** Allow synonym resolution on typo-corrected words in the query. Default: 0 1817 + *) 1818 + val synonym_num_typos : t -> int option 1819 + 1820 + (** Allow synonym resolution on word prefixes in the query. Default: false 1821 + *) 1822 + val synonym_prefix : t -> bool option 1823 + 1824 + (** List of synonym set names to associate with this search query *) 1825 + val synonym_sets : t -> string option 1826 + 1827 + (** 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. *) 1828 + val text_match_type : t -> string option 1829 + 1830 + (** 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 1831 + *) 1832 + val typo_tokens_threshold : t -> int option 1833 + 1834 + (** Enable server side caching of search query results. By default, caching is disabled. 1835 + *) 1836 + val use_cache : t -> bool option 1837 + 1838 + (** Vector query expression for fetching documents "closest" to a given query/document vector. 1839 + *) 1840 + val vector_query : t -> string option 1841 + 1842 + (** The base64 encoded audio file in 16 khz 16-bit WAV format. 1843 + *) 1844 + val voice_query : t -> string option 1845 + 1846 + val jsont : t Jsont.t 1847 + end 1848 + end 1849 + 1850 + module MultiSearchParameters : sig 1851 + module T : sig 1852 + (** Parameters for the multi search API. 1853 + *) 1854 + type t 1855 + 1856 + (** Construct a value 1857 + @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 1858 + 1859 + @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 1860 + 1861 + @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens. 1862 + 1863 + @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. 1864 + Set this parameter to true to do the same 1865 + 1866 + @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others 1867 + 1868 + @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields. 1869 + 1870 + @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text. 1871 + 1872 + @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. 1873 + 1874 + @param conversation Enable conversational search. 1875 + 1876 + @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 1877 + 1878 + @param conversation_model_id The Id of Conversation Model to be used. 1879 + 1880 + @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 1881 + 1882 + @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 1883 + 1884 + @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 1885 + 1886 + @param exclude_fields List of fields from the document to exclude in the search result 1887 + @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). 1888 + 1889 + @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. 1890 + @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". 1891 + @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response. 1892 + 1893 + @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 1894 + 1895 + @param filter_by Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. 1896 + @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 1897 + 1898 + @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. 1899 + @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 1900 + 1901 + @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 1902 + 1903 + @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`. 1904 + 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`. 1905 + 1906 + @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4 1907 + 1908 + @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>` 1909 + 1910 + @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them 1911 + 1912 + @param highlight_full_fields List of fields which should be highlighted fully without snippeting 1913 + @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>` 1914 + 1915 + @param include_fields List of fields from the document to include in the search result 1916 + @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 1917 + @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 1918 + 1919 + @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. 1920 + @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. 1921 + @param max_facet_values Maximum number of facet values to be returned. 1922 + @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. 1923 + 1924 + @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. 1925 + 1926 + @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2 1927 + 1928 + @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. 1929 + @param override_tags Comma separated list of tags to trigger the curations rules that match the tags. 1930 + @param page Results from this specific page number would be fetched. 1931 + @param per_page Number of results to fetch per page. Default: 10 1932 + @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`. 1933 + 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`. 1934 + 1935 + @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. 1936 + @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 1937 + 1938 + @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. 1939 + @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma. 1940 + @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. 1941 + @param remote_embedding_num_tries Number of times to retry fetching remote embeddings. 1942 + 1943 + @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings. 1944 + 1945 + @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. 1946 + 1947 + @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 1948 + 1949 + @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` 1950 + @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. 1951 + 1952 + @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0 1953 + 1954 + @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false 1955 + 1956 + @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. 1957 + @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 1958 + 1959 + @param use_cache Enable server side caching of search query results. By default, caching is disabled. 1960 + 1961 + @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector. 1962 + 1963 + @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format. 1964 + 1965 + *) 1966 + 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 1967 + 1968 + (** 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. 1969 + *) 1970 + val cache_ttl : t -> int option 1971 + 1972 + (** Enable conversational search. 1973 + *) 1974 + val conversation : t -> bool option 1975 + 1976 + (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 1977 + *) 1978 + val conversation_id : t -> string option 1979 + 1980 + (** The Id of Conversation Model to be used. 1981 + *) 1982 + val conversation_model_id : t -> string option 1983 + 1984 + val drop_tokens_mode : t -> DropTokensMode.T.t option 1985 + 1986 + (** 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 1987 + *) 1988 + val drop_tokens_threshold : t -> int option 1989 + 1990 + (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 1991 + *) 1992 + val enable_analytics : t -> bool 1993 + 1994 + (** 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 1995 + *) 1996 + val enable_overrides : t -> bool 1997 + 1998 + (** 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 1999 + *) 2000 + val enable_synonyms : t -> bool option 2001 + 2002 + (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 2003 + *) 2004 + val enable_typos_for_alpha_numerical_tokens : t -> bool option 2005 + 2006 + (** Make Typesense disable typos for numerical tokens. 2007 + *) 2008 + val enable_typos_for_numerical_tokens : t -> bool 2009 + 2010 + (** List of fields from the document to exclude in the search result *) 2011 + val exclude_fields : t -> string option 2012 + 2013 + (** 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). 2014 + *) 2015 + val exhaustive_search : t -> bool option 2016 + 2017 + (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 2018 + val facet_by : t -> string option 2019 + 2020 + (** 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". *) 2021 + val facet_query : t -> string option 2022 + 2023 + (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 2024 + *) 2025 + val facet_return_parent : t -> string option 2026 + 2027 + (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 2028 + *) 2029 + val facet_strategy : t -> string option 2030 + 2031 + (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *) 2032 + val filter_by : t -> string option 2033 + 2034 + (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false 2035 + *) 2036 + val filter_curated_hits : t -> bool option 2037 + 2038 + (** 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. *) 2039 + val group_by : t -> string option 2040 + 2041 + (** 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 2042 + *) 2043 + val group_limit : t -> int option 2044 + 2045 + (** 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 2046 + *) 2047 + val group_missing_values : t -> bool option 2048 + 2049 + (** 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`. 2050 + 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`. 2051 + *) 2052 + val hidden_hits : t -> string option 2053 + 2054 + (** The number of tokens that should surround the highlighted text on each side. Default: 4 2055 + *) 2056 + val highlight_affix_num_tokens : t -> int option 2057 + 2058 + (** The end tag used for the highlighted snippets. Default: `</mark>` 2059 + *) 2060 + val highlight_end_tag : t -> string option 2061 + 2062 + (** A list of custom fields that must be highlighted even if you don't query for them 2063 + *) 2064 + val highlight_fields : t -> string option 2065 + 2066 + (** List of fields which should be highlighted fully without snippeting *) 2067 + val highlight_full_fields : t -> string option 2068 + 2069 + (** The start tag used for the highlighted snippets. Default: `<mark>` 2070 + *) 2071 + val highlight_start_tag : t -> string option 2072 + 2073 + (** List of fields from the document to include in the search result *) 2074 + val include_fields : t -> string option 2075 + 2076 + (** 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 *) 2077 + val infix : t -> string option 2078 + 2079 + (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 2080 + *) 2081 + val limit : t -> int option 2082 + 2083 + (** 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. *) 2084 + val max_extra_prefix : t -> int option 2085 + 2086 + (** 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. *) 2087 + val max_extra_suffix : t -> int option 2088 + 2089 + (** Maximum number of facet values to be returned. *) 2090 + val max_facet_values : t -> int option 2091 + 2092 + (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 2093 + *) 2094 + val min_len_1typo : t -> int option 2095 + 2096 + (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 2097 + *) 2098 + val min_len_2typo : t -> int option 2099 + 2100 + (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 2101 + *) 2102 + val num_typos : t -> string option 2103 + 2104 + (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 2105 + val offset : t -> int option 2106 + 2107 + (** Comma separated list of tags to trigger the curations rules that match the tags. *) 2108 + val override_tags : t -> string option 2109 + 2110 + (** Results from this specific page number would be fetched. *) 2111 + val page : t -> int option 2112 + 2113 + (** Number of results to fetch per page. Default: 10 *) 2114 + val per_page : t -> int option 2115 + 2116 + (** 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`. 2117 + 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`. 2118 + *) 2119 + val pinned_hits : t -> string option 2120 + 2121 + (** 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. 2122 + Set this parameter to true to do the same 2123 + *) 2124 + val pre_segmented_query : t -> bool 2125 + 2126 + (** 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. *) 2127 + val prefix : t -> string option 2128 + 2129 + (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 2130 + *) 2131 + val preset : t -> string option 2132 + 2133 + (** Set this parameter to true to ensure that an exact match is ranked above the others 2134 + *) 2135 + val prioritize_exact_match : t -> bool 2136 + 2137 + (** Make Typesense prioritize documents where the query words appear in more number of fields. 2138 + *) 2139 + val prioritize_num_matching_fields : t -> bool 2140 + 2141 + (** Make Typesense prioritize documents where the query words appear earlier in the text. 2142 + *) 2143 + val prioritize_token_position : t -> bool 2144 + 2145 + (** 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. *) 2146 + val q : t -> string option 2147 + 2148 + (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 2149 + val query_by : t -> string option 2150 + 2151 + (** 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. *) 2152 + val query_by_weights : t -> string option 2153 + 2154 + (** Number of times to retry fetching remote embeddings. 2155 + *) 2156 + val remote_embedding_num_tries : t -> int option 2157 + 2158 + (** Timeout (in milliseconds) for fetching remote embeddings. 2159 + *) 2160 + val remote_embedding_timeout_ms : t -> int option 2161 + 2162 + (** 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. 2163 + *) 2164 + val search_cutoff_ms : t -> int option 2165 + 2166 + (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 2167 + *) 2168 + val snippet_threshold : t -> int option 2169 + 2170 + (** 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` *) 2171 + val sort_by : t -> string option 2172 + 2173 + (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. 2174 + *) 2175 + val stopwords : t -> string option 2176 + 2177 + (** Allow synonym resolution on typo-corrected words in the query. Default: 0 2178 + *) 2179 + val synonym_num_typos : t -> int option 2180 + 2181 + (** Allow synonym resolution on word prefixes in the query. Default: false 2182 + *) 2183 + val synonym_prefix : t -> bool option 2184 + 2185 + (** 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. *) 2186 + val text_match_type : t -> string option 2187 + 2188 + (** 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 2189 + *) 2190 + val typo_tokens_threshold : t -> int option 2191 + 2192 + (** Enable server side caching of search query results. By default, caching is disabled. 2193 + *) 2194 + val use_cache : t -> bool option 2195 + 2196 + (** Vector query expression for fetching documents "closest" to a given query/document vector. 2197 + *) 2198 + val vector_query : t -> string option 2199 + 2200 + (** The base64 encoded audio file in 16 khz 16-bit WAV format. 2201 + *) 2202 + val voice_query : t -> string option 2203 + 2204 + val jsont : t Jsont.t 2205 + end 2206 + end 2207 + 2208 + module MultiSearchCollectionParameters : sig 2209 + module T : sig 2210 + type t 2211 + 2212 + (** Construct a value 2213 + @param enable_analytics Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 2214 + 2215 + @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 2216 + 2217 + @param enable_typos_for_numerical_tokens Make Typesense disable typos for numerical tokens. 2218 + 2219 + @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. 2220 + Set this parameter to true to do the same 2221 + 2222 + @param prioritize_exact_match Set this parameter to true to ensure that an exact match is ranked above the others 2223 + 2224 + @param prioritize_num_matching_fields Make Typesense prioritize documents where the query words appear in more number of fields. 2225 + 2226 + @param prioritize_token_position Make Typesense prioritize documents where the query words appear earlier in the text. 2227 + 2228 + @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. 2229 + 2230 + @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. 2231 + 2232 + @param conversation Enable conversational search. 2233 + 2234 + @param conversation_id The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 2235 + 2236 + @param conversation_model_id The Id of Conversation Model to be used. 2237 + 2238 + @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 2239 + 2240 + @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 2241 + 2242 + @param enable_typos_for_alpha_numerical_tokens Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 2243 + 2244 + @param exclude_fields List of fields from the document to exclude in the search result 2245 + @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). 2246 + 2247 + @param facet_by A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. 2248 + @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". 2249 + @param facet_return_parent Comma separated string of nested facet fields whose parent object should be returned in facet response. 2250 + 2251 + @param facet_strategy Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 2252 + 2253 + @param filter_by Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. 2254 + @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 2255 + 2256 + @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. 2257 + @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 2258 + 2259 + @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 2260 + 2261 + @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`. 2262 + 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`. 2263 + 2264 + @param highlight_affix_num_tokens The number of tokens that should surround the highlighted text on each side. Default: 4 2265 + 2266 + @param highlight_end_tag The end tag used for the highlighted snippets. Default: `</mark>` 2267 + 2268 + @param highlight_fields A list of custom fields that must be highlighted even if you don't query for them 2269 + 2270 + @param highlight_full_fields List of fields which should be highlighted fully without snippeting 2271 + @param highlight_start_tag The start tag used for the highlighted snippets. Default: `<mark>` 2272 + 2273 + @param include_fields List of fields from the document to include in the search result 2274 + @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 2275 + @param limit Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 2276 + 2277 + @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. 2278 + @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. 2279 + @param max_facet_values Maximum number of facet values to be returned. 2280 + @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. 2281 + 2282 + @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. 2283 + 2284 + @param num_typos The number of typographical errors (1 or 2) that would be tolerated. Default: 2 2285 + 2286 + @param offset Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. 2287 + @param override_tags Comma separated list of tags to trigger the curations rules that match the tags. 2288 + @param page Results from this specific page number would be fetched. 2289 + @param per_page Number of results to fetch per page. Default: 10 2290 + @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`. 2291 + 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`. 2292 + 2293 + @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. 2294 + @param preset Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 2295 + 2296 + @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. 2297 + @param query_by A list of `string` fields that should be queried against. Multiple fields are separated with a comma. 2298 + @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. 2299 + @param remote_embedding_num_tries Number of times to retry fetching remote embeddings. 2300 + 2301 + @param remote_embedding_timeout_ms Timeout (in milliseconds) for fetching remote embeddings. 2302 + 2303 + @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. 2304 + 2305 + @param snippet_threshold Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 2306 + 2307 + @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` 2308 + @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. 2309 + 2310 + @param synonym_num_typos Allow synonym resolution on typo-corrected words in the query. Default: 0 2311 + 2312 + @param synonym_prefix Allow synonym resolution on word prefixes in the query. Default: false 2313 + 2314 + @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. 2315 + @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 2316 + 2317 + @param use_cache Enable server side caching of search query results. By default, caching is disabled. 2318 + 2319 + @param vector_query Vector query expression for fetching documents "closest" to a given query/document vector. 2320 + 2321 + @param voice_query The base64 encoded audio file in 16 khz 16-bit WAV format. 2322 + 2323 + @param collection The collection to search in. 2324 + 2325 + @param x_typesense_api_key A separate search API key for each search within a multi_search request 2326 + *) 2327 + 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 2328 + 2329 + (** 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. 2330 + *) 2331 + val cache_ttl : t -> int option 2332 + 2333 + (** Enable conversational search. 2334 + *) 2335 + val conversation : t -> bool option 2336 + 2337 + (** The Id of a previous conversation to continue, this tells Typesense to include prior context when communicating with the LLM. 2338 + *) 2339 + val conversation_id : t -> string option 2340 + 2341 + (** The Id of Conversation Model to be used. 2342 + *) 2343 + val conversation_model_id : t -> string option 2344 + 2345 + val drop_tokens_mode : t -> DropTokensMode.T.t option 2346 + 2347 + (** 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 2348 + *) 2349 + val drop_tokens_threshold : t -> int option 2350 + 2351 + (** Flag for enabling/disabling analytics aggregation for specific search queries (for e.g. those originating from a test script). 2352 + *) 2353 + val enable_analytics : t -> bool 2354 + 2355 + (** 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 2356 + *) 2357 + val enable_overrides : t -> bool 2358 + 2359 + (** 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 2360 + *) 2361 + val enable_synonyms : t -> bool option 2362 + 2363 + (** Set this parameter to false to disable typos on alphanumerical query tokens. Default: true. 2364 + *) 2365 + val enable_typos_for_alpha_numerical_tokens : t -> bool option 2366 + 2367 + (** Make Typesense disable typos for numerical tokens. 2368 + *) 2369 + val enable_typos_for_numerical_tokens : t -> bool 2370 + 2371 + (** List of fields from the document to exclude in the search result *) 2372 + val exclude_fields : t -> string option 2373 + 2374 + (** 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). 2375 + *) 2376 + val exhaustive_search : t -> bool option 2377 + 2378 + (** A list of fields that will be used for faceting your results on. Separate multiple fields with a comma. *) 2379 + val facet_by : t -> string option 2380 + 2381 + (** 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". *) 2382 + val facet_query : t -> string option 2383 + 2384 + (** Comma separated string of nested facet fields whose parent object should be returned in facet response. 2385 + *) 2386 + val facet_return_parent : t -> string option 2387 + 2388 + (** Choose the underlying faceting strategy used. Comma separated string of allows values: exhaustive, top_values or automatic (default). 2389 + *) 2390 + val facet_strategy : t -> string option 2391 + 2392 + (** Filter conditions for refining youropen api validator search results. Separate multiple conditions with &&. *) 2393 + val filter_by : t -> string option 2394 + 2395 + (** Whether the filter_by condition of the search query should be applicable to curated results (override definitions, pinned hits, hidden hits, etc.). Default: false 2396 + *) 2397 + val filter_curated_hits : t -> bool option 2398 + 2399 + (** 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. *) 2400 + val group_by : t -> string option 2401 + 2402 + (** 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 2403 + *) 2404 + val group_limit : t -> int option 2405 + 2406 + (** 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 2407 + *) 2408 + val group_missing_values : t -> bool option 2409 + 2410 + (** 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`. 2411 + 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`. 2412 + *) 2413 + val hidden_hits : t -> string option 2414 + 2415 + (** The number of tokens that should surround the highlighted text on each side. Default: 4 2416 + *) 2417 + val highlight_affix_num_tokens : t -> int option 2418 + 2419 + (** The end tag used for the highlighted snippets. Default: `</mark>` 2420 + *) 2421 + val highlight_end_tag : t -> string option 2422 + 2423 + (** A list of custom fields that must be highlighted even if you don't query for them 2424 + *) 2425 + val highlight_fields : t -> string option 2426 + 2427 + (** List of fields which should be highlighted fully without snippeting *) 2428 + val highlight_full_fields : t -> string option 2429 + 2430 + (** The start tag used for the highlighted snippets. Default: `<mark>` 2431 + *) 2432 + val highlight_start_tag : t -> string option 2433 + 2434 + (** List of fields from the document to include in the search result *) 2435 + val include_fields : t -> string option 2436 + 2437 + (** 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 *) 2438 + val infix : t -> string option 2439 + 2440 + (** Number of hits to fetch. Can be used as an alternative to the per_page parameter. Default: 10. 2441 + *) 2442 + val limit : t -> int option 2443 + 2444 + (** 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. *) 2445 + val max_extra_prefix : t -> int option 2446 + 2447 + (** 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. *) 2448 + val max_extra_suffix : t -> int option 2449 + 2450 + (** Maximum number of facet values to be returned. *) 2451 + val max_facet_values : t -> int option 2452 + 2453 + (** Minimum word length for 1-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 2454 + *) 2455 + val min_len_1typo : t -> int option 2456 + 2457 + (** Minimum word length for 2-typo correction to be applied. The value of num_typos is still treated as the maximum allowed typos. 2458 + *) 2459 + val min_len_2typo : t -> int option 2460 + 2461 + (** The number of typographical errors (1 or 2) that would be tolerated. Default: 2 2462 + *) 2463 + val num_typos : t -> string option 2464 + 2465 + (** Identifies the starting point to return hits from a result set. Can be used as an alternative to the page parameter. *) 2466 + val offset : t -> int option 2467 + 2468 + (** Comma separated list of tags to trigger the curations rules that match the tags. *) 2469 + val override_tags : t -> string option 2470 + 2471 + (** Results from this specific page number would be fetched. *) 2472 + val page : t -> int option 2473 + 2474 + (** Number of results to fetch per page. Default: 10 *) 2475 + val per_page : t -> int option 2476 + 2477 + (** 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`. 2478 + 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`. 2479 + *) 2480 + val pinned_hits : t -> string option 2481 + 2482 + (** 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. 2483 + Set this parameter to true to do the same 2484 + *) 2485 + val pre_segmented_query : t -> bool 2486 + 2487 + (** 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. *) 2488 + val prefix : t -> string option 2489 + 2490 + (** Search using a bunch of search parameters by setting this parameter to the name of the existing Preset. 2491 + *) 2492 + val preset : t -> string option 2493 + 2494 + (** Set this parameter to true to ensure that an exact match is ranked above the others 2495 + *) 2496 + val prioritize_exact_match : t -> bool 2497 + 2498 + (** Make Typesense prioritize documents where the query words appear in more number of fields. 2499 + *) 2500 + val prioritize_num_matching_fields : t -> bool 2501 + 2502 + (** Make Typesense prioritize documents where the query words appear earlier in the text. 2503 + *) 2504 + val prioritize_token_position : t -> bool 2505 + 2506 + (** 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. *) 2507 + val q : t -> string option 2508 + 2509 + (** A list of `string` fields that should be queried against. Multiple fields are separated with a comma. *) 2510 + val query_by : t -> string option 2511 + 2512 + (** 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. *) 2513 + val query_by_weights : t -> string option 2514 + 2515 + (** Number of times to retry fetching remote embeddings. 2516 + *) 2517 + val remote_embedding_num_tries : t -> int option 2518 + 2519 + (** Timeout (in milliseconds) for fetching remote embeddings. 2520 + *) 2521 + val remote_embedding_timeout_ms : t -> int option 2522 + 2523 + (** 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. 2524 + *) 2525 + val search_cutoff_ms : t -> int option 2526 + 2527 + (** Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion. Default: 30 2528 + *) 2529 + val snippet_threshold : t -> int option 2530 + 2531 + (** 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` *) 2532 + val sort_by : t -> string option 2533 + 2534 + (** Name of the stopwords set to apply for this search, the keywords present in the set will be removed from the search query. 2535 + *) 2536 + val stopwords : t -> string option 2537 + 2538 + (** Allow synonym resolution on typo-corrected words in the query. Default: 0 2539 + *) 2540 + val synonym_num_typos : t -> int option 2541 + 2542 + (** Allow synonym resolution on word prefixes in the query. Default: false 2543 + *) 2544 + val synonym_prefix : t -> bool option 2545 + 2546 + (** 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. *) 2547 + val text_match_type : t -> string option 2548 + 2549 + (** 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 2550 + *) 2551 + val typo_tokens_threshold : t -> int option 2552 + 2553 + (** Enable server side caching of search query results. By default, caching is disabled. 2554 + *) 2555 + val use_cache : t -> bool option 2556 + 2557 + (** Vector query expression for fetching documents "closest" to a given query/document vector. 2558 + *) 2559 + val vector_query : t -> string option 2560 + 2561 + (** The base64 encoded audio file in 16 khz 16-bit WAV format. 2562 + *) 2563 + val voice_query : t -> string option 2564 + 2565 + (** The collection to search in. 2566 + *) 2567 + val collection : t -> string option 2568 + 2569 + (** A separate search API key for each search within a multi_search request *) 2570 + val x_typesense_api_key : t -> string option 2571 + 2572 + (** 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. 2573 + *) 2574 + val rerank_hybrid_matches : t -> bool 2575 + 2576 + val jsont : t Jsont.t 2577 + end 2578 + end 2579 + 2580 + module MultiSearchSearchesParameter : sig 2581 + module T : sig 2582 + type t 2583 + 2584 + (** Construct a value 2585 + @param union When true, merges the search results from each search query into a single ordered set of hits. 2586 + *) 2587 + val v : searches:MultiSearchCollectionParameters.T.t list -> ?union:bool -> unit -> t 2588 + 2589 + val searches : t -> MultiSearchCollectionParameters.T.t list 2590 + 2591 + (** When true, merges the search results from each search query into a single ordered set of hits. *) 2592 + val union : t -> bool 2593 + 2594 + val jsont : t Jsont.t 2595 + end 2596 + end 2597 + 2598 + module MultiSearch : sig 2599 + module Result : sig 2600 + type t 2601 + 2602 + (** Construct a value *) 2603 + val v : results:MultiSearchResult.Item.t list -> ?conversation:SearchResultConversation.T.t -> unit -> t 2604 + 2605 + val conversation : t -> SearchResultConversation.T.t option 2606 + 2607 + val results : t -> MultiSearchResult.Item.t list 2608 + 2609 + val jsont : t Jsont.t 2610 + end 2611 + 2612 + (** send multiple search requests in a single HTTP request 2613 + 2614 + 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. *) 2615 + val multi_search : multi_search_parameters:string -> body:MultiSearchSearchesParameter.T.t -> t -> unit -> Result.t 2616 + end 2617 + 2618 + module DirtyValues : sig 2619 + module T : sig 2620 + type t = [ 2621 + | `Coerce_or_reject 2622 + | `Coerce_or_drop 2623 + | `Drop 2624 + | `Reject 2625 + ] 2626 + 2627 + val jsont : t Jsont.t 2628 + end 2629 + end 2630 + 2631 + module CurationSetDeleteSchema : sig 2632 + module T : sig 2633 + type t 2634 + 2635 + (** Construct a value 2636 + @param name Name of the deleted curation set 2637 + *) 2638 + val v : name:string -> unit -> t 2639 + 2640 + (** Name of the deleted curation set *) 2641 + val name : t -> string 2642 + 2643 + val jsont : t Jsont.t 2644 + end 2645 + 2646 + (** Delete a curation set 2647 + 2648 + Delete a specific curation set by its name 2649 + @param curation_set_name The name of the curation set to delete 2650 + *) 2651 + val delete_curation_set : curation_set_name:string -> t -> unit -> T.t 2652 + end 2653 + 2654 + module CurationRule : sig 2655 + module T : sig 2656 + type t 2657 + 2658 + (** Construct a value 2659 + @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). 2660 + 2661 + @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. 2662 + 2663 + @param query Indicates what search queries should be curated 2664 + @param tags List of tag values to associate with this curation rule. 2665 + *) 2666 + val v : ?filter_by:string -> ?match_:string -> ?query:string -> ?tags:string list -> unit -> t 2667 + 2668 + (** 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). 2669 + *) 2670 + val filter_by : t -> string option 2671 + 2672 + (** 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. 2673 + *) 2674 + val match_ : t -> string option 2675 + 2676 + (** Indicates what search queries should be curated *) 2677 + val query : t -> string option 2678 + 2679 + (** List of tag values to associate with this curation rule. *) 2680 + val tags : t -> string list option 2681 + 2682 + val jsont : t Jsont.t 2683 + end 2684 + end 2685 + 2686 + module CurationItemDeleteSchema : sig 2687 + module T : sig 2688 + type t 2689 + 2690 + (** Construct a value 2691 + @param id ID of the deleted curation item 2692 + *) 2693 + val v : id:string -> unit -> t 2694 + 2695 + (** ID of the deleted curation item *) 2696 + val id : t -> string 2697 + 2698 + val jsont : t Jsont.t 2699 + end 2700 + 2701 + (** Delete a curation set item 2702 + 2703 + Delete a specific curation item by its id 2704 + @param curation_set_name The name of the curation set 2705 + @param item_id The id of the curation item to delete 2706 + *) 2707 + val delete_curation_set_item : curation_set_name:string -> item_id:string -> t -> unit -> T.t 2708 + end 2709 + 2710 + module CurationInclude : sig 2711 + module T : sig 2712 + type t 2713 + 2714 + (** Construct a value 2715 + @param id document id that should be included 2716 + @param position position number where document should be included in the search results 2717 + *) 2718 + val v : id:string -> position:int -> unit -> t 2719 + 2720 + (** document id that should be included *) 2721 + val id : t -> string 2722 + 2723 + (** position number where document should be included in the search results *) 2724 + val position : t -> int 2725 + 2726 + val jsont : t Jsont.t 2727 + end 2728 + end 2729 + 2730 + module CurationExclude : sig 2731 + module T : sig 2732 + type t 2733 + 2734 + (** Construct a value 2735 + @param id document id that should be excluded from the search results. 2736 + *) 2737 + val v : id:string -> unit -> t 2738 + 2739 + (** document id that should be excluded from the search results. *) 2740 + val id : t -> string 2741 + 2742 + val jsont : t Jsont.t 2743 + end 2744 + end 2745 + 2746 + module CurationItemCreateSchema : sig 2747 + module T : sig 2748 + type t 2749 + 2750 + (** Construct a value 2751 + @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. 2752 + 2753 + @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. 2754 + 2755 + @param excludes List of document `id`s that should be excluded from the search results. 2756 + @param filter_by A filter by clause that is applied to any search query that matches the curation rule. 2757 + 2758 + @param filter_curated_hits When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. 2759 + 2760 + @param id ID of the curation item 2761 + @param includes List of document `id`s that should be included in the search results with their corresponding `position`s. 2762 + @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. 2763 + 2764 + @param remove_matched_tokens Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 2765 + 2766 + @param replace_query Replaces the current search query with this value, when the search query matches the curation rule. 2767 + 2768 + @param sort_by A sort by clause that is applied to any search query that matches the curation rule. 2769 + 2770 + @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. 2771 + 2772 + *) 2773 + 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 2774 + 2775 + (** 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. 2776 + *) 2777 + val effective_from_ts : t -> int option 2778 + 2779 + (** 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. 2780 + *) 2781 + val effective_to_ts : t -> int option 2782 + 2783 + (** List of document `id`s that should be excluded from the search results. *) 2784 + val excludes : t -> CurationExclude.T.t list option 2785 + 2786 + (** A filter by clause that is applied to any search query that matches the curation rule. 2787 + *) 2788 + val filter_by : t -> string option 2789 + 2790 + (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. 2791 + *) 2792 + val filter_curated_hits : t -> bool option 2793 + 2794 + (** ID of the curation item *) 2795 + val id : t -> string option 2796 + 2797 + (** List of document `id`s that should be included in the search results with their corresponding `position`s. *) 2798 + val includes : t -> CurationInclude.T.t list option 2799 + 2800 + (** 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. 2801 + *) 2802 + val metadata : t -> Jsont.json option 2803 + 2804 + (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 2805 + *) 2806 + val remove_matched_tokens : t -> bool option 2807 + 2808 + (** Replaces the current search query with this value, when the search query matches the curation rule. 2809 + *) 2810 + val replace_query : t -> string option 2811 + 2812 + val rule : t -> CurationRule.T.t 2813 + 2814 + (** A sort by clause that is applied to any search query that matches the curation rule. 2815 + *) 2816 + val sort_by : t -> string option 2817 + 2818 + (** 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. 2819 + *) 2820 + val stop_processing : t -> bool option 2821 + 2822 + val jsont : t Jsont.t 2823 + end 2824 + end 2825 + 2826 + module CurationSetCreateSchema : sig 2827 + module T : sig 2828 + type t 2829 + 2830 + (** Construct a value 2831 + @param items Array of curation items 2832 + @param description Optional description for the curation set 2833 + *) 2834 + val v : items:CurationItemCreateSchema.T.t list -> ?description:string -> unit -> t 2835 + 2836 + (** Optional description for the curation set *) 2837 + val description : t -> string option 2838 + 2839 + (** Array of curation items *) 2840 + val items : t -> CurationItemCreateSchema.T.t list 2841 + 2842 + val jsont : t Jsont.t 2843 + end 2844 + end 2845 + 2846 + module CurationSetSchema : sig 2847 + module T : sig 2848 + type t 2849 + 2850 + (** Construct a value 2851 + @param items Array of curation items 2852 + @param description Optional description for the curation set 2853 + *) 2854 + val v : items:CurationItemCreateSchema.T.t list -> name:string -> ?description:string -> unit -> t 2855 + 2856 + (** Optional description for the curation set *) 2857 + val description : t -> string option 2858 + 2859 + (** Array of curation items *) 2860 + val items : t -> CurationItemCreateSchema.T.t list 2861 + 2862 + val name : t -> string 2863 + 2864 + val jsont : t Jsont.t 2865 + end 2866 + 2867 + (** List all curation sets 2868 + 2869 + Retrieve all curation sets *) 2870 + val retrieve_curation_sets : t -> unit -> T.t 2871 + 2872 + (** Retrieve a curation set 2873 + 2874 + Retrieve a specific curation set by its name 2875 + @param curation_set_name The name of the curation set to retrieve 2876 + *) 2877 + val retrieve_curation_set : curation_set_name:string -> t -> unit -> T.t 2878 + 2879 + (** Create or update a curation set 2880 + 2881 + Create or update a curation set with the given name 2882 + @param curation_set_name The name of the curation set to create/update 2883 + *) 2884 + val upsert_curation_set : curation_set_name:string -> body:CurationSetCreateSchema.T.t -> t -> unit -> T.t 2885 + end 2886 + 2887 + module CurationItemSchema : sig 2888 + module T : sig 2889 + type t 2890 + 2891 + (** Construct a value 2892 + @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. 2893 + 2894 + @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. 2895 + 2896 + @param excludes List of document `id`s that should be excluded from the search results. 2897 + @param filter_by A filter by clause that is applied to any search query that matches the curation rule. 2898 + 2899 + @param filter_curated_hits When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. 2900 + 2901 + @param includes List of document `id`s that should be included in the search results with their corresponding `position`s. 2902 + @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. 2903 + 2904 + @param remove_matched_tokens Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 2905 + 2906 + @param replace_query Replaces the current search query with this value, when the search query matches the curation rule. 2907 + 2908 + @param sort_by A sort by clause that is applied to any search query that matches the curation rule. 2909 + 2910 + @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. 2911 + 2912 + *) 2913 + 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 2914 + 2915 + (** 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. 2916 + *) 2917 + val effective_from_ts : t -> int option 2918 + 2919 + (** 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. 2920 + *) 2921 + val effective_to_ts : t -> int option 2922 + 2923 + (** List of document `id`s that should be excluded from the search results. *) 2924 + val excludes : t -> CurationExclude.T.t list option 2925 + 2926 + (** A filter by clause that is applied to any search query that matches the curation rule. 2927 + *) 2928 + val filter_by : t -> string option 2929 + 2930 + (** When set to true, the filter conditions of the query is applied to the curated records as well. Default: false. 2931 + *) 2932 + val filter_curated_hits : t -> bool option 2933 + 2934 + (** List of document `id`s that should be included in the search results with their corresponding `position`s. *) 2935 + val includes : t -> CurationInclude.T.t list option 2936 + 2937 + (** 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. 2938 + *) 2939 + val metadata : t -> Jsont.json option 2940 + 2941 + (** Indicates whether search query tokens that exist in the curation's rule should be removed from the search query. 2942 + *) 2943 + val remove_matched_tokens : t -> bool option 2944 + 2945 + (** Replaces the current search query with this value, when the search query matches the curation rule. 2946 + *) 2947 + val replace_query : t -> string option 2948 + 2949 + val rule : t -> CurationRule.T.t 2950 + 2951 + (** A sort by clause that is applied to any search query that matches the curation rule. 2952 + *) 2953 + val sort_by : t -> string option 2954 + 2955 + (** 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. 2956 + *) 2957 + val stop_processing : t -> bool option 2958 + 2959 + val id : t -> string 2960 + 2961 + val jsont : t Jsont.t 2962 + end 2963 + 2964 + (** List items in a curation set 2965 + 2966 + Retrieve all curation items in a set 2967 + @param curation_set_name The name of the curation set to retrieve items for 2968 + *) 2969 + val retrieve_curation_set_items : curation_set_name:string -> t -> unit -> T.t 2970 + 2971 + (** Retrieve a curation set item 2972 + 2973 + Retrieve a specific curation item by its id 2974 + @param curation_set_name The name of the curation set 2975 + @param item_id The id of the curation item to retrieve 2976 + *) 2977 + val retrieve_curation_set_item : curation_set_name:string -> item_id:string -> t -> unit -> T.t 2978 + 2979 + (** Create or update a curation set item 2980 + 2981 + Create or update a curation set item with the given id 2982 + @param curation_set_name The name of the curation set 2983 + @param item_id The id of the curation item to upsert 2984 + *) 2985 + val upsert_curation_set_item : curation_set_name:string -> item_id:string -> body:CurationItemCreateSchema.T.t -> t -> unit -> T.t 2986 + end 2987 + 2988 + module ConversationModelUpdateSchema : sig 2989 + module T : sig 2990 + type t 2991 + 2992 + (** Construct a value 2993 + @param account_id LLM service's account ID (only applicable for Cloudflare) 2994 + @param api_key The LLM service's API Key 2995 + @param history_collection Typesense collection that stores the historical conversations 2996 + @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. 2997 + @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. 2998 + 2999 + @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM 3000 + @param system_prompt The system prompt that contains special instructions to the LLM 3001 + @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3002 + 3003 + @param vllm_url URL of vLLM service 3004 + *) 3005 + 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 3006 + 3007 + (** LLM service's account ID (only applicable for Cloudflare) *) 3008 + val account_id : t -> string option 3009 + 3010 + (** The LLM service's API Key *) 3011 + val api_key : t -> string option 3012 + 3013 + (** Typesense collection that stores the historical conversations *) 3014 + val history_collection : t -> string option 3015 + 3016 + (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 3017 + val id : t -> string option 3018 + 3019 + (** 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. 3020 + *) 3021 + val max_bytes : t -> int option 3022 + 3023 + (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 3024 + val model_name : t -> string option 3025 + 3026 + (** The system prompt that contains special instructions to the LLM *) 3027 + val system_prompt : t -> string option 3028 + 3029 + (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3030 + *) 3031 + val ttl : t -> int option 3032 + 3033 + (** URL of vLLM service *) 3034 + val vllm_url : t -> string option 3035 + 3036 + val jsont : t Jsont.t 3037 + end 3038 + end 3039 + 3040 + module ConversationModelCreateSchema : sig 3041 + module T : sig 3042 + type t 3043 + 3044 + (** Construct a value 3045 + @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM 3046 + @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. 3047 + 3048 + @param history_collection Typesense collection that stores the historical conversations 3049 + @param account_id LLM service's account ID (only applicable for Cloudflare) 3050 + @param api_key The LLM service's API Key 3051 + @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. 3052 + @param system_prompt The system prompt that contains special instructions to the LLM 3053 + @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3054 + 3055 + @param vllm_url URL of vLLM service 3056 + *) 3057 + 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 3058 + 3059 + (** LLM service's account ID (only applicable for Cloudflare) *) 3060 + val account_id : t -> string option 3061 + 3062 + (** The LLM service's API Key *) 3063 + val api_key : t -> string option 3064 + 3065 + (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 3066 + val id : t -> string option 3067 + 3068 + (** The system prompt that contains special instructions to the LLM *) 3069 + val system_prompt : t -> string option 3070 + 3071 + (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3072 + *) 3073 + val ttl : t -> int option 3074 + 3075 + (** URL of vLLM service *) 3076 + val vllm_url : t -> string option 3077 + 3078 + (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 3079 + val model_name : t -> string 3080 + 3081 + (** 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. 3082 + *) 3083 + val max_bytes : t -> int 3084 + 3085 + (** Typesense collection that stores the historical conversations *) 3086 + val history_collection : t -> string 3087 + 3088 + val jsont : t Jsont.t 3089 + end 3090 + end 3091 + 3092 + module ConversationModelSchema : sig 3093 + module T : sig 3094 + type t 3095 + 3096 + (** Construct a value 3097 + @param model_name Name of the LLM model offered by OpenAI, Cloudflare or vLLM 3098 + @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. 3099 + 3100 + @param history_collection Typesense collection that stores the historical conversations 3101 + @param id An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. 3102 + @param account_id LLM service's account ID (only applicable for Cloudflare) 3103 + @param api_key The LLM service's API Key 3104 + @param system_prompt The system prompt that contains special instructions to the LLM 3105 + @param ttl Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3106 + 3107 + @param vllm_url URL of vLLM service 3108 + *) 3109 + 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 3110 + 3111 + (** LLM service's account ID (only applicable for Cloudflare) *) 3112 + val account_id : t -> string option 3113 + 3114 + (** The LLM service's API Key *) 3115 + val api_key : t -> string option 3116 + 3117 + (** The system prompt that contains special instructions to the LLM *) 3118 + val system_prompt : t -> string option 3119 + 3120 + (** Time interval in seconds after which the messages would be deleted. Default: 86400 (24 hours) 3121 + *) 3122 + val ttl : t -> int option 3123 + 3124 + (** URL of vLLM service *) 3125 + val vllm_url : t -> string option 3126 + 3127 + (** Name of the LLM model offered by OpenAI, Cloudflare or vLLM *) 3128 + val model_name : t -> string 3129 + 3130 + (** 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. 3131 + *) 3132 + val max_bytes : t -> int 3133 + 3134 + (** Typesense collection that stores the historical conversations *) 3135 + val history_collection : t -> string 3136 + 3137 + (** An explicit id for the model, otherwise the API will return a response with an auto-generated conversation model id. *) 3138 + val id : t -> string 3139 + 3140 + val jsont : t Jsont.t 3141 + end 3142 + 3143 + (** List all conversation models 3144 + 3145 + Retrieve all conversation models *) 3146 + val retrieve_all_conversation_models : t -> unit -> T.t 3147 + 3148 + (** Create a conversation model 3149 + 3150 + Create a Conversation Model *) 3151 + val create_conversation_model : body:ConversationModelCreateSchema.T.t -> t -> unit -> T.t 3152 + 3153 + (** Retrieve a conversation model 3154 + 3155 + Retrieve a conversation model 3156 + @param model_id The id of the conversation model to retrieve 3157 + *) 3158 + val retrieve_conversation_model : model_id:string -> t -> unit -> T.t 3159 + 3160 + (** Update a conversation model 3161 + 3162 + Update a conversation model 3163 + @param model_id The id of the conversation model to update 3164 + *) 3165 + val update_conversation_model : model_id:string -> body:ConversationModelUpdateSchema.T.t -> t -> unit -> T.t 3166 + 3167 + (** Delete a conversation model 3168 + 3169 + Delete a conversation model 3170 + @param model_id The id of the conversation model to delete 3171 + *) 3172 + val delete_conversation_model : model_id:string -> t -> unit -> T.t 3173 + end 3174 + 3175 + module CollectionAliasSchema : sig 3176 + module T : sig 3177 + type t 3178 + 3179 + (** Construct a value 3180 + @param collection_name Name of the collection you wish to map the alias to 3181 + *) 3182 + val v : collection_name:string -> unit -> t 3183 + 3184 + (** Name of the collection you wish to map the alias to *) 3185 + val collection_name : t -> string 3186 + 3187 + val jsont : t Jsont.t 3188 + end 3189 + end 3190 + 3191 + module CollectionAlias : sig 3192 + module T : sig 3193 + type t 3194 + 3195 + (** Construct a value 3196 + @param collection_name Name of the collection the alias mapped to 3197 + @param name Name of the collection alias 3198 + *) 3199 + val v : collection_name:string -> name:string -> unit -> t 3200 + 3201 + (** Name of the collection the alias mapped to *) 3202 + val collection_name : t -> string 3203 + 3204 + (** Name of the collection alias *) 3205 + val name : t -> string 3206 + 3207 + val jsont : t Jsont.t 3208 + end 3209 + 3210 + (** Retrieve an alias 3211 + 3212 + Find out which collection an alias points to by fetching it 3213 + @param alias_name The name of the alias to retrieve 3214 + *) 3215 + val get_alias : alias_name:string -> t -> unit -> T.t 3216 + 3217 + (** Create or update a collection alias 3218 + 3219 + 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. 3220 + @param alias_name The name of the alias to create/update 3221 + *) 3222 + val upsert_alias : alias_name:string -> body:CollectionAliasSchema.T.t -> t -> unit -> T.t 3223 + 3224 + (** Delete an alias 3225 + @param alias_name The name of the alias to delete 3226 + *) 3227 + val delete_alias : alias_name:string -> t -> unit -> T.t 3228 + end 3229 + 3230 + module CollectionAliases : sig 3231 + module Response : sig 3232 + type t 3233 + 3234 + (** Construct a value *) 3235 + val v : aliases:CollectionAlias.T.t list -> unit -> t 3236 + 3237 + val aliases : t -> CollectionAlias.T.t list 3238 + 3239 + val jsont : t Jsont.t 3240 + end 3241 + 3242 + (** List all aliases 3243 + 3244 + List all aliases and the corresponding collections that they map to. *) 3245 + val get_aliases : t -> unit -> Response.t 3246 + end 3247 + 3248 + module Client : sig 3249 + (** Create analytics rule(s) 3250 + 3251 + Create one or more analytics rules. You can send a single rule object or an array of rule objects. *) 3252 + val create_analytics_rule : t -> unit -> Jsont.json 3253 + 3254 + (** Index a document 3255 + 3256 + A document to be indexed in a given collection must conform to the schema of the collection. 3257 + @param collection_name The name of the collection to add the document to 3258 + @param action Additional action to perform 3259 + @param dirty_values Dealing with Dirty Data 3260 + *) 3261 + val index_document : collection_name:string -> ?action:string -> ?dirty_values:string -> t -> unit -> Jsont.json 3262 + 3263 + (** Delete a bunch of documents 3264 + 3265 + 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. 3266 + @param collection_name The name of the collection to delete documents from 3267 + *) 3268 + val delete_documents : collection_name:string -> ?delete_documents_parameters:string -> t -> unit -> Jsont.json 3269 + 3270 + (** Update documents with conditional query 3271 + 3272 + 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. 3273 + @param collection_name The name of the collection to update documents in 3274 + *) 3275 + val update_documents : collection_name:string -> ?update_documents_parameters:string -> t -> unit -> Jsont.json 3276 + 3277 + (** Export all documents in a collection 3278 + 3279 + Export all documents in a collection in JSON lines format. 3280 + @param collection_name The name of the collection 3281 + *) 3282 + val export_documents : collection_name:string -> ?export_documents_parameters:string -> t -> unit -> Jsont.json 3283 + 3284 + (** Import documents into a collection 3285 + 3286 + 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. 3287 + @param collection_name The name of the collection 3288 + *) 3289 + val import_documents : collection_name:string -> ?import_documents_parameters:string -> t -> unit -> Jsont.json 3290 + 3291 + (** Retrieve a document 3292 + 3293 + Fetch an individual document from a collection by using its ID. 3294 + @param collection_name The name of the collection to search for the document under 3295 + @param document_id The Document ID 3296 + *) 3297 + val get_document : collection_name:string -> document_id:string -> t -> unit -> Jsont.json 3298 + 3299 + (** Delete a document 3300 + 3301 + Delete an individual document from a collection by using its ID. 3302 + @param collection_name The name of the collection to search for the document under 3303 + @param document_id The Document ID 3304 + *) 3305 + val delete_document : collection_name:string -> document_id:string -> t -> unit -> Jsont.json 3306 + 3307 + (** Update a document 3308 + 3309 + Update an individual document from a collection by using its ID. The update can be partial. 3310 + @param collection_name The name of the collection to search for the document under 3311 + @param document_id The Document ID 3312 + @param dirty_values Dealing with Dirty Data 3313 + *) 3314 + val update_document : collection_name:string -> document_id:string -> ?dirty_values:string -> t -> unit -> Jsont.json 3315 + 3316 + (** Print debugging information 3317 + 3318 + Print debugging information *) 3319 + val debug : t -> unit -> Jsont.json 3320 + 3321 + (** Get current RAM, CPU, Disk & Network usage metrics. 3322 + 3323 + Retrieve the metrics. *) 3324 + val retrieve_metrics : t -> unit -> Jsont.json 3325 + 3326 + (** List all stemming dictionaries 3327 + 3328 + Retrieve a list of all available stemming dictionaries. *) 3329 + val list_stemming_dictionaries : t -> unit -> Jsont.json 3330 + 3331 + (** Import a stemming dictionary 3332 + 3333 + Upload a JSONL file containing word mappings to create or update a stemming dictionary. 3334 + @param id The ID to assign to the dictionary 3335 + *) 3336 + val import_stemming_dictionary : id:string -> t -> unit -> Jsont.json 3337 + 3338 + (** Delete a stopwords set. 3339 + 3340 + Permanently deletes a stopwords set, given it's name. 3341 + @param set_id The ID of the stopwords set to delete. 3342 + *) 3343 + val delete_stopwords_set : set_id:string -> t -> unit -> Jsont.json 3344 + end 3345 + 3346 + module Apistats : sig 3347 + module Response : sig 3348 + type t 3349 + 3350 + (** Construct a value *) 3351 + 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 3352 + 3353 + val delete_latency_ms : t -> float option 3354 + 3355 + val delete_requests_per_second : t -> float option 3356 + 3357 + val import_latency_ms : t -> float option 3358 + 3359 + val import_requests_per_second : t -> float option 3360 + 3361 + val latency_ms : t -> Jsont.json option 3362 + 3363 + val overloaded_requests_per_second : t -> float option 3364 + 3365 + val pending_write_batches : t -> float option 3366 + 3367 + val requests_per_second : t -> Jsont.json option 3368 + 3369 + val search_latency_ms : t -> float option 3370 + 3371 + val search_requests_per_second : t -> float option 3372 + 3373 + val total_requests_per_second : t -> float option 3374 + 3375 + val write_latency_ms : t -> float option 3376 + 3377 + val write_requests_per_second : t -> float option 3378 + 3379 + val jsont : t Jsont.t 3380 + end 3381 + 3382 + (** Get stats about API endpoints. 3383 + 3384 + Retrieve the stats about API endpoints. *) 3385 + val retrieve_apistats : t -> unit -> Response.t 3386 + end 3387 + 3388 + module ApiKeySchema : sig 3389 + module T : sig 3390 + type t 3391 + 3392 + (** Construct a value *) 3393 + val v : actions:string list -> collections:string list -> description:string -> ?expires_at:int64 -> ?value:string -> unit -> t 3394 + 3395 + val actions : t -> string list 3396 + 3397 + val collections : t -> string list 3398 + 3399 + val description : t -> string 3400 + 3401 + val expires_at : t -> int64 option 3402 + 3403 + val value : t -> string option 3404 + 3405 + val jsont : t Jsont.t 3406 + end 3407 + end 3408 + 3409 + module ApiKey : sig 3410 + module T : sig 3411 + type t 3412 + 3413 + (** Construct a value *) 3414 + val v : actions:string list -> collections:string list -> description:string -> ?expires_at:int64 -> ?value:string -> ?id:int64 -> ?value_prefix:string -> unit -> t 3415 + 3416 + val actions : t -> string list 3417 + 3418 + val collections : t -> string list 3419 + 3420 + val description : t -> string 3421 + 3422 + val expires_at : t -> int64 option 3423 + 3424 + val value : t -> string option 3425 + 3426 + val id : t -> int64 option 3427 + 3428 + val value_prefix : t -> string option 3429 + 3430 + val jsont : t Jsont.t 3431 + end 3432 + 3433 + (** Create an API Key 3434 + 3435 + 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. *) 3436 + val create_key : body:ApiKeySchema.T.t -> t -> unit -> T.t 3437 + 3438 + (** Retrieve (metadata about) a key 3439 + 3440 + 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. 3441 + @param key_id The ID of the key to retrieve 3442 + *) 3443 + val get_key : key_id:string -> t -> unit -> T.t 3444 + end 3445 + 3446 + module ApiKeys : sig 3447 + module Response : sig 3448 + type t 3449 + 3450 + (** Construct a value *) 3451 + val v : keys:ApiKey.T.t list -> unit -> t 3452 + 3453 + val keys : t -> ApiKey.T.t list 3454 + 3455 + val jsont : t Jsont.t 3456 + end 3457 + 3458 + (** Retrieve (metadata about) all keys. *) 3459 + val get_keys : t -> unit -> Response.t 3460 + end 3461 + 3462 + module ApiKeyDelete : sig 3463 + module Response : sig 3464 + type t 3465 + 3466 + (** Construct a value 3467 + @param id The id of the API key that was deleted 3468 + *) 3469 + val v : id:int64 -> unit -> t 3470 + 3471 + (** The id of the API key that was deleted *) 3472 + val id : t -> int64 3473 + 3474 + val jsont : t Jsont.t 3475 + end 3476 + 3477 + (** Delete an API key given its ID. 3478 + @param key_id The ID of the key to delete 3479 + *) 3480 + val delete_key : key_id:string -> t -> unit -> Response.t 3481 + end 3482 + 3483 + module Api : sig 3484 + module Response : sig 3485 + type t 3486 + 3487 + (** Construct a value *) 3488 + val v : message:string -> unit -> t 3489 + 3490 + val message : t -> string 3491 + 3492 + val jsont : t Jsont.t 3493 + end 3494 + end 3495 + 3496 + module AnalyticsRule : sig 3497 + module Update : sig 3498 + (** Fields allowed to update on an analytics rule *) 3499 + type t 3500 + 3501 + (** Construct a value *) 3502 + val v : ?name:string -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t 3503 + 3504 + val name : t -> string option 3505 + 3506 + val params : t -> Jsont.json option 3507 + 3508 + val rule_tag : t -> string option 3509 + 3510 + val jsont : t Jsont.t 3511 + end 3512 + 3513 + module Type : sig 3514 + type t = [ 3515 + | `Popular_queries 3516 + | `Nohits_queries 3517 + | `Counter 3518 + | `Log 3519 + ] 3520 + 3521 + val jsont : t Jsont.t 3522 + end 3523 + 3524 + module Create : sig 3525 + type t 3526 + 3527 + (** Construct a value *) 3528 + val v : collection:string -> event_type:string -> name:string -> type_:Type.t -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t 3529 + 3530 + val collection : t -> string 3531 + 3532 + val event_type : t -> string 3533 + 3534 + val name : t -> string 3535 + 3536 + val params : t -> Jsont.json option 3537 + 3538 + val rule_tag : t -> string option 3539 + 3540 + val type_ : t -> Type.t 3541 + 3542 + val jsont : t Jsont.t 3543 + end 3544 + 3545 + module T : sig 3546 + type t 3547 + 3548 + (** Construct a value *) 3549 + val v : collection:string -> event_type:string -> name:string -> type_:Type.t -> ?params:Jsont.json -> ?rule_tag:string -> unit -> t 3550 + 3551 + val collection : t -> string 3552 + 3553 + val event_type : t -> string 3554 + 3555 + val name : t -> string 3556 + 3557 + val params : t -> Jsont.json option 3558 + 3559 + val rule_tag : t -> string option 3560 + 3561 + val type_ : t -> Type.t 3562 + 3563 + val jsont : t Jsont.t 3564 + end 3565 + 3566 + (** Retrieve analytics rules 3567 + 3568 + Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. 3569 + @param rule_tag Filter rules by rule_tag 3570 + *) 3571 + val retrieve_analytics_rules : ?rule_tag:string -> t -> unit -> T.t 3572 + 3573 + (** Retrieves an analytics rule 3574 + 3575 + Retrieve the details of an analytics rule, given it's name 3576 + @param rule_name The name of the analytics rule to retrieve 3577 + *) 3578 + val retrieve_analytics_rule : rule_name:string -> t -> unit -> T.t 3579 + 3580 + (** Upserts an analytics rule 3581 + 3582 + Upserts an analytics rule with the given name. 3583 + @param rule_name The name of the analytics rule to upsert 3584 + *) 3585 + val upsert_analytics_rule : rule_name:string -> body:Update.t -> t -> unit -> T.t 3586 + 3587 + (** Delete an analytics rule 3588 + 3589 + Permanently deletes an analytics rule, given it's name 3590 + @param rule_name The name of the analytics rule to delete 3591 + *) 3592 + val delete_analytics_rule : rule_name:string -> t -> unit -> T.t 3593 + end 3594 + 3595 + module AnalyticsEvents : sig 3596 + module Response : sig 3597 + type t 3598 + 3599 + (** Construct a value *) 3600 + val v : events:Jsont.json list -> unit -> t 3601 + 3602 + val events : t -> Jsont.json list 3603 + 3604 + val jsont : t Jsont.t 3605 + end 3606 + 3607 + (** Retrieve analytics events 3608 + 3609 + Retrieve the most recent events for a user and rule. 3610 + @param name Analytics rule name 3611 + @param n Number of events to return (max 1000) 3612 + *) 3613 + val get_analytics_events : user_id:string -> name:string -> n:string -> t -> unit -> Response.t 3614 + end 3615 + 3616 + module AnalyticsEvent : sig 3617 + module T : sig 3618 + type t 3619 + 3620 + (** Construct a value 3621 + @param data Event payload 3622 + @param event_type Type of event (e.g., click, conversion, query, visit) 3623 + @param name Name of the analytics rule this event corresponds to 3624 + *) 3625 + val v : data:Jsont.json -> event_type:string -> name:string -> unit -> t 3626 + 3627 + (** Event payload *) 3628 + val data : t -> Jsont.json 3629 + 3630 + (** Type of event (e.g., click, conversion, query, visit) *) 3631 + val event_type : t -> string 3632 + 3633 + (** Name of the analytics rule this event corresponds to *) 3634 + val name : t -> string 3635 + 3636 + val jsont : t Jsont.t 3637 + end 3638 + end 3639 + 3640 + module AnalyticsEventCreate : sig 3641 + module Response : sig 3642 + type t 3643 + 3644 + (** Construct a value *) 3645 + val v : ok:bool -> unit -> t 3646 + 3647 + val ok : t -> bool 3648 + 3649 + val jsont : t Jsont.t 3650 + end 3651 + 3652 + (** Create an analytics event 3653 + 3654 + Submit a single analytics event. The event must correspond to an existing analytics rule by name. *) 3655 + val create_analytics_event : body:AnalyticsEvent.T.t -> t -> unit -> Response.t 3656 + 3657 + (** Flush in-memory analytics to disk 3658 + 3659 + Triggers a flush of analytics data to persistent storage. *) 3660 + val flush_analytics : t -> unit -> Response.t 3661 + end 3662 + 3663 + module Analytics : sig 3664 + module Status : sig 3665 + type t 3666 + 3667 + (** Construct a value *) 3668 + 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 3669 + 3670 + val doc_counter_events : t -> int option 3671 + 3672 + val doc_log_events : t -> int option 3673 + 3674 + val log_prefix_queries : t -> int option 3675 + 3676 + val nohits_prefix_queries : t -> int option 3677 + 3678 + val popular_prefix_queries : t -> int option 3679 + 3680 + val query_counter_events : t -> int option 3681 + 3682 + val query_log_events : t -> int option 3683 + 3684 + val jsont : t Jsont.t 3685 + end 3686 + 3687 + (** Get analytics subsystem status 3688 + 3689 + Returns sizes of internal analytics buffers and queues. *) 3690 + val get_analytics_status : t -> unit -> Status.t 3691 + end
+6
typesense.opam
··· 11 11 depends: [ 12 12 "dune" {>= "3.20"} 13 13 "ocaml" {>= "5.1.0"} 14 + "openapi" {>= "0.4.0"} 14 15 "eio" {>= "1.2"} 16 + "eio_main" {>= "1.2"} 15 17 "requests" {>= "0.3.1"} 16 18 "uri" {>= "4.4.0"} 17 19 "jsont" {>= "0.2.0"} 18 20 "bytesrw" 21 + "ptime" {>= "1.0.0"} 22 + "ptime-clock-os" 23 + "cmdliner" {>= "1.3.0"} 24 + "fmt" {>= "0.9.0"} 19 25 "logs" {>= "0.7.0"} 20 26 "odoc" {with-doc} 21 27 "alcotest" {with-test}