From 6ad2e31976212278dc3f260ed90c2bfb136e12f9 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 8 Dec 2021 04:20:54 -0300 Subject: [PATCH] sync and search sd_hash --- .../wallet/server/db/elasticsearch/constants.py | 17 +++++++++++++++-- lbry/wallet/server/leveldb.py | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lbry/wallet/server/db/elasticsearch/constants.py b/lbry/wallet/server/db/elasticsearch/constants.py index 09bd1d1f2..9a2726daf 100644 --- a/lbry/wallet/server/db/elasticsearch/constants.py +++ b/lbry/wallet/server/db/elasticsearch/constants.py @@ -27,6 +27,19 @@ INDEX_DEFAULT_SETTINGS = { "max_chars": 10 } }, + "sd_hash": { + "fields": { + "keyword": { + "ignore_above": 96, + "type": "keyword" + } + }, + "type": "text", + "index_prefixes": { + "min_chars": 1, + "max_chars": 2 + } + }, "height": {"type": "integer"}, "claim_type": {"type": "byte"}, "censor_type": {"type": "byte"}, @@ -52,14 +65,14 @@ FIELDS = { 'timestamp', 'creation_timestamp', 'duration', 'release_time', 'tags', 'languages', 'has_source', 'reposted_claim_type', - 'reposted_claim_id', 'repost_count', + 'reposted_claim_id', 'repost_count', 'sd_hash', 'trending_score', 'tx_num' } TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'description', 'claim_id', 'censoring_channel_id', 'media_type', 'normalized_name', 'public_key_bytes', 'public_key_id', 'short_url', 'signature', 'claim_name', 'signature_digest', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id', - 'tags'} + 'tags', 'sd_hash'} RANGE_FIELDS = { 'height', 'creation_height', 'activation_height', 'expiration_height', diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 01da6dd39..007d7c02c 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -625,6 +625,7 @@ class LevelDB: 'claim_type': CLAIM_TYPES[metadata.claim_type], 'has_source': reposted_has_source if metadata.is_repost else ( False if not metadata.is_stream else metadata.stream.has_source), + 'sd_hash': metadata.stream.source.sd_hash if metadata.is_stream and metadata.stream.has_source else None, 'stream_type': STREAM_TYPES[guess_stream_type(metadata.stream.source.media_type)] if metadata.is_stream and metadata.stream.has_source else reposted_stream_type if metadata.is_repost else 0,