Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1163

Could not create index for embedded documents

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.0, 2.3.1
    • Affects Version/s: 2.3.0
    • Component/s: None
    • None
    • Environment:
      Ruby 2.3.1, Linux

      I am not able to create indexes for embedded documents. I.e I have Contact which has many email addresses and i want to create index on "emails.address". I can do this directly via Mongo console (and it was possible in older versions of Mongo/Mongoid) but now I am getting following error:
      'emails.address' is an illegal key in MongoDB. Keys may not start with '$' or contain a '.'.

      Backtrace:
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/string.rb:69:in `to_bson_key'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/symbol.rb:74:in `to_bson_key'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:45:in `block in to_bson'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:43:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:43:in `to_bson'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:46:in `block in to_bson'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:43:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/bson-4.1.1/lib/bson/hash.rb:43:in `to_bson'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/serializers.rb:163:in `serialize'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:202:in `block (2 levels) in serialize_fields'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:200:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:200:in `block in serialize_fields'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:197:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:197:in `serialize_fields'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/protocol/message.rb:100:in `serialize'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:187:in `block in write'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:186:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:186:in `write'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:158:in `deliver'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:105:in `block in dispatch'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/monitoring/publishable.rb:47:in `publish_command'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection.rb:104:in `dispatch'
      /usr/lib/ruby/gems/2.3.0/gems/newrelic_mongodb-0.1.2/lib/newrelic_mongodb/instrumentation.rb:33:in `block in logging_with_newrelic_trace'
      /usr/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/datastores.rb:111:in `wrap'
      /usr/lib/ruby/gems/2.3.0/gems/newrelic_mongodb-0.1.2/lib/newrelic_mongodb/instrumentation.rb:32:in `logging_with_newrelic_trace'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/operation/write/gle.rb:31:in `block in execute_message'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server/connection_pool.rb:107:in `with_connection'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/server.rb:231:in `with_connection'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/operation/write/gle.rb:28:in `execute_message'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/operation/write/write_command_enabled.rb:39:in `execute'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/index/view.rb:154:in `create_many'
      /usr/lib/ruby/gems/2.3.0/gems/mongo-2.3.0/lib/mongo/index/view.rb:129:in `create_one'
      /usr/lib/ruby/gems/2.3.0/gems/mongoid-5.1.4/lib/mongoid/indexable.rb:37:in `block in create_indexes'
      /usr/lib/ruby/gems/2.3.0/gems/mongoid-5.1.4/lib/mongoid/indexable.rb:31:in `each'
      /usr/lib/ruby/gems/2.3.0/gems/mongoid-5.1.4/lib/mongoid/indexable.rb:31:in `create_indexes'

            Assignee:
            Unassigned Unassigned
            Reporter:
            pawel_xap Pawe? Smoli?ski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: