How to limit what records are sent to Algolia?

220 views Asked by At

Using Algolia in Ruby on Rails, I can easily index a model:

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

Is there some way to limit which Service I want sent?

For example: Only index Services where name != nil

1

There are 1 answers

0
Nicolas Baissas On BEST ANSWER

it's definitely possible to do: 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