chromadb_vector_search

package module
v0.0.0-...-27f129f Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

This plugin enables semantic/vector search in Apache Answer using ChromaDB.

Prerequisites

  • ChromaDB instance (self-hosted)
  • An OpenAI-compatible embedding API (e.g., OpenAI, Azure OpenAI, or any compatible provider)

Installation

Build Apache Answer with this plugin:

./answer build --with github.com/apache/answer-plugins/vector-search-chromadb

Configuration

After enabling the plugin in the Admin UI (Admin > Plugins > Vector Search), configure the following fields:

Field Description Example
ChromaDB Endpoint ChromaDB HTTP API URL http://localhost:8000
Embedding API Host OpenAI-compatible API base URL https://api.openai.com
Embedding API Key API key for the embedding service sk-...
Embedding Model Model name for generating embeddings text-embedding-3-small
Embedding Level question embeds question + all answers + comments together; answer embeds each answer separately question
Similarity Threshold Minimum cosine similarity score (0-1). Default 0 means no filtering 0.5

How It Works

  • Embedding dimensions are auto-detected from the configured model. No manual dimension configuration is needed.
  • On first configuration, the plugin creates a collection answer_vector_embeddings with hnsw:space set to cosine.
  • Uses the ChromaDB REST API directly (no external Go SDK required).
  • ChromaDB cosine distance (0 = identical, 2 = opposite) is converted to a similarity score (1.0 = identical, 0.0 = opposite).
  • A full sync of all questions/answers is triggered when the plugin starts.

Running ChromaDB Locally

Using Docker:

docker run -p 8000:8000 chromadb/chroma

The REST API will be available at http://localhost:8000.

License

Apache License 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Info embed.FS

Functions

This section is empty.

Types

type VectorSearchConfig

type VectorSearchConfig struct {
	Endpoint            string  `json:"endpoint"`
	APIHost             string  `json:"api_host"`
	APIKey              string  `json:"api_key"`
	EmbeddingModel      string  `json:"embedding_model"`
	EmbeddingLevel      string  `json:"embedding_level"`
	SimilarityThreshold float64 `json:"similarity_threshold"`
}

VectorSearchConfig holds all plugin configuration.

type VectorSearchEngine

type VectorSearchEngine struct {
	Config *VectorSearchConfig
	// contains filtered or unexported fields
}

VectorSearchEngine implements plugin.VectorSearch using ChromaDB REST API.

func (*VectorSearchEngine) ConfigFields

func (e *VectorSearchEngine) ConfigFields() []plugin.ConfigField

ConfigFields returns the plugin configuration form fields.

func (*VectorSearchEngine) ConfigReceiver

func (e *VectorSearchEngine) ConfigReceiver(config []byte) error

ConfigReceiver applies configuration from the admin UI.

func (*VectorSearchEngine) DeleteContent

func (e *VectorSearchEngine) DeleteContent(ctx context.Context, objectID string) error

DeleteContent removes a document by object ID.

func (*VectorSearchEngine) Description

func (e *VectorSearchEngine) Description() plugin.VectorSearchDesc

Description returns metadata about this vector search engine.

func (*VectorSearchEngine) Info

func (e *VectorSearchEngine) Info() plugin.Info

func (*VectorSearchEngine) RegisterSyncer

func (e *VectorSearchEngine) RegisterSyncer(ctx context.Context, syncer plugin.VectorSearchSyncer)

RegisterSyncer stores the syncer and triggers a full sync.

func (*VectorSearchEngine) SearchSimilar

func (e *VectorSearchEngine) SearchSimilar(ctx context.Context, query string, topK int) ([]plugin.VectorSearchResult, error)

SearchSimilar performs a cosine similarity search via ChromaDB REST API.

func (*VectorSearchEngine) UpdateContent

func (e *VectorSearchEngine) UpdateContent(ctx context.Context, content *plugin.VectorSearchContent) error

UpdateContent upserts a single document via ChromaDB REST API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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