Queries and results

group Queries

Build, inspect, and execute vector, scalar, and take queries.

Enums

enum LanceDBFtsOperator

Term combination operator for lancedb_fts_query_new_match() and lancedb_fts_query_new_multi_match().

LANCEDB_FTS_OPERATOR_OR matches documents containing any query term and is the SDK default. LANCEDB_FTS_OPERATOR_AND requires every term.

Values:

enumerator LANCEDB_FTS_OPERATOR_OR
enumerator LANCEDB_FTS_OPERATOR_AND
enum LanceDBFtsOccur

Occurrence of one clause in lancedb_fts_query_new_boolean().

LANCEDB_FTS_OCCUR_MUST clauses must all match and their scores are summed. LANCEDB_FTS_OCCUR_SHOULD clauses are optional when at least one MUST clause exists and add their score when they match; without MUST clauses, at least one SHOULD clause must match and the matching SHOULD scores are summed. LANCEDB_FTS_OCCUR_MUST_NOT clauses exclude matching documents and never contribute to the score.

Values:

enumerator LANCEDB_FTS_OCCUR_SHOULD
enumerator LANCEDB_FTS_OCCUR_MUST
enumerator LANCEDB_FTS_OCCUR_MUST_NOT

Functions

LanceDBQuery *lancedb_query_new(const LanceDBTable *table)

Create a new query for the given table.

Parameters:

table – - pointer to LanceDBTable

Returns:

Pointer to LanceDBQuery on success, NULL on failure Caller must free with lancedb_query_free()

LanceDBVectorQuery *lancedb_vector_query_new(const LanceDBTable *table, const float *vector, size_t dimension)

Create a vector query from table with query vector.

Parameters:
  • table – - pointer to LanceDBTable

  • vector – - array of floats representing the query vector

  • dimension – - dimension of the vector

Returns:

Pointer to LanceDBVectorQuery on success, NULL on failure Caller must free with lancedb_vector_query_free()

LanceDBVectorQuery *lancedb_vector_query_new_typed(const LanceDBTable *table, const LanceDBQueryVector *vectors, size_t num_vectors)

Create a vector query from one or more typed query vectors.

vectors is borrowed for this call and every input is copied before the function returns. The first vector becomes the nearest-neighbour query and each later vector is added as an SDK batch query vector. num_vectors must be at least one.

F16, F32 and F64 inputs are passed to the SDK in their declared element type; the SDK converts F16 and F64 components to Float32 before planning. The binary form widens each byte to its numeric Float32 value, so a FixedSizeList<UInt8> column is cast back to UInt8 at planning time. Lance supports only LANCEDB_DISTANCE_HAMMING for such a column. No additional precision is preserved for F64 input.

Against a fixed-size-list float vector column, multiple vectors produce one top-K result set per vector and the result adds an Int32 query_index column. Against a List<FixedSizeList<…>> multivector column, multiple vectors form one multivector search and no query_index column is added. A UInt8 fixed-size vector column keeps one plan per vector and also adds query_index; Hamming is the only supported distance.

These batch contracts apply to an ordinary vector search, without a full-text query. limit and offset apply independently to each vector in a batch, and query_index is the zero-based position of that vector, not a rank. Rows for different indexes are not required to be grouped or ordered. On a multivector column, limit selects table rows in total and each row’s _distance includes the contribution of every input vector.

The SDK cannot merge a hybrid query whose vector leg returns batch results with query_index and whose full-text leg returns matches: the SDK’s RRF merge combines the batch query_index column with the full-text schema and returns an Arrow schema error. This includes multiple vectors on a fixed-size-list float column and the per-vector UInt8/Hamming path. This binding forwards the configured SDK query; it does not split the batch, drop query_index, or run a C-side fusion. Use one query vector for that hybrid shape until the SDK supports it. A List<FixedSizeList<…>> multivector column adds no query_index, so it does not hit that merge shape.

A vector-only query is planned locally by the native table, including on a native namespace connection. On a namespace connection with QueryTable pushdown, only an eligible hybrid full-text leg can use the namespace QueryTable path; the vector batch remains a locally planned query. This binding does not choose a different route.

For a remote LanceDB, the SDK sends Float32 vectors. Enterprise server 0.2.0 and later receive all input vectors in one request; older servers receive one request per vector and the SDK combines the responses with query_index. The server decides how it interprets the vector shape and distance and which schema it returns; this binding does not reshape or re-issue the result.

A table routed through the pinned MemWAL LSM scanner rejects a single plan containing multiple query vectors, UInt8 vector search, or both vector and full-text search with LANCEDB_NOT_SUPPORTED. Hybrid execution does not build such a plan: it runs separate vector and full-text searches, and can fall back to primary-key fusion when the table rejects _rowid. An eligible single-vector hybrid query can therefore execute. This binding exposes no route override.

This constructor only copies and checks the description. Like lancedb_vector_query_new(), the SDK reports non-finite values, F64 values that become non-finite after conversion, and mismatched dimensions when the query is executed or its plan or output schema is requested.

Parameters:
  • table – - pointer to LanceDBTable

  • vectors – - borrowed array of num_vectors typed vectors

  • num_vectors – - number of entries; must be at least 1

Returns:

Pointer to LanceDBVectorQuery on success, NULL when an argument is missing, a kind is outside LanceDBQueryVectorType, or a vector has NULL data or zero dimension. Caller must free with lancedb_vector_query_free()

LanceDBError lancedb_vector_query_add_query_vector(LanceDBVectorQuery *query, const LanceDBQueryVector *vector, char **error_message)

Add a typed query vector to a vector query.

The vector is borrowed for this call and copied before it returns. On success it is appended to the SDK query as a batch query vector, with the same result schema and validation timing as lancedb_vector_query_new_typed(). The builder may come from either constructor. Appending a second or later vector makes the query use the batch shape described there, including its ordinary-vector top-K/query_index contract and its hybrid and MemWAL limitations.

A missing query or vector, NULL data, zero dimension, or a kind outside LanceDBQueryVectorType returns LANCEDB_INVALID_ARGUMENT without changing the builder, so it still executes with the vectors it already had.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • vector – - borrowed typed vector

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_limit(LanceDBQuery *query, size_t limit, char **error_message)

Set limit for query.

This limits the final query result. It is independent of a structured full-text query’s candidate ceiling, which is set with lancedb_fts_query_limit().

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • limit – - maximum number of results

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_offset(LanceDBQuery *query, size_t offset, char **error_message)

Set offset for query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • offset – - number of results to skip

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_select(LanceDBQuery *query, const char *const *columns, size_t num_columns, char **error_message)

Set columns to select for query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • columns – - array of column name strings

  • num_columns – - number of columns

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_select_all(LanceDBQuery *query, char **error_message)

Reset a plain query to every non-system column.

This clears a projection set by lancedb_query_select() or lancedb_query_select_dynamic(). The most recent projection call wins. lancedb_query_with_row_id() still appends the _rowid metadata column.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_select_dynamic(LanceDBQuery *query, const char *const *names, const char *const *expressions, size_t num_columns, char **error_message)

Set an expression-based column projection for query.

Each pair adds one output column: names[i] is the output name and expressions[i] is an SQL expression over the table columns. Columns are returned in the given order, which may differ from the table order. The names and expressions are copied; the arrays may be released after the call.

A zero num_columns selects no columns. Both arrays must still be non-NULL. Calling this function replaces a projection from lancedb_query_select() or lancedb_query_select_all(), and a later call to either of those replaces this projection.

The SDK evaluates the expressions and decides whether a backend supports dynamic projection. An unsupported backend’s SDK error is returned unchanged.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • names – - array of num_columns output column names

  • expressions – - array of num_columns SQL expressions

  • num_columns – - number of entries in each array

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_order_by(LanceDBQuery *query, const LanceDBColumnOrdering *orderings, size_t num_orderings, char **error_message)

Set the column ordering for query.

The first entry is the primary sort key. A nonempty ordering sorts an ordinary scan before limit and offset are applied. On a standalone full-text search it sorts all matches before the search page is selected. Execution, EXPLAIN, output-schema inspection and ANALYZE use the same configured ordering.

A zero num_orderings clears the ordering, restoring the query’s default order; orderings may be NULL in that case. A positive count requires a non-NULL array whose entries and column names are non-NULL, NUL-terminated UTF-8 strings. Invalid input returns LANCEDB_INVALID_ARGUMENT and leaves the previous ordering unchanged. The array and its strings are borrowed for the duration of the call and are copied into the query.

A native namespace connection with QueryTable pushdown executes a nonempty ordering locally, so it needs client access to table storage. A table routed through the MemWAL LSM scanner rejects a nonempty ordering with LANCEDB_NOT_SUPPORTED; clear the ordering to return to the default route. A remote LanceDB forwards the ordering to the server.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • orderings – - array of column orderings, or NULL when num_orderings is 0

  • num_orderings – - number of entries in orderings; 0 clears the ordering

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_scan_in_order(LanceDBQuery *query, bool ordered, char **error_message)

Set whether an ordinary scan must follow storage order.

With true, an embedded scan reads fragments and rows in manifest order for the version being scanned. It disables scalar index filtering, so filters can read more data and fast_search no longer skips unindexed rows. The order can change across dataset versions. False permits unordered scanning and lets an explicit sort or full-text ranking apply. Omitting this setter preserves the backend default.

For Embedded queries, a nonempty order_by or full-text search conflicts with true and returns LANCEDB_INVALID_INPUT during execution or inspection. Enterprise tables and queries routed through the MemWAL LSM scanner reject true with LANCEDB_NOT_SUPPORTED. Native namespace tables with QueryTable pushdown execute the ordered scan locally and need access to table storage.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • ordered – - true to require storage order, false to permit unordered scanning

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_with_row_id(LanceDBQuery *query, char **error_message)

Ask a plain query to return the _rowid metadata column.

This applies to ordinary scans and standalone full-text searches built with lancedb_query_full_text_search(). The UInt64 metadata column is appended to the projection, even when lancedb_query_select() names specific columns.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_fast_search(LanceDBQuery *query, char **error_message)

Restrict a plain query to data covered by an index.

For an ordinary scan this applies only when the filter plan uses a scalar index. An unfiltered scan, or a filter without an index, still reads every selected fragment. A standalone full-text search reads only rows covered by the text index. Rows appended after the index was built can therefore be absent. A filter that cannot use an index is not an error.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_where_filter(LanceDBQuery *query, const char *filter, char **error_message)

Set WHERE filter for query.

If both a SQL WHERE clause and a DataFusion filters are set, the DataFusion expression takes precedence.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • filter – - SQL WHERE clause string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_full_text_search(LanceDBQuery *query, const char *text, const char *column, char **error_message)

Set full-text search for query.

LanceDB applies the filter and projection in the same query and adds its score column. If no limit is set, LanceDB’s default top-K applies.

If column is NULL or empty, LanceDB discovers the text columns itself and searches every column that has a full-text index. An explicit column selects that text column; embedded LanceDB can also scan it without an index, while an index is recommended for larger tables.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • text – - full-text query string

  • column – - text column name, or NULL/empty for automatic discovery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_new_match(const char *text, const char *column, const LanceDBFtsMatchOptions *options, LanceDBFtsQuery **query_out, char **error_message)

Create a structured Match full-text query.

The text is tokenized by the target index at execution time, and empty text is passed through unchanged. options == NULL uses the SDK’s MatchQuery defaults, which are also returned by lancedb_fts_match_options_default(). The constructor copies text and column, so the caller may change or free them after this call returns. A NULL or empty column leaves the choice to the index.

fuzziness uses -1 for the SDK’s automatic mode and 0 through UINT32_MAX for an explicit edit distance. The pinned embedded and MemWAL paths currently resolve automatic fuzziness to exact matching. boost, max_expansions and prefix_length are forwarded to the SDK without additional validation; boost is checked when the query is planned.

A successfully constructed query can still be limited by the selected backend. A namespace QueryTable pushdown sends a root OR Match as text and column only, so its fuzziness, boost, max_expansions, prefix_length and OR operator are not transmitted; a root AND Match keeps the structured node. The namespace model stores fuzziness, max_expansions and prefix_length as signed 32-bit values. Values above INT32_MAX still construct, but an AND pushdown fails during execution with LANCEDB_INVALID_INPUT. This also applies to a pushed-down hybrid query’s full-text branch.

A MemWAL LSM query requires an explicit single text column; automatic discovery through a NULL or empty column does not satisfy this requirement. The write spec must maintain that column’s FTS index, and every resident MemTable must carry it. Otherwise the query fails with LANCEDB_NOT_SUPPORTED rather than silently omitting un-compacted documents.

LanceDB Enterprise servers 0.3.0 and later accept the structured query. Older Enterprise servers receive only text and column, so those options are not transmitted, and a root AND Match returns LANCEDB_NOT_SUPPORTED.

On entry *query_out and the error message are cleared. On success *query_out owns a handle that the caller frees with lancedb_fts_query_free(). On failure *query_out stays NULL and the error is LANCEDB_INVALID_ARGUMENT for a missing text or output pointer, invalid UTF-8, an operator outside LanceDBFtsOperator, or a fuzziness outside -1 through UINT32_MAX.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • text – - Match text, a valid null-terminated UTF-8 string

  • column – - text column name, or NULL/empty for automatic discovery

  • options – - Match options, or NULL for the SDK defaults

  • query_out – - pointer to receive the structured full-text query

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBFtsMatchOptions lancedb_fts_match_options_default(void)

Return the default structured Match query options.

The values are read from the SDK’s MatchQuery constructor: OR term combination, boost 1.0, exact matching (fuzziness 0), 50 maximum expansions, and prefix length 0. The returned struct is a value; no free function is needed.

Returns:

Default options for lancedb_fts_query_new_match()

LanceDBError lancedb_fts_query_new_multi_match(const char *text, const char *const *columns, size_t num_columns, const LanceDBFtsMultiMatchOptions *options, LanceDBFtsQuery **query_out, char **error_message)

Create a structured MultiMatch full-text query.

One Match leaf is created for every column, in the order given, and all leaves share the text and the operator. The constructor copies text, the column name array and any boosts, so the caller may change or free them after this call returns. columns may be NULL only when num_columns is 0; an empty column list is rejected by the SDK constructor with LANCEDB_INVALID_INPUT. A NULL options pointer uses the SDK defaults: no per-column boosts and OR term combination, which are also returned by lancedb_fts_multi_match_options_default().

Every row is scored independently by each leaf and returned once with the highest leaf score (best fields), so a row matching several columns is not duplicated. A per-column boost multiplies that leaf’s score, and the shared operator applies to every leaf. The SDK defaults for fuzziness (exact), max_expansions (50) and prefix_length (0) apply to every leaf; each leaf has its own max_expansions budget.

Embedded LanceDB rejects a MultiMatch that resolves to ListElement documents, including a single-column or nested MultiMatch. Lance reports the rejection as its internal Error::NotSupported; the pinned SDK wraps that variant as Error::Lance, so the C status is LANCEDB_LANCE with the “MultiMatch does not

support ListElement document granularity” diagnostic, not LANCEDB_NOT_SUPPORTED. That is an embedded dataset-scanner check and is separate from the MemWAL routing limits below.

The constructor validates representation only and leaves semantics to the SDK. A nonzero boost count that differs from the column count fails here with LANCEDB_INVALID_INPUT. Boost values are not checked here: the embedded dataset scanner requires each to be finite and non-negative when it plans the query and otherwise fails with LANCEDB_INVALID_INPUT.

