class Meilisearch::Crystal::Client

Overview

Manages a connection to a Meilisearch server and provides the typed request plumbing shared by all resource classes.

Defined in:

meilisearch/crystal/client.cr

Constant Summary

DEFAULT_TIMEOUT = 5.seconds
DEFAULT_URL = "http://localhost:7700"
ENV_API_KEY = "MEILISEARCH_API_KEY"
ENV_URL = "MEILISEARCH_URL"

Environment variables consulted when Client.new is called without explicit arguments.

USER_AGENT = "meilisearch-crystal/#{VERSION}"

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(url : String | URI | Nil = nil, api_key : String | Nil = nil, timeout : Time::Span | Nil = nil) #

Builds a client against #url with optional #api_key and #timeout.

When #url/#api_key are omitted, environment variables (MEILISEARCH_URL, MEILISEARCH_API_KEY) are consulted; #timeout defaults to 5 seconds.


[View source]

Class Method Detail

def self.resolve_url(url : String | URI) : URI #

[View source]

Instance Method Detail

def api_key : String | Nil #

[View source]
def batches : Batches #

[View source]
def build_http_client : HTTP::Client #

Builds an HTTP::Client bound to this client's URL, with authentication, accept, and user-agent headers injected.


[View source]
def close : Nil #

Closes the underlying persistent HTTP connection.


[View source]
def create_dump : TaskResult #

[View source]
def create_snapshot : TaskResult #

[View source]
def delete(path : String, query : HTTP::Params | Nil = nil) : HTTP::Client::Response #

[View source]
def experimental_features : ExperimentalFeaturesAPI #

[View source]
def generate_tenant_token(api_key_uid : String, search_rules, expires_at : Time | Nil = nil, api_key : String | Nil = @api_key) : String #

[View source]
def get(path : String, query : HTTP::Params | Nil = nil) : HTTP::Client::Response #

[View source]
def health : Health #

[View source]
def http : HTTP::Client #

[View source]
def index(uid : String) : IndexClient #

Handle for index-scoped operations (search, documents, settings, ...). The returned IndexClient binds uid to this client.


[View source]
def indexes : Indexes #

Index lifecycle operations and typed metadata access.


[View source]
def keys : Keys #

[View source]
def network : Network #

[View source]
def patch(path : String, body : String = "", headers : HTTP::Headers | Nil = nil) : HTTP::Client::Response #

[View source]
def post(path : String, body : HTTP::Client::BodyType = nil, headers : HTTP::Headers | Nil = nil) : HTTP::Client::Response #

[View source]
def put(path : String, body : HTTP::Client::BodyType = nil, headers : HTTP::Headers | Nil = nil) : HTTP::Client::Response #

[View source]
def search : Search #

Search, facet, similar-document, and multi-index operations.


[View source]
def settings : SettingsAPI #

Index settings operations.


[View source]
def stats : Stats #

[View source]
def tasks : Tasks #

Task lookup and listing operations.


[View source]
def timeout : Time::Span #

[View source]
def url : URI #

[View source]
def version : Version #

[View source]
def wait_for_task(uid : Int32 | Int64, timeout : Time::Span | Nil = nil, poll_interval : Time::Span = 100.milliseconds) : BasicTask #

Fetches a task by uid, polling until it reaches a terminal status (succeeded / failed / canceled). Raises TimeoutError when the task does not complete within the client's timeout.

task = client.wait_for_task(task_uid, poll_interval: 50.milliseconds)

[View source]
def wait_for_task(task : BasicTask, timeout : Time::Span | Nil = nil, poll_interval : Time::Span = 100.milliseconds) : BasicTask #

[View source]
def wait_for_task(task : TaskResult, timeout : Time::Span | Nil = nil, poll_interval : Time::Span = 100.milliseconds) : BasicTask #

[View source]