Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how mongoid create index for test and production environment

How mongoid create index for test and production environment? I mean

     rake db:mongoid:create_indexes => environment

how to set the environment?

I use mongoid 2.4.9 and rails 3.2.7.

like image 950
eleven_huang Avatar asked Aug 08 '12 06:08

eleven_huang


People also ask

How does indexing in MongoDB work?

MongoDB uses multikey indexes to index the content stored in arrays. If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array. These multikey indexes allow queries to select documents that contain arrays by matching on element or elements of the arrays.

How does MongoDB calculate index size?

Get size of index and data in MongoDB collection with scaling factor. db. user. stats(1024) , is used to get size of data and size of index on user collection in MongoDB.

Which type of indexes does MongoDB support?

Geospatial Index. To query geospatial data, MongoDB supports two types of indexes – 2d indexes and 2d sphere indexes.

What are indexes MongoDB?

An index in MongoDB is a special data structure that holds the data of few fields of documents on which the index is created. Indexes improve the speed of search operations in database because instead of searching the whole document, the search is performed on the indexes that holds only few fields.


Video Answer


1 Answers

As with other rake tasks for Rails, simply specify RAILS_ENV to rake on the command line, e.g.,

rake db:mongoid:create_indexes RAILS_ENV=test

You can tail your log files in another window to watch it happen.

tail -f log/*.log
like image 98
Gary Murakami Avatar answered Nov 15 '22 05:11

Gary Murakami