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 Mon, 13 Apr 2009 16:29:05 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

The comment on the change is:
update to 0.2 format.

------------------------------------------------------------------------------
  
  === Lucene reference implementation ===
  
- You can customize the indexing process (by default, all attributes of all documents are
indexed) using a special document at _design/lucene with a "transform" function;
+ You can enable the indexing process (by default, no documents are indexed) using a special
document at _design/lucene with a "transform" function;
  
  {{{
  {
-   "transform":"function(doc) { return doc; }"
+   "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;
+   }
  }
  }}}
  

Mime
View raw message