search

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package search is the parent of this module's four search packages and holds no code of its own. It exists so the question "which of these do I need?" has an answer that does not require reading four package docs to find out that three of them are not it.

search/text         query an index by words
search/vector       query an index by nearest neighbor
search/sync         keep either one in step with the database
search/pagination   turn a text search into a page an API can hand back

The two indexes

github.com/primandproper/primitives-go/search/text and github.com/primandproper/primitives-go/search/vector are deliberate mirrors: both define an Index[T] over a metadata payload, both put each provider in a subpackage selected by a config subpackage, both ship a noop and a mock. Text searches by term and gives back a cursor; vector searches by embedding proximity and gives back distances. Which one an application wants follows from whether it has an embedding to search with — see github.com/primandproper/primitives-go/embeddings — and applications that want both run both, because a hybrid of the two is a composition rather than a third index.

Neither of them owns index creation. Dimensions, distance metrics, analyzers and mappings are settled at construction through each provider's Config, so the interface is the four operations a request performs and not the shape of the thing it performs them on.

The two seams around them

An index is a second copy of data whose first copy is a database row, which makes both of the remaining packages inevitable rather than optional.

github.com/primandproper/primitives-go/search/sync is the write side. The index event is enqueued in the transaction that changed the row, through github.com/primandproper/primitives-go/outbox, and applied afterwards from a consumer — so the two systems converge rather than diverging silently the first time the second write fails. It targets either index.

github.com/primandproper/primitives-go/search/pagination is the read side. A text index's cursor and a github.com/primandproper/primitives-go/filtering.QueryFilter's cursor travel in the same field and are not the same model, and an index reports whether another page exists without reporting how many results there are in all. Both facts have an obvious wrong handling; this package is where they are handled once, along with the index-then-hydrate loop that a text search always is.

What is not here

Retrieval-augmented generation, hybrid sparse-plus-dense retrieval and reranking are compositions of these packages with github.com/primandproper/primitives-go/embeddings and github.com/primandproper/primitives-go/llm. They are an application's pipeline, built from these parts, rather than a fifth package beside them.

Nor is there an HTTP surface. Search results are the application's own types shaped for the application's own clients, so the handler is theirs — see the module README's "Transports" section for where that line is drawn across the module.

Directories

Path Synopsis
Package searchpagination adapts a text index's cursor pagination to the filtering.QueryFilter pagination an API hands back to clients, and runs the index-then-hydrate loop that a text search always is.
Package searchpagination adapts a text index's cursor pagination to the filtering.QueryFilter pagination an API hands back to clients, and runs the index-then-hydrate loop that a text search always is.
Package textsearch defines an interface for a search index management structure
Package textsearch defines an interface for a search index management structure
algolia
Package algolia provides an interface-compatible wrapper around the algolia indexer
Package algolia provides an interface-compatible wrapper around the algolia indexer
config
Package textsearchcfg selects and builds a text search index from configuration: Elasticsearch, Algolia, or noop.
Package textsearchcfg selects and builds a text search index from configuration: Elasticsearch, Algolia, or noop.
elasticsearch
Package elasticsearch provides an interface-compatible wrapper around the elasticsearch indexer
Package elasticsearch provides an interface-compatible wrapper around the elasticsearch indexer
mock
Package textsearchmock provides moq-generated mocks for the search/text package.
Package textsearchmock provides moq-generated mocks for the search/text package.
noop
Package noop is the textsearch.Index for a service with no search cluster: Index, Delete, and Wipe all succeed and keep nothing, and Search returns zero hits.
Package noop is the textsearch.Index for a service with no search cluster: Index, Delete, and Wipe all succeed and keep nothing, and Search returns zero hits.
Package vectorsearch provides a generic interface for vector (nearest-neighbor) search backends, parallel to the textsearch package under search/text.
Package vectorsearch provides a generic interface for vector (nearest-neighbor) search backends, parallel to the textsearch package under search/text.
config
Package vectorsearchcfg selects and builds a vector search index from configuration: pgvector, Qdrant, or noop.
Package vectorsearchcfg selects and builds a vector search index from configuration: pgvector, Qdrant, or noop.
mock
Package vectorsearchmock provides moq-generated mocks for the search/vector package.
Package vectorsearchmock provides moq-generated mocks for the search/vector package.
noop
Package noop is the vectorsearch.Index for a deployment running no vector store: Upsert, Delete, and Wipe report success without keeping anything, and Query returns an empty result slice.
Package noop is the vectorsearch.Index for a deployment running no vector store: Upsert, Delete, and Wipe report success without keeping anything, and Query returns an empty result slice.
pgvector
Package pgvector implements vectorsearch.Index against a PostgreSQL database running the pgvector extension.
Package pgvector implements vectorsearch.Index against a PostgreSQL database running the pgvector extension.
qdrant
Package qdrant implements vectorsearch.Index against a Qdrant vector database over its REST API.
Package qdrant implements vectorsearch.Index against a Qdrant vector database over its REST API.

Jump to

Keyboard shortcuts

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