in backend/lambda/app.py [0:0]
def es_match_query(payload, es, k=3):
idx_name = 'idx_zalando'
search_body = {
"_source": {
"excludes": ["zalando_nlu_vector"]
},
"highlight": {
"fields": {
"description": {}
}
},
"query": {
"match": {
"description": {
"query": payload
}
}
}
}
search_response = es.search(request_timeout=30, index=idx_name,
body=search_body)['hits']['hits'][:k]
response = [{'image': x['_source']['image'], 'description': x['highlight']['description']} for x in search_response]
return response