A namespace QueryTable pushdown sends MultiMatch as a structured node rather than as text, because only a root OR Match uses the string form. The namespace multi_match model carries the ordered match_queries leaves with their per-leaf boost and operator, so those settings survive the pushdown. The namespace Match model stores fuzziness, max_expansions and prefix_length as signed 32-bit values; this constructor leaves them at the SDK defaults, so it cannot exceed those ranges. A non-finite boost becomes JSON null in the intermediate value and then an unset optional in the namespace model, so the REST request omits it and the server applies its default instead of failing locally. A finite negative boost is forwarded unchanged; the server determines whether to accept it.

LanceDB Enterprise servers 0.3.0 and later receive the structured node with every leaf, so ordered columns, per-column boosts and the shared operator are preserved. A non-finite boost stays an explicit JSON null in that request; the client does not reject it and the server determines the outcome. Older Enterprise servers reject AND only for a root Match or MultiMatch, including a hybrid query’s full-text leg, with LANCEDB_NOT_SUPPORTED. A MultiMatch nested under Boolean or Boost is not inspected by that check; it follows the parent’s legacy text projection, which can lose the AND constraint. For example, a Boost whose positive leg is an AND MultiMatch sends the positive leg’s shared text over the union of the columns, so the server can treat it as OR. With a root OR MultiMatch, an older server receives the shared text and the union of the columns; every per-column boost is dropped, and the client does not guarantee the resulting membership or ranking. The server determines the result from that projection.

A MemWAL LSM full-text query first checks the table’s unenforced primary key, and a table without one fails with LANCEDB_INVALID_INPUT before FTS planning. The pinned SDK then requires the whole full-text tree to name exactly one explicit column, and that column’s FTS index must be maintained by the write spec and carried by every resident MemTable; otherwise the query fails with LANCEDB_NOT_SUPPORTED. A MultiMatch spanning several columns fails that check even when the table has a primary key, before Lance’s lower-level cross-column path is reached. The same single-column check applies to a hybrid query’s full-text leg. Every leaf keeps its own max_expansions budget.

On entry *query_out and the error message are cleared. On success *query_out owns a handle that the caller frees with lancedb_fts_query_free(). On failure *query_out stays NULL. A missing text, output, or columns pointer with a nonzero count, a NULL column entry, invalid UTF-8, a NULL boost array with a nonzero count, or an operator outside LanceDBFtsOperator returns LANCEDB_INVALID_ARGUMENT. An empty column list or a nonzero boost count that differs from the column count returns LANCEDB_INVALID_INPUT from the SDK.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • text – - text matched against every column, a valid null-terminated UTF-8 string

  • columns – - ordered array of column names, or NULL when num_columns is 0

  • num_columns – - number of column names

  • options – - MultiMatch options, or NULL for the SDK defaults

  • query_out – - pointer to receive the structured full-text query

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBFtsMultiMatchOptions lancedb_fts_multi_match_options_default(void)

Return the default structured MultiMatch query options.

The SDK default is OR term combination for every leaf and no per-column boost, so every leaf uses the MatchQuery defaults. The returned struct is a value; no free function is needed.

Returns:

Default options for lancedb_fts_query_new_multi_match()

LanceDBError lancedb_fts_query_new_phrase(const char *text, const char *column, uint32_t slop, LanceDBFtsQuery **query_out, char **error_message)

Create a structured phrase full-text query.

The phrase text is tokenized by the target index at execution time. slop = 0 requires adjacent tokens in order; a positive slop allows up to that many intervening tokens, so slop = 1 matches both alpha beta and alpha gap beta for the phrase alpha beta.

If column is NULL or empty, the SDK chooses an indexed text column. An explicit column can be scanned without an index by embedded LanceDB; an indexed phrase query requires positions in the index.

The constructor copies text and column, so the caller may change or free them after this call returns. The returned handle owns an SDK query. Attach it with lancedb_query_full_text_search_query() or lancedb_vector_query_full_text_search_query(); each setter clones it, so the same handle can be used for several builders and freed once those calls return.

The SDK selects embedded, namespace, or Enterprise execution from the connection. Embedded LanceDB can scan an explicitly named column without an index; an indexed phrase query requires a full-text index with stored positions. Create it with lancedb_table_create_index() and fts_with_position = 1; an index without positions makes an indexed phrase query fail with the SDK’s missing-position error. A namespace connection forwards the structured node only when QueryTable pushdown is enabled and selected with LANCEDB_NAMESPACE_PUSHDOWN_QUERY_TABLE. LanceDB Enterprise servers 0.3.0 and later accept the structured node. Older Enterprise servers receive only the column and the phrase text quoted as one string, so a nonzero slop is not transmitted.

The pinned Lance indexed path converts slop to signed 32-bit. Values from 0 through INT32_MAX keep their indexed meaning; larger uint32_t values are forwarded unchanged by this API but can return no matches because of that internal conversion. This function does not clamp or reject them.

On entry *query_out and the error message are cleared. On success *query_out owns a handle that the caller frees with lancedb_fts_query_free(). On failure *query_out stays NULL and the error is LANCEDB_INVALID_ARGUMENT for NULL text or invalid UTF-8.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • text – - phrase text, a valid null-terminated UTF-8 string

  • column – - text column name, or NULL/empty for automatic discovery

  • slop – - maximum number of intervening tokens; 0 requires an exact phrase

  • query_out – - pointer to receive the structured full-text query

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_new_boolean(const LanceDBFtsClause *clauses, size_t num_clauses, LanceDBFtsQuery **query_out, char **error_message)

Create a structured Boolean full-text query.

Clauses are a flat borrowed array; Boolean nodes compose without a recursive C representation, and a child can itself be a Boolean or Boost handle. The constructor copies each clause’s structured query node and occurrence, so child handles may be reused in several clauses or freed after this call returns. Only the node is copied; a child handle’s candidate limit set with lancedb_fts_query_limit() is not part of the node and does not constrain the Boolean query.

SDK clause semantics apply unchanged. MUST clauses must all match and their scores are summed. SHOULD clauses are optional when a MUST clause exists and add their score when they match; without MUST clauses, at least one SHOULD must match and the matching SHOULD scores are summed. MUST_NOT clauses exclude matching documents and never contribute score. An empty Boolean query, and a query whose only clauses are MUST_NOT, construct successfully; the embedded dataset scanner rejects them at execution with LANCEDB_INVALID_INPUT because it requires a leaf for document-granularity resolution and a SHOULD or MUST clause for scoring. This constructor does not impose either requirement early. A MemWAL LSM query runs its column and maintained-index checks first, so a tree without a named column reports that column error before clause validation, and a negative-only query that passes the column checks is validated by the LSM path. A namespace QueryTable pushdown and Enterprise forward the structured tree instead of planning it locally, so the server determines the error after forwarding or projection.

A successful construction can still be limited by the selected backend. Embedded LanceDB evaluates the clauses directly, including across several text columns, and resolves a NULL or empty child column against the indexed text columns.

A namespace QueryTable pushdown sends Boolean and Boost roots as structured nodes rather than text. The tree is converted through the namespace model, whose Match fuzziness, max_expansions and prefix_length and Phrase slop are signed 32-bit, so any of those values above INT32_MAX fails the pushdown with LANCEDB_INVALID_INPUT before it is sent. A non-finite boost or multiplier becomes JSON null in the intermediate value and then an unset optional in the namespace model, so the REST request omits it and the server applies its default. A structured Enterprise request keeps the explicit JSON null instead.

A MemWAL LSM query requires every clause to name the same explicit text column: the union of the child columns must contain exactly one column whose FTS index is maintained by the write spec and carried by every resident MemTable. A query with no named column or with several columns fails with LANCEDB_NOT_SUPPORTED, and a query in which only some clauses name the column fails the LSM scanner’s column check with LANCEDB_INVALID_INPUT. Each Match leaf keeps its own max_expansions budget, which the pinned MemWAL path applies separately to the base table, each SSTable and each in-memory source.

LanceDB Enterprise servers 0.3.0 and later receive the structured Boolean node. Older servers receive a degraded projection: the union of the child columns and an empty text query, because the SDK’s flat query string for a Boolean node is empty. The SDK does not reject this locally, so an older server cannot execute the intended Boolean semantics.

