Created
June 3, 2013 23:19
-
-
Save jwoertink/5702300 to your computer and use it in GitHub Desktop.
What is the best way to index this in MongoDB? Even more so, what is the best way to index this with mongoid in rails?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$or" => [{"receivers"=>"5149fb21d863673f0f000001"}, {"actor_id"=>"5149fb21d863673f0f000001"}], | |
| "_id" => {"$ne" => "51a91dd4d8636716cc000015"}, | |
| "created_at" => {"$gt" => 2013-05-31 22:01:56 UTC}, | |
| "action" => {"$nin" => [:comment, :favorite]}, | |
| "object_type" => {"$nin" => ["User"]} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #mongoid model | |
| class Activity | |
| # stuff | |
| # How do I index that query? | |
| index {receivers: 1, actor_id: 1, created_at: 1, action: 1, object_type: 1} | |
| # mode stuff | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment