debian-mirror-gitlab/elasticsearch-model/spec/support/app/mongoid_article.rb
2020-03-13 15:44:24 +05:30

21 lines
545 B
Ruby

class ::MongoidArticle
include Mongoid::Document
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
field :id, type: String
field :title, type: String
field :views, type: Integer
attr_accessible :title if respond_to? :attr_accessible
settings index: { number_of_shards: 1, number_of_replicas: 0 } do
mapping do
indexes :title, type: 'text', analyzer: 'snowball'
indexes :created_at, type: 'date'
end
end
def as_indexed_json(options={})
as_json(except: [:id, :_id])
end
end