Skip to content
Browse files

formatting and minor editing

  • Loading branch information...
1 parent 3a7a297 commit 3c16299872b024a1b70eabbdb8ccbca4d3a1e1c6 @tnm tnm committed Apr 22, 2010
Showing with 22 additions and 20 deletions.
  1. +22 −20 recipes/4_higher_level_data_structures/implement_tags_and_search_them/recipe.md
View
42 recipes/4_higher_level_data_structures/implement_tags_and_search_them/recipe.md
@@ -1,11 +1,13 @@
### Problem
You want tags for your objects, and want to be able to search them.
-This recipe is loosely based on this presentation: http://www.slideshare.net/gleicon/redis-3025589
### Solution
-In this case, using books as an example, create one SET for each tag, and associate the given ids to the correct sets.
-Selecting a combination between tags is simple as using SINTER, SUNION and SDIFF.
-The same principle can be used for document storage, taking care to use words or its stems as 'tags'
+In this case, using books as an example, create one SET for each tag, and
+associate the given ids to the correct sets. Selecting a combination
+between tags is simple as using SINTER, SUNION and SDIFF. The same principle
+can be used for document storage, taking care to use words or its stems
+as 'tags'
+
In redis-cli:
SET book:1 {'title' : 'Diving into Python',
@@ -15,7 +17,6 @@ In redis-cli:
SET book:3 { 'title' : 'Programing in Haskell',
'author': 'Graham Hutton'}
-
SADD tag:python 1
SADD tag:erlang 2
SADD tag:haskell 3
@@ -24,7 +25,6 @@ In redis-cli:
SADD tag:distributedcomputing 2
SADD tag:FP 2 3
-
Now, the searching/selecting part:
a) SINTER 'tag:erlang' 'tag:haskell'
@@ -41,21 +41,23 @@ Now, the searching/selecting part:
### Discussion
- SETs and ZSETs operations are building blocks for basic and advanced combinations which yields more results per search.
-
- In (a), there is no book tagged erlang AND haskell.
- (b) is the same as searching for ALL BOOKS tagged programming and computing
- BOOKS that are tagged either erlang or haskell are found on (c)
- (d) excludes all books tagged haskell from the programming group.
-
- For a document based storage and search, check meta code at http://github.com/gleicon/docdb, but basically it would abuse SETs treating each word stem as a tag.
- It may look overkill, but after some documents, the number of sets doesnt grow that much. See slides 13 and 14 of presentation.
+SETs and ZSETs operations are building blocks for basic and advanced
+combinations which yields more results per search.
+
+* In (a), there is no book tagged erlang AND haskell.
+* In (b) is the same as searching for ALL BOOKS tagged programming and
+computing
+* BOOKS that are tagged either erlang or haskell are found on (c)
+* (d) excludes all books tagged haskell from the programming group.
+
+For a document based storage and search, check meta code at
+http://github.com/gleicon/docdb. It may look overkill, but after some
+documents, the number of sets doesnt grow that much.
-
### See Also
- http://www.slideshare.net/gleicon/redis-3025589
- http://docs.python.org/library/sets.html
- http://en.wikipedia.org/wiki/Stemming
- http://tartarus.org/~martin/PorterStemmer/
+* http://www.slideshare.net/gleicon/redis-3025589
+* http://docs.python.org/library/sets.html
+* http://en.wikipedia.org/wiki/Stemming
+* http://tartarus.org/~martin/PorterStemmer/

0 comments on commit 3c16299

Please sign in to comment.
Something went wrong with that request. Please try again.