Last Updated: February 25, 2016
·
786
· jbowles

(Gold)mining MongoDB collections

Using the goldmine gem and the ruby mongo driver:

require File.join(File.dirname(__FILE__), 'digger')
digger = Digger
cursor1 = digger.find_all('tamil','onovate')
list1 = digger.collect_array(cursor1,'ono_stream')


fn = list1.dig("more than 1 follower"){|i| i['user']['followers_count'] > 1}
bjw = list1.dig("bowleslingjw"){|i| i['user']['screen_name'] == 'bowleslingjw'}
arrays = list1.dig("array"){|i| i["entities"]["hashtags"].is_a?(Array)}

See the gist