mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
fixed text_search result conversion
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
3376912871
commit
fb0b3121bf
@ -266,7 +266,24 @@ def text_search(conn, search, table='assets', limit=0):
|
|||||||
res = conn.run(
|
res = conn.run(
|
||||||
conn.space(table).call('indexed_pattern_search', (table, field_no, pattern))
|
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):
|
def _remove_text_score(asset):
|
||||||
asset.pop('score', None)
|
asset.pop('score', None)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user