added limit to text_Search

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2022-06-20 15:51:14 +02:00
parent e5c6282490
commit 772b28eabc
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A

View File

@ -260,12 +260,10 @@ def get_txids_filtered(connection, asset_id: str, operation: str = None,
@register_query(TarantoolDBConnection) @register_query(TarantoolDBConnection)
def text_search(conn, search, table='assets', limit=0): def text_search(conn, search, table='assets', limit=0):
pattern = ".{}.".format(search) pattern = ".{}.".format(search)
print("TEXT SEARCH FOR: {}".format(search))
res = conn.run( res = conn.run(
conn.space(table).call('indexed_pattern_search', (table, 1, pattern)) conn.space(table).call('indexed_pattern_search', (table, 1, pattern))
) )
print("TEXT SEARCH RES: {}".format(res)) return res[0] if limit == 0 else res[0][:limit]
return res
def _remove_text_score(asset): def _remove_text_score(asset):
asset.pop('score', None) asset.pop('score', None)