On entry *query_out and the error message are cleared. On success *query_out owns a handle that the caller frees with lancedb_fts_query_free(). On failure *query_out stays NULL and the error is LANCEDB_INVALID_ARGUMENT for a missing output pointer, a NULL clause array with a nonzero count, a NULL child handle, or an occurrence outside LanceDBFtsOccur.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • clauses – - array of borrowed clauses, or NULL when num_clauses is 0

  • num_clauses – - number of clauses in the array

  • query_out – - pointer to receive the structured full-text query

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_new_boost(const LanceDBFtsQuery *positive, const LanceDBFtsQuery *negative, const float *negative_boost, LanceDBFtsQuery **query_out, char **error_message)

Create a structured Boost full-text query.

positive and negative are required borrowed handles; the constructor copies each handle’s structured query node, so the caller may reuse or free the handles after this call returns. Only the node is copied; a child handle’s candidate limit set with lancedb_fts_query_limit() is not part of the node and does not constrain the Boost query. negative_boost may be NULL, which passes “unset” to the SDK constructor so the SDK supplies its default of 0.5. A pointed-to value is forwarded unchanged. The embedded dataset scanner requires a finite, non-negative multiplier when it plans the query and otherwise fails with LANCEDB_INVALID_INPUT. A MemWAL LSM query runs its column checks before that validation, and a namespace or Enterprise execution determines the outcome after forwarding the structured tree.

The positive query drives iteration: only documents matching it appear. When the negative query also matches a document, its score times the multiplier is subtracted from the positive score; otherwise the positive score is returned unchanged. Boost is a positive gate plus a demotion, not a disjunction.

A successful construction can still be limited by the selected backend. Embedded LanceDB evaluates the node directly, including across columns, and resolves NULL or empty child columns against the indexed text columns.

A namespace QueryTable pushdown sends Boolean and Boost roots as structured nodes rather than text. The tree is converted through the namespace model, whose Match fuzziness, max_expansions and prefix_length and Phrase slop are signed 32-bit, so any of those values above INT32_MAX fails the pushdown with LANCEDB_INVALID_INPUT before it is sent. A non-finite boost or multiplier becomes JSON null in the intermediate value and then an unset optional in the namespace model, so the REST request omits it and the server applies its default. A structured Enterprise request keeps the explicit JSON null instead.

A MemWAL LSM query requires both legs to name the same explicit text column: the union of the leg columns must contain exactly one column whose FTS index is maintained by the write spec and carried by every resident MemTable. A query with no named column or with several columns fails with LANCEDB_NOT_SUPPORTED, and a query in which only one leg names the column fails the LSM scanner’s column check with LANCEDB_INVALID_INPUT. Each Match leaf keeps its own max_expansions budget, which the pinned MemWAL path applies separately to the base table, each SSTable and each in-memory source.

LanceDB Enterprise servers 0.3.0 and later receive the structured Boost node. Older servers receive a degraded projection: the SDK’s flat query string of the positive leg (empty for a Boolean positive) searched over the union of both legs’ columns, so the negative leg and the multiplier are silently dropped. The SDK does not reject this locally.

On entry *query_out and the error message are cleared. On success *query_out owns a handle that the caller frees with lancedb_fts_query_free(). On failure *query_out stays NULL and the error is LANCEDB_INVALID_ARGUMENT for a missing output pointer or a NULL positive or negative handle.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • positive – - required borrowed handle matching the scored documents

  • negative – - required borrowed handle demoting documents it matches

  • negative_boost – - multiplier, or NULL for the SDK default of 0.5

  • query_out – - pointer to receive the structured full-text query

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_with_columns(LanceDBFtsQuery *query, const char *const *columns, size_t num_columns, char **error_message)

Replace the column selection of a structured full-text query.

This applies the pinned SDK’s FullTextSearchQuery::with_columns to a copy and publishes the result only after the SDK accepts it. A failure leaves the handle’s previous query, candidate limit and settings unchanged. The operation replaces the columns of every Match and Phrase leaf; it does not fill only leaves that lack a column.

A Match leaf becomes one leaf per selected column. Several columns therefore turn it into a MultiMatch, and every scalar setting of the original leaf (boost, fuzziness, max_expansions, operator, prefix_length and document granularity) is copied to each new leaf. A Phrase leaf accepts exactly one selected column; zero or several columns fail with LANCEDB_INVALID_INPUT. Boolean nodes recurse into must, should and must_not, and Boost nodes recurse into both legs. A MultiMatch expands each existing Match leaf by every selected column, so N existing leaves produce N * M leaves and each copy keeps its original scalar settings. Prefer constructing a MultiMatch with its columns; this operation is intended for trees whose leaves have not selected columns. A selection that makes the tree span several columns follows the existing MultiMatch backend limits: native MemWAL requires one explicit column. An empty Boolean has no leaves and succeeds unchanged.

A zero column count is forwarded as an empty selection and normally fails with LANCEDB_INVALID_INPUT, except for an empty Boolean. Empty strings are forwarded as named columns rather than automatic discovery; the SDK reports their resolution error when the query runs. A NULL array with a nonzero count, a NULL entry or invalid UTF-8 returns LANCEDB_INVALID_ARGUMENT and leaves the handle usable. SDK errors keep their mapped status.

Backend routing follows the rewritten tree. A namespace QueryTable pushdown sends a root OR Match as a string query, with the selected columns in string_query.columns. A root MultiMatch, including a Match that this call rewrote because several columns were selected, and a root AND Match, Phrase, Boolean or Boost use the structured node form, where the selected columns live inside the Match leaves instead. Enterprise 0.3.0 and later receive the structured node; older Enterprise projections remain the ones documented on the constructors.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBFtsQuery

  • columns – - ordered column names, or NULL when num_columns is zero

  • num_columns – - number of column names

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_limit(LanceDBFtsQuery *query, int64_t limit, char **error_message)

Set the candidate limit of a structured full-text query.

This sets the pinned SDK’s FullTextSearchQuery candidate ceiling. It is separate from lancedb_query_limit() and lancedb_vector_query_limit(), which limit the final query result. On a backend that consumes the field, zero requests no full-text candidates, so a standalone full-text query returns no rows and a hybrid query keeps only its vector contribution. A positive value caps the candidates the full-text leg may produce before the final query limit and offset are applied.

The value is forwarded unchanged as int64_t. Embedded planning converts it to size_t, so a negative value becomes a very large ceiling on a 64-bit target. The native MemWAL LSM path rejects a negative value at execution with LANCEDB_INVALID_INPUT. This setter does not clamp or reject negative values; the selected backend determines the outcome.

There is no upper bound. A very large positive value can exhaust memory or otherwise fail during execution. The native MemWAL LSM path is the most exposed because it applies the value to every planned FTS column. When the intent is no explicit ceiling, call lancedb_fts_query_unset_limit() instead of passing a very large value.

The pinned SDK consumes the ceiling for standalone embedded full-text search, for the full-text leg of an embedded hybrid query, and for a native MemWAL LSM full-text query. Namespace QueryTable pushdown and LanceDB Enterprise requests do not carry the field: only their outer result limit applies, so the ceiling is silently absent on those backends.

The limit belongs to the full-text search wrapper, not to the query tree. lancedb_fts_query_new_boolean() and lancedb_fts_query_new_boost() copy child query nodes and do not copy a child’s candidate limit. Attaching the handle with lancedb_query_full_text_search_query() or lancedb_vector_query_full_text_search_query() copies the whole wrapper, including this limit, so later changes to the handle do not affect builders that already attached it.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBFtsQuery

  • limit – - candidate ceiling

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_fts_query_unset_limit(LanceDBFtsQuery *query, char **error_message)

Remove the candidate limit from a structured full-text query.

