Answer the question
In order to leave comments, you need to log in
How to set a composite index in MongoDB with Ruby Driver?
From the documentation you can see
require 'mongo'
include Mongo
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'publicdb')
client[:con].indexes.create_many([
{ :key => { name: 1 }},
{ :key => { label: -1 }}
])
db.con.createIndex({"name.tree":1}), when trying to tell Ruby the string {:key => {name.tree: 1}} gives an error
syntax error, unexpected ':', expecting =>
{ :key => { name.wer: 1 }},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question