lib/activesearch/algolia.rb in activesearch-0.3.0 vs lib/activesearch/algolia.rb in activesearch-0.3.1

- old
+ new

@@ -8,11 +8,11 @@ def self.search(text, conditions = {}, options = {}) locale = options[:locale] || I18n.locale conditions[:locale] ||= locale Proxy.new(text, conditions, options) do |text, conditions| - Algolia::Client.new.query(text, tags: conditions_to_tags(conditions))["hits"].map! do |hit| + Algolia::Client.new.query(text, { tags: conditions_to_tags(conditions) }, options)["hits"].map! do |hit| if hit["_tags"] hit["_tags"].each do |tag| # preserve other ":" characters _segments = tag.split(':') @@ -47,17 +47,19 @@ def deindex Worker.new.async.perform(task: :deindex, id: self.id, type: self.class.to_s) end - def to_indexable + def to_indexable(depth = 0) {}.tap do |doc| _locale = search_locale search_fields.each do |field| if content = send(field) doc[field.to_s] = if content.is_a?(Hash) && content.has_key?(_locale) ActiveSearch.strip_tags(content[_locale]) + elsif content && content.respond_to?(:to_indexable) + ActiveSearch.strip_tags(content.to_indexable(depth + 1)) else ActiveSearch.strip_tags(content) end end end \ No newline at end of file