RethinkDB: UNION example

To do a UNION query in RethinkDB, you’ll need to identify your two datasets, combine them, and then manually de-duplicate the results:

r.db('test')
 .table('users')
 .filter( (x) => x('user_name').match('test ') )
 .union(
   r.db('test')
    .table('users')
    .filter(
      (x) => x('user_name').match('9')
    )
 )
 .distinct()