Module: Chewy::Type::Actions::ClassMethods

Defined in:
lib/chewy/type/actions.rb

Instance Method Summary collapse

Instance Method Details

#journalChewy::Journal

A Journal instance for the particular type

Returns:



37
38
39
# File 'lib/chewy/type/actions.rb', line 37

def journal
  @journal ||= Chewy::Journal.new(self)
end

#resettrue, false

Deletes all documents of a type and reimports them

Examples:

UsersIndex::User.reset

Returns:

  • (true, false)

    the result of import

See Also:



15
16
17
18
# File 'lib/chewy/type/actions.rb', line 15

def reset
  delete_all
  import
end

#sync(parallel: nil) ⇒ Hash{Symbol, Object}?

Performs missing and outdated objects synchronization for the current type.

Examples:

UsersIndex::User.sync

Parameters:

  • parallel (true, Integer, Hash) (defaults to: nil)

    options for parallel execution or the number of processes

Returns:

  • (Hash{Symbol, Object}, nil)

    a number of missing and outdated documents reindexed and their ids, nil in case of errors

See Also:



28
29
30
31
32
# File 'lib/chewy/type/actions.rb', line 28

def sync(parallel: nil)
  syncer = Syncer.new(self, parallel: parallel)
  count = syncer.perform
  {count: count, missing: syncer.missing_ids, outdated: syncer.outdated_ids} if count
end