Module: OpenLoam::Search

Defined in:
lib/open_loam/search.rb,
lib/open_loam/search/driver.rb,
lib/open_loam/search/like_driver.rb,
lib/open_loam/search/token_driver.rb

Overview

The search seam. Model.search(q) and the searchable_by declaration never change; the STRATEGY behind them is a swappable driver:

OpenLoam::Search.driver = OpenLoam::Search::TokenDriver   # in an initializer

The default is the LIKE driver — portable and zero-setup — so nothing changes out of the box. A driver turns a text query into a subset of an already-tenant-scoped relation and maintains whatever index it needs; see OpenLoam::Search::Driver for the contract. This is the same shape as OpenLoam::EventStream.broadcaster and OpenLoam::Enrichers: one seam, drivers behind it, callers untouched.

Defined Under Namespace

Classes: Driver, LikeDriver, TokenDriver

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.driver ⇒ Object



17
18
19
# File 'lib/open_loam/search.rb', line 17

def driver
  @driver ||= OpenLoam::Search::LikeDriver
end

Class Method Details

.index(record) ⇒ Object



22
# File 'lib/open_loam/search.rb', line 22

def index(record)  = driver.index(record)

.reindex(model) ⇒ Object



24
# File 'lib/open_loam/search.rb', line 24

def reindex(model) = driver.reindex(model)

.remove(record) ⇒ Object



23
# File 'lib/open_loam/search.rb', line 23

def remove(record) = driver.remove(record)

.search(model, query, scope:) ⇒ Object



21
# File 'lib/open_loam/search.rb', line 21

def search(model, query, scope:) = driver.search(model, query, scope: scope)