3

在 Ruby on Rails 中使用 Algolia,我可以轻松地索引模型:

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

4

1 回答 1

3

绝对可以这样做: 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
于 2015-06-23T17:26:03.860 回答