':param FriendlySearchQuery query:
:return (,)[]: T411RestClient.search compatible'

@cache_required
@with_session
def friendly_query_to_client_query(self, friendly_query, session=None):

    client_query = {u'expression': friendly_query.expression}
    if (friendly_query.category_name is not None):
        try:
            (category_id,) = session.query(Category.id).filter((Category.name == friendly_query.category_name)).one()
            client_query[u'category_id'] = category_id
            log.debug(u'Category    named    "%s"    resolved    by    id    %d', friendly_query.category_name, category_id)
            if (len(friendly_query.term_names) > 0):
                log.debug((u'Resolving    terms    :    %s' % friendly_query.term_names))
                or_like = Term.name.like((friendly_query.term_names[0] + u'%'))
                for term_name in friendly_query.term_names[1:]:
                    or_like |= Term.name.like((term_name + u'%'))
                client_query[u'terms'] = session.query(Term.type_id, Term.id).filter(or_like).filter(TermType.categories.any((Category.id == category_id))).filter((Term.type_id == TermType.id)).all()
        except NoResultFound:
            log.warning(u'Unable    to    resolve    category    named    %s', friendly_query.category_name)
            log.warning(u'Terms    filter    will    be    passed')
    if (friendly_query.max_results is not None):
        client_query[u'result_per_page'] = friendly_query.max_results
        client_query[u'page_index'] = 0
    return client_query
