Quick search (sqs) on field based on many to many relationship or middle table

As we have sqs object for the contacts i am now doing a customization that only contacts will be in the search which are associated with the account. and with the account we have a middle table account_contacts. so how can i achieve this in sqs object. how to link contact with the account in condition parameter of sqs_object