Как ограничить, какие записи отправляются в Алголию?

Используя Algolia в Ruby on Rails, я могу легко проиндексировать модель:

class Service < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch per_environment: true do
    attributesToIndex ['name', 'canonical_url']
    attributes ['name', 'canonical_url]
    add_attribute :type do
      "Service"
    end
  end
end

Есть ли способ ограничить, какие Service я хочу отправить?

Например: Only index Services where name != nil


person sergserg    schedule 23.06.2015    source источник


Ответы (1)


это определенно возможно сделать: https://github.com/algolia/algoliasearch-rails#restrict-indexing-to-a-subset-of-your-data

class Service < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch if: :name? do
  end

end
person Nicolas Baissas    schedule 23.06.2015