Class: Boxcars::VectorStore::Hnswlib::Search

Inherits:
Object
  • Object
show all
Includes:
Boxcars::VectorStore
Defined in:
lib/boxcars/vector_store/hnswlib/search.rb

Instance Method Summary collapse

Methods included from Boxcars::VectorStore

included

Constructor Details

#initialize(params) ⇒ Search

initialize the vector store search with the following parameters: example: {

type: :hnswlib,
vector_store: [
  Boxcars::VectorStore::Document.new(
    content: "hello",
    embedding: [0.1, 0.2, 0.3],
    metadata: { a: 1 }
  )
]

}

Parameters:

  • params (Hash)

    A Hash containing the initial configuration.



25
26
27
28
29
# File 'lib/boxcars/vector_store/hnswlib/search.rb', line 25

def initialize(params)
  @vector_store = validate_params(params[:vector_documents])
  @metadata, @index_file = validate_files(vector_store)
  @search_index = load_index(, index_file)
end

Instance Method Details

#call(query_vector:, count: 1) ⇒ Array

Returns array of hashes with :document and :distance keys.

Parameters:

  • query_vector (Array)

    The query vector to search for.

  • count (Integer) (defaults to: 1)

    The number of results to return.

Returns:

  • (Array)

    array of hashes with :document and :distance keys



34
35
36
# File 'lib/boxcars/vector_store/hnswlib/search.rb', line 34

def call(query_vector:, count: 1)
  search(query_vector, count)
end