Hi,
I have encountered an issue with the creation of comments: when creating comments or updating its commentable resource, a MongoID exception raised saying that my operation failed with error 17280: "Btree::insert: key too large to index, failing my_db.my_commentable.$comments_1.
After some investigations, I found that the index comments_1 was created directly by mongoid_commentable in lib/mongoid/commentable.rb:
module Mongoid::Commentable
extend ActiveSupport::Concern
included do |base|
base.embeds_many :comments, :as => :commentable
if Gem::Version.new(Mongoid::VERSION) < Gem::Version.new('3.0.0')
base.index [['comments', Mongo::ASCENDING]]
else
base.index 'comments' => 1 # Index created right here....
end
end
Why are you indexing the whole comment? Didn't you mean to index comment._id instead?
Hi,
I have encountered an issue with the creation of comments: when creating comments or updating its commentable resource, a MongoID exception raised saying that my operation
failed with error 17280: "Btree::insert: key too large to index, failing my_db.my_commentable.$comments_1.After some investigations, I found that the index
comments_1was created directly by mongoid_commentable inlib/mongoid/commentable.rb:Why are you indexing the whole comment? Didn't you mean to index
comment._idinstead?