def search_facts(query, pattern, facts = [], facts_found = [], check_names = false)
      collection = connection[nodes_collection]
      result = {}
      collection.find(query).batch_size(999).each do |values|
        id = values.delete('_id')
        found = {}
        values.each do |k, v|
          if v =~ pattern
            found[k] = v
          elsif check_names && k =~ pattern
            found[k] = v
          end
        end
        next if found.empty?
        facts_found.concat(found.keys).uniq!
        facts.each do |f|
          found[f] = values[f]
        end
        result[id] = found
      end
      result
    end
def search_facts(query, pattern, facts = [], facts_found = [], check_names = false)
      collection = connection[nodes_collection]
      result = {}
      collection.find(query).batch_size(999).each do |values|
        id = values.delete('_id')
        found = {}
        values.each do |k, v|
          if v =~ pattern
            found[k] = v
          elsif check_names && k =~ pattern
            found[k] = v
          end
        end
        next if found.empty?
        facts_found.concat(found.keys).uniq!
        facts.each do |f|
          found[f] = values[f]
        end
        result[id] = found
      end
      result
    end
get nodes and their facts for a pattern

 @param query mongodb query
 @param pattern [RegExp] search for
 @param facts [Array<String>] get these facts in the result, eg ['fqdn'], empty for all
 @param facts_found [Array<String>] fact names are added to this array
 @param check_names [Boolean] also search fact names