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
outmust be null, or a live handle returned bykjarni_searcher_newthat has not been freed.
kjarni_searcher_free
void kjarni_searcher_free(struct KjarniSearcher *searcher);
Safety
searchermust be null, or a handle returned bykjarni_searcher_newthat has not already been passed to this function. It is invalid to use afterwards.
kjarni_searcher_search
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
searchermust be null, or a live handle returned bykjarni_searcher_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.querymust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to aKjarniSearchResults. OnKJARNI_OKit 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.querymust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to aKjarniSearchResults. OnKJARNI_OKit 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_pathmust be null, or a valid pointer to a nul-terminated C string.querymust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to aKjarniSearchResults. OnKJARNI_OKit 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat has not been freed.bufmust be null, or point to at leastbuf_lenwritable 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
searchermust be null, or a live handle returned bykjarni_searcher_newthat has not been freed.bufmust be null, or point to at leastbuf_lenwritable bytes. When it is null the required size is returned and nothing is written.
Kjarni runs the same engine on every platform: