Last active
March 10, 2016 23:12
-
-
Save Erliz/3dc196632e6e141c172e to your computer and use it in GitHub Desktop.
Creating search collection for subs
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
db.Anime.aggregate([{$project:{_id: true, title: true, "externalDbs.titles": true, startDate: true, endDate: true}}, {$unwind: "$externalDbs"}, {$unwind: "$externalDbs.titles"}, {$group: {_id: "$_id", titles: {$addToSet: "$title"}, titles: {$addToSet: "$externalDbs.titles"}}}, {$out: "Search"}]) | |
db.Search.find({$text: {$search: 'ajin'}}) | |
// multiple fields https://docs.mongodb.org/manual/tutorial/create-text-index-on-multiple-fields/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment