Sha256: 25bc4b82b0a630e15c8a4dc66ababb0f4e66dca98e1e1e230157c132ef83db9c

Contents?: true

Size: 520 Bytes

Versions: 136

Compression:

Stored size: 520 Bytes

Contents

require 'rubygems'
require 'couchrest'

couch = CouchRest.new("http://127.0.0.1:5984")
db = couch.database('word-count-example')

word_count = {
  :map => 'function(doc){
    var words = doc.text.split(/\W/);
    words.forEach(function(word){
      if (word.length > 0) emit([word,doc.title],1);
    });
  }',
  :reduce => 'function(key,combine){
    return sum(combine);
  }'
}

db.delete db.get("_design/word_count") rescue nil

db.save({
  "_id" => "_design/word_count",
  :views => {
    :words => word_count
  }
})

Version data entries

136 entries across 136 versions & 26 rubygems

Version Path
brianmario-couchrest-0.23 examples/word_count/word_count_views.rb
derfred-couchrest-0.12.6.3 examples/word_count/word_count_views.rb
derfred-couchrest-0.12.6 examples/word_count/word_count_views.rb
gbuesing-couchrest-0.23 examples/word_count/word_count_views.rb
glasner-couchrest-0.2.2 examples/word_count/word_count_views.rb
gohanlonllc-couchrest-0.2.3.1 examples/word_count/word_count_views.rb
halfninja-couchrest-0.23.2 examples/word_count/word_count_views.rb
halfninja-couchrest-0.23.3 examples/word_count/word_count_views.rb
jchris-couchrest-0.12.4 examples/word_count/word_count_views.rb
jchris-couchrest-0.12.5 examples/word_count/word_count_views.rb
jchris-couchrest-0.12.6 examples/word_count/word_count_views.rb
jchris-couchrest-0.16 examples/word_count/word_count_views.rb
jchris-couchrest-0.17.0 examples/word_count/word_count_views.rb
jchris-couchrest-0.2.1 examples/word_count/word_count_views.rb
jchris-couchrest-0.2.2 examples/word_count/word_count_views.rb
jchris-couchrest-0.2 examples/word_count/word_count_views.rb
jchris-couchrest-0.22 examples/word_count/word_count_views.rb
jchris-couchrest-0.23 examples/word_count/word_count_views.rb
jgre-couchrest-0.12.6 examples/word_count/word_count_views.rb
jkestr-couchrest-0.23 examples/word_count/word_count_views.rb