Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:visionmedia/reds

  • Loading branch information...
commit c77586870c3a5c581d463d583e311febe9b91ee6 2 parents 1c5008c + 5ed1965
TJ Holowaychuk authored January 30, 2012

Showing 1 changed file with 21 additions and 18 deletions. Show diff stats Hide diff stats

  1. 39  Readme.md
39  Readme.md
Source Rendered
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 # reds
3 2
 
4 3
   reds is a light-weight Redis search for node.js. This module was originally developed to provide search capabilities for [Kue](http://learnboost.github.com/kue) a priority job queue, however it is very much a light general purpose search library that could be integrated into a blog, a documentation server, etc.
@@ -31,15 +30,17 @@ strs.forEach(function(str, i){ search.index(str, i); });
31 30
  To perform a query against reds simply invoke `Search#query()` with a string, and pass a callback, which receives an array of ids when present, or an empty array otherwise.
32 31
 
33 32
 ```js
34  
-search.query(query = 'Tobi dollars', function(err, ids){
35  
-  if (err) throw err;
36  
-  console.log('Search results for "%s":', query);
37  
-  ids.forEach(function(id){
38  
-    console.log('  - %s', strs[id]);
  33
+search
  34
+  .query(query = 'Tobi dollars')
  35
+  .end(function(err, ids){
  36
+    if (err) throw err;
  37
+    console.log('Search results for "%s":', query);
  38
+    ids.forEach(function(id){
  39
+      console.log('  - %s', strs[id]);
  40
+    });
  41
+    process.exit();
39 42
   });
40  
-  process.exit();
41  
-});
42  
-```
  43
+  ```
43 44
 
44 45
  By default reds performs an intersection of the search words, the previous example would yield the following output:
45 46
 
@@ -51,14 +52,16 @@ Search results for "Tobi dollars":
51 52
  We can tweak reds to perform a union by passing either "union" or "or" to `reds.search()` after the callback, indicating that _any_ of the constants computed may be present for the id to match.
52 53
 
53 54
 ```js
54  
-search.query(query = 'tobi dollars', function(err, ids){
55  
-  if (err) throw err;
56  
-  console.log('Search results for "%s":', query);
57  
-  ids.forEach(function(id){
58  
-    console.log('  - %s', strs[id]);
59  
-  });
60  
-  process.exit();
61  
-}, 'or');
  55
+search
  56
+  .query(query = 'tobi dollars')
  57
+  .end(function(err, ids){
  58
+    if (err) throw err;
  59
+    console.log('Search results for "%s":', query);
  60
+    ids.forEach(function(id){
  61
+      console.log('  - %s', strs[id]);
  62
+    });
  63
+    process.exit();
  64
+  }, 'or');
62 65
 ```
63 66
 
64 67
  The intersection would yield the following since only one string contains both "Tobi" _and_ "dollars".
@@ -86,7 +89,7 @@ var search = reds.createSearch('misc');
86 89
 search.index('Foo bar baz', 'abc');
87 90
 search.index('Foo bar', 'bcd');
88 91
 search.remove('bcd');
89  
-search.query('foo bar', function(err, ids){});
  92
+search.query('foo bar').end(function(err, ids){});
90 93
 ```
91 94
 
92 95
 ## About

0 notes on commit c775868

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