R
R
rumkin2011-02-17 16:45:07
NoSQL
rumkin, 2011-02-17 16:45:07

tagging system on MongoDB

Is it possible to select all unique values ​​of the tags array from documents of the ... type with a single request?
{...,
    tags: ['php','nosql',...]
}


Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sadist007, 2011-02-17
@sadist007

http://www.mongodb.org/display/DOCS/MapReduce - Shell Example 2 looks like what you need.

R
rumkin, 2011-02-17
@rumkin

Thanks to all!
After searching, I came across a tip from the Mongo authors:
cookbook.mongodb.org/patterns/count_tags/
sadist007 > yes it looks like it, thanks. In the example from the link I provided above, the table is not deleted later, i.e. a permanent table is created that is updated each time a tag is added. Having understood the principle, I can offer the following option:
with each addition/deletion, add/delete tags from this table and once every N-th period of time, do a map-reduce for recalculation, for accuracy.
Now the next question arose: how to select posts by tag? Again Map/Reduce'om? Isn't it too long?

A
Anatoly, 2011-02-18
@taliban

TimTowdy correctly said above: if you want uniqueness, store it as a hash

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question