Module: Chewy::Search::ClassMethods

Defined in:
lib/chewy/search.rb

Instance Method Summary collapse

Instance Method Details

#allChewy::Search::Request

This is the entry point for the request composition, however, most of the Request methods are delegated directly as well.

This method also provides an ability to use names scopes.

Examples:

PlacesIndex.all.limit(10)
# is basically the same as:
PlacesIndex.limit(10)

Returns:

See Also:



42
43
44
# File 'lib/chewy/search.rb', line 42

def all
  search_class.scopes.last || search_class.new(self)
end

#respond_to_missing?(name, _) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/chewy/search.rb', line 67

def respond_to_missing?(name, _)
  search_class::DELEGATED_METHODS.include?(name) || super
end

#search_string(query, options = {}) ⇒ Hash

A simple way to execute search string query.



50
51
52
53
# File 'lib/chewy/search.rb', line 50

def search_string(query, options = {})
  options = options.merge(all.render.slice(:index).merge(q: query))
  Chewy.client.search(options)
end