To solve the problem directly asked, you're calling SSL::release in CLIENTSSL_DATA, so you're telling the BIG-IP to stop collecting data, so it's no surprise that that's what it's doing.

You'd want to do something like:
when CLIENTSSL_DATA {
if { [SSL::payload] contains "the query string" } {
log local0. "I got the query!"
SSL::release
} else {
SSL::collect
}
}
That said, what are you hoping to do with the LDAP query? If it involves making a pool selection or other load-balancing decision, then you'll probably run into bug 224958 (which basically says that the connection isn't held up by SSL::collect, and it should be) if you keep going with the SSL::collect route (which, under ordinary circumstances, would be your best bet). You might be able to get away with doing an LB::detach before doing your selection, or doing an LB::reselect or something, but you might not; you'd just have to try for sure.
If you want to go down your original route, then you can just do a "virtual other_virtual" command right at CLIENT_ACCEPTED if you always want SSL-decrypted traffic to be send to that other VIP. There's no better event to do that in in this case.
Hope this helps!