couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Full text search" by RobertNewson
Date Thu, 30 Apr 2009 09:33:38 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by RobertNewson:
http://wiki.apache.org/couchdb/Full_text_search

------------------------------------------------------------------------------
  
  === Lucene reference implementation ===
  
- You can enable the indexing process (by default, no documents are indexed) using a special
document at _design/lucene with a "transform" function;
+ You must supply a index function in order to enable couchdb-lucene as by default, nothing
will be indexed.
+ 
+ You may add any number of index views in any number of design documents. All searches will
be constrained to documents emitted by those view functions.
+ 
+ Declare your functions as follows;
  
  {{{
  {
+   "views": {
+     // conventional view code goes here
+   },
+   "fulltext": {
+     "by_subject": {
+       "defaults": { "store":"yes" },
+       "index":"function(doc) { var ret=new Document(); ret.add(doc.subject); return ret
}"
-   "transform": {
-     function(doc) {
-     var ret = new Document();
- 
-     function idx(obj) {
-       for (var key in obj) {
-         switch (typeof obj[key]) {
-           case 'object':
-             idx(obj[key]);
-             break;
-           case 'function':
-             break;
-           default:
-             ret.field(key, obj[key]);
-             break;
-         }
-       }
      }
-   
-     // Index all attributes
-     idx(doc);
- 
-     // Index all attachments
-     for(var a in doc._attachments) {
-       ret.attachment("attachment", a);
-     }
-     return ret;
    }
  }
+ 
  }}}
  
  ==== Dependencies ====

Mime
View raw message