From fb0b3121bf0db3e70cf61bc89b8521fd2c04c6eb Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger Date: Tue, 21 Jun 2022 17:12:31 +0200 Subject: [PATCH] fixed text_search result conversion Signed-off-by: Lorenz Herzberger --- planetmint/backend/tarantool/query.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/planetmint/backend/tarantool/query.py b/planetmint/backend/tarantool/query.py index 499c1c3..c25519a 100644 --- a/planetmint/backend/tarantool/query.py +++ b/planetmint/backend/tarantool/query.py @@ -266,7 +266,24 @@ def text_search(conn, search, table='assets', limit=0): res = conn.run( conn.space(table).call('indexed_pattern_search', (table, field_no, pattern)) ) - return res[0] if limit == 0 else res[0][:limit] + + to_return = [] + + if len(res[0]): # NEEDS BEAUTIFICATION + if table == 'assets': + for result in res[0]: + to_return.append({ + 'data': json.loads(result[0])['data'], + 'id': result[1] + }) + else: + for result in res[0]: + to_return.append({ + 'metadata': json.loads(result[1]), + 'id': result[0] + }) + + return to_return if limit == 0 else to_return[:limit] def _remove_text_score(asset): asset.pop('score', None)