Adding an index to mongodb collection hash field with dynamic key values -


i m using mongoid , rails 4. have model has 'data' field of type hash. field store dynamic key value pairs. know can add indexing static fields possible add indexing keys of 'data' , how should done.

you can add in same way if index not in dynamic field, this:

class person   field :data, type: hash   index('data.foo' => 1) end 

i pretty sure mongoid dont validate if fields exists, can create index on model. if dont have docs containing field, add sparse option index, save space in memory.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -