def _search_document_to_dict(doc):
    """Converts and returns the search document into a dict format.

    Args:
        doc: Document. The document to be converted into dict format.

    Returns:
        dict(str, str). The document in dict format.
    """
    d = {'id': doc.doc_id, 'language_code': doc.language, 'rank': doc.rank}

    for field in doc.fields:
        d[field.name] = field.value

    return d