This sets the pinned SDK FullTextSearchQuery limit to unset. Embedded standalone full-text search derives its search ceiling from the final query limit, plus any offset, when that limit is set. With an explicit column ordering, no ceiling is derived: the full match set is retained so the ordering can select the page. Native MemWAL derives its ceiling from the scanner limit and offset. The final query result limit remains independent.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBFtsQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

void lancedb_fts_query_free(LanceDBFtsQuery *query)

Free a structured full-text query.

The handle is independent of every builder it was attached to, so freeing it does not change those builders. Create it with lancedb_fts_query_new_match(), lancedb_fts_query_new_multi_match(), lancedb_fts_query_new_phrase(), lancedb_fts_query_new_boolean() or lancedb_fts_query_new_boost().

Parameters:

query – - pointer to LanceDBFtsQuery, or NULL

LanceDBError lancedb_query_full_text_search_query(LanceDBQuery *query, const LanceDBFtsQuery *full_text_query, char **error_message)

Set a structured full-text query for query.

This replaces the text Match query set by lancedb_query_full_text_search() or an earlier call to this function. The builder clones the handle’s query, so full_text_query is borrowed: the caller keeps ownership and may reuse or free it immediately after this call returns. On failure, including a NULL handle, any previous full-text setting stays unchanged.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery

  • full_text_query – - pointer to LanceDBFtsQuery (borrowed, not consumed)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_df_filter(LanceDBQuery *query, LanceDBExpr *expr, char **error_message)

Set DataFusion Expr filter for query.

If both a DataFusion and a SQL WHERE clause filters are set, the DataFusion expression takes precedence.

Parameters:
  • query – - pointer to LanceDBQuery

  • expr – - pointer to LanceDBExpr (consumed by this function; do not use or free after calling)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_limit(LanceDBVectorQuery *query, size_t limit, char **error_message)

Set limit for vector query.

This limits the final query result. It is independent of a structured full-text query’s candidate ceiling, which is set with lancedb_fts_query_limit().

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • limit – - maximum number of results

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_offset(LanceDBVectorQuery *query, size_t offset, char **error_message)

Set offset for vector query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • offset – - number of results to skip

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_column(LanceDBVectorQuery *query, const char *column, char **error_message)

Set vector column for vector query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • column – - vector column name

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_select(LanceDBVectorQuery *query, const char *const *columns, size_t num_columns, char **error_message)

Set columns to select for vector query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • columns – - array of column name strings

  • num_columns – - number of columns

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_select_all(LanceDBVectorQuery *query, char **error_message)

Reset a vector query to every non-system column.

This clears a projection set by lancedb_vector_query_select() or lancedb_vector_query_select_dynamic(). The most recent projection call wins. lancedb_vector_query_with_row_id() still appends the _rowid metadata column.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_select_dynamic(LanceDBVectorQuery *query, const char *const *names, const char *const *expressions, size_t num_columns, char **error_message)

Set an expression-based column projection for vector query.

Each pair adds one output column: names[i] is the output name and expressions[i] is an SQL expression over the table columns. Columns are returned in the given order, which may differ from the table order. The names and expressions are copied; the arrays may be released after the call.

A zero num_columns selects no columns. Both arrays must still be non-NULL. Calling this function replaces a projection from lancedb_vector_query_select() or lancedb_vector_query_select_all(), and a later call to either of those replaces this projection.

The SDK evaluates the expressions and decides whether a backend supports dynamic projection. An unsupported backend’s SDK error is returned unchanged.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • names – - array of num_columns output column names

  • expressions – - array of num_columns SQL expressions

  • num_columns – - number of entries in each array

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_order_by(LanceDBVectorQuery *query, const LanceDBColumnOrdering *orderings, size_t num_orderings, char **error_message)

Set the column ordering for vector query.

The first entry is the primary sort key. For an embedded vector search, the nearest-neighbour candidate count is limit + offset, or the SDK’s default top-K + offset when no limit is set. The search orders those candidates and then applies offset and limit to the ordered page; it does not sort the whole table. On a hybrid vector plus full-text query it applies to both search legs, and the reranker still determines the final fused order. EXPLAIN, output-schema inspection and ANALYZE use the same configured ordering, subject to the hybrid inspection limits documented below.

A zero num_orderings clears the ordering, restoring the query’s default order; orderings may be NULL in that case. A positive count requires a non-NULL array whose entries and column names are non-NULL, NUL-terminated UTF-8 strings. Invalid input returns LANCEDB_INVALID_ARGUMENT and leaves the previous ordering unchanged. The array and its strings are borrowed for the duration of the call and are copied into the query.

A native namespace connection with QueryTable pushdown executes a nonempty ordering locally, so it needs client access to table storage. A table routed through the MemWAL LSM scanner rejects a nonempty ordering with LANCEDB_NOT_SUPPORTED; clear the ordering to return to the default route. A remote LanceDB forwards the ordering to the server.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • orderings – - array of column orderings, or NULL when num_orderings is 0

  • num_orderings – - number of entries in orderings; 0 clears the ordering

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_with_row_id(LanceDBVectorQuery *query, char **error_message)

Ask a vector query to return the _rowid metadata column.

This also applies to a hybrid vector plus full-text query. The UInt64 metadata column is appended to the projection, even when lancedb_vector_query_select() names specific columns.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_fast_search(LanceDBVectorQuery *query, char **error_message)

Restrict a vector query to rows covered by the vector index.

The SDK turns this into an index-only search: rows appended or updated after the index was built may be absent, and a query with no usable vector index returns no rows. A SQL or DataFusion filter keeps its configured pre-filter or post-filter placement.

On a hybrid query, fast search is part of the vector query’s shared request, so it applies to both the full-text and vector legs. In contrast, lancedb_vector_query_bypass_vector_index() only affects the vector leg. Embedded LanceDB applies fast search after the bypass flag, so fast search wins when both are set. A remote LanceDB forwards both flags to the server, which decides their interaction.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_bypass_vector_index(LanceDBVectorQuery *query, char **error_message)

Skip the vector index and compare the query vector with every row.

This performs an exhaustive flat search even when a vector index exists. It is useful as ground truth for recall measurements and returns exact distances without index quantization. A filter still keeps its configured pre-filter or post-filter placement.

On a hybrid query this only affects the vector leg; the full-text leg remains unchanged. Embedded LanceDB applies fast search after this flag, so a query with both set behaves as a fast search. A remote LanceDB forwards both flags to the server, which decides their interaction.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_where_filter(LanceDBVectorQuery *query, const char *filter, char **error_message)

Set WHERE filter for vector query.

If both a SQL WHERE clause and a DataFusion filters are set, the DataFusion expression takes precedence.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • filter – - SQL WHERE clause string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_full_text_search(LanceDBVectorQuery *query, const char *text, const char *column, char **error_message)

Set full-text search for vector query.

This turns the vector query into a hybrid nearest-neighbour plus full-text search. Embedded LanceDB executes it as two searches and fuses the result sets. LanceDB applies the vector, filter, projection and limit settings to both searches and adds its relevance score column.

If column is NULL or empty, LanceDB discovers the text columns itself and searches every column that has a full-text index. An explicit column selects that text column; embedded LanceDB can also scan it without an index, while an index is recommended for larger tables.

Embedded LanceDB executes this hybrid query as two searches and fuses their results. EXPLAIN, output schema inspection, and ANALYZE need a single SDK plan, so lancedb_vector_query_explain_plan(), lancedb_vector_query_output_schema() and lancedb_vector_query_analyze_plan() may return the SDK’s unsupported-shape error. Execute the query instead.

If the vector leg returns batch results with query_index and the full-text leg returns matches, the SDK’s RRF merge fails with an Arrow schema error. See lancedb_vector_query_new_typed() for the vector types and routing that produce query_index.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • text – - full-text query string

  • column – - text column name, or NULL/empty for automatic discovery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_full_text_search_query(LanceDBVectorQuery *query, const LanceDBFtsQuery *full_text_query, char **error_message)

Set a structured full-text query for vector query.

