How do I limit which records are sent to Algolia?
Using Algolia in Ruby on Rails I can index the model easily:
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 a way to limit which one Service
I want to send?
For example: Only index Services where name != nil
+3
source to share
1 answer
this is definitely possible: 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
+3
source to share