Vecto (vecto v0.1.3)

Hybrid Search with Postgres and Ecto

Summary

Functions

Link to this function

hybrid_search(schema, query_embedding, query_string, opts \\ [])

Postgres Hybrid Search

Uses Reciprocal Rank Fusion (RRF) approach to combine full-text search and vector search.

Assumes your primary key is "id", vector column is "embedding" and tsvector column is "content", but is flexible enough to work with any table or column name

Options:

  • rrf_k: The number of top results to consider for RRF (default: 50)
  • vector_column: The column name of the vector field (default: :embedding)
  • vector_weight: The weight of the vector search (default: 1.0)
  • tsvector_column: The column name of the tsvector field (default: :content)
  • tsvector_weight: The weight of the tsvector search (default: 1.0)
  • select_columns: The columns to select from the schema (default: all columns)
  • limit: The number of results to return (default: 100)
Link to this function

keyword_search(schema, query_field, query_string, limit_by \\ 100, select_columns \\ [])

Keyword Search

Uses Postgres full-text search (tsvector) to find documents that match the query string, ranked by relevance.

Link to this function

semantic_search(schema, query_field, query_embedding, limit_by \\ 100, select_columns \\ [])

Semantic Search

Uses Postgres vector search (pg_vector) to find documents that are semantically similar to the query embedding, ranked by similarity.