Class: Leann::Rails::Index
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Leann::Rails::Index
- Defined in:
- lib/leann/rails/active_record/index.rb
Overview
ActiveRecord model for storing LEANN indexes
Instance Method Summary collapse
-
#document_count ⇒ Integer
Get number of documents.
-
#embedding_provider_sym ⇒ Symbol
Get embedding provider as symbol.
-
#inspect ⇒ String
Detailed inspection.
-
#search(query, limit: 5, threshold: nil, filters: nil) ⇒ Leann::SearchResults
Search this index.
-
#to_s ⇒ String
Index info as string.
Instance Method Details
#document_count ⇒ Integer
Get number of documents
39 40 41 |
# File 'lib/leann/rails/active_record/index.rb', line 39 def document_count passages.count end |
#embedding_provider_sym ⇒ Symbol
Get embedding provider as symbol
45 46 47 |
# File 'lib/leann/rails/active_record/index.rb', line 45 def .to_sym end |
#inspect ⇒ String
Detailed inspection
65 66 67 |
# File 'lib/leann/rails/active_record/index.rb', line 65 def inspect "#<Leann::Rails::Index id=#{id} name=#{name.inspect} documents=#{document_count}>" end |
#search(query, limit: 5, threshold: nil, filters: nil) ⇒ Leann::SearchResults
Search this index
32 33 34 35 |
# File 'lib/leann/rails/active_record/index.rb', line 32 def search(query, limit: 5, threshold: nil, filters: nil) searcher = Searcher.new(self) searcher.search(query, limit: limit, threshold: threshold, filters: filters) end |
#to_s ⇒ String
Index info as string
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/leann/rails/active_record/index.rb', line 51 def to_s lines = [ "Index: #{name}", " Documents: #{document_count}", " Embedding: #{}/#{}", " Dimensions: #{dimensions}", " Backend: active_record", " Created: #{created_at&.strftime('%Y-%m-%d %H:%M:%S') || 'unknown'}" ] lines.join("\n") end |