def _translate_hits(es_response):
def translate_result(result):<EOL><INDENT>"""<STR_LIT>"""<EOL>translated_result = copy.copy(result)<EOL>data = translated_result.pop("<STR_LIT>")<EOL>translated_result.update({<EOL>"<STR_LIT:data>": data,<EOL>"<STR_LIT>": translated_result["<STR_LIT>"]<EOL>})<EOL>return translated_result<EOL><DEDENT>def translate_facet(result):<EOL><INDENT>"""<STR_LIT>"""<EOL>terms = {term["<STR_LIT>"]: term["<STR_LIT:count>"] for term in result["<STR_LIT>"]}<EOL>return {<EOL>"<STR_LIT>": terms,<EOL>"<STR_LIT>": result["<STR_LIT>"],<EOL>"<STR_LIT>": result["<STR_LIT>"],<EOL>}<EOL><DEDENT>results = [translate_result(hit) for hit in es_response["<STR_LIT>"]["<STR_LIT>"]]<EOL>response = {<EOL>"<STR_LIT>": es_response["<STR_LIT>"],<EOL>"<STR_LIT>": es_response["<STR_LIT>"]["<STR_LIT>"],<EOL>"<STR_LIT>": es_response["<STR_LIT>"]["<STR_LIT>"],<EOL>"<STR_LIT>": results,<EOL>}<EOL>if "<STR_LIT>" in es_response:<EOL><INDENT>response["<STR_LIT>"] = {facet: translate_facet(es_response["<STR_LIT>"][facet]) for facet in es_response["<STR_LIT>"]}<EOL><DEDENT>return response<EOL>
Provide resultset in our desired format from elasticsearch results