This replaces the text Match query set by lancedb_vector_query_full_text_search() or an earlier call to this function, making the builder a hybrid nearest-neighbour plus full-text search. The builder clones the handle’s query, so full_text_query is borrowed: the caller keeps ownership and may reuse or free it immediately after this call returns. On failure, including a NULL handle, any previous full-text setting stays unchanged.

The SDK’s default RRF reranker applies when no reranker is set explicitly. Match, MultiMatch, phrase, Boolean and Boost evaluation, including backend limitations, are described on lancedb_fts_query_new_match(), lancedb_fts_query_new_multi_match(), lancedb_fts_query_new_phrase(), lancedb_fts_query_new_boolean() and lancedb_fts_query_new_boost().

If the vector leg returns batch results with query_index and the full-text leg returns matches, the SDK’s RRF merge fails with an Arrow schema error. See lancedb_vector_query_new_typed() for the vector types and routing that produce query_index.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • full_text_query – - pointer to LanceDBFtsQuery (borrowed, not consumed)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_df_filter(LanceDBVectorQuery *query, LanceDBExpr *expr, char **error_message)

Set DataFusion Expr filter for vector query.

If both a DataFusion and a SQL WHERE clause filters are set, the DataFusion expression takes precedence.

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • expr – - pointer to LanceDBExpr (consumed by this function; do not use or free after calling)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_postfilter(LanceDBVectorQuery *query, char **error_message)

Make the vector query filter run after the vector search.

By default, the filter set with lancedb_vector_query_where_filter() or lancedb_vector_query_df_filter() is applied before the vector search. Calling this function applies the filter to the vector search results instead, matching the Rust SDK’s postfilter().

This only affects queries that also set a filter. Post-filtering can return fewer than limit rows, or no rows, when the nearest vectors do not match the filter. Setting a refine_factor can help recover some results.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_rerank_rrf(LanceDBVectorQuery *query, float k, char **error_message)

Use reciprocal rank fusion with an explicit k for hybrid search.

This installs the SDK’s RRFReranker on the vector query. It only changes the result of a hybrid query built with lancedb_vector_query_full_text_search(); on a vector-only query the reranker is stored but unused. Fusion scores each result as 1 / (k + rank) with ranks starting at 1, summed across the vector and full-text lists, and returns that sum as _relevance_score. When this setter is not called, the SDK uses its own default k = 60. The value is forwarded unchanged, so a caller that treats zero as “use the default” must pass 60 here instead.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • k – - RRF constant; the SDK default is 60 when no setter is called

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_norm(LanceDBVectorQuery *query, LanceDBNormalizeMethod normalize_method, char **error_message)

Set how hybrid-search scores are normalized before reranking.

This only affects a hybrid query built with lancedb_vector_query_full_text_search(). LANCEDB_NORMALIZE_SCORE normalizes the raw vector distance and full-text score columns; LANCEDB_NORMALIZE_RANK converts them to ranks first. The SDK always normalizes both channels before invoking the reranker, and this setter selects what that normalization starts from. When this setter is not called, the SDK’s default normalization applies.

The built-in RRF reranker uses only row identities and list positions, so this setting does not change its ranking or _relevance_score. It does change the normalized score columns preserved in the result. When this setter is not called, the SDK’s default normalization applies. Out-of-range values are rejected with LANCEDB_INVALID_ARGUMENT and leave any previously selected normalization unchanged.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • normalize_method – - normalization method to use

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_distance_type(LanceDBVectorQuery *query, LanceDBDistanceType distance_type, char **error_message)

Set distance type for vector query.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • distance_type – - distance metric to use

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_nprobes(LanceDBVectorQuery *query, size_t nprobes, char **error_message)

Set number of probes for vector query.

This parameter controls how many partitions to search in IVF (Inverted File) based indices such as IVF_FLAT, IVF_PQ, IVF_HNSW_PQ, and IVF_HNSW_SQ.

IVF indices partition the vector space into clusters. During search, nprobes determines how many of these partitions are searched. Higher values improve recall (find more relevant results) at the cost of slower queries. Lower values make queries faster but may miss relevant results that are in non-searched partitions.

When this setter is not called, LanceDB leaves the probe bounds unset and uses Lance’s adaptive IVF probe defaults. This replaces the fixed minimum/maximum of 20 used by LanceDB 0.33 and earlier. Call this setter with 20 to request the previous fixed behavior.

Typical values:

  • Range: 1 to num_partitions (specified during index creation)

  • Higher nprobes (e.g., num_partitions/2) → better recall, slower queries

  • Lower nprobes (e.g., 1-10) → faster queries, lower recall

This setter returns LANCEDB_SUCCESS even for 0. The value is validated when the query is executed: lancedb_vector_query_execute() returns NULL for nprobes 0, and lancedb_vector_query_explain_plan() returns LANCEDB_INVALID_INPUT with the message “nprobes must be greater than 0”. Callers that accept untrusted values should validate them before executing.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • nprobes – - number of IVF partitions to search (must be <= num_partitions)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_refine_factor(LanceDBVectorQuery *query, unsigned int refine_factor, char **error_message)

Set refine factor for vector query.

This parameter enables a refinement step to improve result accuracy for approximate vector indices (IVF_PQ, IVF_HNSW_PQ, IVF_HNSW_SQ).

When refine_factor is set, the search process works in two stages:

  1. Fetch (limit × refine_factor) approximate nearest neighbors using the index

  2. Re-rank these candidates using exact distance calculations on original vectors

  3. Return the top ‘limit’ results after refinement

This improves accuracy because approximate indices (especially quantized ones like PQ/SQ) can have ranking errors. Refinement corrects these errors by recalculating exact distances.

Typical values:

  • Default: No refinement (refine_factor = 1 or not set)

  • Range: 1 to ~100

  • refine_factor = 1 → no refinement (fastest, least accurate)

  • refine_factor = 10 → fetch 10x results and refine (good balance)

  • refine_factor = 50+ → very accurate but slower

Note: Higher values increase query latency proportionally. Not useful for exact indices like IVF_FLAT which already use exact distances.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • refine_factor – - multiplier for candidate set size (fetches limit × refine_factor results)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_ef(LanceDBVectorQuery *query, size_t ef, char **error_message)

Set ef parameter for HNSW vector query.

This parameter controls the exploration factor for HNSW (Hierarchical Navigable Small World) based indices such as IVF_HNSW_PQ and IVF_HNSW_SQ.

HNSW is a graph-based index that navigates through a multi-layer graph to find nearest neighbors. The ‘ef’ parameter determines the size of the dynamic candidate list maintained during the graph traversal. A larger candidate list explores more of the graph, leading to better recall but slower queries.

How it works:

  • During search, HNSW maintains a priority queue of size ‘ef’ with candidate neighbors

  • The algorithm explores neighbors of candidates in this queue

  • Larger ef → explores more paths through the graph → better recall

  • After exploration, the top ‘limit’ results are returned

Typical values:

  • Default is usually 100

  • Must be >= limit (query result size)

  • Range: limit to ~1000

  • ef = limit → fastest, lowest recall

  • ef = 100-200 → good balance for most use cases

  • ef = 500+ → very high recall, slower queries

Note: The ef parameter at query time is different from ef_construction used during index building. Query-time ef controls search quality, while ef_construction controls index quality.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • ef – - exploration factor for HNSW search (must be >= query limit)

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_search_effort(LanceDBVectorQuery *query, const double *effort, char **error_message)

Set the initial IVF partition search effort.

The value is copied. It must be finite and in [0, 1]. At 0 the search starts at the caller minimum. At 1 it searches all partitions allowed by the caller maximum. The SDK may probe further if too few candidates are found. Any explicit effort, including 0.5, overrides nprobes regardless of setter order. Passing NULL clears the override, restoring fixed probing if nprobes is set and the SDK adaptive default of 0.5 otherwise. Effort does not change refinement, HNSW ef or flat search.

