When a resource is CRUD'd it must update the Search index:
Search.put(:study, attributes) # create, update
Search.rm(:study, id) # delete
If the resource has an attributes
method you can pass the resource directly instead of a hash:
Search.put(:study, study) # create, update
In fact why not just pass the object and use its class as the namespace:
Search.put(study)
Search.get(:study, { 'organisation_id_in' => [12,16,72] }) # => [1,2,3]
Returns an array of ids.
To get a collection pass a repository object instead. The object must have a find
method which accepts an array of ids.
Search.get(Study, { 'organisation_id_in' => [12,16,72] }) # => [Study(id: 1), Study(id: 2), Study(id: 3)]
Internally the work is delegated to an adapter which wraps an indexer such as Elastic Search.