Module: OpenLoam::Searchable

Extended by:
ActiveSupport::Concern
Defined in:
lib/open_loam/searchable.rb

Overview

Text search over an entity's own columns:

class Equipment < OpenLoam::TenantRecord
include OpenLoam::Searchable
searchable_by :name, :status
end

Equipment.search("cat")   # => a relation, still tenant-scoped

search returns a relation, so tenant isolation is not something this has to remember: the default scope is already on it, and the result composes with ordering, pagination and anything else.

HOW a query matches is a swappable driver (OpenLoam::Search.driver): the default LikeDriver is a substring LIKE; the TokenDriver is a portable word-level index; an external engine is a third. This concern is only the DECLARATION (searchable_by) and the untouched call site (Model.search(q)) — swapping the driver changes neither. See OpenLoam::Search.