The SDK forwards explicit effort to Enterprise. Native namespace tables with QueryTable pushdown execute locally when effort is set. Vector queries routed through the MemWAL LSM scanner reject explicit effort with LANCEDB_NOT_SUPPORTED.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • effort – - pointer to a finite value in [0, 1], or NULL to clear the override

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_INVALID_INPUT for an invalid value, leaving the previous setting intact

LanceDBError lancedb_vector_query_approx_mode(LanceDBVectorQuery *query, int mode, char **error_message)

Set the speed and accuracy tradeoff for approximate vector search.

The SDK uses this setting with RQ-quantized vector indexes and prefiltered search on HNSW sub-indexes, where LANCEDB_APPROX_MODE_FAST enables ACORN traversal. Other indexes, flat search and the MemWAL LSM scanner ignore it. The Embedded default is LANCEDB_APPROX_MODE_NORMAL. The SDK forwards explicit modes to Enterprise. Native namespace tables with QueryTable pushdown execute locally when a mode is set.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery

  • mode – - integer value of a LanceDBApproxMode enumerator

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_INVALID_ARGUMENT for an unknown mode, leaving the previous setting intact

LanceDBError lancedb_query_output_schema(const LanceDBQuery *query, FFI_ArrowSchema **schema_out, char **error_message)

Get the output schema of a query.

The schema comes from the same configured query that lancedb_query_execute() would run, so a dynamic projection’s aliases, types and order are visible before execution. The query is not consumed. The SDK decides how a backend resolves the plan; an Enterprise table may send the SDK’s /query/ request and read the schema from the returned stream.

On entry, *schema_out and the error message are cleared. On success, *schema_out holds an owned Arrow C Data schema; release it with lancedb_free_arrow_schema(). On failure it stays NULL and the error message is set when requested. A schema that the C data interface cannot represent returns LANCEDB_ARROW with the conversion detail.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery (NOT consumed)

  • schema_out – - pointer to receive the Arrow schema

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_explain_plan(const LanceDBQuery *query, bool verbose, char **plan_out, char **error_message)

Get the query execution plan without executing the query.

Returns a human-readable string describing what steps will be taken to execute the query. Does NOT consume the query — it can still be executed afterwards.

