turbopuffer

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 21 Imported by: 0

README

turbopuffer Go API Library

Go Reference

The turbopuffer Go library provides convenient access to the turbopuffer HTTP API from applications written in Go.

It is generated with Stainless.

Documentation

The HTTP API documentation can be found at turbopuffer.com/docs.

The full API of this library can be found at https://pkg.go.dev/github.com/turbopuffer/turbopuffer-go.

Installation

import (
	"github.com/turbopuffer/turbopuffer-go" // imported as turbopuffer
)

Or to pin the version:

go get -u 'github.com/turbopuffer/turbopuffer-go@v1.2.0'

Requirements

This library requires Go 1.22+.

Usage

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/turbopuffer/turbopuffer-go"
	"github.com/turbopuffer/turbopuffer-go/option"
)

func main() {
	ctx := context.Background()
	tpuf := turbopuffer.NewClient(
		option.WithAPIKey(os.Getenv("TURBOPUFFER_API_KEY")), // this is the default and can be omitted
		option.WithRegion("gcp-us-central1"),                // defaults to os.Getenv("TURBOPUFFER_REGION")
	)

	ns := tpuf.Namespace("example")

	// Query nearest neighbors with filter.
	queryRes, err := ns.Query(
		ctx,
		turbopuffer.NamespaceQueryParams{
			RankBy: turbopuffer.NewRankByVector("vector", []float32{0.1, 0.2}),
			TopK:   turbopuffer.Int(10),
			Filters: turbopuffer.NewFilterAnd([]turbopuffer.Filter{
				turbopuffer.NewFilterEq("name", "foo"),
				turbopuffer.NewFilterEq("public", 1),
			}),
			IncludeAttributes: turbopuffer.IncludeAttributesParam{StringArray: []string{"name"}},
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Print(turbopuffer.PrettyPrint(queryRes.Rows))
	// [{"id": 1, "vector": null, "$dist": 0.009067952632904053, "name": "foo"}]

	// Full-text search on an attribute.
	ftsRes, err := ns.Query(
		ctx,
		turbopuffer.NamespaceQueryParams{
			TopK:    turbopuffer.Int(10),
			Filters: turbopuffer.NewFilterEq("name", "foo"),
			RankBy:  turbopuffer.NewRankByTextBM25("text", "quick walrus"),
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Print(turbopuffer.PrettyPrint(ftsRes.Rows))
	// [{"id": 1, "vector": null, "$dist": 0.19, "name": "foo"}]
	// [{"id": 2, "vector": null, "$dist": 0.168, "name": "foo"}]

	// See https://turbopuffer.com/docs/quickstart for more.
}

Request fields

The turbopuffer library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, turbopuffer.String(string), turbopuffer.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := turbopuffer.ExampleParams{
	ID:   "id_xxx",                  // required property
	Name: turbopuffer.String("..."), // optional property

	Point: turbopuffer.Point{
		X: 0,                  // required field will serialize as 0
		Y: turbopuffer.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: turbopuffer.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[turbopuffer.FooParams](12)
Request unions

Unions are represented as a struct with fields for each of it's variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalParam struct {
	Cat *Cat `json:",omitzero,inline`
	Dog *Dog `json:",omitzero,inline`
}

animal := AnimalParam{
	Cat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type Animal struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := turbopuffer.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Namespaces(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

iter := client.NamespacesAutoPaging(context.TODO(), turbopuffer.NamespacesParams{
	Prefix: turbopuffer.String("products"),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	namespaceSummary := iter.Current()
	fmt.Printf("%+v\n", namespaceSummary)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

page, err := client.Namespaces(context.TODO(), turbopuffer.NamespacesParams{
	Prefix: turbopuffer.String("products"),
})
for page != nil {
	for _, client := range page.Namespaces {
		fmt.Printf("%+v\n", client)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *turbopuffer.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Namespaces(context.TODO(), turbopuffer.NamespacesParams{
	Prefix: turbopuffer.String("foo"),
})
if err != nil {
	var apierr *turbopuffer.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v1/namespaces": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Namespaces(
	ctx,
	turbopuffer.NamespacesParams{
		Prefix: turbopuffer.String("foo"),
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper turbopuffer.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 4 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := turbopuffer.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Namespaces(
	context.TODO(),
	turbopuffer.NamespacesParams{
		Prefix: turbopuffer.String("foo"),
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
namespaces, err := client.Namespaces(
	context.TODO(),
	turbopuffer.NamespacesParams{
		Prefix: turbopuffer.String("foo"),
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", namespaces)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: turbopuffer.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := turbopuffer.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (TURBOPUFFER_API_KEY, TURBOPUFFER_REGION, TURBOPUFFER_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func PrettyPrint

func PrettyPrint(v any) string

PrettyPrint pretty prints a JSON-encodable value to a string.

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AggregateBy

type AggregateBy interface {
	// contains filtered or unexported methods
}

type AggregateByCount

type AggregateByCount struct {
}

func NewAggregateByCount

func NewAggregateByCount() AggregateByCount

func (AggregateByCount) MarshalJSON

func (v AggregateByCount) MarshalJSON() ([]byte, error)

type AggregationGroup added in v1.2.0

type AggregationGroup map[string]any

type AttributeSchemaConfig

type AttributeSchemaConfig struct {
	// Whether to create an approximate nearest neighbor index for the attribute.
	Ann bool `json:"ann"`
	// Whether or not the attributes can be used in filters.
	Filterable bool `json:"filterable"`
	// Whether this attribute can be used as part of a BM25 full-text search. Requires
	// the `string` or `[]string` type, and by default, BM25-enabled attributes are not
	// filterable. You can override this by setting `filterable: true`.
	FullTextSearch FullTextSearchConfig `json:"full_text_search"`
	// Whether to enable Regex filters on this attribute.
	Regex bool `json:"regex"`
	// The data type of the attribute. Valid values: string, int, uint, uuid, datetime,
	// bool, []string, []int, []uint, []uuid, []datetime, [DIMS]f16, [DIMS]f32.
	Type AttributeType `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Ann            respjson.Field
		Filterable     respjson.Field
		FullTextSearch respjson.Field
		Regex          respjson.Field
		Type           respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Detailed configuration for an attribute attached to a document.

func (AttributeSchemaConfig) RawJSON

func (r AttributeSchemaConfig) RawJSON() string

Returns the unmodified JSON received from the API

func (AttributeSchemaConfig) ToParam

ToParam converts this AttributeSchemaConfig to a AttributeSchemaConfigParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AttributeSchemaConfigParam.Overrides()

func (*AttributeSchemaConfig) UnmarshalJSON

func (r *AttributeSchemaConfig) UnmarshalJSON(data []byte) error

type AttributeSchemaConfigParam

type AttributeSchemaConfigParam struct {
	// Whether to create an approximate nearest neighbor index for the attribute.
	Ann param.Opt[bool] `json:"ann,omitzero"`
	// Whether or not the attributes can be used in filters.
	Filterable param.Opt[bool] `json:"filterable,omitzero"`
	// Whether to enable Regex filters on this attribute.
	Regex param.Opt[bool] `json:"regex,omitzero"`
	// The data type of the attribute. Valid values: string, int, uint, uuid, datetime,
	// bool, []string, []int, []uint, []uuid, []datetime, [DIMS]f16, [DIMS]f32.
	Type param.Opt[AttributeType] `json:"type,omitzero"`
	// Whether this attribute can be used as part of a BM25 full-text search. Requires
	// the `string` or `[]string` type, and by default, BM25-enabled attributes are not
	// filterable. You can override this by setting `filterable: true`.
	FullTextSearch *FullTextSearchConfigParam `json:"full_text_search,omitzero"`
	// contains filtered or unexported fields
}

Detailed configuration for an attribute attached to a document.

func (AttributeSchemaConfigParam) MarshalJSON

func (r AttributeSchemaConfigParam) MarshalJSON() (data []byte, err error)

func (*AttributeSchemaConfigParam) UnmarshalJSON

func (r *AttributeSchemaConfigParam) UnmarshalJSON(data []byte) error

type AttributeType

type AttributeType = string

type Bm25ClauseParams added in v1.2.0

type Bm25ClauseParams struct {
	// Whether to treat the last token in the query input as a literal prefix.
	LastAsPrefix param.Opt[bool] `json:"last_as_prefix,omitzero"`
	// contains filtered or unexported fields
}

Additional (optional) parameters for a single BM25 query clause.

func (Bm25ClauseParams) MarshalJSON added in v1.2.0

func (r Bm25ClauseParams) MarshalJSON() (data []byte, err error)

func (*Bm25ClauseParams) UnmarshalJSON added in v1.2.0

func (r *Bm25ClauseParams) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	Options []option.RequestOption
}

Client creates a struct with services and top level methods that help with interacting with the turbopuffer API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (TURBOPUFFER_API_KEY, TURBOPUFFER_REGION, TURBOPUFFER_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Namespace

func (r *Client) Namespace(namespace string) Namespace

Namespace creates a new namespace resource.

func (*Client) Namespaces

func (r *Client) Namespaces(ctx context.Context, query NamespacesParams, opts ...option.RequestOption) (res *pagination.NamespacePage[NamespaceSummary], err error)

List namespaces.

func (*Client) NamespacesAutoPaging

List namespaces.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type ColumnsParam

type ColumnsParam map[string][]any

A list of documents in columnar format. Each key is a column name, mapped to an array of values for that column.

type ContainsAllTokensFilterParams added in v1.2.0

type ContainsAllTokensFilterParams struct {
	// Whether to treat the last token in the query input as a literal prefix.
	LastAsPrefix param.Opt[bool] `json:"last_as_prefix,omitzero"`
	// contains filtered or unexported fields
}

Additional (optional) parameters for the ContainsAllTokens filter.

func (ContainsAllTokensFilterParams) MarshalJSON added in v1.2.0

func (r ContainsAllTokensFilterParams) MarshalJSON() (data []byte, err error)

func (*ContainsAllTokensFilterParams) UnmarshalJSON added in v1.2.0

func (r *ContainsAllTokensFilterParams) UnmarshalJSON(data []byte) error

type DistanceMetric

type DistanceMetric string

A function used to calculate vector similarity.

const (
	DistanceMetricCosineDistance   DistanceMetric = "cosine_distance"
	DistanceMetricEuclideanSquared DistanceMetric = "euclidean_squared"
)

type Error

type Error = apierror.Error

type Expr added in v0.1.4

type Expr interface {
	// contains filtered or unexported methods
}

type ExprRefNew added in v0.1.4

type ExprRefNew struct {
	// contains filtered or unexported fields
}

func NewExprRefNew added in v0.1.4

func NewExprRefNew(
	refNew string,
) ExprRefNew

func (ExprRefNew) MarshalJSON added in v0.1.4

func (v ExprRefNew) MarshalJSON() ([]byte, error)

type Filter

type Filter interface {
	// contains filtered or unexported methods
}

type FilterAnd

type FilterAnd struct {
	// contains filtered or unexported fields
}

func NewFilterAnd

func NewFilterAnd(
	filters []Filter,
) FilterAnd

func (FilterAnd) MarshalJSON

func (v FilterAnd) MarshalJSON() ([]byte, error)

type FilterAnyGt added in v1.2.0

type FilterAnyGt struct {
	// contains filtered or unexported fields
}

func NewFilterAnyGt added in v1.2.0

func NewFilterAnyGt(
	attr string,
	value any,
) FilterAnyGt

func (FilterAnyGt) MarshalJSON added in v1.2.0

func (v FilterAnyGt) MarshalJSON() ([]byte, error)

type FilterAnyGte added in v1.2.0

type FilterAnyGte struct {
	// contains filtered or unexported fields
}

func NewFilterAnyGte added in v1.2.0

func NewFilterAnyGte(
	attr string,
	value any,
) FilterAnyGte

func (FilterAnyGte) MarshalJSON added in v1.2.0

func (v FilterAnyGte) MarshalJSON() ([]byte, error)

type FilterAnyLt added in v1.2.0

type FilterAnyLt struct {
	// contains filtered or unexported fields
}

func NewFilterAnyLt added in v1.2.0

func NewFilterAnyLt(
	attr string,
	value any,
) FilterAnyLt

func (FilterAnyLt) MarshalJSON added in v1.2.0

func (v FilterAnyLt) MarshalJSON() ([]byte, error)

type FilterAnyLte added in v1.2.0

type FilterAnyLte struct {
	// contains filtered or unexported fields
}

func NewFilterAnyLte added in v1.2.0

func NewFilterAnyLte(
	attr string,
	value any,
) FilterAnyLte

func (FilterAnyLte) MarshalJSON added in v1.2.0

func (v FilterAnyLte) MarshalJSON() ([]byte, error)

type FilterContains added in v0.1.5

type FilterContains struct {
	// contains filtered or unexported fields
}

func NewFilterContains added in v0.1.5

func NewFilterContains(
	attr string,
	value any,
) FilterContains

func (FilterContains) MarshalJSON added in v0.1.5

func (v FilterContains) MarshalJSON() ([]byte, error)

type FilterContainsAllTokens

type FilterContainsAllTokens struct {
	// contains filtered or unexported fields
}

func NewFilterContainsAllTokens

func NewFilterContainsAllTokens(
	attr string,
	value string,
) FilterContainsAllTokens

func (FilterContainsAllTokens) MarshalJSON

func (v FilterContainsAllTokens) MarshalJSON() ([]byte, error)

type FilterContainsAllTokensArray added in v0.1.4

type FilterContainsAllTokensArray struct {
	// contains filtered or unexported fields
}

func NewFilterContainsAllTokensArray added in v0.1.4

func NewFilterContainsAllTokensArray(
	attr string,
	value []string,
) FilterContainsAllTokensArray

func (FilterContainsAllTokensArray) MarshalJSON added in v0.1.4

func (v FilterContainsAllTokensArray) MarshalJSON() ([]byte, error)

type FilterContainsAllTokensArrayWithParams added in v1.2.0

type FilterContainsAllTokensArrayWithParams struct {
	// contains filtered or unexported fields
}

func NewFilterContainsAllTokensArrayWithParams added in v1.2.0

func NewFilterContainsAllTokensArrayWithParams(
	attr string,
	value []string,
	params ContainsAllTokensFilterParams,
) FilterContainsAllTokensArrayWithParams

func (FilterContainsAllTokensArrayWithParams) MarshalJSON added in v1.2.0

func (v FilterContainsAllTokensArrayWithParams) MarshalJSON() ([]byte, error)

type FilterContainsAllTokensWithParams added in v1.2.0

type FilterContainsAllTokensWithParams struct {
	// contains filtered or unexported fields
}

func NewFilterContainsAllTokensWithParams added in v1.2.0

func NewFilterContainsAllTokensWithParams(
	attr string,
	value string,
	params ContainsAllTokensFilterParams,
) FilterContainsAllTokensWithParams

func (FilterContainsAllTokensWithParams) MarshalJSON added in v1.2.0

func (v FilterContainsAllTokensWithParams) MarshalJSON() ([]byte, error)

type FilterContainsAny added in v0.1.5

type FilterContainsAny[T any] struct {
	// contains filtered or unexported fields
}

func NewFilterContainsAny added in v0.1.5

func NewFilterContainsAny[T any](
	attr string,
	value []T,
) FilterContainsAny[T]

func (FilterContainsAny[T]) MarshalJSON added in v0.1.5

func (v FilterContainsAny[T]) MarshalJSON() ([]byte, error)

type FilterEq

type FilterEq struct {
	// contains filtered or unexported fields
}

func NewFilterEq

func NewFilterEq(
	attr string,
	value any,
) FilterEq

func (FilterEq) MarshalJSON

func (v FilterEq) MarshalJSON() ([]byte, error)

type FilterGlob

type FilterGlob struct {
	// contains filtered or unexported fields
}

func NewFilterGlob

func NewFilterGlob(
	attr string,
	value string,
) FilterGlob

func (FilterGlob) MarshalJSON

func (v FilterGlob) MarshalJSON() ([]byte, error)

type FilterGt

type FilterGt struct {
	// contains filtered or unexported fields
}

func NewFilterGt

func NewFilterGt(
	attr string,
	value any,
) FilterGt

func (FilterGt) MarshalJSON

func (v FilterGt) MarshalJSON() ([]byte, error)

type FilterGte

type FilterGte struct {
	// contains filtered or unexported fields
}

func NewFilterGte

func NewFilterGte(
	attr string,
	value any,
) FilterGte

func (FilterGte) MarshalJSON

func (v FilterGte) MarshalJSON() ([]byte, error)

type FilterIGlob

type FilterIGlob struct {
	// contains filtered or unexported fields
}

func NewFilterIGlob

func NewFilterIGlob(
	attr string,
	value string,
) FilterIGlob

func (FilterIGlob) MarshalJSON

func (v FilterIGlob) MarshalJSON() ([]byte, error)

type FilterIn

type FilterIn[T any] struct {
	// contains filtered or unexported fields
}

func NewFilterIn

func NewFilterIn[T any](
	attr string,
	value []T,
) FilterIn[T]

func (FilterIn[T]) MarshalJSON

func (v FilterIn[T]) MarshalJSON() ([]byte, error)

type FilterLt

type FilterLt struct {
	// contains filtered or unexported fields
}

func NewFilterLt

func NewFilterLt(
	attr string,
	value any,
) FilterLt

func (FilterLt) MarshalJSON

func (v FilterLt) MarshalJSON() ([]byte, error)

type FilterLte

type FilterLte struct {
	// contains filtered or unexported fields
}

func NewFilterLte

func NewFilterLte(
	attr string,
	value any,
) FilterLte

func (FilterLte) MarshalJSON

func (v FilterLte) MarshalJSON() ([]byte, error)

type FilterNot

type FilterNot struct {
	// contains filtered or unexported fields
}

func NewFilterNot

func NewFilterNot(
	filter Filter,
) FilterNot

func (FilterNot) MarshalJSON

func (v FilterNot) MarshalJSON() ([]byte, error)

type FilterNotContains added in v0.1.5

type FilterNotContains struct {
	// contains filtered or unexported fields
}

func NewFilterNotContains added in v0.1.5

func NewFilterNotContains(
	attr string,
	value any,
) FilterNotContains

func (FilterNotContains) MarshalJSON added in v0.1.5

func (v FilterNotContains) MarshalJSON() ([]byte, error)

type FilterNotContainsAny added in v0.1.5

type FilterNotContainsAny[T any] struct {
	// contains filtered or unexported fields
}

func NewFilterNotContainsAny added in v0.1.5

func NewFilterNotContainsAny[T any](
	attr string,
	value []T,
) FilterNotContainsAny[T]

func (FilterNotContainsAny[T]) MarshalJSON added in v0.1.5

func (v FilterNotContainsAny[T]) MarshalJSON() ([]byte, error)

type FilterNotEq

type FilterNotEq struct {
	// contains filtered or unexported fields
}

func NewFilterNotEq

func NewFilterNotEq(
	attr string,
	value any,
) FilterNotEq

func (FilterNotEq) MarshalJSON

func (v FilterNotEq) MarshalJSON() ([]byte, error)

type FilterNotGlob

type FilterNotGlob struct {
	// contains filtered or unexported fields
}

func NewFilterNotGlob

func NewFilterNotGlob(
	attr string,
	value string,
) FilterNotGlob

func (FilterNotGlob) MarshalJSON

func (v FilterNotGlob) MarshalJSON() ([]byte, error)

type FilterNotIGlob

type FilterNotIGlob struct {
	// contains filtered or unexported fields
}

func NewFilterNotIGlob

func NewFilterNotIGlob(
	attr string,
	value string,
) FilterNotIGlob

func (FilterNotIGlob) MarshalJSON

func (v FilterNotIGlob) MarshalJSON() ([]byte, error)

type FilterNotIn

type FilterNotIn[T any] struct {
	// contains filtered or unexported fields
}

func NewFilterNotIn

func NewFilterNotIn[T any](
	attr string,
	value []T,
) FilterNotIn[T]

func (FilterNotIn[T]) MarshalJSON

func (v FilterNotIn[T]) MarshalJSON() ([]byte, error)

type FilterOr

type FilterOr struct {
	// contains filtered or unexported fields
}

func NewFilterOr

func NewFilterOr(
	filters []Filter,
) FilterOr

func (FilterOr) MarshalJSON

func (v FilterOr) MarshalJSON() ([]byte, error)

type FilterRegex added in v0.1.12

type FilterRegex struct {
	// contains filtered or unexported fields
}

func NewFilterRegex added in v0.1.12

func NewFilterRegex(
	attr string,
	value string,
) FilterRegex

func (FilterRegex) MarshalJSON added in v0.1.12

func (v FilterRegex) MarshalJSON() ([]byte, error)

type FullTextSearchConfig

type FullTextSearchConfig struct {
	// The `b` document length normalization parameter for BM25. Defaults to `0.75`.
	B float64 `json:"b"`
	// Whether searching is case-sensitive. Defaults to `false` (i.e.
	// case-insensitive).
	CaseSensitive bool `json:"case_sensitive"`
	// The `k1` term saturation parameter for BM25. Defaults to `1.2`.
	K1 float64 `json:"k1"`
	// Describes the language of a text attribute. Defaults to `english`.
	//
	// Any of "arabic", "danish", "dutch", "english", "finnish", "french", "german",
	// "greek", "hungarian", "italian", "norwegian", "portuguese", "romanian",
	// "russian", "spanish", "swedish", "tamil", "turkish".
	Language Language `json:"language"`
	// Maximum length of a token in bytes. Tokens larger than this value during
	// tokenization will be filtered out. Has to be between `1` and `254` (inclusive).
	// Defaults to `39`.
	MaxTokenLength int64 `json:"max_token_length"`
	// Removes common words from the text based on language. Defaults to `true` (i.e.
	// remove common words).
	RemoveStopwords bool `json:"remove_stopwords"`
	// Language-specific stemming for the text. Defaults to `false` (i.e., do not
	// stem).
	Stemming bool `json:"stemming"`
	// The tokenizer to use for full-text search on an attribute. Defaults to
	// `word_v2`.
	//
	// Any of "pre_tokenized_array", "word_v0", "word_v1", "word_v2".
	Tokenizer Tokenizer `json:"tokenizer"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		B               respjson.Field
		CaseSensitive   respjson.Field
		K1              respjson.Field
		Language        respjson.Field
		MaxTokenLength  respjson.Field
		RemoveStopwords respjson.Field
		Stemming        respjson.Field
		Tokenizer       respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Configuration options for full-text search.

func (FullTextSearchConfig) RawJSON

func (r FullTextSearchConfig) RawJSON() string

Returns the unmodified JSON received from the API

func (FullTextSearchConfig) ToParam

ToParam converts this FullTextSearchConfig to a FullTextSearchConfigParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with FullTextSearchConfigParam.Overrides()

func (*FullTextSearchConfig) UnmarshalJSON

func (r *FullTextSearchConfig) UnmarshalJSON(data []byte) error

type FullTextSearchConfigParam

type FullTextSearchConfigParam struct {
	// The `b` document length normalization parameter for BM25. Defaults to `0.75`.
	B param.Opt[float64] `json:"b,omitzero"`
	// Whether searching is case-sensitive. Defaults to `false` (i.e.
	// case-insensitive).
	CaseSensitive param.Opt[bool] `json:"case_sensitive,omitzero"`
	// The `k1` term saturation parameter for BM25. Defaults to `1.2`.
	K1 param.Opt[float64] `json:"k1,omitzero"`
	// Removes common words from the text based on language. Defaults to `true` (i.e.
	// remove common words).
	RemoveStopwords param.Opt[bool] `json:"remove_stopwords,omitzero"`
	// Language-specific stemming for the text. Defaults to `false` (i.e., do not
	// stem).
	Stemming param.Opt[bool] `json:"stemming,omitzero"`
	// Describes the language of a text attribute. Defaults to `english`.
	//
	// Any of "arabic", "danish", "dutch", "english", "finnish", "french", "german",
	// "greek", "hungarian", "italian", "norwegian", "portuguese", "romanian",
	// "russian", "spanish", "swedish", "tamil", "turkish".
	Language Language `json:"language,omitzero"`
	// Maximum length of a token in bytes. Tokens larger than this value during
	// tokenization will be filtered out. Has to be between `1` and `254` (inclusive).
	// Defaults to `39`.
	MaxTokenLength param.Opt[int64] `json:"max_token_length,omitzero"`
	// The tokenizer to use for full-text search on an attribute. Defaults to
	// `word_v2`.
	//
	// Any of "pre_tokenized_array", "word_v0", "word_v1", "word_v2".
	Tokenizer Tokenizer `json:"tokenizer,omitzero"`
	// contains filtered or unexported fields
}

Configuration options for full-text search.

func (FullTextSearchConfigParam) MarshalJSON

func (r FullTextSearchConfigParam) MarshalJSON() (data []byte, err error)

func (*FullTextSearchConfigParam) UnmarshalJSON

func (r *FullTextSearchConfigParam) UnmarshalJSON(data []byte) error

type ID

type ID struct {
	// This field will be present if the value is a [string] instead of an object.
	String string `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	Int  int64 `json:",inline"`
	JSON struct {
		String respjson.Field
		Int    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ID contains all possible properties and values from [string], [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: String Int]

func (ID) AsInt

func (u ID) AsInt() (v int64)

func (ID) AsString

func (u ID) AsString() (v string)

func (ID) RawJSON

func (u ID) RawJSON() string

Returns the unmodified JSON received from the API

func (ID) ToParam

func (r ID) ToParam() IDParam

ToParam converts this ID to a IDParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with IDParam.Overrides()

func (*ID) UnmarshalJSON

func (r *ID) UnmarshalJSON(data []byte) error

type IDParam

type IDParam struct {
	String param.Opt[string] `json:",omitzero,inline"`
	Int    param.Opt[int64]  `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (IDParam) MarshalJSON

func (u IDParam) MarshalJSON() ([]byte, error)

func (*IDParam) UnmarshalJSON

func (u *IDParam) UnmarshalJSON(data []byte) error

type IncludeAttributesParam

type IncludeAttributesParam struct {
	Bool        param.Opt[bool] `json:",omitzero,inline"`
	StringArray []string        `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (IncludeAttributesParam) MarshalJSON

func (u IncludeAttributesParam) MarshalJSON() ([]byte, error)

func (*IncludeAttributesParam) UnmarshalJSON

func (u *IncludeAttributesParam) UnmarshalJSON(data []byte) error

type Language

type Language string

Describes the language of a text attribute. Defaults to `english`.

const (
	LanguageArabic     Language = "arabic"
	LanguageDanish     Language = "danish"
	LanguageDutch      Language = "dutch"
	LanguageEnglish    Language = "english"
	LanguageFinnish    Language = "finnish"
	LanguageFrench     Language = "french"
	LanguageGerman     Language = "german"
	LanguageGreek      Language = "greek"
	LanguageHungarian  Language = "hungarian"
	LanguageItalian    Language = "italian"
	LanguageNorwegian  Language = "norwegian"
	LanguagePortuguese Language = "portuguese"
	LanguageRomanian   Language = "romanian"
	LanguageRussian    Language = "russian"
	LanguageSpanish    Language = "spanish"
	LanguageSwedish    Language = "swedish"
	LanguageTamil      Language = "tamil"
	LanguageTurkish    Language = "turkish"
)

type Namespace

type Namespace struct {
	NamespaceService
}

Represents a turbopuffer namespace.

type NamespaceDeleteAllParams

type NamespaceDeleteAllParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// contains filtered or unexported fields
}

type NamespaceDeleteAllResponse

type NamespaceDeleteAllResponse struct {
	// The status of the request.
	Status constant.Ok `json:"status,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response to a successful namespace deletion request.

func (NamespaceDeleteAllResponse) RawJSON

func (r NamespaceDeleteAllResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceDeleteAllResponse) UnmarshalJSON

func (r *NamespaceDeleteAllResponse) UnmarshalJSON(data []byte) error

type NamespaceExplainQueryParams added in v0.1.14

type NamespaceExplainQueryParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// The number of results to return.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Aggregations to compute over all documents in the namespace that match the
	// filters.
	AggregateBy map[string]AggregateBy `json:"aggregate_by,omitzero"`
	// The consistency level for a query.
	Consistency NamespaceExplainQueryParamsConsistency `json:"consistency,omitzero"`
	// A function used to calculate vector similarity.
	//
	// Any of "cosine_distance", "euclidean_squared".
	DistanceMetric DistanceMetric `json:"distance_metric,omitzero"`
	// List of attribute names to exclude from the response. All other attributes will
	// be included in the response.
	ExcludeAttributes []string `json:"exclude_attributes,omitzero"`
	// Exact filters for attributes to refine search results for. Think of it as a SQL
	// WHERE clause.
	Filters Filter `json:"filters,omitzero"`
	// Groups documents by the specified attributes (the "group key") before computing
	// aggregates. Aggregates are computed separately for each group.
	GroupBy []string `json:"group_by,omitzero"`
	// Whether to include attributes in the response.
	IncludeAttributes IncludeAttributesParam `json:"include_attributes,omitzero"`
	// How to rank the documents in the namespace.
	RankBy RankBy `json:"rank_by,omitzero"`
	// The encoding to use for vectors in the response.
	//
	// Any of "float", "base64".
	VectorEncoding VectorEncoding `json:"vector_encoding,omitzero"`
	// contains filtered or unexported fields
}

func (NamespaceExplainQueryParams) MarshalJSON added in v0.1.14

func (r NamespaceExplainQueryParams) MarshalJSON() (data []byte, err error)

func (*NamespaceExplainQueryParams) UnmarshalJSON added in v0.1.14

func (r *NamespaceExplainQueryParams) UnmarshalJSON(data []byte) error

type NamespaceExplainQueryParamsConsistency added in v0.1.14

type NamespaceExplainQueryParamsConsistency struct {
	// The query's consistency level.
	//
	// Any of "strong", "eventual".
	Level NamespaceExplainQueryParamsConsistencyLevel `json:"level,omitzero"`
	// contains filtered or unexported fields
}

The consistency level for a query.

func (NamespaceExplainQueryParamsConsistency) MarshalJSON added in v0.1.14

func (r NamespaceExplainQueryParamsConsistency) MarshalJSON() (data []byte, err error)

func (*NamespaceExplainQueryParamsConsistency) UnmarshalJSON added in v0.1.14

func (r *NamespaceExplainQueryParamsConsistency) UnmarshalJSON(data []byte) error

type NamespaceExplainQueryParamsConsistencyLevel added in v0.1.14

type NamespaceExplainQueryParamsConsistencyLevel string

The query's consistency level.

const (
	NamespaceExplainQueryParamsConsistencyLevelStrong   NamespaceExplainQueryParamsConsistencyLevel = "strong"
	NamespaceExplainQueryParamsConsistencyLevelEventual NamespaceExplainQueryParamsConsistencyLevel = "eventual"
)

type NamespaceExplainQueryResponse added in v0.1.14

type NamespaceExplainQueryResponse struct {
	// The textual representation of the query plan.
	PlanText string `json:"plan_text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		PlanText    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response to a successful query explain.

func (NamespaceExplainQueryResponse) RawJSON added in v0.1.14

Returns the unmodified JSON received from the API

func (*NamespaceExplainQueryResponse) UnmarshalJSON added in v0.1.14

func (r *NamespaceExplainQueryResponse) UnmarshalJSON(data []byte) error

type NamespaceHintCacheWarmParams

type NamespaceHintCacheWarmParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// contains filtered or unexported fields
}

type NamespaceHintCacheWarmResponse

type NamespaceHintCacheWarmResponse struct {
	// The status of the request.
	Status  constant.Accepted `json:"status,required"`
	Message string            `json:"message"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response to a successful cache warm request.

func (NamespaceHintCacheWarmResponse) RawJSON

Returns the unmodified JSON received from the API

func (*NamespaceHintCacheWarmResponse) UnmarshalJSON

func (r *NamespaceHintCacheWarmResponse) UnmarshalJSON(data []byte) error

type NamespaceMetadata added in v0.1.7

type NamespaceMetadata struct {
	// The approximate number of logical bytes in the namespace.
	ApproxLogicalBytes int64 `json:"approx_logical_bytes,required"`
	// The approximate number of rows in the namespace.
	ApproxRowCount int64 `json:"approx_row_count,required"`
	// The timestamp when the namespace was created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// The schema of the namespace.
	Schema map[string]AttributeSchemaConfig `json:"schema,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ApproxLogicalBytes respjson.Field
		ApproxRowCount     respjson.Field
		CreatedAt          respjson.Field
		Schema             respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Metadata about a namespace.

func (NamespaceMetadata) RawJSON added in v0.1.7

func (r NamespaceMetadata) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceMetadata) UnmarshalJSON added in v0.1.7

func (r *NamespaceMetadata) UnmarshalJSON(data []byte) error

type NamespaceMetadataParams added in v0.1.7

type NamespaceMetadataParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// contains filtered or unexported fields
}

type NamespaceMultiQueryParams added in v0.1.1

type NamespaceMultiQueryParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	Queries   []QueryParam      `json:"queries,omitzero,required"`
	// The consistency level for a query.
	Consistency NamespaceMultiQueryParamsConsistency `json:"consistency,omitzero"`
	// The encoding to use for vectors in the response.
	//
	// Any of "float", "base64".
	VectorEncoding VectorEncoding `json:"vector_encoding,omitzero"`
	// contains filtered or unexported fields
}

func (NamespaceMultiQueryParams) MarshalJSON added in v0.1.1

func (r NamespaceMultiQueryParams) MarshalJSON() (data []byte, err error)

func (*NamespaceMultiQueryParams) UnmarshalJSON added in v0.1.1

func (r *NamespaceMultiQueryParams) UnmarshalJSON(data []byte) error

type NamespaceMultiQueryParamsConsistency added in v0.1.1

type NamespaceMultiQueryParamsConsistency struct {
	// The query's consistency level.
	//
	// Any of "strong", "eventual".
	Level NamespaceMultiQueryParamsConsistencyLevel `json:"level,omitzero"`
	// contains filtered or unexported fields
}

The consistency level for a query.

func (NamespaceMultiQueryParamsConsistency) MarshalJSON added in v0.1.1

func (r NamespaceMultiQueryParamsConsistency) MarshalJSON() (data []byte, err error)

func (*NamespaceMultiQueryParamsConsistency) UnmarshalJSON added in v0.1.1

func (r *NamespaceMultiQueryParamsConsistency) UnmarshalJSON(data []byte) error

type NamespaceMultiQueryParamsConsistencyLevel added in v0.1.1

type NamespaceMultiQueryParamsConsistencyLevel string

The query's consistency level.

const (
	NamespaceMultiQueryParamsConsistencyLevelStrong   NamespaceMultiQueryParamsConsistencyLevel = "strong"
	NamespaceMultiQueryParamsConsistencyLevelEventual NamespaceMultiQueryParamsConsistencyLevel = "eventual"
)

type NamespaceMultiQueryResponse added in v0.1.1

type NamespaceMultiQueryResponse struct {
	// The billing information for a query.
	Billing QueryBilling `json:"billing,required"`
	// The performance information for a query.
	Performance QueryPerformance                    `json:"performance,required"`
	Results     []NamespaceMultiQueryResponseResult `json:"results,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Billing     respjson.Field
		Performance respjson.Field
		Results     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The result of a multi-query.

func (NamespaceMultiQueryResponse) RawJSON added in v0.1.1

func (r NamespaceMultiQueryResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceMultiQueryResponse) UnmarshalJSON added in v0.1.1

func (r *NamespaceMultiQueryResponse) UnmarshalJSON(data []byte) error

type NamespaceMultiQueryResponseResult added in v0.1.1

type NamespaceMultiQueryResponseResult struct {
	AggregationGroups []AggregationGroup `json:"aggregation_groups"`
	Aggregations      map[string]any     `json:"aggregations"`
	Rows              []Row              `json:"rows"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AggregationGroups respjson.Field
		Aggregations      respjson.Field
		Rows              respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (NamespaceMultiQueryResponseResult) RawJSON added in v0.1.1

Returns the unmodified JSON received from the API

func (*NamespaceMultiQueryResponseResult) UnmarshalJSON added in v0.1.1

func (r *NamespaceMultiQueryResponseResult) UnmarshalJSON(data []byte) error

type NamespaceQueryParams

type NamespaceQueryParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// The number of results to return.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Aggregations to compute over all documents in the namespace that match the
	// filters.
	AggregateBy map[string]AggregateBy `json:"aggregate_by,omitzero"`
	// The consistency level for a query.
	Consistency NamespaceQueryParamsConsistency `json:"consistency,omitzero"`
	// A function used to calculate vector similarity.
	//
	// Any of "cosine_distance", "euclidean_squared".
	DistanceMetric DistanceMetric `json:"distance_metric,omitzero"`
	// List of attribute names to exclude from the response. All other attributes will
	// be included in the response.
	ExcludeAttributes []string `json:"exclude_attributes,omitzero"`
	// Exact filters for attributes to refine search results for. Think of it as a SQL
	// WHERE clause.
	Filters Filter `json:"filters,omitzero"`
	// Groups documents by the specified attributes (the "group key") before computing
	// aggregates. Aggregates are computed separately for each group.
	GroupBy []string `json:"group_by,omitzero"`
	// Whether to include attributes in the response.
	IncludeAttributes IncludeAttributesParam `json:"include_attributes,omitzero"`
	// How to rank the documents in the namespace.
	RankBy RankBy `json:"rank_by,omitzero"`
	// The encoding to use for vectors in the response.
	//
	// Any of "float", "base64".
	VectorEncoding VectorEncoding `json:"vector_encoding,omitzero"`
	// contains filtered or unexported fields
}

func (NamespaceQueryParams) MarshalJSON

func (r NamespaceQueryParams) MarshalJSON() (data []byte, err error)

func (*NamespaceQueryParams) UnmarshalJSON

func (r *NamespaceQueryParams) UnmarshalJSON(data []byte) error

type NamespaceQueryParamsConsistency

type NamespaceQueryParamsConsistency struct {
	// The query's consistency level.
	//
	// Any of "strong", "eventual".
	Level NamespaceQueryParamsConsistencyLevel `json:"level,omitzero"`
	// contains filtered or unexported fields
}

The consistency level for a query.

func (NamespaceQueryParamsConsistency) MarshalJSON

func (r NamespaceQueryParamsConsistency) MarshalJSON() (data []byte, err error)

func (*NamespaceQueryParamsConsistency) UnmarshalJSON

func (r *NamespaceQueryParamsConsistency) UnmarshalJSON(data []byte) error

type NamespaceQueryParamsConsistencyLevel

type NamespaceQueryParamsConsistencyLevel string

The query's consistency level.

const (
	NamespaceQueryParamsConsistencyLevelStrong   NamespaceQueryParamsConsistencyLevel = "strong"
	NamespaceQueryParamsConsistencyLevelEventual NamespaceQueryParamsConsistencyLevel = "eventual"
)

type NamespaceQueryResponse

type NamespaceQueryResponse struct {
	// The billing information for a query.
	Billing QueryBilling `json:"billing,required"`
	// The performance information for a query.
	Performance       QueryPerformance   `json:"performance,required"`
	AggregationGroups []AggregationGroup `json:"aggregation_groups"`
	Aggregations      map[string]any     `json:"aggregations"`
	Rows              []Row              `json:"rows"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Billing           respjson.Field
		Performance       respjson.Field
		AggregationGroups respjson.Field
		Aggregations      respjson.Field
		Rows              respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The result of a query.

func (NamespaceQueryResponse) RawJSON

func (r NamespaceQueryResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceQueryResponse) UnmarshalJSON

func (r *NamespaceQueryResponse) UnmarshalJSON(data []byte) error

type NamespaceRecallParams

type NamespaceRecallParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// Include ground truth data (query vectors and true nearest neighbors) in the
	// response.
	IncludeGroundTruth param.Opt[bool] `json:"include_ground_truth,omitzero"`
	// The number of searches to run.
	Num param.Opt[int64] `json:"num,omitzero"`
	// Search for `top_k` nearest neighbors.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Filter by attributes. Same syntax as the query endpoint.
	Filters any `json:"filters,omitzero"`
	// Use specific query vectors for the measurement. If omitted, sampled from the
	// index.
	Queries []float32 `json:"queries,omitzero"`
	// contains filtered or unexported fields
}

func (NamespaceRecallParams) MarshalJSON

func (r NamespaceRecallParams) MarshalJSON() (data []byte, err error)

func (*NamespaceRecallParams) UnmarshalJSON

func (r *NamespaceRecallParams) UnmarshalJSON(data []byte) error

type NamespaceRecallResponse

type NamespaceRecallResponse struct {
	// The average number of documents retrieved by the approximate nearest neighbor
	// searches.
	AvgAnnCount float64 `json:"avg_ann_count,required"`
	// The average number of documents retrieved by the exhaustive searches.
	AvgExhaustiveCount float64 `json:"avg_exhaustive_count,required"`
	// The average recall of the queries.
	AvgRecall float64 `json:"avg_recall,required"`
	// Ground truth data including query vectors and true nearest neighbors. Only
	// included when include_ground_truth is true.
	GroundTruth []NamespaceRecallResponseGroundTruth `json:"ground_truth"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AvgAnnCount        respjson.Field
		AvgExhaustiveCount respjson.Field
		AvgRecall          respjson.Field
		GroundTruth        respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response to a successful cache warm request.

func (NamespaceRecallResponse) RawJSON

func (r NamespaceRecallResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceRecallResponse) UnmarshalJSON

func (r *NamespaceRecallResponse) UnmarshalJSON(data []byte) error

type NamespaceRecallResponseGroundTruth added in v1.2.0

type NamespaceRecallResponseGroundTruth struct {
	// The true nearest neighbors with their distances and vectors.
	NearestNeighbors []Row `json:"nearest_neighbors,required"`
	// The query vector used for this search.
	QueryVector []float64 `json:"query_vector,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		NearestNeighbors respjson.Field
		QueryVector      respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (NamespaceRecallResponseGroundTruth) RawJSON added in v1.2.0

Returns the unmodified JSON received from the API

func (*NamespaceRecallResponseGroundTruth) UnmarshalJSON added in v1.2.0

func (r *NamespaceRecallResponseGroundTruth) UnmarshalJSON(data []byte) error

type NamespaceSchemaParams

type NamespaceSchemaParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// contains filtered or unexported fields
}

type NamespaceSchemaResponse

type NamespaceSchemaResponse map[string]AttributeSchemaConfig

type NamespaceService

type NamespaceService struct {
	Options []option.RequestOption
}

NamespaceService contains methods and other services that help with interacting with the turbopuffer API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the [NewNamespaceService] method instead.

func (*NamespaceService) DeleteAll

Delete namespace.

func (*NamespaceService) ExplainQuery added in v0.1.14

Explain a query plan.

func (*NamespaceService) HintCacheWarm

Warm the cache for a namespace.

func (*NamespaceService) ID

func (r *NamespaceService) ID() string

func (*NamespaceService) Metadata added in v0.1.7

Get metadata about a namespace.

func (*NamespaceService) MultiQuery added in v0.1.1

Issue multiple concurrent queries filter or search documents.

func (*NamespaceService) Query

Query, filter, full-text search and vector search documents.

func (*NamespaceService) Recall

Evaluate recall.

func (*NamespaceService) Schema

Get namespace schema.

func (*NamespaceService) UpdateSchema

Update namespace schema.

func (*NamespaceService) Write

Create, update, or delete documents.

type NamespaceSummary

type NamespaceSummary struct {
	// The namespace ID.
	ID string `json:"id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A summary of a namespace.

func (NamespaceSummary) RawJSON

func (r NamespaceSummary) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceSummary) UnmarshalJSON

func (r *NamespaceSummary) UnmarshalJSON(data []byte) error

type NamespaceUpdateSchemaParams

type NamespaceUpdateSchemaParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// The desired schema for the namespace.
	Schema map[string]AttributeSchemaConfigParam
	// contains filtered or unexported fields
}

func (NamespaceUpdateSchemaParams) MarshalJSON

func (r NamespaceUpdateSchemaParams) MarshalJSON() (data []byte, err error)

func (*NamespaceUpdateSchemaParams) UnmarshalJSON

func (r *NamespaceUpdateSchemaParams) UnmarshalJSON(data []byte) error

type NamespaceUpdateSchemaResponse

type NamespaceUpdateSchemaResponse map[string]AttributeSchemaConfig

type NamespaceWriteParams

type NamespaceWriteParams struct {
	Namespace param.Opt[string] `path:"namespace,omitzero,required" json:"-"`
	// The namespace to copy documents from.
	CopyFromNamespace param.Opt[string] `json:"copy_from_namespace,omitzero"`
	// The filter specifying which documents to delete.
	DeleteByFilter Filter `json:"delete_by_filter,omitzero"`
	// A condition evaluated against the current value of each document targeted by a
	// delete write. Only documents that pass the condition are deleted.
	DeleteCondition Filter `json:"delete_condition,omitzero"`
	Deletes         []any  `json:"deletes,omitzero"`
	// A function used to calculate vector similarity.
	//
	// Any of "cosine_distance", "euclidean_squared".
	DistanceMetric DistanceMetric `json:"distance_metric,omitzero"`
	// The encryption configuration for a namespace.
	Encryption NamespaceWriteParamsEncryption `json:"encryption,omitzero"`
	// A list of documents in columnar format. Each key is a column name, mapped to an
	// array of values for that column.
	PatchColumns ColumnsParam `json:"patch_columns,omitzero"`
	// A condition evaluated against the current value of each document targeted by a
	// patch write. Only documents that pass the condition are patched.
	PatchCondition Filter     `json:"patch_condition,omitzero"`
	PatchRows      []RowParam `json:"patch_rows,omitzero"`
	// The schema of the attributes attached to the documents.
	Schema map[string]AttributeSchemaConfigParam `json:"schema,omitzero"`
	// A list of documents in columnar format. Each key is a column name, mapped to an
	// array of values for that column.
	UpsertColumns ColumnsParam `json:"upsert_columns,omitzero"`
	// A condition evaluated against the current value of each document targeted by an
	// upsert write. Only documents that pass the condition are upserted.
	UpsertCondition Filter     `json:"upsert_condition,omitzero"`
	UpsertRows      []RowParam `json:"upsert_rows,omitzero"`
	// contains filtered or unexported fields
}

func (NamespaceWriteParams) MarshalJSON

func (r NamespaceWriteParams) MarshalJSON() (data []byte, err error)

func (*NamespaceWriteParams) UnmarshalJSON

func (r *NamespaceWriteParams) UnmarshalJSON(data []byte) error

type NamespaceWriteParamsEncryption

type NamespaceWriteParamsEncryption struct {
	Cmek NamespaceWriteParamsEncryptionCmek `json:"cmek,omitzero"`
	// contains filtered or unexported fields
}

The encryption configuration for a namespace.

func (NamespaceWriteParamsEncryption) MarshalJSON

func (r NamespaceWriteParamsEncryption) MarshalJSON() (data []byte, err error)

func (*NamespaceWriteParamsEncryption) UnmarshalJSON

func (r *NamespaceWriteParamsEncryption) UnmarshalJSON(data []byte) error

type NamespaceWriteParamsEncryptionCmek

type NamespaceWriteParamsEncryptionCmek struct {
	// The identifier of the CMEK key to use for encryption. For GCP, the
	// fully-qualified resource name of the key. For AWS, the ARN of the key.
	KeyName string `json:"key_name,required"`
	// contains filtered or unexported fields
}

The property KeyName is required.

func (NamespaceWriteParamsEncryptionCmek) MarshalJSON

func (r NamespaceWriteParamsEncryptionCmek) MarshalJSON() (data []byte, err error)

func (*NamespaceWriteParamsEncryptionCmek) UnmarshalJSON

func (r *NamespaceWriteParamsEncryptionCmek) UnmarshalJSON(data []byte) error

type NamespaceWriteResponse

type NamespaceWriteResponse struct {
	// The billing information for a write request.
	Billing WriteBilling `json:"billing,required"`
	// A message describing the result of the write request.
	Message string `json:"message,required"`
	// The number of rows affected by the write request.
	RowsAffected int64 `json:"rows_affected,required"`
	// The status of the request.
	Status constant.Ok `json:"status,required"`
	// The number of rows deleted by the write request.
	RowsDeleted int64 `json:"rows_deleted"`
	// The number of rows patched by the write request.
	RowsPatched int64 `json:"rows_patched"`
	// The number of rows upserted by the write request.
	RowsUpserted int64 `json:"rows_upserted"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Billing      respjson.Field
		Message      respjson.Field
		RowsAffected respjson.Field
		Status       respjson.Field
		RowsDeleted  respjson.Field
		RowsPatched  respjson.Field
		RowsUpserted respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response to a successful write request.

func (NamespaceWriteResponse) RawJSON

func (r NamespaceWriteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*NamespaceWriteResponse) UnmarshalJSON

func (r *NamespaceWriteResponse) UnmarshalJSON(data []byte) error

type NamespacesParams

type NamespacesParams struct {
	// Retrieve the next page of results.
	Cursor param.Opt[string] `query:"cursor,omitzero" json:"-"`
	// Limit the number of results per page.
	PageSize param.Opt[int64] `query:"page_size,omitzero" json:"-"`
	// Retrieve only the namespaces that match the prefix.
	Prefix param.Opt[string] `query:"prefix,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (NamespacesParams) URLQuery

func (r NamespacesParams) URLQuery() (v url.Values, err error)

URLQuery serializes NamespacesParams's query parameters as `url.Values`.

type QueryBilling

type QueryBilling struct {
	// The number of billable logical bytes queried from the namespace.
	BillableLogicalBytesQueried int64 `json:"billable_logical_bytes_queried,required"`
	// The number of billable logical bytes returned from the query.
	BillableLogicalBytesReturned int64 `json:"billable_logical_bytes_returned,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BillableLogicalBytesQueried  respjson.Field
		BillableLogicalBytesReturned respjson.Field
		ExtraFields                  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The billing information for a query.

func (QueryBilling) RawJSON

func (r QueryBilling) RawJSON() string

Returns the unmodified JSON received from the API

func (*QueryBilling) UnmarshalJSON

func (r *QueryBilling) UnmarshalJSON(data []byte) error

type QueryParam added in v0.1.3

type QueryParam struct {
	// The number of results to return.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Aggregations to compute over all documents in the namespace that match the
	// filters.
	AggregateBy map[string]AggregateBy `json:"aggregate_by,omitzero"`
	// A function used to calculate vector similarity.
	//
	// Any of "cosine_distance", "euclidean_squared".
	DistanceMetric DistanceMetric `json:"distance_metric,omitzero"`
	// List of attribute names to exclude from the response. All other attributes will
	// be included in the response.
	ExcludeAttributes []string `json:"exclude_attributes,omitzero"`
	// Exact filters for attributes to refine search results for. Think of it as a SQL
	// WHERE clause.
	Filters Filter `json:"filters,omitzero"`
	// Groups documents by the specified attributes (the "group key") before computing
	// aggregates. Aggregates are computed separately for each group.
	GroupBy []string `json:"group_by,omitzero"`
	// Whether to include attributes in the response.
	IncludeAttributes IncludeAttributesParam `json:"include_attributes,omitzero"`
	// How to rank the documents in the namespace.
	RankBy RankBy `json:"rank_by,omitzero"`
	// contains filtered or unexported fields
}

Query, filter, full-text search and vector search documents.

func (QueryParam) MarshalJSON added in v0.1.3

func (r QueryParam) MarshalJSON() (data []byte, err error)

func (*QueryParam) UnmarshalJSON added in v0.1.3

func (r *QueryParam) UnmarshalJSON(data []byte) error

type QueryPerformance

type QueryPerformance struct {
	// the approximate number of documents in the namespace.
	ApproxNamespaceSize int64 `json:"approx_namespace_size,required"`
	// The ratio of cache hits to total cache lookups.
	CacheHitRatio float64 `json:"cache_hit_ratio,required"`
	// A qualitative description of the cache hit ratio (`hot`, `warm`, or `cold`).
	CacheTemperature string `json:"cache_temperature,required"`
	// The number of unindexed documents processed by the query.
	ExhaustiveSearchCount int64 `json:"exhaustive_search_count,required"`
	// Request time measured on the server, excluding time spent waiting due to the
	// namespace concurrency limit.
	QueryExecutionMs int64 `json:"query_execution_ms,required"`
	// Request time measured on the server, including time spent waiting for other
	// queries to complete if the namespace was at its concurrency limit.
	ServerTotalMs int64 `json:"server_total_ms,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ApproxNamespaceSize   respjson.Field
		CacheHitRatio         respjson.Field
		CacheTemperature      respjson.Field
		ExhaustiveSearchCount respjson.Field
		QueryExecutionMs      respjson.Field
		ServerTotalMs         respjson.Field
		ExtraFields           map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The performance information for a query.

func (QueryPerformance) RawJSON

func (r QueryPerformance) RawJSON() string

Returns the unmodified JSON received from the API

func (*QueryPerformance) UnmarshalJSON

func (r *QueryPerformance) UnmarshalJSON(data []byte) error

type RankBy

type RankBy interface {
	// contains filtered or unexported methods
}

type RankByAttribute

type RankByAttribute struct {
	// contains filtered or unexported fields
}

func NewRankByAttribute

func NewRankByAttribute(
	attr string,
	order RankByAttributeOrder,
) RankByAttribute

func (RankByAttribute) MarshalJSON

func (v RankByAttribute) MarshalJSON() ([]byte, error)

type RankByAttributeOrder

type RankByAttributeOrder string
const (
	RankByAttributeOrderAsc  RankByAttributeOrder = "asc"
	RankByAttributeOrderDesc RankByAttributeOrder = "desc"
)

type RankByText

type RankByText interface {
	// contains filtered or unexported methods
}

type RankByTextBM25

type RankByTextBM25 struct {
	// contains filtered or unexported fields
}

func NewRankByTextBM25

func NewRankByTextBM25(
	attr string,
	value string,
) RankByTextBM25

func (RankByTextBM25) MarshalJSON

func (v RankByTextBM25) MarshalJSON() ([]byte, error)

type RankByTextBM25Array

type RankByTextBM25Array struct {
	// contains filtered or unexported fields
}

func NewRankByTextBM25Array

func NewRankByTextBM25Array(
	attr string,
	value []string,
) RankByTextBM25Array

func (RankByTextBM25Array) MarshalJSON

func (v RankByTextBM25Array) MarshalJSON() ([]byte, error)

type RankByTextBM25ArrayWithParams added in v1.2.0

type RankByTextBM25ArrayWithParams struct {
	// contains filtered or unexported fields
}

func NewRankByTextBM25ArrayWithParams added in v1.2.0

func NewRankByTextBM25ArrayWithParams(
	attr string,
	value []string,
	params Bm25ClauseParams,
) RankByTextBM25ArrayWithParams

func (RankByTextBM25ArrayWithParams) MarshalJSON added in v1.2.0

func (v RankByTextBM25ArrayWithParams) MarshalJSON() ([]byte, error)

type RankByTextBM25WithParams added in v1.2.0

type RankByTextBM25WithParams struct {
	// contains filtered or unexported fields
}

func NewRankByTextBM25WithParams added in v1.2.0

func NewRankByTextBM25WithParams(
	attr string,
	value string,
	params Bm25ClauseParams,
) RankByTextBM25WithParams

func (RankByTextBM25WithParams) MarshalJSON added in v1.2.0

func (v RankByTextBM25WithParams) MarshalJSON() ([]byte, error)

type RankByTextMax

type RankByTextMax struct {
	// contains filtered or unexported fields
}

func NewRankByTextMax

func NewRankByTextMax(
	subqueries []RankByText,
) RankByTextMax

func (RankByTextMax) MarshalJSON

func (v RankByTextMax) MarshalJSON() ([]byte, error)

type RankByTextProduct

type RankByTextProduct struct {
	// contains filtered or unexported fields
}

func NewRankByTextProduct

func NewRankByTextProduct(
	weight float64,
	subquery RankByText,
) RankByTextProduct

func (RankByTextProduct) MarshalJSON

func (v RankByTextProduct) MarshalJSON() ([]byte, error)

type RankByTextSum

type RankByTextSum struct {
	// contains filtered or unexported fields
}

func NewRankByTextSum

func NewRankByTextSum(
	subqueries []RankByText,
) RankByTextSum

func (RankByTextSum) MarshalJSON

func (v RankByTextSum) MarshalJSON() ([]byte, error)

type RankByVector

type RankByVector struct {
	// contains filtered or unexported fields
}

func NewRankByVector

func NewRankByVector(
	attr string,
	value []float32,
) RankByVector

func (RankByVector) MarshalJSON

func (v RankByVector) MarshalJSON() ([]byte, error)

type Row

type Row map[string]any

A single document, in a row-based format.

type RowParam

type RowParam Row

type Tokenizer

type Tokenizer string

The tokenizer to use for full-text search on an attribute. Defaults to `word_v2`.

const (
	TokenizerPreTokenizedArray Tokenizer = "pre_tokenized_array"
	TokenizerWordV0            Tokenizer = "word_v0"
	TokenizerWordV1            Tokenizer = "word_v1"
	TokenizerWordV2            Tokenizer = "word_v2"
)

type Vector

type Vector struct {
	// This field will be present if the value is a [[]float32] instead of an object.
	FloatArray []float32 `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	String string `json:",inline"`
	JSON   struct {
		FloatArray respjson.Field
		String     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Vector contains all possible properties and values from [[]float32], [string].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: FloatArray String]

func (Vector) AsFloatArray

func (u Vector) AsFloatArray() (v []float32)

func (Vector) AsString

func (u Vector) AsString() (v string)

func (Vector) RawJSON

func (u Vector) RawJSON() string

Returns the unmodified JSON received from the API

func (Vector) ToParam

func (r Vector) ToParam() VectorParam

ToParam converts this Vector to a VectorParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with VectorParam.Overrides()

func (*Vector) UnmarshalJSON

func (r *Vector) UnmarshalJSON(data []byte) error

type VectorEncoding

type VectorEncoding string

The encoding to use for vectors in the response.

const (
	VectorEncodingFloat  VectorEncoding = "float"
	VectorEncodingBase64 VectorEncoding = "base64"
)

type VectorParam

type VectorParam struct {
	FloatArray []float32         `json:",omitzero,inline"`
	String     param.Opt[string] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorParam) MarshalJSON

func (u VectorParam) MarshalJSON() ([]byte, error)

func (*VectorParam) UnmarshalJSON

func (u *VectorParam) UnmarshalJSON(data []byte) error

type WriteBilling

type WriteBilling struct {
	// The number of billable logical bytes written to the namespace.
	BillableLogicalBytesWritten int64 `json:"billable_logical_bytes_written,required"`
	// The billing information for a query.
	Query QueryBilling `json:"query"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BillableLogicalBytesWritten respjson.Field
		Query                       respjson.Field
		ExtraFields                 map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The billing information for a write request.

func (WriteBilling) RawJSON

func (r WriteBilling) RawJSON() string

Returns the unmodified JSON received from the API

func (*WriteBilling) UnmarshalJSON

func (r *WriteBilling) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
examples
bulk_write command
list_namespaces command
write_and_query command
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages
shared

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL