47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/models/supplejack_api/support/concept/searchable.rb', line 47
def build_sunspot_schema(builder)
ConceptSchema.model_fields.each do |_name, field|
options = {}
search_as = field.search_as || []
value_block = nil
if field.search_value.present?
value_block = proc do
field.search_value.call(self)
end
end
options[:as] = field.solr_name if field.solr_name.present?
if search_as.include? :filter
filter_options = {}
filter_options[:multiple] = true if field.multi_value.present?
type = SUNSPOT_TYPE_NAMES[field.type]
builder.public_send(type, field.name, options.merge(filter_options), &value_block)
end
if search_as.include? :fulltext
options[:boost] = field.search_boost if field.search_boost.present?
builder.text field.name, options, &value_block
end
end
end
|