Caller must free the returned plan string with lancedb_free_string(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery (NOT consumed)

  • verbose – - if true, include additional detail in the plan

  • plan_out – - pointer to receive the plan string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_query_analyze_plan(const LanceDBQuery *query, char **plan_out, char **error_message)

Execute the query and return an analyzed plan with runtime metrics.

ANALYZE executes an analyzable query plan to collect runtime metrics. It reads the same data and has the same side effects as execution while returning no rows. The query is not consumed and can still be executed.

On entry, *plan_out and the error message are cleared. On success, *plan_out holds a NUL-terminated plan string; release it with lancedb_free_string(). On failure it stays NULL and the error message is set when requested.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery (NOT consumed)

  • plan_out – - pointer to receive the plan string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_output_schema(const LanceDBVectorQuery *query, FFI_ArrowSchema **schema_out, char **error_message)

Get the output schema of a vector query.

The schema comes from the same configured query that lancedb_vector_query_execute() would run, so a dynamic projection’s aliases, types and order are visible before execution. The query is not consumed. The SDK decides how a backend resolves the plan; an Enterprise table may send the SDK’s /query/ request and read the schema from the returned stream.

Embedded LanceDB executes a hybrid nearest-neighbour plus full-text query as two searches and fuses their results. Output schema inspection requires a single SDK plan, so it may return the same unsupported hybrid error as lancedb_vector_query_explain_plan().

On entry, *schema_out and the error message are cleared. On success, *schema_out holds an owned Arrow C Data schema; release it with lancedb_free_arrow_schema(). On failure it stays NULL and the error message is set when requested. A schema that the C data interface cannot represent returns LANCEDB_ARROW with the conversion detail.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery (NOT consumed)

  • schema_out – - pointer to receive the Arrow schema

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_explain_plan(const LanceDBVectorQuery *query, bool verbose, char **plan_out, char **error_message)

Get the vector query execution plan without executing the query.

Returns a human-readable string describing what steps will be taken to execute the query. Does NOT consume the query — it can still be executed afterwards.

Embedded LanceDB executes a hybrid query that combines nearest-neighbour and full-text search as two searches and fuses their results. EXPLAIN requires a single SDK plan, so embedded LanceDB rejects that hybrid at plan time with the SDK’s unsupported-shape error. That is an SDK limitation, not a C-side argument error; execute the query instead.

Caller must free the returned plan string with lancedb_free_string(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery (NOT consumed)

  • verbose – - if true, include additional detail in the plan

  • plan_out – - pointer to receive the plan string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_vector_query_analyze_plan(const LanceDBVectorQuery *query, char **plan_out, char **error_message)

Execute the vector query and return an analyzed plan with runtime metrics.

ANALYZE executes an analyzable query plan to collect runtime metrics. It reads the same data and has the same side effects as execution while returning no rows. The query is not consumed and can still be executed.

Embedded LanceDB executes a hybrid nearest-neighbour plus full-text query as two searches and fuses their results. ANALYZE requires one analyzable SDK plan, so it may return the same unsupported hybrid error as lancedb_vector_query_explain_plan().

On entry, *plan_out and the error message are cleared. On success, *plan_out holds a NUL-terminated plan string; release it with lancedb_free_string(). On failure it stays NULL and the error message is set when requested.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery (NOT consumed)

  • plan_out – - pointer to receive the plan string

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBQueryResult *lancedb_query_execute(LanceDBQuery *query)

Execute query and return streaming result.

Parameters:

query – - pointer to LanceDBQuery (consumed by this function)

Returns:

Pointer to LanceDBQueryResult on success, NULL on failure Caller must free with lancedb_query_result_free()

LanceDBQueryResult *lancedb_vector_query_execute(LanceDBVectorQuery *query)

Execute vector query and return streaming result.

Parameters:

query – - pointer to LanceDBVectorQuery (consumed by this function)

Returns:

Pointer to LanceDBQueryResult on success, NULL on failure Caller must free with lancedb_query_result_free()

LanceDBError lancedb_query_execute_with_status(LanceDBQuery *query, LanceDBQueryResult **result_out, char **error_message)

Execute query and report why it could not start.

The SDK only hands over a result once it started the query, so a failure carries the SDK status and its message instead of a NULL pointer. On entry, *result_out and the error message are cleared. Caller must free a returned result with lancedb_query_result_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBQuery (consumed by this function on every path with a non-NULL pointer, including a rejected result pointer)

  • result_out – - pointer to receive the streaming result

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *result_out set, otherwise the SDK error code

LanceDBError lancedb_vector_query_execute_with_status(LanceDBVectorQuery *query, LanceDBQueryResult **result_out, char **error_message)

Execute vector query and report why it could not start.

Same contract as lancedb_query_execute_with_status(). On entry, *result_out and the error message are cleared. Caller must free a returned result with lancedb_query_result_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBVectorQuery (consumed by this function on every path with a non-NULL pointer, including a rejected result pointer)

  • result_out – - pointer to receive the streaming result

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *result_out set, otherwise the SDK error code

LanceDBError lancedb_table_take_offsets(const LanceDBTable *table, const uint64_t *offsets, size_t count, LanceDBTakeQuery **query_out, char **error_message)

Create a take query that selects rows by dataset offset.

Offsets are 0-indexed and relative to the current table version; they can change when rows are added or deleted. The requested offsets are copied, including duplicates. Without lancedb_take_query_preserve_order() the result order is unspecified. Missing offsets are omitted.

The caller keeps ownership of offsets and may release or change it after this call returns. On entry, *query_out and the error message are cleared. Free the returned builder with lancedb_take_query_free() or consume it with lancedb_take_query_execute(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • offsets – - borrowed array of dataset offsets, or NULL when count is zero

  • count – - number of offsets in the array

  • query_out – - pointer to receive the TakeQuery builder

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *query_out set, otherwise LANCEDB_INVALID_ARGUMENT

LanceDBError lancedb_table_take_row_ids(const LanceDBTable *table, const uint64_t *row_ids, size_t count, LanceDBTakeQuery **query_out, char **error_message)

Create a take query that selects rows by row ID.

Row IDs are relative to the current table version and can change after compaction or updates. The SDK follows the requested order, including repeated IDs, and omits missing or deleted IDs.

The caller keeps ownership of row_ids and may release or change it after this call returns. On entry, *query_out and the error message are cleared. Free the returned builder with lancedb_take_query_free() or consume it with lancedb_take_query_execute(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • row_ids – - borrowed array of row IDs, or NULL when count is zero

  • count – - number of row IDs in the array

  • query_out – - pointer to receive the TakeQuery builder

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *query_out set, otherwise LANCEDB_INVALID_ARGUMENT

LanceDBError lancedb_take_query_select(LanceDBTakeQuery *query, const char *const *columns, size_t num_columns, char **error_message)

Set the column projection of a take query.

Columns are returned in the requested order. A zero num_columns selects no columns and keeps an empty result schema; columns may then be NULL. The names are copied and are not borrowed after this call.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBTakeQuery

  • columns – - borrowed array of column names, or NULL when num_columns is zero

  • num_columns – - number of column names in the array

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_take_query_with_row_id(LanceDBTakeQuery *query, char **error_message)

Ask a take query to return the _rowid metadata column.

The metadata column is appended to the projection. For an offset take it carries the row ID, which is not the same as the requested dataset offset.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBTakeQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_take_query_preserve_order(LanceDBTakeQuery *query, char **error_message)

Restore offset-take occurrences in the exact requested order.

Row-ID takes already follow the requested order and ignore this flag. For an offset take, the result follows the input order, including repeated offsets, and missing offsets are omitted.

If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBTakeQuery

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_take_query_execute(LanceDBTakeQuery *query, LanceDBQueryResult **result_out, char **error_message)

Execute a take query and report why it could not start.

The returned result uses the same Arrow C Data and Arrow IPC conversions as every other query result. On entry, *result_out and the error message are cleared. Caller must free a returned result with lancedb_query_result_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • query – - pointer to LanceDBTakeQuery (consumed by this function on every path with a non-NULL pointer, including a rejected result pointer)

  • result_out – - pointer to receive the streaming result

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *result_out set, otherwise the SDK error code

void lancedb_take_query_free(LanceDBTakeQuery *query)

Free a TakeQuery.

Parameters:

query – - pointer to LanceDBTakeQuery

LanceDBError lancedb_query_result_to_arrow(LanceDBQueryResult *result, struct FFI_ArrowArray ***result_arrays, struct FFI_ArrowSchema **result_schema, size_t *count_out, char **error_message)

Convert query result to Arrow RecordBatch arrays.

On entry, non-NULL output slots and the error message are cleared. On success, *count_out is the number of batches, and *result_arrays and *result_schema hold the batches and their schema. An empty result succeeds with both pointers NULL and *count_out zero. On failure, all three outputs stay clear. The caller must free returned arrays with lancedb_free_arrow_arrays() and the schema with lancedb_free_arrow_schema(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • result – - pointer to LanceDBQueryResult. When result, result_arrays, result_schema and count_out are all non-NULL, the result is consumed on every path, including failure. When any of the four is NULL, the call returns LANCEDB_INVALID_ARGUMENT and does not consume a non-NULL result, so the caller can retry it or free it with lancedb_query_result_free().

  • result_arrays – - pointer to receive array of Arrow C ABI arrays

  • result_schema – - pointer to receive single Arrow C ABI schema

  • count_out – - pointer to receive number of result batches

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS, the SDK error code when the stream fails, or LANCEDB_ARROW when the result schema cannot be represented through the Arrow C data interface

LanceDBError lancedb_query_result_to_ipc_file(LanceDBQueryResult *result, LanceDBIpcBuffer *buffer_out, char **error_message)

Convert a query result into an Arrow IPC file.

The file carries the projected schema and one record batch per batch the result yielded, in order, including zero-row batches. A result without any batch keeps the projected schema and holds no batch. The bytes are handed over only after the file footer is written, so a failure leaves the buffer empty. On entry, *buffer_out and the error message are cleared. The caller must free the bytes with lancedb_ipc_buffer_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • result – - pointer to LanceDBQueryResult (consumed by this function on every path with a non-NULL pointer, including a rejected buffer pointer)

  • buffer_out – - pointer to receive the file bytes

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

LANCEDB_SUCCESS with *buffer_out holding one complete IPC file, the SDK error code of a stream that failed, or LANCEDB_ARROW when encoding failed

void lancedb_query_free(LanceDBQuery *query)

Free a Query.

Parameters:

query – - pointer to LanceDBQuery

void lancedb_vector_query_free(LanceDBVectorQuery *query)

Free a VectorQuery.

Parameters:

query – - pointer to LanceDBVectorQuery

void lancedb_query_result_free(LanceDBQueryResult *result)

Free a QueryResult.

Parameters:

result – - pointer to LanceDBQueryResult

struct LanceDBColumnOrdering
#include <lancedb.h>

One column ordering for lancedb_query_order_by() and lancedb_vector_query_order_by().

column is a NUL-terminated UTF-8 column name. ascending is non-zero for ascending order and 0 for descending. nulls_first is non-zero to place NULL values first, regardless of direction. Entries are applied in array order, so the first entry is the primary sort key. The ordering setters validate the array and UTF-8 but do not check that a named column exists; the SDK checks column names when it plans the query and reports an unknown column from execution or inspection.

struct LanceDBFtsMatchOptions
#include <lancedb.h>

Options for lancedb_fts_query_new_match().

Initialize with lancedb_fts_match_options_default() and change only the fields that need a non-default value. The defaults come from the SDK’s MatchQuery constructor: OR matching, boost 1.0, fuzziness 0 (exact), max_expansions 50, and prefix_length 0.

fuzziness is -1 to pass the SDK’s automatic choice, or 0 through UINT32_MAX for an explicit maximum edit distance. Keeping -1 distinct from 0 preserves the SDK’s automatic-versus-exact distinction. With the pinned Lance version, embedded and MemWAL queries currently treat automatic matching as exact.

boost is a score multiplier. The constructor forwards it unchanged; the SDK requires a finite, non-negative value when the query is planned.

max_expansions is the maximum final vocabulary size for this Match leaf. The ordinary embedded planner shares one budget across its query positions and selected physical segments. The pinned MemWAL path applies the budget separately to the base table, each SSTable and each in-memory source, using each source’s own vocabulary, so its effective total can exceed one budget. Every sibling Match leaf has its own budget.

term_operator must be a LanceDBFtsOperator value. Any other integer is rejected by the constructor rather than converted to an SDK operator.

prefix_length is the number of leading characters kept unchanged during fuzzy matching.

struct LanceDBFtsMultiMatchOptions
#include <lancedb.h>

Options for lancedb_fts_query_new_multi_match().

boosts points to num_boosts per-column score multipliers in column order. num_boosts == 0 uses the SDK default of 1.0 for every column and does not read boosts; otherwise boosts must be non-NULL and num_boosts must equal the constructor’s num_columns. The constructor forwards values unchanged; the embedded planner requires each to be finite and non-negative and otherwise fails with LANCEDB_INVALID_INPUT.

term_operator is the shared term combination operator applied to the Match leaf for every column. It must be a LanceDBFtsOperator value; any other integer is rejected by the constructor. The SDK default is OR, which is also returned by lancedb_fts_multi_match_options_default().

struct LanceDBFtsClause
#include <lancedb.h>

One clause of lancedb_fts_query_new_boolean().

query is a borrowed handle; the constructor copies its structured query node, so the caller may reuse or free the child handle after the call returns. occur must be a LanceDBFtsOccur value; any other integer is rejected by the constructor rather than converted to an SDK occurrence.