cirandas.net

ref: master

plugins/solr/lib/ext/category.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require_dependency 'category'

ActiveSupport.run_load_hooks :solr_category

class Category

  after_save_reindex [:articles, :profiles], with: :delayed_job

  extend SolrPlugin::ActsAsSearchable

  acts_as_searchable fields: [
    {type: :string}, {environment_id: :integer},
    # searched fields
    {name: {type: :text, boost: 2.0}},
    {path: :text}, {slug: :text},
    {abbreviation: :text}, {acronym: :text},
    # filtered fields
    :parent_id,
    # ordered/query-boosted fields
    {solr_name_sortable: :string},
  ]

  private

  def solr_name_sortable
    name
  end

end