Im trying to build a simple application in python, where I have tags that I associated to tags.
Given the following data:
Book:
+-------------+--------------------------------+
| id | tags |
+-------------+--------------------------------+
| 1 | [python, ruby, rails] |
+-------------+--------------------------------+
| 2 | [fiction, fantasy] |
+-------------+--------------------------------+
| 3 | [fiction, adventure] |
+-------------+--------------------------------+
How would I (using pymongo) find:
- All books tagged as "fiction"
- All unique tags in the system
1. Find all books by tag:
This will be faster if you index the field.
2. Find all unique tags
You can use map-reduce
All examples are in javascript, they should work right away in mongo shell. I leave it to you to read the pymongo docs and translate the snippets.