为什么.Filter(func())中的Contains在gorethink中不起作用并且部分查询被忽略?

I am trying to do this:

r.table(table).filter(
  function (doc) {
    return r.expr(array)
            .contains(doc("name"));
  }
)

written in golang that is

rethink.Table(table).GetAllByIndex(index, value).Filter(func(row rethink.Term) interface {}{

    return rethink.Expr([]string{}).Contains(row.Field("type"))
})

I am not sure but it is like rethink.Expr is ignored. That is first problem.

Second problem is next. If I have query written like this:

query := rethink.Table(table).GetAllByIndex(index, value)

and then try to do next:

if some_condition {
   q.Filter(some_filter)
}

if some_other_condition {
   q.Filter(some_other_filter)
}

when i print out q.String() i got only that first part and everything else is ignored rethink.Table(table).GetAllByIndex(index, value)

Since the Filter method returns a new Term, which will contain the expression of the previous term, you need to re-assing the result back to q.

if some_condition {
   q = q.Filter(some_filter)
}

if some_other_condition {
   q = q.Filter(some_other_filter)
}