app/models/attachment.rb in tawork-0.0.22 vs app/models/attachment.rb in tawork-0.0.23
- old
+ new
@@ -4,10 +4,21 @@
# after_save :save_to_git
belongs_to :attachable, :polymorphic => true
validates_presence_of :attachable
+ settings do
+ mappings dynamic: 'false' do
+ indexes :id, :index => :not_analyzed
+ indexes :type, :as => :type, :boost => 100
+ indexes :filename, :analyzer => 'snowball', :boost => 100
+ indexes :content_type, :analyzer => 'snowball'
+ indexes :created_at, :type => 'date', :include_in_all => false
+ indexes :updated_at, :type => 'date', :include_in_all => false
+ end
+ end
+
def self.create_from_uploaded_file(file, user, options = {})
filename = file.original_filename
attachment = Attachment.create( options.merge(
filename: filename,
content_type: file.content_type,
@@ -69,10 +80,10 @@
end
end
def as_indexed_json(options = {})
json = self.as_json
- json[:tag] = [self.class.to_s.underscore]
+ json[:type] = self.class.to_s.underscore
json
end
protected