Gathering emails, phones, URIs, and tag related to a room
There's really not much we can help you, given the low level of detail in the question. 

There are somethings you have in this code snippet that are generally considered a Very Bad Idea, so I'll give what help I can in that regard.

Null Checks

There are a bunch of these types of checks in the posted code:

if(room.id != null &amp;&amp; !room.id.isEmpty)


If you have any control at all over Room you should be using Option instead. If you have no control over Room, define these methods using an implicit. These checks should only every be made in one place, not every place that accesses the code. 

Assuming that id is a String (just a guess). The signature should in Room should be:

def idOption: Option[String] = Option(this.id).filter(_.nonEmpty)


Which would drop the code in the snippet to:

room.idOption.foreach(id =&gt; query += ("_id" -&gt; id))


Much simpler.

Premature Optimizations

If you ever have enough members in a room for the MutableList optimization to gain you anything, you'll probably be exceeding the length of the Mongodb query. This needlessly complicates your code.

Ironically, any gains are lost when you forgot to use nonEmpty rather than .size &gt; 0, which needs to iterate through the lists you just made to avoid iterating through the lists.

It looks like the accessors for the Member attributes already return Option values, so this can be much more readably rendered like this:

val emails = for {
  member &lt;- room.members
  email &lt;- member.email
} yield email

val phones = for {
  member &lt;- room.members
  phone &lt;- member.phoneNumber
} field phone

// 'uri' is not the plural of 'url', they are not
// actually equivalent, please don't conflate them.
val forwardUrls = for {
  member &lt;- room.members
  url &lt;- member.forwardUrl
} yield url

if(emails.nonEmpty)
  query+=("members.user.email" -&gt; MongoDBObject("$all" -&gt; emails))

if(phones.nonEmpty)
  query+=("members.user.phoneNumber" -&gt; MongoDBObject("$all" -&gt; phones))

if(forwardUrls.nonEmpty)
  query+=("members.user.forwardUrl" -&gt; MongoDBObject("$all" -&gt; forwardUrls))


Redundant Code

Much of the tags block is a no-op. It condenses down to just this:

if (room.tags.nonEmpty) {
  query+=("tags" -&gt; MongoDBObject("$in" -&gt; room.tags))
}