C API reference · Kjarni 0.2.8

searcher

kjarni_search_results_free

void kjarni_search_results_free(struct KjarniSearchResults results);

Safety Must only be called once per KjarniSearchResults returned from search functions.

kjarni_search_options_default

struct KjarniSearchOptions kjarni_search_options_default(void);

kjarni_searcher_config_default

struct KjarniSearcherConfig kjarni_searcher_config_default(void);

kjarni_searcher_new

enum KjarniErrorCode kjarni_searcher_new(const struct KjarniSearcherConfig *config, struct KjarniSearcher **out);
  • The returned handle must be freed with kjarni_searcher_free

Safety

  • out must be null, or a live handle returned by kjarni_searcher_new that has not been freed.

kjarni_searcher_free

void kjarni_searcher_free(struct KjarniSearcher *searcher);

Safety

  • searcher must be null, or a handle returned by kjarni_searcher_new that has not already been passed to this function. It is invalid to use afterwards.
enum KjarniErrorCode kjarni_searcher_search(struct KjarniSearcher *searcher, const char *index_path, const char *query, struct KjarniSearchResults *out);

All pointers must be valid. Results must be freed with kjarni_search_results_free.

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • query must be null, or a valid pointer to a nul-terminated C string.
  • out must be a valid, writable pointer to a KjarniSearchResults. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_searcher_search_with_options

enum KjarniErrorCode kjarni_searcher_search_with_options(struct KjarniSearcher *searcher, const char *index_path, const char *query, const struct KjarniSearchOptions *options, struct KjarniSearchResults *out);

All pointers must be valid. Results must be freed with kjarni_search_results_free.

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.
  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • query must be null, or a valid pointer to a nul-terminated C string.
  • out must be a valid, writable pointer to a KjarniSearchResults. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_search_keywords

enum KjarniErrorCode kjarni_search_keywords(const char *index_path, const char *query, uintptr_t top_k, struct KjarniSearchResults *out);

All pointers must be valid. Results must be freed with kjarni_search_results_free.

Safety

  • index_path must be null, or a valid pointer to a nul-terminated C string.
  • query must be null, or a valid pointer to a nul-terminated C string.
  • out must be a valid, writable pointer to a KjarniSearchResults. On KJARNI_OK it receives a value the caller owns and must release with the matching *_free; on failure it is either cleared or left unmodified, and must not be read.

kjarni_searcher_has_reranker

bool kjarni_searcher_has_reranker(const struct KjarniSearcher *searcher);

searcher must be a valid handle or null.

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.

kjarni_searcher_default_mode

enum KjarniSearchMode kjarni_searcher_default_mode(const struct KjarniSearcher *searcher);

searcher must be a valid handle or null.

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.

kjarni_searcher_default_top_k

uintptr_t kjarni_searcher_default_top_k(const struct KjarniSearcher *searcher);

searcher must be a valid handle or null.

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.

kjarni_searcher_model_name

uintptr_t kjarni_searcher_model_name(const struct KjarniSearcher *searcher, char *buf, uintptr_t buf_len);

Get searcher model name into caller-provided buffer

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.
  • buf must be null, or point to at least buf_len writable bytes. When it is null the required size is returned and nothing is written.

kjarni_searcher_reranker_model

uintptr_t kjarni_searcher_reranker_model(const struct KjarniSearcher *searcher, char *buf, uintptr_t buf_len);

Get reranker model name into caller-provided buffer

Safety

  • searcher must be null, or a live handle returned by kjarni_searcher_new that has not been freed.
  • buf must be null, or point to at least buf_len writable bytes. When it is null the required size is returned and nothing is written.

Kjarni runs the same engine on every platform: