Documentation
¶
Overview ¶
Package query provides a unified search engine that combines full-text (Bleve), structured metadata (SQLite), and vector similarity search into a single interface.
Index ¶
- type Cache
- type CacheEntry
- type Facet
- type MetadataMatch
- type QueryEngine
- func (qe *QueryEngine) Close() error
- func (qe *QueryEngine) FindSimilar(entityType, accession string, limit int) ([]vectors.SimilarityResult, error)
- func (qe *QueryEngine) GetStats() (map[string]interface{}, error)
- func (qe *QueryEngine) IndexDocument(docType string, doc interface{}) error
- func (qe *QueryEngine) Search(query string, opts SearchOptions) (*SearchResults, error)
- type SearchOptions
- type SearchResults
- type TextMatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides a simple in-memory cache
type CacheEntry ¶
CacheEntry represents a cached item
type MetadataMatch ¶
type MetadataMatch struct {
ID string `json:"id"`
Type string `json:"type"`
Fields map[string]interface{} `json:"fields"`
}
MetadataMatch represents a result from structured metadata filtering (e.g., organism or library strategy).
type QueryEngine ¶
type QueryEngine struct {
// contains filtered or unexported fields
}
QueryEngine provides a unified interface combining Bleve full-text search, SQLite metadata queries, and optional vector similarity search.
func NewQueryEngine ¶
func NewQueryEngine(dataDir string) (*QueryEngine, error)
NewQueryEngine creates a new QueryEngine with database, Bleve, and optional vector search backends initialized from the given data directory.
func (*QueryEngine) Close ¶
func (qe *QueryEngine) Close() error
Close releases all resources held by the query engine, including database connections, search indexes, vector store, and embedder.
func (*QueryEngine) FindSimilar ¶
func (qe *QueryEngine) FindSimilar(entityType, accession string, limit int) ([]vectors.SimilarityResult, error)
FindSimilar finds studies or samples similar to the given accession using vector embeddings.
func (*QueryEngine) GetStats ¶
func (qe *QueryEngine) GetStats() (map[string]interface{}, error)
GetStats returns statistics from all query engine subsystems including database counts, Bleve document counts, vector store stats, and cache metrics.
func (*QueryEngine) IndexDocument ¶
func (qe *QueryEngine) IndexDocument(docType string, doc interface{}) error
IndexDocument indexes a document in Bleve and optionally generates and stores a vector embedding. The docType must be "study", "experiment", or "sample".
func (*QueryEngine) Search ¶
func (qe *QueryEngine) Search(query string, opts SearchOptions) (*SearchResults, error)
Search performs a hybrid search across Bleve, SQLite metadata, and optionally vector similarity, merging and ranking results from all systems.
type SearchOptions ¶
type SearchOptions struct {
UseVectors bool `json:"use_vectors"`
UseFuzzy bool `json:"use_fuzzy"`
Filters map[string]string `json:"filters"`
Limit int `json:"limit"`
IncludeFacets bool `json:"include_facets"`
VectorThreshold float32 `json:"vector_threshold"`
}
SearchOptions configures search behavior including vector search, fuzzy matching, filters, and result limits.
type SearchResults ¶
type SearchResults struct {
TextMatches []TextMatch `json:"text_matches,omitempty"`
MetadataMatches []MetadataMatch `json:"metadata_matches,omitempty"`
SimilarProjects []vectors.SimilarityResult `json:"similar_projects,omitempty"`
Facets map[string][]Facet `json:"facets,omitempty"`
TotalHits int `json:"total_hits"`
SearchTime time.Duration `json:"search_time"`
Query string `json:"query"`
}
SearchResults contains merged results from text, metadata, and vector search systems.
type TextMatch ¶
type TextMatch struct {
ID string `json:"id"`
Type string `json:"type"`
Score float64 `json:"score"`
Title string `json:"title"`
Highlight map[string][]string `json:"highlight,omitempty"`
Fields map[string]interface{} `json:"fields"`
}
TextMatch represents a single full-text search hit with its relevance score and highlighted fragments.